{
  "openapi": "3.1.0",
  "info": {
    "title": "Granite Manager API",
    "description": "JSON API behind Granite Manager, a CRM for countertop and stone fabrication companies. Every request acts as the signed-in user and only sees data of that user's company.",
    "version": "0.1.0"
  },
  "paths": {
    "/v1/me": {
      "get": {
        "tags": [
          "me"
        ],
        "summary": "Get the signed-in user",
        "description": "Returns the user behind the session, including their permission flags and\nthe company every other request acts in.",
        "operationId": "get_current_user",
        "responses": {
          "200": {
            "description": "The signed-in user",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SessionUser"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/me/mfa": {
      "get": {
        "tags": [
          "me"
        ],
        "summary": "My two-step sign-in",
        "description": "Whether two-step sign-in (an authenticator app code after the password)\nis on for the caller, since when, and whether they must keep it on\n(superusers). Turn it on with `POST /v1/me/mfa/setup` then `POST\n/v1/me/mfa/confirm`; off with `POST /v1/me/mfa/disable`.",
        "operationId": "get_my_mfa",
        "responses": {
          "200": {
            "description": "My two-step sign-in",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MfaStatus"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          },
          {
            "device_token": []
          }
        ]
      }
    },
    "/v1/me/mfa/setup": {
      "post": {
        "tags": [
          "me"
        ],
        "summary": "Start setting up two-step sign-in",
        "description": "A new secret for an authenticator app (Google Authenticator, Microsoft\nAuthenticator, 1Password...): a QR code to scan, an `otpauth://` link to\nopen on the phone that has the app, and the secret to type in. Asking\nagain within 10 minutes answers the same secret. Nothing changes until\n`POST /v1/me/mfa/confirm` gets a code from it; when it is already on,\nconfirming replaces the old authenticator.",
        "operationId": "start_my_mfa_setup",
        "responses": {
          "200": {
            "description": "What to add to the authenticator app",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AuthenticatorSetup"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          },
          {
            "device_token": []
          }
        ]
      }
    },
    "/v1/me/mfa/confirm": {
      "post": {
        "tags": [
          "me"
        ],
        "summary": "Turn on two-step sign-in",
        "description": "The code the authenticator app shows for the secret of `POST\n/v1/me/mfa/setup`: turns two-step sign-in on (from the next sign-in,\nevery sign-in asks for a code; sessions signed in now stay). 400 when\nthe code is wrong or no setup was started in the last hour.",
        "operationId": "confirm_my_mfa",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/MfaCode"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "On",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MfaStatus"
                }
              }
            }
          },
          "400": {
            "description": "Wrong code, or no setup started",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "429": {
            "description": "Too many wrong codes; try later",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          },
          {
            "device_token": []
          }
        ]
      }
    },
    "/v1/me/mfa/disable": {
      "post": {
        "tags": [
          "me"
        ],
        "summary": "Turn off two-step sign-in",
        "description": "Needs a current code of the authenticator app. Superusers must keep it\non (403). Sign-ins then ask for the password only.",
        "operationId": "disable_my_mfa",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/MfaCode"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Off",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MfaStatus"
                }
              }
            }
          },
          "400": {
            "description": "Wrong code",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Superusers must keep two-step sign-in on",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "429": {
            "description": "Too many wrong codes; try later",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          },
          {
            "device_token": []
          }
        ]
      }
    },
    "/v1/me/account": {
      "get": {
        "tags": [
          "me"
        ],
        "summary": "My account",
        "description": "What the My Account page shows from the database, in one call: the user's\ndetails in their home company, the texting providers, the signature, the\nguided tours rating, and the settings that `GET /v1/me/mfa`,\n`/v1/me/undo-send` and `/v1/me/lead-automation` answer one by one (the\nemployee-only ones are null for a shop manager or worker who is not an\nemployee). The parts that ask other services stay their own calls: `GET\n/v1/me/telegram` (asks Telegram) and `GET /v1/me/gmail` (asks Amazon).\nSave with `PUT /v1/me/account`; the other settings keep their own routes\nfor changes.",
        "operationId": "get_my_account",
        "responses": {
          "200": {
            "description": "The account",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Account"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or of the shop",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "put": {
        "tags": [
          "me"
        ],
        "summary": "Save my account",
        "description": "Saves the user's details in their home company. A new password ends the\nuser's other sessions and signs out their Granite Manager apps. The texting line is checked with its provider (the\n`RingCentral` extension is looked up from the number), and a number moved\nfrom `CloudTalk` to `RingCentral` brings its texting history along. A newly\nfilled email name or signature completes its setup task, with its points.",
        "operationId": "update_my_account",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AccountInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Saved",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AccountSaved"
                }
              }
            }
          },
          "400": {
            "description": "A field is invalid",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or of the shop",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "409": {
            "description": "The email belongs to another account",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/me/gmail": {
      "get": {
        "tags": [
          "me"
        ],
        "summary": "My Gmail",
        "description": "Whether the caller's emails go out through their own Gmail, and which.",
        "operationId": "get_my_gmail",
        "responses": {
          "200": {
            "description": "The caller's Gmail connection",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MyGmail"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "post": {
        "tags": [
          "me"
        ],
        "summary": "Finish connecting my Gmail",
        "description": "Trades the code for the caller's Gmail tokens. From then on their emails\ngo out through that Gmail.",
        "operationId": "finish_my_gmail",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/GmailReturn"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Connected",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GmailConnected"
                }
              }
            }
          },
          "400": {
            "description": "Cancelled, expired or foreign state, send permission not given, or Google refused the code",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "delete": {
        "tags": [
          "me"
        ],
        "summary": "Disconnect my Gmail",
        "description": "Ends the caller's Gmail connection; their emails go out through Granite\nManager's sending again.",
        "operationId": "disconnect_my_gmail",
        "responses": {
          "204": {
            "description": "Disconnected (or was not connected)"
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/me/gmail/start": {
      "post": {
        "tags": [
          "me"
        ],
        "summary": "Start connecting my Gmail",
        "description": "Google's sign-in page for the caller, asking for send-only Gmail access.\nGoogle returns to `/redirects/google/gmail-auth` with `code` and `state`\n(or `error`); post them to `POST /v1/me/gmail` within 15 minutes.",
        "operationId": "start_my_gmail",
        "responses": {
          "200": {
            "description": "Google's sign-in page",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GmailSignIn"
                }
              }
            }
          },
          "400": {
            "description": "Gmail connect is not set up, or the company sends through its own Amazon domain",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/me/gmail/app": {
      "post": {
        "tags": [
          "me"
        ],
        "summary": "Connect my Gmail from the app",
        "description": "The Granite Manager app signs in with Google's own sign-in (no web page)\nand posts the code it got. Google sent the code to the app itself, so\nthere is no `state` to check; it is traded with no redirect URI.",
        "operationId": "connect_my_gmail_from_app",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/GmailAppSignIn"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Connected",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GmailAppConnected"
                }
              }
            }
          },
          "400": {
            "description": "Gmail connect is not set up, send permission not given, or Google refused the code",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/me/ringcentral/start": {
      "post": {
        "tags": [
          "me"
        ],
        "summary": "Start connecting my RingCentral",
        "description": "`RingCentral`'s sign-in page for the caller. `RingCentral` returns to\n`/redirects/ringcentral/user-auth` with `code` and `state` (or `error`);\npost them to `POST /v1/me/ringcentral` within 15 minutes.",
        "operationId": "start_my_ringcentral",
        "responses": {
          "200": {
            "description": "RingCentral's sign-in page",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RingcentralSignIn"
                }
              }
            }
          },
          "400": {
            "description": "The company has no RingCentral connection, or connect is not set up",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/me/ringcentral": {
      "post": {
        "tags": [
          "me"
        ],
        "summary": "Finish connecting my RingCentral",
        "description": "Trades the code for the caller's own tokens, after checking they signed\nin to the company's `RingCentral` account. Their line becomes the\nextension that signed in and its texting number, their earlier texts\nfollow them, and `RingCentral` pushes their new texts to the CRM (a\nfailed subscription does not undo the connect).",
        "operationId": "finish_my_ringcentral",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RingcentralReturn"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Connected",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RingcentralConnected"
                }
              }
            }
          },
          "400": {
            "description": "Cancelled, expired or foreign state, another RingCentral account, or RingCentral refused the code",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "delete": {
        "tags": [
          "me"
        ],
        "summary": "Disconnect my RingCentral",
        "description": "Forgets the caller's own `RingCentral` sign-in; their line stays, but\ntexts from the CRM can't go out as them until they connect again.",
        "operationId": "disconnect_my_ringcentral",
        "responses": {
          "204": {
            "description": "Disconnected (or was not connected)"
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/me/positions": {
      "get": {
        "tags": [
          "me"
        ],
        "summary": "List the signed-in user's positions",
        "description": "Returns the position ids (job roles such as sales rep) the user holds in\nthe company the request acts in.",
        "operationId": "list_current_user_positions",
        "responses": {
          "200": {
            "description": "Position ids in the current company",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/PositionRow"
                  }
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/me/sales-goal": {
      "get": {
        "tags": [
          "me"
        ],
        "summary": "Get my monthly sales goal",
        "description": "Returns the amount the signed-in user aims to sell each month, or null\nwhen they have not set one. Set it with `PUT /v1/me/sales-goal`.",
        "operationId": "get_my_sales_goal",
        "responses": {
          "200": {
            "description": "The goal, null when not set",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SalesGoal"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "put": {
        "tags": [
          "me"
        ],
        "summary": "Set my monthly sales goal",
        "description": "Saves the amount the signed-in user aims to sell each month (USD, above 0,\nrounded to cents) and returns it as saved.",
        "operationId": "set_my_sales_goal",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateSalesGoal"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "The goal as saved",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SalesGoal"
                }
              }
            }
          },
          "400": {
            "description": "The amount is not above 0 or too large",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/me/telegram": {
      "get": {
        "tags": [
          "me"
        ],
        "summary": "Get my Telegram link status",
        "description": "Returns whether the signed-in user's Telegram is linked to the lead alerts\nbot and to the notifications bot, and the bots' ids for the Telegram login\nwidget. When a bot is configured, the saved link is checked with Telegram\nfirst; a link Telegram rejects (bot blocked, chat gone) is removed and\nreported as not linked, so the user is asked to connect again.",
        "operationId": "get_my_telegram_status",
        "responses": {
          "200": {
            "description": "Link status per bot",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TelegramStatus"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or of the shop",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/me/telegram/leads": {
      "post": {
        "tags": [
          "me"
        ],
        "summary": "Link my Telegram to the lead alerts bot",
        "description": "Checks the Telegram login widget's signature (made in the last day) and\nsaves the Telegram id for lead alerts.",
        "operationId": "link_leads_telegram",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TelegramLink"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Linked"
          },
          "400": {
            "description": "Bad, expired or forged login",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session, or another user's login",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Bot not configured, or database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/me/telegram/notifications": {
      "post": {
        "tags": [
          "me"
        ],
        "summary": "Link my Telegram to the notifications bot",
        "description": "Like the lead alerts link, for the CRM notifications bot; shop staff may\nlink it too.",
        "operationId": "link_notifications_telegram",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TelegramLink"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Linked"
          },
          "400": {
            "description": "Bad, expired or forged login",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session, or another user's login",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or shop staff",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Bot not configured, or database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/me/sidebar-pin": {
      "put": {
        "tags": [
          "me"
        ],
        "summary": "Pin or unpin my sidebar",
        "description": "Saves whether the desktop sidebar stays open (`pined_bar` on `GET /v1/me`).",
        "operationId": "set_sidebar_pin",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SidebarPin"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Saved"
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/me/undo-send": {
      "get": {
        "tags": [
          "me"
        ],
        "summary": "Get my Undo send",
        "description": "Whether my sent texts and emails wait 10 seconds with Undo before they go out (on by\ndefault), on the website and in the phone app.",
        "operationId": "get_my_undo_send",
        "responses": {
          "200": {
            "description": "Undo send",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UndoSend"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "put": {
        "tags": [
          "me"
        ],
        "summary": "Turn my Undo send on or off",
        "description": "My Account on the website, Settings › General in the phone app. Off: my texts and emails\ngo out the moment I send them, with no Undo.",
        "operationId": "set_my_undo_send",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UndoSend"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Saved"
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/me/photo": {
      "put": {
        "tags": [
          "me"
        ],
        "summary": "Set my picture",
        "description": "Makes an uploaded image my picture: first `POST /v1/uploads` with folder\n`user-photos`, `PUT` the file to its `upload_url`, then send its `url`\nhere. The picture I had before is deleted from storage. 400 when `url`\nis not a `user-photos` file of my company, or was never uploaded.",
        "operationId": "set_my_photo",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PhotoInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "My picture now",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MyPhoto"
                }
              }
            }
          },
          "400": {
            "description": "Not an uploaded `user-photos` file of my company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database or storage error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "delete": {
        "tags": [
          "me"
        ],
        "summary": "Remove my picture",
        "description": "I have no picture afterwards (my initials show); the file is deleted\nfrom storage. Fine to call when I have none.",
        "operationId": "delete_my_photo",
        "responses": {
          "204": {
            "description": "Removed"
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/me/ai-assistant": {
      "put": {
        "tags": [
          "me"
        ],
        "summary": "Turn my AI personal assistant on or off",
        "description": "For users who have the AI personal assistant (`users.ai_promises` 1 = on,\n2 = switched off by the user): off stops reading their calls, texts and\nemails, the reminders and the morning list, and hides it in the CRM; on\nresumes it. Users without it get 403.",
        "operationId": "set_ai_assistant",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AiAssistantSwitch"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Saved"
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee, or has no AI personal assistant",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/me/onboarding-feedback": {
      "post": {
        "tags": [
          "me"
        ],
        "summary": "Rate the onboarding",
        "description": "Saves the signed-in user's rating of the guided tours; once per user.",
        "operationId": "send_onboarding_feedback",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/OnboardingFeedback"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Saved"
          },
          "400": {
            "description": "Rating not 1-5 or text too long",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "409": {
            "description": "Feedback already submitted",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/me/notification-preferences": {
      "get": {
        "tags": [
          "me"
        ],
        "summary": "Get my notification settings",
        "description": "Which alerts the notifications Telegram bot sends the signed-in user.",
        "operationId": "get_notification_preferences",
        "responses": {
          "200": {
            "description": "Settings",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/NotificationPreferences"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "put": {
        "tags": [
          "me"
        ],
        "summary": "Save my notification settings",
        "description": "Turns each kind of Telegram alert on or off; returns the saved settings.",
        "operationId": "set_notification_preferences",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/NotificationPreferencesInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Saved settings",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/NotificationPreferences"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/me/marketing-companies": {
      "get": {
        "tags": [
          "me"
        ],
        "summary": "List the companies I market for",
        "description": "Live companies where the signed-in user holds the External Marketing\nposition, for the marketing portal's company switcher.",
        "operationId": "list_marketing_companies",
        "responses": {
          "200": {
            "description": "Companies",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/MarketingCompany"
                  }
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/me/todos": {
      "get": {
        "tags": [
          "me"
        ],
        "summary": "List my to-dos",
        "description": "The caller's to-dos, open ones first unless reordered by hand.",
        "operationId": "list_todos",
        "responses": {
          "200": {
            "description": "To-dos by position",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/Todo"
                  }
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "post": {
        "tags": [
          "me"
        ],
        "summary": "Add a to-do",
        "description": "It goes to the top of the list.",
        "operationId": "create_todo",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TodoText"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Added",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CreatedTodo"
                }
              }
            }
          },
          "400": {
            "description": "Empty or too long",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/me/todos/{id}": {
      "put": {
        "tags": [
          "me"
        ],
        "summary": "Change a to-do's text",
        "description": "Only the caller's own to-dos.",
        "operationId": "update_todo",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "To-do id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TodoText"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Saved"
          },
          "400": {
            "description": "Empty or too long",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "Not the caller's to-do",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "delete": {
        "tags": [
          "me"
        ],
        "summary": "Delete a to-do",
        "description": "Someone else's to-do is left alone.",
        "operationId": "delete_todo",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "To-do id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Deleted (or already gone)"
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/me/todos/{id}/done": {
      "put": {
        "tags": [
          "me"
        ],
        "summary": "Tick or untick a to-do",
        "description": "A ticked to-do moves to the bottom; an unticked one goes back above the\nticked ones.",
        "operationId": "set_todo_done",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "To-do id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TodoDone"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Saved"
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "Not the caller's to-do",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/me/todos/done": {
      "delete": {
        "tags": [
          "me"
        ],
        "summary": "Delete ticked to-dos",
        "description": "Clears every to-do the caller ticked off.",
        "operationId": "delete_done_todos",
        "responses": {
          "204": {
            "description": "Deleted"
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/me/todo-order": {
      "put": {
        "tags": [
          "me"
        ],
        "summary": "Order my to-dos",
        "description": "The caller's to-dos in the order given (others keep their place).",
        "operationId": "order_todos",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "array",
                "items": {
                  "type": "integer",
                  "format": "int32"
                }
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Saved"
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/ai/agent-actions": {
      "post": {
        "tags": [
          "ai"
        ],
        "summary": "Propose an action",
        "description": "For the Agent page's agent only (its token): proposes a write for the\nperson who asked to confirm. The endpoint must be one of the confirmable\nones, and the arguments must match its description: path parameters,\nquery and body exactly as the endpoint takes them. Nothing changes until\nthe user confirms on the Agent page; tell them it is waiting there.",
        "operationId": "propose_agent_action",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/NewAgentAction"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Kept for the user to confirm",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AgentAction"
                }
              }
            }
          },
          "400": {
            "description": "Not confirmable, or the arguments do not match the endpoint",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid agent token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Not the agent",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "agent_token": []
          }
        ]
      }
    },
    "/v1/ai/agent-actions/{id}/run": {
      "post": {
        "tags": [
          "ai"
        ],
        "summary": "Confirm an agent's action",
        "description": "Runs one of the caller's pending agent actions, with the arguments sent\n(the proposal, maybe edited), as the caller: exactly as if they did it in\nthe app. It runs once: a second confirm, or one after dismissing, is a\n409. Answers the action with its outcome: `done`, or `failed` and why.",
        "operationId": "run_agent_action",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "The action's id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ActionArgs"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Ran; `status` says whether it worked",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AgentAction"
                }
              }
            }
          },
          "400": {
            "description": "The arguments do not match the endpoint",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such action of the caller",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "409": {
            "description": "Not pending any more",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/ai/agent-actions/{id}/dismiss": {
      "post": {
        "tags": [
          "ai"
        ],
        "summary": "Dismiss an agent's action",
        "description": "Turns down one of the caller's pending agent actions: nothing is done.",
        "operationId": "dismiss_agent_action",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "The action's id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Dismissed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AgentAction"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such action of the caller",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "409": {
            "description": "Not pending any more",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/me/badges": {
      "get": {
        "tags": [
          "me"
        ],
        "summary": "Get my badges",
        "description": "The sidebar badges and desktop alerts the CRM polls each minute, in one\nrequest: name the parts with `include` (repeat the key). Each part is what\nits own route returns: `emails_unread` as `GET /v1/emails/unread`,\n`sms_unread` as `GET /v1/sms/mine/unread-count`, `sms_alerts` as\n`GET /v1/sms/mine/desktop-alerts` (opening the `inbox` provider's page),\n`sales_orders` the count of pending `GET /v1/sales-orders` (absent unless\nthe caller is a superuser, or their positions open the Sales orders tab\nand have the Confirm sales orders skill), `support_unread` the\ncaller's support requests with unread answers (as `unread` of\n`GET /v1/support/thread`), `phone_app` whether the caller is signed in to\nthe phone app (a sign-in of `GET /v1/me/devices` that is not `web`),\n`payments` whether customer payments are on and the bank account is\nconnected (as `GET /v1/company/payment-settings`, without asking Stripe).\nParts not asked for are\nabsent. A part that cannot be read this time is absent too and named in\n`failed` (keep its last value); only when every part asked fails is the\nanswer a 500. Reads only the CRM's database; the notification bell is\n`GET /v1/notifications`.",
        "operationId": "get_my_badges",
        "parameters": [
          {
            "name": "include",
            "in": "query",
            "description": "The parts to return; repeat the key for several\n(`include=emails_unread&include=sms_unread`). At least one.",
            "required": false,
            "schema": {
              "type": "array",
              "items": {
                "type": "string",
                "description": "A part of `GET /v1/me/badges`.",
                "enum": [
                  "emails_unread",
                  "sms_unread",
                  "sms_alerts",
                  "sales_orders",
                  "support_unread",
                  "phone_app",
                  "payments"
                ]
              }
            }
          },
          {
            "name": "inbox",
            "in": "query",
            "description": "The SMS page the `sms_alerts` open (the caller's inbox); default\n`telnyx`. Used only with `sms_alerts`.",
            "required": false,
            "schema": {
              "type": "string",
              "description": "The SMS provider a company texts through: `cloudtalk`, `ringcentral`, or\n`telnyx` (Granite Manager: texts from the company's Telnyx numbers).",
              "enum": [
                "cloudtalk",
                "ringcentral",
                "telnyx"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The parts asked for",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Badges"
                }
              }
            }
          },
          "400": {
            "description": "No part named in `include`, or an unknown one",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error: every part asked failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/me/dashboard/stats": {
      "get": {
        "tags": [
          "stats"
        ],
        "summary": "Get my dashboard stats",
        "description": "The employee dashboard's own numbers in one request: name the parts with\n`include` (repeat the key). Each part is what its own route returns:\n`sales` as `GET /v1/me/stats/sales`, `deal_conversion` as\n`GET /v1/me/stats/deal-conversion`, `top_stones` as\n`GET /v1/me/stats/top-stones`, `sent_emails` as\n`GET /v1/me/stats/sent-emails`, `sent_sms` as `GET /v1/me/stats/sent-sms`,\n`sales_goal` as `GET /v1/me/sales-goal`, `leaderboard` as\n`GET /v1/points-leaderboard?period=<leaderboard_period>`. Parts not asked\nfor are absent. A part that cannot be read (the leaderboard while the\ncompany has it switched off, a database error) is absent too and named in\n`failed`; only when every part asked fails is the answer that part's\nerror. Reads only the CRM's database: QuickBooks sales, feature sales and\nTelegram keep their own routes.",
        "operationId": "get_my_dashboard_stats",
        "parameters": [
          {
            "name": "include",
            "in": "query",
            "description": "The parts to return; repeat the key for several\n(`include=sales&include=sales_goal`). At least one.",
            "required": false,
            "schema": {
              "type": "array",
              "items": {
                "type": "string",
                "description": "A part of `GET /v1/me/dashboard/stats`.",
                "enum": [
                  "sales",
                  "deal_conversion",
                  "top_stones",
                  "sent_emails",
                  "sent_sms",
                  "sales_goal",
                  "leaderboard"
                ]
              }
            }
          },
          {
            "name": "leaderboard_period",
            "in": "query",
            "description": "The `leaderboard`'s period: `all` (default) or `month`, as `period`\nof `GET /v1/points-leaderboard`. Used only with `leaderboard`.",
            "required": false,
            "schema": {
              "type": "string",
              "description": "Which points count.",
              "enum": [
                "all",
                "month"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The parts asked for",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DashboardStats"
                }
              }
            }
          },
          "400": {
            "description": "No part named in `include`, or an unknown one",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "Only the leaderboard was asked for and it is switched off",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error: every part asked failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/live/ticket": {
      "post": {
        "tags": [
          "me"
        ],
        "summary": "Get where my tab connects for live updates",
        "description": "The address of the WebSocket gateway with a ticket for the caller, good\nfor one minute: the CRM opens it and then hears `{\"topic\": \"sms\"}` or\n`{\"topic\": \"emails\"}` when a text or an email arrives for the caller's\ncompany, and reads its badges and lists again (`GET /v1/me/badges` and\nthe lists' own routes; those decide what the caller sees). The line only\nsays that something came in, never what. `url` is null when the API has\nno gateway: the CRM then keeps polling each minute, as it does whenever\nthe line is down. Ask again for every connection.",
        "operationId": "get_live_ticket",
        "responses": {
          "200": {
            "description": "Where to connect, or null",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LiveTicket"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/webhooks/live/connect": {
      "post": {
        "tags": [
          "me"
        ],
        "summary": "A tab connected to the live line",
        "description": "Called by the WebSocket gateway when a browser opens a connection, not\nby the CRM: `x-live-connection` is the gateway's id of the connection and\n`x-live-ticket` the ticket from the address the tab opened\n(`POST /v1/live/ticket`). A valid ticket keeps the connection for its\nuser and company, and the gateway lets the tab in; anything else answers\n401 and the gateway refuses the tab. No session and no key: the ticket is\nthe proof.",
        "operationId": "receive_live_connect",
        "parameters": [
          {
            "name": "x-live-connection",
            "in": "header",
            "description": "The gateway's connection id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-live-ticket",
            "in": "header",
            "description": "The ticket the tab connected with",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Connection kept; the gateway lets the tab in",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LiveAck"
                }
              }
            }
          },
          "400": {
            "description": "Missing or invalid connection id",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "Missing, wrong or expired ticket",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        }
      }
    },
    "/v1/webhooks/live/disconnect": {
      "post": {
        "tags": [
          "me"
        ],
        "summary": "A tab left the live line",
        "description": "Called by the WebSocket gateway when a connection closes (the tab was\nclosed, lost its network, or its two hours ran out): the connection\n`x-live-connection` is forgotten. Unknown ids answer 200 too. No session\nand no key: only the gateway knows a connection's id.",
        "operationId": "receive_live_disconnect",
        "parameters": [
          {
            "name": "x-live-connection",
            "in": "header",
            "description": "The gateway's connection id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Forgotten",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LiveAck"
                }
              }
            }
          },
          "400": {
            "description": "Missing or invalid connection id",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        }
      }
    },
    "/v1/support/thread": {
      "get": {
        "tags": [
          "support"
        ],
        "summary": "Get my support chat",
        "description": "The signed-in user's conversation with Granite Manager's support team:\ntheir messages and the team's answers over all their support requests,\noldest first (the team's internal notes are never included). Without\n`after`, the latest 100; with `after` (the newest message id the caller\nhas), only newer ones (at most 200), so a poll that finds nothing is a\ntiny answer. `active` says whether a request is still open, `unread` how\nmany have answers not yet read (mark them with\n`POST /v1/support/thread/read`). Write with `POST /v1/support/messages`.",
        "operationId": "get_support_thread",
        "parameters": [
          {
            "name": "after",
            "in": "query",
            "description": "Only messages newer than this message id (the newest one the caller\nhas). Leave out for the latest 100.",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The messages and the thread's state",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportThread"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/support/messages": {
      "post": {
        "tags": [
          "support"
        ],
        "summary": "Write to support",
        "description": "Sends a message to Granite Manager's support team: into the user's\nconversation `conversation_id` (opened again when resolved), into a new\nconversation with `new_conversation`, else into the user's open request\n(status `open` or `waiting`) or, when they have none, a new one. A new\nconversation's subject the AI writes from the message (its first\nline when the AI cannot). The request\nbecomes `open` (the team owes an answer). Pictures must be uploaded to\nthe `chats` folder first (`POST /v1/uploads`); they are private, and\nmessages show them through links that work for an hour or two. The page, the\nPostHog session and the window size help the team see what the user\nsaw. A new request is announced to the support team in Telegram.\nReturns the saved message; answers come back through\n`GET /v1/support/thread`.",
        "operationId": "send_support_message",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/NewSupportMessage"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Sent",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportMessage"
                }
              }
            }
          },
          "400": {
            "description": "Empty or too long, or a picture that was not uploaded for this",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/support/thread/read": {
      "post": {
        "tags": [
          "support"
        ],
        "summary": "Mark support's answers read",
        "description": "Marks every answer of the support team to the signed-in user as read,\nwhich clears the Chat button's support badge (`support_unread` of\n`GET /v1/me/badges`, `unread` of `GET /v1/support/thread`). Call it when\nthe support chat shows new answers.",
        "operationId": "mark_support_thread_read",
        "responses": {
          "204": {
            "description": "Marked read"
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/support/conversations": {
      "get": {
        "tags": [
          "support"
        ],
        "summary": "List my support conversations",
        "description": "The signed-in user's conversations with Granite Manager's support team,\neach a separate request named by its subject (written by the AI from the\nfirst message), latest message first, at most 100: status, the start of\nthe latest message, unread answers. Open one with\n`GET /v1/support/conversations/{id}`; start another with\n`POST /v1/support/messages` and `new_conversation`.",
        "operationId": "list_my_support_conversations",
        "responses": {
          "200": {
            "description": "The conversations",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MyConversations"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/support/conversations/{id}": {
      "get": {
        "tags": [
          "support"
        ],
        "summary": "Open one of my support conversations",
        "description": "One of the signed-in user's conversations with its messages, oldest\nfirst (the team's internal notes are never included). With `after` (the\nnewest message id the caller has), only newer ones, so a poll that finds\nnothing is a tiny answer. Write in it with `POST /v1/support/messages`\nand its `conversation_id`; mark answers read with\n`POST /v1/support/conversations/{id}/read`. Another user's conversation\nis 404.",
        "operationId": "get_my_support_conversation",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Conversation id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "after",
            "in": "query",
            "description": "Only messages newer than this message id (the newest one the caller\nhas), for polling.",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The conversation",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MyConversationDetail"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such conversation of the user",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/support/conversations/{id}/read": {
      "post": {
        "tags": [
          "support"
        ],
        "summary": "Mark a support conversation read",
        "description": "Marks support's answers in one of the signed-in user's conversations as\nread (its unread mark and its share of the Chat button's badge go).\nAnother user's conversation is 404.",
        "operationId": "mark_my_support_conversation_read",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Conversation id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Marked read"
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such conversation of the user",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/support/agent/bootstrap": {
      "get": {
        "tags": [
          "support"
        ],
        "summary": "Start the Support app",
        "description": "Who is signed in, the team (every superuser; requests go to whoever\nstarts answering first) and the choices of the request fields: types, statuses,\npriorities, and whether the member should connect Telegram to get the\nsupport alerts there. Superusers whose session began with two-step sign-in only\n(403 otherwise: the app then asks to sign in again). Next:\n`GET /v1/support/agent/conversations`.",
        "operationId": "start_support_app",
        "responses": {
          "200": {
            "description": "The signed-in member, the team and the choices",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Bootstrap"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Not a superuser, or not signed in with two-step sign-in",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/support/agent/conversations": {
      "get": {
        "tags": [
          "support"
        ],
        "summary": "List support requests",
        "description": "The Support app's inbox: support requests, unread ones first, then the\nlatest message first (at most 200), with the client, their company, the\nassignee and the start of the latest message, plus counts per pile.\n`view` picks the statuses (default `active`: open and waiting),\n`assignee` whose (`me`, `unassigned`, a user id), `q` searches the\nsubject, the client and the company. Poll it with `version` (from the\nlast answer): when no request changed, it answers `unchanged` only.\nOpen one with `GET /v1/support/agent/conversations/{id}`.",
        "operationId": "list_support_conversations",
        "parameters": [
          {
            "name": "view",
            "in": "query",
            "description": "Which statuses (default `active`: open and waiting).",
            "required": false,
            "schema": {
              "type": "string",
              "description": "Which requests the inbox shows.",
              "enum": [
                "active",
                "open",
                "waiting",
                "resolved",
                "all"
              ]
            }
          },
          {
            "name": "assignee",
            "in": "query",
            "description": "`me` (assigned to the caller), `unassigned`, or a user id; leave out\nfor everyone's.",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "q",
            "in": "query",
            "description": "Words to find in the subject, the client's name or email, or the\ncompany's name.",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "version",
            "in": "query",
            "description": "The `version` of the caller's last answer: when nothing changed\nsince, the answer is `{\"unchanged\": true}` without the lists.",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The inbox, or `unchanged`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Inbox"
                }
              }
            }
          },
          "400": {
            "description": "Unknown assignee",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Not a superuser, or not signed in with two-step sign-in",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/support/agent/conversations/{id}": {
      "get": {
        "tags": [
          "support"
        ],
        "summary": "Open a support request",
        "description": "One request with its messages (oldest first, the team's internal notes\nincluded, each client message with the page they were on, their browser\nand the link to their PostHog recording at that moment), who wrote\n(their account, company, plan and usage), their PostHog person page and\nthe company's other requests. Poll an open one with `after` (the newest\nmessage id): only newer messages and the request's state come back.\n`typing` names the other members writing an answer right now\n(`POST .../typing`).\nMark it read with `POST .../read`; answer with `POST .../messages`.",
        "operationId": "get_support_conversation",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Conversation id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "after",
            "in": "query",
            "description": "Only messages newer than this id (a poll of an open conversation):\nthe client and their other requests are then left out.",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ConversationDetail"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Not a superuser, or not signed in with two-step sign-in",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "patch": {
        "tags": [
          "support"
        ],
        "summary": "Change a support request",
        "description": "Sets its subject, status (`resolved` closes it; the client writing in it\nopens it again), type or priority. Fields left out stay. Nobody assigns\na request by hand: the first member to start an answer takes it\n(`POST /v1/support/agent/conversations/{id}/claim`). Returns the request\nas the inbox lists it.",
        "operationId": "update_support_conversation",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Conversation id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ConversationChange"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Changed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ConversationSummary"
                }
              }
            }
          },
          "400": {
            "description": "Empty or long subject, unknown status, type or priority, or an unknown field (`assignee_id` is no longer taken)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Not a superuser, or not signed in with two-step sign-in",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/support/agent/conversations/{id}/messages": {
      "post": {
        "tags": [
          "support"
        ],
        "summary": "Answer a support request",
        "description": "Sends the team's answer to the client (it shows in their support chat\nand badges the Chat button), or with `internal` adds a note only the\nteam sees. An answer makes the request `waiting` (on the client), and\nassigns it to the one answering when nobody has it. Marks the request\nread. Returns the saved message. With `seen`, an answer is refused (409)\nwhen another member answered the client after that message: two members\ndo not answer the same thing at the same moment.",
        "operationId": "answer_support_conversation",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Conversation id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "seen",
            "in": "query",
            "description": "The newest message id on the sender's screen. When another member\nanswered the client after it, the answer is not sent (409): the\nsender reads theirs first. Left out: always sent. Notes ignore it.",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AgentReply"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Sent",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportMessage"
                }
              }
            }
          },
          "400": {
            "description": "Empty or too long, or a picture that was not uploaded for this",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Not a superuser, or not signed in with two-step sign-in",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "409": {
            "description": "Another member answered the client after `seen`; nothing was sent",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/support/agent/conversations/{id}/messages/{message_id}": {
      "delete": {
        "tags": [
          "support"
        ],
        "summary": "Delete my answer",
        "description": "Deletes an answer or note the signed-in team member wrote in this\nrequest (only their own). The client no longer sees it the next time\ntheir support chat loads; the inbox shows the message before it.",
        "operationId": "delete_support_message",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Conversation id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "message_id",
            "in": "path",
            "description": "Message id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Deleted"
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Not a superuser, or not signed in with two-step sign-in",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such message of mine in this request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "patch": {
        "tags": [
          "support"
        ],
        "summary": "Change my answer",
        "description": "Changes the text of an answer or note the signed-in team member wrote\nin this request (only their own). The client sees the new text the\nnext time their support chat loads. Returns the saved message.",
        "operationId": "edit_support_message",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Conversation id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "message_id",
            "in": "path",
            "description": "Message id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/MessageEdit"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Saved",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportMessage"
                }
              }
            }
          },
          "400": {
            "description": "Empty or too long",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Not a superuser, or not signed in with two-step sign-in",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such message of mine in this request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/support/agent/conversations/{id}/claim": {
      "post": {
        "tags": [
          "support"
        ],
        "summary": "Take a support request",
        "description": "Assigns the request to the signed-in member when nobody has it yet: the\nSupport app calls it as soon as a member starts typing an answer, so the\nfirst one to write owns it. A request someone already has stays theirs.\nReturns the request as the inbox lists it (`assignee_id` says who has it).",
        "operationId": "claim_support_conversation",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Conversation id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The request, with who has it now",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ConversationSummary"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Not a superuser, or not signed in with two-step sign-in",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/support/agent/conversations/{id}/typing": {
      "post": {
        "tags": [
          "support"
        ],
        "summary": "Say that I am writing an answer",
        "description": "The Support app calls it while a member types an answer (not a note),\nevery few seconds, so the others who have the request open see \"… is\nanswering\" and do not answer the same client at the same moment. A\nmember counts as writing for 30 seconds after the last call; sending the\nanswer, or `typing: false` (the box was emptied), ends it at once.\nReturns the other members writing in it right now.",
        "operationId": "type_in_support_conversation",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Conversation id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TypingChange"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Noted; the others writing in it now",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Typing"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Not a superuser, or not signed in with two-step sign-in",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/support/agent/conversations/{id}/read": {
      "post": {
        "tags": [
          "support"
        ],
        "summary": "Mark a support request read",
        "description": "The team has read the client's messages: the request loses its unread\nmark in every member's inbox. Call it when the request is on screen and\nthe client wrote since.",
        "operationId": "mark_support_conversation_read",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Conversation id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Marked read"
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Not a superuser, or not signed in with two-step sign-in",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/support/conversations/{id}/messages/{message_id}/reaction": {
      "post": {
        "tags": [
          "support"
        ],
        "summary": "React to a message of my support conversation",
        "description": "Puts an emoji on a message of one of the signed-in user's support\nconversations (theirs or the team's answer), like Telegram: one per\nmessage, another emoji replaces it, the same one again or `null` removes\nit. Returns every reaction of the conversation. Another user's\nconversation, or a note of the team, is 404.",
        "operationId": "react_to_my_support_message",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Conversation id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "message_id",
            "in": "path",
            "description": "Message id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ReactionInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Saved",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ReactionsOut"
                }
              }
            }
          },
          "400": {
            "description": "Not an emoji",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such message in a conversation of the user",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/support/agent/conversations/{id}/messages/{message_id}/reaction": {
      "post": {
        "tags": [
          "support"
        ],
        "summary": "React to a message of a support request",
        "description": "The team member puts an emoji on a message of the request (the client's,\nan answer or a note), like Telegram: one per message, another emoji\nreplaces it, the same one again or `null` removes it. The client sees it\non everything but notes. Returns every reaction of the request.",
        "operationId": "react_to_support_message",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Conversation id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "message_id",
            "in": "path",
            "description": "Message id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ReactionInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Saved",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ReactionsOut"
                }
              }
            }
          },
          "400": {
            "description": "Not an emoji",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Not a superuser, or not signed in with two-step sign-in",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such message in this request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/support/agent/conversations/{id}/autocomplete": {
      "post": {
        "tags": [
          "support"
        ],
        "summary": "Predict the next words of a support answer",
        "description": "The gray suggestion in the Support app's answer box, like the CRM's SMS\nand email composers: with an empty box after a new client message, how\nthe answer starts (\"Checking that\"); while typing, the next words.\nLearns from the team's real answers (the member's own and the team's\nmost used short ones), and reads the request (internal notes too, never\nquoted), the client and the CRM manual sections it is about. `warm`\ngathers that only, so the first suggestion is quick. Sends nothing.",
        "operationId": "support_autocomplete",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Conversation id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SupportAutocompleteInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "The suggestion",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportCompletion"
                }
              }
            }
          },
          "400": {
            "description": "The draft is too long",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Not a superuser, or not signed in with two-step sign-in",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "502": {
            "description": "The model failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "503": {
            "description": "AI is not configured",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/customers": {
      "get": {
        "tags": [
          "customers"
        ],
        "summary": "List the company's customers",
        "description": "Returns every non-deleted customer of the caller's company, optionally\nfiltered by sales rep. Invalid leads are hidden unless `show_invalid=1`.\nWith `view=companies` it returns only customers that have a company name,\neach with revenue and project totals. Rows carry the primary email only;\nuse `POST /v1/customers/emails/batch` for all addresses.",
        "operationId": "list_customers",
        "parameters": [
          {
            "name": "view",
            "in": "query",
            "description": "`customers` (default) lists every customer. `companies` lists one row\nper company name (its contacts together) with revenue and project totals.\nAny other value is treated as `customers`.",
            "required": false,
            "schema": {
              "type": "string",
              "description": "Which list `GET /v1/customers` returns.",
              "enum": [
                "customers",
                "companies"
              ]
            }
          },
          {
            "name": "sales_rep",
            "in": "query",
            "description": "Only customers assigned to this sales rep (a user id, see\n`GET /v1/users/sales-reps`). Omit or leave empty for all reps.",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "show_invalid",
            "in": "query",
            "description": "`1` also returns leads marked invalid. Ignored when `view=companies`,\nwhich never filters invalid leads out.",
            "required": false,
            "schema": {
              "type": "string"
            },
            "example": "1"
          }
        ],
        "responses": {
          "200": {
            "description": "Customer rows, or company rows when `view=companies`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ListResponse"
                }
              }
            }
          },
          "400": {
            "description": "`sales_rep` is not an integer",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "post": {
        "tags": [
          "customers"
        ],
        "summary": "Create a customer",
        "description": "Saves a customer with its addresses (a phone or address of another\ncustomer is refused). Without a sales rep, a sales rep creating a customer (other\nthan a walk-in) becomes its rep. An assigned customer gets an open deal\nand an audit line; the telephony address books are updated.",
        "operationId": "create_customer",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CustomerInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CreatedCustomer"
                }
              }
            }
          },
          "400": {
            "description": "Missing name, unknown source or sales rep, or a value longer than its limit",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "409": {
            "description": "A phone or address belongs to another customer, or an assigned customer's deal has no stage to start in (the company has no pipeline with a stage)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/customers/page": {
      "get": {
        "tags": [
          "customers"
        ],
        "summary": "One page of the company's customers",
        "description": "The customers page's table, filtered, sorted and paged here instead of\nin the browser. Filters as `GET /v1/customers`, plus the tab's lead\nsources; the onboarding sample customer is left out. Each page carries\nevery email of its customers, and `month_rows` the rows behind the\n\"this month\" counts per sales rep.",
        "operationId": "list_customers_page",
        "parameters": [
          {
            "name": "view",
            "in": "query",
            "description": "As in `GET /v1/customers`.",
            "required": false,
            "schema": {
              "type": "string",
              "description": "Which list `GET /v1/customers` returns.",
              "enum": [
                "customers",
                "companies"
              ]
            }
          },
          {
            "name": "sales_rep",
            "in": "query",
            "description": "As in `GET /v1/customers`.",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "show_invalid",
            "in": "query",
            "description": "As in `GET /v1/customers`.",
            "required": false,
            "schema": {
              "type": "string"
            },
            "example": "1"
          },
          {
            "name": "tab",
            "in": "query",
            "description": "`walkin` (default), `leads`, `call-in`, `other` (with `user-input`) or\n`all`. Any other value matches no customers.",
            "required": false,
            "schema": {
              "type": "string"
            },
            "example": "leads"
          },
          {
            "name": "sort_by",
            "in": "query",
            "description": "Sort column: `name`, `phone`, `email`, `sales_rep_name`,\n`company_name`, `created_date`, `assigned_date`, and in the companies\nview `revenue_generated`, `projects_count`. Omitted or unknown: newest\nfirst by the tab's date (leads by when they were assigned).",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "order",
            "in": "query",
            "description": "`asc` (default) or `desc`.",
            "required": false,
            "schema": {
              "type": "string"
            },
            "example": "desc"
          },
          {
            "name": "page",
            "in": "query",
            "description": "1-based page, default 1. Past the last page, the last page is returned.",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int32",
              "minimum": 0
            }
          },
          {
            "name": "page_size",
            "in": "query",
            "description": "Rows per page, default 20, at most 500.",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int32",
              "minimum": 0
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The page",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CustomersPage"
                }
              }
            }
          },
          "400": {
            "description": "`sales_rep` is not an integer",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/customers/emails/batch": {
      "post": {
        "tags": [
          "customers"
        ],
        "summary": "Get all emails of several customers",
        "description": "Returns every email address of the given customers, primary address\nfirst, keyed by customer id. Customers without emails, and ids belonging\nto another company, are absent from the result.",
        "operationId": "get_customer_emails",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/EmailsBatchRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Map of customer id to email addresses, primary first",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "propertyNames": {
                    "type": "string"
                  }
                },
                "example": {
                  "1000": [
                    "primary@example.com",
                    "other@example.com"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "More than 20000 ids, or a malformed body",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/customers/search": {
      "get": {
        "tags": [
          "customers"
        ],
        "summary": "Search the company's customers",
        "description": "Returns up to 15 live customers matching `term` by name (typos\ntolerated, also matches the company name), phone digits, any email, or\ncompany name. Customers with a live deal of the caller come first, then\nthe caller's own customers, then the best text matches. Each row carries\nevery email and the customer's latest deal. Fetch one in full with\n`GET /v1/customers/{id}`.",
        "operationId": "search_customers",
        "parameters": [
          {
            "name": "term",
            "in": "query",
            "description": "What the user typed. Required (may be empty for phone search).",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "by",
            "in": "query",
            "description": "Which field to match: `name` (default), `phone`, `email`, `company`, `address`.",
            "required": false,
            "schema": {
              "type": "string",
              "description": "How `GET /v1/customers/search` matches `term`.",
              "enum": [
                "name",
                "phone",
                "email",
                "company",
                "address"
              ]
            }
          },
          {
            "name": "own_only",
            "in": "query",
            "description": "`true` returns only customers assigned to the caller or unassigned.",
            "required": false,
            "schema": {
              "type": "boolean"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Matching customers, best first",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/CustomerSearchRow"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Missing `term` or unknown `by`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/customers/lead-inbox": {
      "get": {
        "tags": [
          "customers"
        ],
        "summary": "List my lead notifications",
        "description": "The leads assigned to me in the last 14 days; for a sales manager or an\nadmin, also the company's leads of the last 14 days that have no rep yet\nand the sales reps to give them to (with this month's lead count each).\nEveryone also gets `team`: each sales rep of the company and the leads\ngiven to them this month.",
        "operationId": "lead_inbox",
        "responses": {
          "200": {
            "description": "My lead notifications",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LeadInbox"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/customers/duplicates": {
      "get": {
        "tags": [
          "customers"
        ],
        "summary": "Find customers with a contact",
        "description": "Up to 5 live customers of the company that already have one of the\nphones (last 10 digits) or addresses, for the \"already exists\" warning\nof the add form. Empty without any contact.",
        "operationId": "find_duplicate_customers",
        "parameters": [
          {
            "name": "phone",
            "in": "query",
            "description": "Phone (its last 10 digits are compared).",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "phone_2",
            "in": "query",
            "description": "Second phone.",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "email",
            "in": "query",
            "description": "Email addresses (repeat the parameter), compared case-insensitively.",
            "required": false,
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              }
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Matching customers",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/DuplicateCustomer"
                  }
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/customers/email-recipients": {
      "get": {
        "tags": [
          "customers"
        ],
        "summary": "Suggest email recipients",
        "description": "Addresses of the company's live customers matching `term` by name,\ncompany or address, tolerating one typo in the address; with a domain\ntyped, every address of that domain. Best matches first, at most 15.\nWith `include_users`, also the company's users (empty `term`: all).",
        "operationId": "suggest_email_recipients",
        "parameters": [
          {
            "name": "term",
            "in": "query",
            "description": "What was typed (name, company or address).",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "include_users",
            "in": "query",
            "description": "Also suggest the company's users.",
            "required": false,
            "schema": {
              "type": "boolean"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Suggestions",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Recipients"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/customers/{id}": {
      "get": {
        "tags": [
          "customers"
        ],
        "summary": "Get one customer",
        "description": "Returns a customer of the caller's company with contact details, every\nemail address (primary first), the assigned sales rep and the lead form\nanswers. 404 for other companies' customers, and for deleted ones unless\n`include_deleted=true` (a deal page still shows its deleted customer).",
        "operationId": "get_customer",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Customer id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "include_deleted",
            "in": "query",
            "description": "Also return the customer when it was deleted.",
            "required": false,
            "schema": {
              "type": "boolean"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The customer",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CustomerDetail"
                }
              }
            }
          },
          "400": {
            "description": "Malformed query",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such customer in the caller's company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "put": {
        "tags": [
          "customers"
        ],
        "summary": "Change a customer",
        "description": "Saves the contact details, source and addresses (exactly `emails`, the\nfirst one primary). A new sales rep is recorded in the audit trail (with\nthe sales manager's original assignment of a lead first), stamps the\nfirst assignment date, and gets the open deal. The automatic emails and\ntexts waiting for the customer's deals follow them to the new rep: those\nthat rep's deals do not get (a template for other reps, the old rep's\nown, the company's when the new rep uses their own automations) are\ncalled off, the rest go out from the new rep.",
        "operationId": "update_customer",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Customer id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CustomerInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Saved"
          },
          "400": {
            "description": "Missing name, unknown source or sales rep, or a value longer than its limit",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such live customer in the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "409": {
            "description": "A phone or address belongs to another customer, or an assigned customer's deal has no stage to start in (the company has no pipeline with a stage)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "delete": {
        "tags": [
          "customers"
        ],
        "summary": "Delete a customer",
        "description": "Hides the customer (soft delete) and removes it from the telephony\naddress books. A customer with live deals needs `cascade_deals=true`,\nwhich hides the deals too. Admins, sales managers and managers only.",
        "operationId": "delete_customer",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Customer id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "cascade_deals",
            "in": "query",
            "description": "Also delete the customer's live deals (required when it has any).",
            "required": false,
            "schema": {
              "type": "boolean"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Deleted"
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is neither an admin, a sales manager nor a manager",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such live customer in the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "409": {
            "description": "The customer has live deals and `cascade_deals` is not set",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/customers/{id}/sales-rep": {
      "put": {
        "tags": [
          "customers"
        ],
        "summary": "Assign a customer's sales rep",
        "description": "Records the change in the audit trail, stamps the first assignment\ndate, gives the rep the open deal and two reminders (text within a\nday, check within three). A newly assigned rep (other than the caller)\nis told on their phones (a `lead` push) and in Telegram. The automatic\nemails and texts waiting for the customer's deals follow them to the new\nrep: those that rep's deals do not get (a template for other reps, the\nold rep's own, the company's when the new rep uses their own\nautomations) are called off, the rest go out from the new rep. The\nGranite Phone app may call this with its device token.",
        "operationId": "set_customer_sales_rep",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Customer id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SalesRepInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Saved"
          },
          "400": {
            "description": "Unknown sales rep",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such live customer in the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "409": {
            "description": "The deal has no stage to start in: the chosen pipeline has no stage, or the company has no pipeline",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/customers/{id}/temperature": {
      "put": {
        "tags": [
          "customers"
        ],
        "summary": "Set a lead's temperature",
        "description": "`hot`, `medium` or `cold`, or null to clear it.",
        "operationId": "set_customer_temperature",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Customer id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TemperatureInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Saved"
          },
          "400": {
            "description": "Unknown temperature",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such live customer in the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/customers/{id}/invalid": {
      "put": {
        "tags": [
          "customers"
        ],
        "summary": "Mark a lead invalid",
        "description": "Records why the lead is invalid, unassigns it and hides its live deals\n(each deletion audited). The sales managers' Telegram lead alerts end with\n\"Lead marked invalid: {reason}\" and lose their rep buttons. Admins and\nsales managers only.",
        "operationId": "mark_customer_invalid",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Customer id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/InvalidInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Marked"
          },
          "400": {
            "description": "Missing reason",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is neither an admin nor a sales manager",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such live customer in the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/customers/{id}/history": {
      "get": {
        "tags": [
          "customers"
        ],
        "summary": "Get a customer's history",
        "description": "The customer dialog's history: creation and assignment, deals (live,\ncreated, deleted, won or lost), reassignments, email history (first\nrecording drips that were sent but are missing from it) and the\nactivities and notes of the live deals. Deleted customers included.",
        "operationId": "get_customer_history",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Customer id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The history",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CustomerHistory"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such customer in the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/customers/{id}/signature-requests": {
      "get": {
        "tags": [
          "customers"
        ],
        "summary": "List a customer's signature requests",
        "description": "Documents sent to the customer for e-signature, newest first. Open\n`SignWell` requests are checked with `SignWell` first.",
        "operationId": "list_customer_signature_requests",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Customer id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Requests",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/SignatureRequest"
                  }
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such customer in the caller's company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/customers/{id}/files": {
      "get": {
        "tags": [
          "customers"
        ],
        "summary": "List a customer's files",
        "description": "Files kept on the customer, newest first.",
        "operationId": "list_customer_files",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Customer id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Files",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/CustomerFile"
                  }
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such customer in the caller's company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/customers/{id}/activity-search": {
      "post": {
        "tags": [
          "customers"
        ],
        "summary": "Ask about a customer's history",
        "description": "Answers a question from the customer's emails, texts, deal notes and\nactivities (and, with `include_calls`, transcripts of their last two\nrecorded calls), with links to the sources. Texts and calls of every\nprovider count: `CloudTalk`, `RingCentral` and the company's own numbers.\nA call the caller may not hear is left out.",
        "operationId": "search_customer_activity",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Customer id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ActivitySearchInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Answer",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ActivityAnswer"
                }
              }
            }
          },
          "400": {
            "description": "Question too short or too long",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such customer in the caller's company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "502": {
            "description": "OpenAI failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/customers/{id}/estimate-time": {
      "get": {
        "tags": [
          "customers"
        ],
        "summary": "Find the agreed estimate time",
        "description": "Reads the customer's last 30 texts and emails with AI and returns the\nin-home estimate time both sides agreed on, if there is an exact one.",
        "operationId": "find_customer_estimate_time",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Customer id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "tz",
            "in": "query",
            "description": "The user's IANA time zone; the answer is on its clock.",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The time, or null",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EstimateTime"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such customer in the caller's company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/customers/{id}/projects": {
      "get": {
        "tags": [
          "customers"
        ],
        "summary": "List a customer's projects",
        "description": "The live customers of the family the customer belongs to (its parent and\nthe parent's projects, or the customer and its own projects), by name,\nwith their addresses, newest deal stage and sales.",
        "operationId": "list_customer_projects",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Customer id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The family",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CustomerProjects"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such customer in the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/customers/{id}/parent": {
      "put": {
        "tags": [
          "customers"
        ],
        "summary": "Link a customer under a parent",
        "description": "Makes the customer a project of `parent_id` (both of the company).",
        "operationId": "set_customer_parent",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Customer id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ParentInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Linked"
          },
          "400": {
            "description": "A customer cannot be its own parent",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "Customer or parent not in the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/customers/{id}/sales": {
      "get": {
        "tags": [
          "customers"
        ],
        "summary": "List a customer's sales",
        "description": "The company's sales to the customer, newest first, with the seller.",
        "operationId": "list_customer_sales",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Customer id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Sales",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/CustomerSale"
                  }
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such customer in the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/customers/sms-contacts": {
      "get": {
        "tags": [
          "customers"
        ],
        "summary": "Find people to text",
        "description": "Customers whose name matches `term` (typos allowed) or whose phone or\nsecond phone contains its digits, and suppliers by name or phone. A\ncustomer found by a phone comes with the number that matched; one found\nby name with its phone, or its second phone when it has no first.",
        "operationId": "find_sms_contacts",
        "parameters": [
          {
            "name": "term",
            "in": "query",
            "description": "A name (typos allowed) or phone digits; at least two characters.",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Matches (none for a term under two characters)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SmsContacts"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/customers/{id}/phone": {
      "post": {
        "tags": [
          "customers"
        ],
        "summary": "Link a phone to a customer",
        "description": "Saves the phone as the customer's phone, or as the second phone when the\nfirst is taken, and pushes the customer to the telephony address books\nso the conversation shows their name. A number the customer has already\nchanges nothing. 409 for a number another customer has, and for a\ncustomer whose two phones are both filled: none is overwritten, change\none with `PUT /v1/customers/{id}`.",
        "operationId": "link_customer_phone",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Customer id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PhoneInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Linked",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PhoneCustomer"
                }
              }
            }
          },
          "400": {
            "description": "Not a phone number (`invalid_phone`)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such customer in the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "409": {
            "description": "Another customer has the phone, or the customer's two phones are both filled",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/customers/from-phone": {
      "post": {
        "tags": [
          "customers"
        ],
        "summary": "Create a customer for a phone",
        "description": "A new customer with just a name and the phone, for an unknown number in\nthe SMS inbox.",
        "operationId": "create_customer_from_phone",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/NewPhoneCustomer"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PhoneCustomer"
                }
              }
            }
          },
          "400": {
            "description": "`invalid_phone` or `empty_name`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "409": {
            "description": "Another customer has the phone",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/customers/by-phone": {
      "get": {
        "tags": [
          "customers"
        ],
        "summary": "Find who a phone belongs to",
        "description": "The company's live customer whose phone or second phone is this number\n(with or without the country code), for an incoming call.",
        "operationId": "find_customer_by_phone",
        "parameters": [
          {
            "name": "phone",
            "in": "query",
            "description": "A phone in any format.",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The customer, or nulls",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PhoneOwner"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/customer-checklists": {
      "get": {
        "tags": [
          "schedule"
        ],
        "summary": "List the company's customer checklists",
        "description": "The lists of to-dos a template maker picks from at a template appointment\n(what the customer must do before install), in order, each with its\nto-dos. Anyone in the company. Send the picked ones with `POST\n/v1/events/{id}/customer-todos`.",
        "operationId": "list_customer_checklists",
        "responses": {
          "200": {
            "description": "The lists",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/CustomerChecklist"
                  }
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee, admin or shop manager or worker",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "post": {
        "tags": [
          "schedule"
        ],
        "summary": "Add a customer checklist",
        "description": "A named list of to-dos the customer may need to do before install. Admins\nonly. It goes last. Returns every list, the new one included.",
        "operationId": "create_customer_checklist",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CustomerChecklistInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Added; every list",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/CustomerChecklist"
                  }
                }
              }
            }
          },
          "400": {
            "description": "No name, one over 120 characters, a to-do over 200 characters, or over 60 to-dos",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/customer-checklists/{id}": {
      "put": {
        "tags": [
          "schedule"
        ],
        "summary": "Rename a customer checklist and set its to-dos",
        "description": "Replaces the name and the to-dos, in the order given. To-dos already sent\nto customers stay as they were. Admins only. Returns every list.",
        "operationId": "update_customer_checklist",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Checklist id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CustomerChecklistInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Saved; every list",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/CustomerChecklist"
                  }
                }
              }
            }
          },
          "400": {
            "description": "No name, one over 120 characters, a to-do over 200 characters, or over 60 to-dos",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such list in the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "delete": {
        "tags": [
          "schedule"
        ],
        "summary": "Delete a customer checklist",
        "description": "Template makers no longer see it. To-dos already sent to customers stay.\nAdmins only.",
        "operationId": "delete_customer_checklist",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Checklist id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Deleted"
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such list in the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/events/{id}/customer-todos": {
      "post": {
        "tags": [
          "schedule"
        ],
        "summary": "Send a template appointment's customer to-dos",
        "description": "What the customer must do before install, picked at the template\nappointment (from `GET /v1/customer-checklists`, or written in), each\nwith an optional note. Empty `items` means there is nothing to do.\nSending again adds to what was sent. The to-dos go on the appointment's\ncustomer and their open project, and the job's sales rep (the sale's\nseller, else the deal's owner, else the project's sales rep, else the\ncustomer's sales rep, else whoever made the event) gets a bell\nnotification of type `customer_todos` and a phone push, unless they sent\nthem. Returns the appointment's to-dos.",
        "operationId": "send_event_customer_todos",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Event id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SendCustomerTodosInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Sent; the appointment's to-dos",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EventCustomerTodos"
                }
              }
            }
          },
          "400": {
            "description": "A to-do over 200 characters, a note over 1000, or over 60 to-dos",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee, admin or shop manager or worker",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such event in the caller's company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "409": {
            "description": "The appointment has no customer",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/customer-todos/{id}": {
      "put": {
        "tags": [
          "schedule"
        ],
        "summary": "Tick a customer to-do off, or mark it not done again",
        "description": "Anyone in the company: the sales rep on the deal, the office on the\nproject, the template maker on the appointment. Done keeps who did it\nfirst and when.",
        "operationId": "set_customer_todo_done",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "To-do id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CustomerTodoDoneInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Saved"
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee, admin or shop manager or worker",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such to-do in the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "delete": {
        "tags": [
          "schedule"
        ],
        "summary": "Delete a customer to-do",
        "description": "For one sent by mistake. Only whoever sent it, an admin or a superuser.",
        "operationId": "delete_customer_todo",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "To-do id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Deleted"
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee, admin or shop manager or worker",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "Not a to-do the caller may delete",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/customers/{id}/customer-todos": {
      "get": {
        "tags": [
          "customers"
        ],
        "summary": "List a customer's to-dos",
        "description": "What the customer must do before install, from their template\nappointments: open ones first, then done ones, each oldest first. For the\ncustomer's page and their deals. Tick one off with `PUT\n/v1/customer-todos/{id}`.",
        "operationId": "list_customer_todos",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Customer id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The to-dos",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/CustomerTodo"
                  }
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such customer in the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/crew-checklists": {
      "get": {
        "tags": [
          "schedule"
        ],
        "summary": "List the company's crew checklists",
        "description": "The lists of checks Template Guy (`template`) and the installer\n(`install`) go through on the job, in order, each with its checks.\nAnyone in the company.",
        "operationId": "list_crew_checklists",
        "responses": {
          "200": {
            "description": "The lists",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/CrewChecklist"
                  }
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee, admin or shop manager or worker",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "post": {
        "tags": [
          "schedule"
        ],
        "summary": "Add a crew checklist",
        "description": "A named list of checks for Template Guy or the installer. Admins only.\nIt goes last. Returns every list, the new one included.",
        "operationId": "create_crew_checklist",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateCrewChecklistInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Added; every list",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/CrewChecklist"
                  }
                }
              }
            }
          },
          "400": {
            "description": "No name, one over 120 characters, a check over 200 characters, or over 80 checks",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/crew-checklists/{id}": {
      "put": {
        "tags": [
          "schedule"
        ],
        "summary": "Rename a crew checklist and set its checks",
        "description": "Replaces the name and the checks, in the order given. Jobs already saved\nstay as they were. Admins only. Returns every list.",
        "operationId": "update_crew_checklist",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Checklist id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateCrewChecklistInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Saved; every list",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/CrewChecklist"
                  }
                }
              }
            }
          },
          "400": {
            "description": "No name, one over 120 characters, a check over 200 characters, or over 80 checks",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such list in the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "delete": {
        "tags": [
          "schedule"
        ],
        "summary": "Delete a crew checklist",
        "description": "The crew no longer sees it. Jobs already saved stay. Admins only.",
        "operationId": "delete_crew_checklist",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Checklist id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Deleted"
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such list in the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/events/{id}/crew-checks": {
      "put": {
        "tags": [
          "schedule"
        ],
        "summary": "Save an appointment's crew checks",
        "description": "What Template Guy checked in the template, or the installer at the\ninstall: every check, ticked or not, each with an optional note.\nReplaces what was saved before. Returns the appointment's checks.",
        "operationId": "save_event_crew_checks",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Event id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SaveEventCrewChecksInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Saved; the appointment's checks",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EventCrewChecks"
                }
              }
            }
          },
          "400": {
            "description": "No checks, a check over 200 characters, a note over 1000, or over 80 checks",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee, admin or shop manager or worker",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such event in the caller's company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/customer-sources": {
      "get": {
        "tags": [
          "customers"
        ],
        "summary": "List customer sources",
        "description": "The company's live sources, built-in ones first, then by label.",
        "operationId": "list_customer_sources",
        "responses": {
          "200": {
            "description": "Sources",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/CustomerSource"
                  }
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "post": {
        "tags": [
          "customers"
        ],
        "summary": "Add a customer source",
        "description": "Its key and label are the name.",
        "operationId": "create_customer_source",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SourceName"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Added",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CreatedSource"
                }
              }
            }
          },
          "400": {
            "description": "Empty or too long",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "409": {
            "description": "A source with that name exists, or the name is a built-in key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/customer-sources/{id}": {
      "put": {
        "tags": [
          "customers"
        ],
        "summary": "Rename a customer source",
        "description": "A built-in source only changes its label; a custom one also changes its\nkey, and its customers and the SMS automations sent to it move to the new\nname. A custom source cannot take a built-in key (`leads`, `check-in`,\n`call-in`, `other`, `check-list`, `user-input`).",
        "operationId": "rename_customer_source",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Source id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SourceName"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Renamed"
          },
          "400": {
            "description": "Empty or too long",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such source in the caller's company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "409": {
            "description": "A source with that name exists, or the name is a built-in key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "delete": {
        "tags": [
          "customers"
        ],
        "summary": "Delete a customer source",
        "description": "Hides a custom source from the dropdown; its customers keep it.",
        "operationId": "delete_customer_source",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Source id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Deleted"
          },
          "400": {
            "description": "A built-in source",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such source in the caller's company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/customer-sources/{id}/walk-in": {
      "put": {
        "tags": [
          "customers"
        ],
        "summary": "Count a customer source as a walk-in",
        "description": "Its customers show under the Customers list's Walk-in filter and in the\nwalk-in statistics, like the built-in walk-in (for a second showroom).",
        "operationId": "set_customer_source_walk_in",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Source id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WalkIn"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Saved"
          },
          "400": {
            "description": "A built-in source",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such source in the caller's company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/customer-types": {
      "get": {
        "tags": [
          "customers"
        ],
        "summary": "List customer types",
        "description": "The company's live customer types, by name.",
        "operationId": "list_customer_types",
        "responses": {
          "200": {
            "description": "Types",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/CustomerType"
                  }
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "post": {
        "tags": [
          "customers"
        ],
        "summary": "Add a customer type",
        "operationId": "create_customer_type",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TypeName"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Added",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CreatedType"
                }
              }
            }
          },
          "400": {
            "description": "Empty or too long",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "409": {
            "description": "A type with that name exists",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/customer-types/{id}": {
      "put": {
        "tags": [
          "customers"
        ],
        "summary": "Rename a customer type",
        "operationId": "rename_customer_type",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Type id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TypeName"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Renamed"
          },
          "400": {
            "description": "Empty or too long",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such type in the caller's company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "409": {
            "description": "A type with that name exists",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "delete": {
        "tags": [
          "customers"
        ],
        "summary": "Delete a customer type",
        "description": "Hides it from the dropdown; its customers keep it.",
        "operationId": "delete_customer_type",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Type id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Deleted"
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such type in the caller's company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/public/customer-view/{company_id}/{view_id}": {
      "get": {
        "tags": [
          "customer-view"
        ],
        "summary": "Open a customer's page",
        "description": "Whether the visitor already entered a code for it, else where a code\nwould go. Unknown pages are 404.",
        "operationId": "get_customer_view",
        "parameters": [
          {
            "name": "company_id",
            "in": "path",
            "description": "Company id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "view_id",
            "in": "path",
            "description": "The customer's page id (a UUID)",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The gate",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ViewGate"
                }
              }
            }
          },
          "404": {
            "description": "No such page",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        }
      }
    },
    "/v1/public/customer-view/{company_id}/{view_id}/code": {
      "post": {
        "tags": [
          "customer-view"
        ],
        "summary": "Email or text a login code",
        "description": "Sends a one-time code (10 minutes) to the customer's email, or with\n`channel: sms` texts it to their phone (`has_phone` on the gate). An\naddress gets at most one code every 45 seconds and 5 an hour; a new code\nreplaces the previous one.",
        "operationId": "send_customer_view_code",
        "parameters": [
          {
            "name": "company_id",
            "in": "path",
            "description": "Company id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "view_id",
            "in": "path",
            "description": "The customer's page id (a UUID)",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CodeRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Sent"
          },
          "404": {
            "description": "No such page",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "409": {
            "description": "The customer has no email (or no phone, or the company cannot text)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "429": {
            "description": "A code was just sent, or 5 this hour",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "502": {
            "description": "The email or text could not be sent",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        }
      }
    },
    "/v1/public/customer-view/{company_id}/{view_id}/verify": {
      "post": {
        "tags": [
          "customer-view"
        ],
        "summary": "Enter a login code",
        "description": "Unlocks the page for this browser for 7 days. A code takes 8 attempts at\nmost.",
        "operationId": "verify_customer_view_code",
        "parameters": [
          {
            "name": "company_id",
            "in": "path",
            "description": "Company id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "view_id",
            "in": "path",
            "description": "The customer's page id (a UUID)",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/EnteredCode"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Verified"
          },
          "400": {
            "description": "Wrong or expired code, or too many attempts",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such page",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        }
      }
    },
    "/v1/public/customer-view/{company_id}/{view_id}/projects": {
      "get": {
        "tags": [
          "customer-view"
        ],
        "summary": "List the customer's projects",
        "description": "Newest first, with the stone, sink and how far the work is. Needs a\nverified visitor.",
        "operationId": "list_customer_view_projects",
        "parameters": [
          {
            "name": "company_id",
            "in": "path",
            "description": "Company id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "view_id",
            "in": "path",
            "description": "The customer's page id (a UUID)",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The projects",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/ViewProject"
                  }
                }
              }
            }
          },
          "401": {
            "description": "No code entered for this page",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such page",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        }
      }
    },
    "/v1/public/customer-view/{company_id}/{view_id}/schedule": {
      "get": {
        "tags": [
          "customer-view"
        ],
        "summary": "List the customer's appointments",
        "description": "Their templates, installations, estimates and other visits, by start:\nwaiting-for-a-date ones last. Repeating events are left out. Needs a\nverified visitor.",
        "operationId": "list_customer_view_schedule",
        "parameters": [
          {
            "name": "company_id",
            "in": "path",
            "description": "Company id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "view_id",
            "in": "path",
            "description": "The customer's page id (a UUID)",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The appointments",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/ViewAppointment"
                  }
                }
              }
            }
          },
          "401": {
            "description": "No code entered for this page",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such page",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        }
      }
    },
    "/v1/public/customer-view/{company_id}/{view_id}/quotes": {
      "get": {
        "tags": [
          "customer-view"
        ],
        "summary": "List the customer's online quotes",
        "description": "The quotes the customer made with the online quote, newest first: each\nwith its drawing and each color's total (no price breakdown). Only for a\nverified visitor.",
        "operationId": "list_customer_view_quotes",
        "parameters": [
          {
            "name": "company_id",
            "in": "path",
            "description": "Company id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "view_id",
            "in": "path",
            "description": "The customer's page id (a UUID)",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The quotes",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/CustomerOnlineQuote"
                  }
                }
              }
            }
          },
          "401": {
            "description": "No code entered for this page",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such page",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        }
      }
    },
    "/v1/public/customer-view/{company_id}/{view_id}/invoices": {
      "get": {
        "tags": [
          "customer-view"
        ],
        "summary": "List the customer's invoices",
        "description": "Their `QuickBooks` invoices, newest first; `status` says why there are\nnone (`missing_qbo_id` until the company links the customer to\n`QuickBooks`). Needs a verified visitor.",
        "operationId": "list_customer_view_invoices",
        "parameters": [
          {
            "name": "company_id",
            "in": "path",
            "description": "Company id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "view_id",
            "in": "path",
            "description": "The customer's page id (a UUID)",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The invoices",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CustomerInvoices"
                }
              }
            }
          },
          "401": {
            "description": "No code entered for this page",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such page",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        }
      }
    },
    "/v1/public/customer-view/{company_id}/{view_id}/invoices/{invoice_id}/pdf": {
      "get": {
        "tags": [
          "customer-view"
        ],
        "summary": "Get one of the customer's invoices as a PDF",
        "description": "Only an invoice of this customer's `QuickBooks` customer. Needs a\nverified visitor.",
        "operationId": "get_customer_view_invoice_pdf",
        "parameters": [
          {
            "name": "company_id",
            "in": "path",
            "description": "Company id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "view_id",
            "in": "path",
            "description": "The customer's page id (a UUID)",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "invoice_id",
            "in": "path",
            "description": "QuickBooks invoice id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The PDF",
            "content": {
              "application/pdf": {
                "schema": {
                  "type": "array",
                  "items": {
                    "type": "integer",
                    "format": "int32",
                    "minimum": 0
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid invoice id",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No code entered for this page",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Not this customer's invoice",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such page, or not linked to QuickBooks",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "409": {
            "description": "QuickBooks is not connected",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "502": {
            "description": "QuickBooks failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        }
      }
    },
    "/v1/public/customer-view/{company_id}/login": {
      "get": {
        "tags": [
          "customer-view"
        ],
        "summary": "Check a pending sign-in",
        "description": "Whether a code was asked for on the company's account page\n(`pendingAccountLoginChallenge`).",
        "operationId": "get_customer_view_login",
        "parameters": [
          {
            "name": "company_id",
            "in": "path",
            "description": "Company id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The pending sign-in",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PendingLogin"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        }
      }
    },
    "/v1/public/customer-view/{company_id}/login/code": {
      "post": {
        "tags": [
          "customer-view"
        ],
        "summary": "Email or text a code to an account",
        "description": "Sends a code when a customer of the company has that email, or texts one\nwhen a customer has that phone (or phone 2). The answer is the same\neither way, so it does not reveal who is a customer. Same limits as\n`send_customer_view_code`.",
        "operationId": "send_customer_view_login_code",
        "parameters": [
          {
            "name": "company_id",
            "in": "path",
            "description": "Company id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/LoginEmail"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Sent (if the address is a customer's)"
          },
          "400": {
            "description": "Not an email or a phone",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "409": {
            "description": "The company cannot text codes",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "429": {
            "description": "A code was just sent, or 5 this hour",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "502": {
            "description": "The email or text could not be sent",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        }
      }
    },
    "/v1/public/customer-view/{company_id}/login/verify": {
      "post": {
        "tags": [
          "customer-view"
        ],
        "summary": "Enter an account sign-in code",
        "description": "Verifies the code sent to the account's address or phone (8 attempts at most);\nanswers the page it unlocks.",
        "operationId": "verify_customer_view_login_code",
        "parameters": [
          {
            "name": "company_id",
            "in": "path",
            "description": "Company id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/EnteredCode"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Verified",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenedView"
                }
              }
            }
          },
          "400": {
            "description": "Wrong or expired code, or too many attempts",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        }
      }
    },
    "/v1/public/customer-view/login": {
      "delete": {
        "tags": [
          "customer-view"
        ],
        "summary": "Drop a pending code",
        "description": "So the visitor can sign in with another email or phone.",
        "operationId": "cancel_customer_view_code",
        "responses": {
          "204": {
            "description": "Dropped"
          }
        }
      }
    },
    "/v1/superuser/customer-view/{company_id}/{customer_id}": {
      "post": {
        "tags": [
          "customer-view"
        ],
        "summary": "Open a customer's page as a super admin",
        "description": "Marks this browser verified for the customer's page, with no code, and\nanswers the page to open. Super admins only.",
        "operationId": "superuser_open_customer_view",
        "parameters": [
          {
            "name": "company_id",
            "in": "path",
            "description": "Company id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "customer_id",
            "in": "path",
            "description": "Customer id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Verified",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenedView"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not a super admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such customer page",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/public/customer-view/{company_id}/{view_id}/contact": {
      "get": {
        "tags": [
          "customer-view"
        ],
        "summary": "Get who the customer deals with",
        "description": "Their sales rep's name, email and phone, and the company. Needs a\nverified visitor.",
        "operationId": "get_customer_view_contact",
        "parameters": [
          {
            "name": "company_id",
            "in": "path",
            "description": "Company id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "view_id",
            "in": "path",
            "description": "The customer's page id (a UUID)",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The contact",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ViewContact"
                }
              }
            }
          },
          "401": {
            "description": "No code entered for this page",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such page",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        }
      }
    },
    "/v1/public/customer-view/{company_id}/{view_id}/documents": {
      "get": {
        "tags": [
          "customer-view"
        ],
        "summary": "List the customer's documents",
        "description": "The contracts sent to them for signature (sent, opened or signed; not\ndrafts, declined or expired ones) and the quotes emailed to them, newest\nfirst. Needs a verified visitor.",
        "operationId": "list_customer_view_documents",
        "parameters": [
          {
            "name": "company_id",
            "in": "path",
            "description": "Company id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "view_id",
            "in": "path",
            "description": "The customer's page id (a UUID)",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The documents",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/ViewDocument"
                  }
                }
              }
            }
          },
          "401": {
            "description": "No code entered for this page",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such page",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        }
      }
    },
    "/v1/public/customer-view/{company_id}/{view_id}/documents/{id}": {
      "get": {
        "tags": [
          "customer-view"
        ],
        "summary": "Open one of the customer's contracts",
        "description": "The PDF of a contract sent to this customer: signed once they signed it,\nelse as sent. Opened in a browser tab: errors are plain text. Needs a\nverified visitor.",
        "operationId": "open_customer_view_document",
        "parameters": [
          {
            "name": "company_id",
            "in": "path",
            "description": "Company id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "view_id",
            "in": "path",
            "description": "The customer's page id (a UUID)",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "id",
            "in": "path",
            "description": "Signature request id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The PDF",
            "content": {
              "application/pdf": {}
            }
          },
          "302": {
            "description": "Over 4 MB: redirect to a presigned link"
          },
          "401": {
            "description": "No code entered for this page",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such page, or not this customer's contract",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "502": {
            "description": "The document could not be downloaded",
            "content": {
              "text/plain": {}
            }
          },
          "503": {
            "description": "The file cannot be read right now",
            "content": {
              "text/plain": {}
            }
          }
        }
      }
    },
    "/v1/public/customer-view/{company_id}/{view_id}/crew/{event_id}": {
      "get": {
        "tags": [
          "customer-view"
        ],
        "summary": "Where the crew is",
        "description": "Only while the crew of this customer's visit is on the way (they tapped\n**On my way** and have not arrived) and their phone reported in the last\n30 minutes; otherwise 404. Needs a verified visitor.",
        "operationId": "get_customer_view_crew",
        "parameters": [
          {
            "name": "company_id",
            "in": "path",
            "description": "Company id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "view_id",
            "in": "path",
            "description": "The customer's page id (a UUID)",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "event_id",
            "in": "path",
            "description": "The visit (event id)",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The crew",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ViewCrew"
                }
              }
            }
          },
          "401": {
            "description": "No code entered for this page",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such page, or the crew is not on the way",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        }
      }
    },
    "/v1/public/customer-view/{company_id}/{view_id}/visits/options": {
      "get": {
        "tags": [
          "customer-view"
        ],
        "summary": "Get the visits the customer can book",
        "description": "The kinds of visit (`estimate`: a salesperson comes to the customer's\naddress; `showroom`: the customer comes to the showroom), each an hour,\nand the open start times of the next 30 days by local day (ISO 8601 UTC,\nevery 30 minutes, at least 2 hours ahead). A time is open when it is\ninside the company's booking hours and at least one Sales Rep or Sales\nManager is free for the whole hour (inside their own working hours, with\nnothing else on their schedule). `salespeople` lists them and each day's\n`people` says who is free at each time. Book one with `POST .../visits`.\nNeeds a verified visitor.",
        "operationId": "get_customer_view_visit_options",
        "parameters": [
          {
            "name": "company_id",
            "in": "path",
            "description": "Company id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "view_id",
            "in": "path",
            "description": "The customer's page id (a UUID)",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The kinds and open times",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/VisitOptions"
                }
              }
            }
          },
          "401": {
            "description": "No code entered for this page",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such page",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        }
      }
    },
    "/v1/public/customer-view/{company_id}/{view_id}/visits": {
      "post": {
        "tags": [
          "customer-view"
        ],
        "summary": "Book a visit for the customer",
        "description": "Books the kind of visit at one of the open `times` of\n`GET .../visits/options`, re-checked now: it goes to the `salesperson_id`\npicked, else a Sales Rep or Sales Manager free then (at random when\nseveral are), lands on the Estimates\ncalendar with them as its person, is emailed to the customer (texted\nwhen they have no email), and gets the usual reminders. An in-home\nestimate needs an address (the one sent, else the customer's on file).\nA customer may have at most 3 visits coming. Needs a verified visitor.",
        "operationId": "book_customer_view_visit",
        "parameters": [
          {
            "name": "company_id",
            "in": "path",
            "description": "Company id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "view_id",
            "in": "path",
            "description": "The customer's page id (a UUID)",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/BookVisitInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Booked",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BookedVisit"
                }
              }
            }
          },
          "400": {
            "description": "Not a time, no address for an estimate, a note too long, or no Estimates calendar",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No code entered for this page",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such page",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "409": {
            "description": "The time is no longer open, or 3 visits are already coming",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        }
      }
    },
    "/v1/company/payment-settings": {
      "get": {
        "tags": [
          "customer-payments"
        ],
        "summary": "Show the company's customer payment settings",
        "description": "Whether the company's bank account is connected (so customers can pay\nit), and for each payment method the fee and how much of it the company\npasses on to the customer. While the account is being verified, Stripe is\nasked whether it approved it at most once a minute per company; between\nthose the answer is the last one kept. Connect an account with `POST\n/v1/company/payment-settings/bank-account`; make payment links with `POST\n/v1/customers/{id}/payments`.",
        "operationId": "get_company_payment_settings",
        "responses": {
          "200": {
            "description": "The settings",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CompanyPaymentSettings"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "put": {
        "tags": [
          "customer-payments"
        ],
        "summary": "Set who pays the payment fees",
        "description": "How much of each method's fee the company adds to what its customers pay\n(the company pays the rest). Payment links made afterwards use the new\nsplit; existing ones keep theirs. Superusers and admins who are Managers\nonly.",
        "operationId": "set_company_payment_fees",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PaymentFeesInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Saved"
          },
          "400": {
            "description": "A share is out of range",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not a superuser or an admin Manager, or customer payments are not turned on for the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/company/payment-settings/bank-account": {
      "post": {
        "tags": [
          "customer-payments"
        ],
        "summary": "Connect the company's bank account",
        "description": "Starts, or continues, Stripe's onboarding of the company: the first call\ncreates its Stripe account. Open `url`; afterwards `GET\n/v1/company/payment-settings` says `setup_unfinished` until the form is\nsent, `pending_verification` until Stripe approves the account, then\n`connected`. Superusers and admins who are\nManagers only.",
        "operationId": "start_company_bank_onboarding",
        "responses": {
          "200": {
            "description": "Stripe's page",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BankOnboarding"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not a superuser or an admin Manager, or customer payments are not turned on for the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "The company was deleted",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "502": {
            "description": "Stripe failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "503": {
            "description": "Payments are not set up",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/customers/{id}/payments": {
      "get": {
        "tags": [
          "customer-payments"
        ],
        "summary": "List a customer's payments",
        "description": "The payments and unpaid payment links of the jobs of the customer's\nfamily (the customer, its parent and the parent's other projects: what\n`GET /v1/customers/{id}/projects` lists), newest first, withdrawn links\nincluded. `project_key` names the job. Money that reached the company is\n`paid`; an ACH transfer on its way is `pending`; a `disputed` payment\nstill counts toward its job, a `lost` one no longer does. A waiting payment whose\nnews from Stripe may have been missed is checked with Stripe here, at\nmost once in 5 minutes each. Unpaid links made for a Stripe account the\ncompany no longer uses are withdrawn here (`canceled`).",
        "operationId": "list_customer_payments",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Customer id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The payments, newest first",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/CustomerPayment"
                  }
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such customer in the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "post": {
        "tags": [
          "customer-payments"
        ],
        "summary": "Make a payment link",
        "description": "A link the customer pays `amount_cents` of one job on, by card or ACH.\nThe fee split in effect now is saved on the payment. Send `url` to the\ncustomer: it never expires, and the payment stays `created` until they\npay. The amount cannot be more than is left to pay on the job: its price\nless what was paid (a disputed payment counts until the bank decides),\nwhat is on its way and the links not paid yet (400 says how much that\nis). A deal's payments include those made for its sales before they\njoined it. A sale that is part of a deal takes no link of its own (400:\nmake it for the deal), nor does a cancelled sale. 409 until the company's bank account is connected (`GET\n/v1/company/payment-settings`). Withdraw an unpaid link with `DELETE\n/v1/customers/{id}/payments/{payment_id}`.",
        "operationId": "create_customer_payment",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Customer id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/NewPayment"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "The payment link",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CustomerPayment"
                }
              }
            }
          },
          "400": {
            "description": "Unknown job, a sale that is part of a deal or was cancelled, the amount is out of range, or it is more than is left to pay on the job",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin, or customer payments are not turned on for the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such customer in the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "409": {
            "description": "The company's bank account is not connected",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/customers/{id}/payments/{payment_id}": {
      "delete": {
        "tags": [
          "customer-payments"
        ],
        "summary": "Withdraw a payment link",
        "description": "Cancels a link nobody paid yet (`created`): its page then says it is no\nlonger active, and its open Stripe page is closed. A payment that was\nmade, is on its way or failed cannot be canceled (409). Canceling a\ncanceled link again changes nothing.",
        "operationId": "cancel_customer_payment",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Customer id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "payment_id",
            "in": "path",
            "description": "The payment's id (`pay_...`)",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Canceled"
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such customer or payment in the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "409": {
            "description": "The payment was already made or started",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/public/pay/{payment_id}": {
      "get": {
        "tags": [
          "customer-payments"
        ],
        "summary": "Show a payment link's page",
        "description": "What the customer is asked to pay, to whom and for which job, and whether\nit can still be paid (`status` is `created`). Once the customer opened\nStripe's page, Stripe is asked where the payment is (at most once a\nminute), so the page is right even when Stripe's own message was missed.\nA link made for a Stripe account the company no longer uses is withdrawn\n(`canceled`): it would send the money to the old account.\nNo session: the link's\nunguessable id is the credential. Next: `POST\n/v1/public/pay/{payment_id}/checkout`.",
        "operationId": "get_pay_page",
        "parameters": [
          {
            "name": "payment_id",
            "in": "path",
            "description": "The last part of the payment link (`pay_...`)",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The payment",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PayPage"
                }
              }
            }
          },
          "404": {
            "description": "No such payment link",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        }
      }
    },
    "/v1/public/pay/{payment_id}/checkout": {
      "post": {
        "tags": [
          "customer-payments"
        ],
        "summary": "Open Stripe's page for a payment link",
        "description": "A Stripe Checkout page on the company's account for the payment's amount\nplus the customer's part of the fee, with the payment's one method. A\npage opened before is reused while Stripe keeps it open (24 hours), and\nrequests at the same time (two tabs) get the same page, so a payment is\nnot made twice. 409 unless the payment is `created`, and for a link made\nfor a Stripe account the company no longer uses (the link is withdrawn;\nthe company makes a new one, which charges its account of today).",
        "operationId": "create_pay_checkout",
        "parameters": [
          {
            "name": "payment_id",
            "in": "path",
            "description": "The last part of the payment link (`pay_...`)",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Stripe's page",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PayCheckout"
                }
              }
            }
          },
          "404": {
            "description": "No such payment link",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "409": {
            "description": "The payment was made, is on its way, failed or was withdrawn, or the link was made for a Stripe account the company no longer uses",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "502": {
            "description": "Stripe failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "503": {
            "description": "Payments are not set up",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        }
      }
    },
    "/v1/public/pay/{payment_id}/bank-form": {
      "post": {
        "tags": [
          "customer-payments"
        ],
        "summary": "Open the bank form on the payment page",
        "description": "What Stripe.js needs to show the bank form on our own page, with the\ncustomer's name and email to fill in (they can change both): they sign\nin to their bank, or type the routing and account numbers. Nothing is\ncharged until they confirm it there. Asked again, the same payment intent\nis used while it can still be confirmed, so a payment is not made twice;\nan open Checkout page of the payment is closed first. ACH links only.\n503 when the form is not set up (no publishable key, demo mode): use\n`POST /v1/public/pay/{payment_id}/checkout` then.",
        "operationId": "create_pay_bank_form",
        "parameters": [
          {
            "name": "payment_id",
            "in": "path",
            "description": "The last part of the payment link (`pay_...`)",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "What Stripe.js needs",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BankForm"
                }
              }
            }
          },
          "404": {
            "description": "No such payment link",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "409": {
            "description": "The payment was made, is on its way, failed or was withdrawn; a card link; or the link was made for a Stripe account the company no longer uses",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "502": {
            "description": "Stripe failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "503": {
            "description": "The form is not set up",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        }
      }
    },
    "/v1/public/pay/{payment_id}/bank-transfer": {
      "post": {
        "tags": [
          "customer-payments"
        ],
        "summary": "Send the payment from the customer's bank app",
        "description": "The routing and account number the customer sends the payment to from\ntheir own bank app (Stripe's US bank transfers), with the amount still\nto send. The account number is the customer's own, so the money is\nmatched to them by itself; the payment is `paid` once it arrives\n(usually 1-3 business days). Asked again, the same transfer is shown.\nACH links only, of a company whose Stripe account takes US bank\ntransfers (`bank_app` on the page). 409 unless the payment is `created`,\nfor a card link, when the company does not take such transfers, and for\na link made for a Stripe account the company no longer uses.",
        "operationId": "create_pay_bank_transfer",
        "parameters": [
          {
            "name": "payment_id",
            "in": "path",
            "description": "The last part of the payment link (`pay_...`)",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Where to send the money",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BankTransfer"
                }
              }
            }
          },
          "404": {
            "description": "No such payment link",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "409": {
            "description": "The payment was made, is on its way, failed or was withdrawn; a card link; the company does not take transfers from a bank app; or the link was made for a Stripe account the company no longer uses",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "502": {
            "description": "Stripe failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "503": {
            "description": "Payments are not set up",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        }
      }
    },
    "/v1/public/pay/{payment_id}/demo": {
      "post": {
        "tags": [
          "customer-payments"
        ],
        "summary": "Report a demo payment's outcome",
        "description": "Demo mode only (`CUSTOMER_PAYMENTS_DEMO=1`, local runs; 404 otherwise):\nstands in for Stripe's webhook, moving the payment on and notifying the\ncompany exactly as a real payment would. Nothing is charged.",
        "operationId": "report_demo_payment",
        "parameters": [
          {
            "name": "payment_id",
            "in": "path",
            "description": "The last part of the payment link (`pay_...`)",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DemoPayment"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Recorded (or the payment was already past that point)"
          },
          "400": {
            "description": "Unknown outcome",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "Not in demo mode, or no such payment link",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        }
      }
    },
    "/v1/public/customer-view/{company_id}/{view_id}/payments": {
      "get": {
        "tags": [
          "customer-view"
        ],
        "summary": "List the customer's payments",
        "description": "The customer's jobs (the deals they signed and their sales) with what\nthey cost, what the customer paid through payment links and what is\nleft, with each payment and each link still to pay. Needs a verified\nvisitor.",
        "operationId": "list_customer_view_payments",
        "parameters": [
          {
            "name": "company_id",
            "in": "path",
            "description": "Company id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "view_id",
            "in": "path",
            "description": "The customer's page id (a UUID)",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The jobs, the payments and the balance",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CustomerViewPayments"
                }
              }
            }
          },
          "401": {
            "description": "No code entered for this page",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such page",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "customer-view"
        ],
        "summary": "Pay on the customer's own page",
        "description": "Makes a payment link for `amount_cents` of one of the customer's jobs, as\n`POST /v1/customers/{id}/payments` does, with the fee split the company\nset: the customer pays the 3% card fee on top only while the company has\n\"Add 3% on top\" on. The customer's earlier unpaid links of this page for\nthe same job are withdrawn first, so a page left half paid never blocks\nthe balance; their links of other jobs and invoices stay (one may be a\ntransfer they already sent from their bank app). Then open Stripe's page\nwith `POST /v1/public/pay/{payment_id}/checkout`.\nNeeds a verified visitor.",
        "operationId": "create_customer_view_payment",
        "parameters": [
          {
            "name": "company_id",
            "in": "path",
            "description": "Company id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "view_id",
            "in": "path",
            "description": "The customer's page id (a UUID)",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SelfPayment"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "The payment link",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SelfPaymentMade"
                }
              }
            }
          },
          "400": {
            "description": "Unknown job, or the amount is out of range or more than is left to pay",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No code entered for this page",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Customer payments are not turned on for the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such page",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "409": {
            "description": "The company's bank account is not connected",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        }
      }
    },
    "/v1/customers/{id}/qbo-invoices/{invoice_id}/pay-link": {
      "get": {
        "tags": [
          "customer-payments"
        ],
        "summary": "Get the pay link of a customer's invoice",
        "description": "The page the customer pays the invoice on (the PDF's \"View and pay\"), for\nthe email that sends it.",
        "operationId": "get_customer_qbo_invoice_pay_link",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Customer id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "invoice_id",
            "in": "path",
            "description": "QuickBooks invoice id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The link",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InvoicePayLink"
                }
              }
            }
          },
          "400": {
            "description": "Invalid invoice id",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Not an invoice of this customer",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such customer, or it is not linked to QuickBooks",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "409": {
            "description": "QuickBooks is not connected",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "502": {
            "description": "QuickBooks failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/public/invoice-pay/{link_id}": {
      "get": {
        "tags": [
          "customer-payments"
        ],
        "summary": "Show an invoice's payment page",
        "description": "The invoice, what is left to pay on it, and whether the customer can pay\nit here and how much each way costs. No sign-in: the link's unguessable\nid is the credential. Next: `POST /v1/public/invoice-pay/{link_id}/payments`.",
        "operationId": "get_invoice_pay_page",
        "parameters": [
          {
            "name": "link_id",
            "in": "path",
            "description": "The last part of the invoice's link (`inv_...`)",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The invoice",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InvoicePayPage"
                }
              }
            }
          },
          "404": {
            "description": "No such link",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "409": {
            "description": "QuickBooks is not connected",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "502": {
            "description": "QuickBooks failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        }
      }
    },
    "/v1/public/invoice-pay/{link_id}/payments": {
      "post": {
        "tags": [
          "customer-payments"
        ],
        "summary": "Pay an invoice on its page",
        "description": "Makes a payment link for what the page offers (`amount_cents`), by card\nor bank, for this invoice of its job, with the fee split the company set\n(as the customer's own page does). Paid, it counts toward the job and is\nrecorded on this invoice first, never on an older one of the job. The\ncustomer's earlier unpaid links of their own for this invoice (or the\njob as a whole) are withdrawn first; those of other invoices stay. Then\nopen Stripe's page with `POST /v1/public/pay/{payment_id}/checkout`.",
        "operationId": "create_invoice_pay_payment",
        "parameters": [
          {
            "name": "link_id",
            "in": "path",
            "description": "The last part of the invoice's link (`inv_...`)",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/InvoicePayment"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "The payment link",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SelfPaymentMade"
                }
              }
            }
          },
          "400": {
            "description": "Nothing left to pay, or too little for a card",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Customer payments are not turned on for the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such link",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "409": {
            "description": "The company's bank account is not connected, or QuickBooks is not",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "502": {
            "description": "QuickBooks failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        }
      }
    },
    "/v1/public/invoice-pay/{link_id}/pdf": {
      "get": {
        "tags": [
          "customer-payments"
        ],
        "summary": "Get an invoice's PDF from its page",
        "description": "The invoice as we send it. No sign-in: the link is the credential.",
        "operationId": "get_invoice_pay_pdf",
        "parameters": [
          {
            "name": "link_id",
            "in": "path",
            "description": "The last part of the invoice's link (`inv_...`)",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The PDF",
            "content": {
              "application/pdf": {
                "schema": {
                  "type": "array",
                  "items": {
                    "type": "integer",
                    "format": "int32",
                    "minimum": 0
                  }
                }
              }
            }
          },
          "404": {
            "description": "No such link",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "409": {
            "description": "QuickBooks is not connected",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "502": {
            "description": "QuickBooks failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        }
      }
    },
    "/v1/webhooks/stripe-connect": {
      "post": {
        "tags": [
          "customer-payments"
        ],
        "summary": "Receive a Stripe Connect event",
        "description": "Stripe's webhook for the companies' connected accounts: Checkout,\npayment intent, refund and dispute events move a customer's payment on\n(and notify the company), and account events update the company's bank\nstatus. A declined card only notifies: the link stays payable. A partial\nrefund keeps the payment `paid` and records what was given back. A\ndispute makes it `disputed`, then `paid` again when won or `lost` when\nthe bank gives the money back (the dispute's own status decides, on any\n`charge.dispute.*` event). `account.application.deauthorized` (the\ncompany cut the platform off from its Stripe account) leaves the company\nnot connected. Events of an account only move payments made for that\naccount, also after the company changed to another one. Each\nchange is made once, however often Stripe sends the event. Needs a valid\n`Stripe-Signature` for `STRIPE_CONNECT_WEBHOOK_SECRET`; no session.",
        "operationId": "receive_stripe_connect_webhook",
        "parameters": [
          {
            "name": "Stripe-Signature",
            "in": "header",
            "description": "Stripe's signature of the body",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "description": "The Stripe event, as Stripe sent it",
          "content": {
            "application/json": {
              "schema": {
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Processed (or ignored)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ConnectWebhookReceived"
                }
              }
            }
          },
          "400": {
            "description": "Missing or invalid signature, or not configured",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Processing failed; Stripe retries",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        }
      }
    },
    "/v1/payments": {
      "get": {
        "tags": [
          "customer-payments"
        ],
        "summary": "List the company's payments for the app",
        "description": "The Payments tab of the Granite Manager app: the company's payments and\nunpaid payment links, newest first (100 at most, withdrawn links left\nout), each with its customer, its job and who took it, and whether a\npayment can be taken now. Someone who is only an installer gets the\npayments they took themselves; `customer_id` keeps one customer's. A\nwaiting payment whose news from Stripe may have been missed is checked\nwith Stripe here, a few at a time.",
        "operationId": "list_app_payments",
        "parameters": [
          {
            "name": "mine",
            "in": "query",
            "description": "Only the payments the caller took. Always so for someone who is only\nan installer.",
            "required": false,
            "schema": {
              "type": "boolean"
            }
          },
          {
            "name": "customer_id",
            "in": "query",
            "description": "Only this customer's payments (the app's contact card).",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The payments, newest first",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AppPayments"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "post": {
        "tags": [
          "customer-payments"
        ],
        "summary": "Take a payment in the app",
        "description": "Makes a payment link for an amount of one of the customer's jobs, as\n`POST /v1/customers/{id}/payments` does, for the app to show as a code\nthe customer scans (`url`) or to send them. With `add_card_fee` a card\npayment's 3% fee is added on top of the amount (`customer_fee_cents`).\nWithout `customer_id` the payment is for no customer and no job: any\namount in range, recorded on no invoice. Read it again with `GET /v1/payments/{payment_id}` to learn when it is\npaid.",
        "operationId": "take_app_payment",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TakePayment"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "The payment",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AppPayment"
                }
              }
            }
          },
          "400": {
            "description": "Unknown job, or the amount is out of range or more than is left to pay on the job",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Customer payments are not turned on for the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such customer in the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "409": {
            "description": "The company's bank account is not connected",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/payments/jobs": {
      "get": {
        "tags": [
          "customer-payments"
        ],
        "summary": "List what a customer can pay for",
        "description": "A company on `QuickBooks`: the customer's open `QuickBooks` invoices\n(`kind` `invoice`, oldest first), then their jobs with no invoice that\nwere made after their newest invoice and still owe something. Any other\ncompany: the customer's jobs that still owe something (the deals they\nsigned and their sales outside them, oldest first). Each with its total,\nwhat was paid toward it, what is on its way and what is left:\n`free_cents` is the most a new payment can be for. Something paid in full\nis left out.",
        "operationId": "list_app_payment_jobs",
        "parameters": [
          {
            "name": "customer_id",
            "in": "query",
            "description": "The customer.",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The jobs",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/PayJob"
                  }
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such customer in the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/payments/my-jobs": {
      "get": {
        "tags": [
          "customer-payments"
        ],
        "summary": "List my jobs to take a payment on",
        "description": "The events of the range assigned to the caller or that they were added\nto, that have a customer (the event's own, else its sale's), by start,\nwith what the customer still owes: on the job the event's sale is part\nof, else on all the customer's jobs. `can_take` is false until the\ncompany's bank account is connected: the app then shows no Take payment.",
        "operationId": "list_my_payment_jobs",
        "parameters": [
          {
            "name": "start",
            "in": "query",
            "description": "Range start (ISO 8601): the start of the caller's day.",
            "required": true,
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "end",
            "in": "query",
            "description": "Range end (ISO 8601).",
            "required": true,
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The jobs",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MyPayJobs"
                }
              }
            }
          },
          "400": {
            "description": "Missing or invalid range",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/payments/{payment_id}": {
      "get": {
        "tags": [
          "customer-payments"
        ],
        "summary": "Show one payment for the app",
        "description": "Where a payment is, for the app's screen that waits for the customer to\npay. While it waits, Stripe is asked about it at most once a minute, so\na missed webhook does not leave the screen waiting.",
        "operationId": "get_app_payment",
        "parameters": [
          {
            "name": "payment_id",
            "in": "path",
            "description": "The payment's id (`pay_...`)",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The payment",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AppPayment"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such payment in the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "delete": {
        "tags": [
          "customer-payments"
        ],
        "summary": "Withdraw a payment taken in the app",
        "description": "Cancels a payment nobody paid yet, as `DELETE\n/v1/customers/{id}/payments/{payment_id}` does: its code and link stop\nworking. 409 once it was paid or is on its way.",
        "operationId": "cancel_app_payment",
        "parameters": [
          {
            "name": "payment_id",
            "in": "path",
            "description": "The payment's id (`pay_...`)",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Canceled"
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such payment in the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "409": {
            "description": "The payment was already made or started",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "patch": {
        "tags": [
          "customer-payments"
        ],
        "summary": "Change the amount of a payment nobody paid yet",
        "description": "Its code and link stay the same and ask for the new amount; the fee is\nsplit as before. A Stripe page the customer had open for the old amount\nis closed. One the customer started on their own page counts as taken by\nthe caller from then on. 409 once it was paid or is on its way, and when\nthe customer was shown an account number to send it to.",
        "operationId": "change_app_payment",
        "parameters": [
          {
            "name": "payment_id",
            "in": "path",
            "description": "The payment's id (`pay_...`)",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ChangePayment"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "The payment",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AppPayment"
                }
              }
            }
          },
          "400": {
            "description": "The amount is out of range or more than is left to pay",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such payment in the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "409": {
            "description": "The payment was already made or started",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "502": {
            "description": "Stripe did not close the customer's open page; nothing changed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/payments/{payment_id}/refund": {
      "post": {
        "tags": [
          "customer-payments"
        ],
        "summary": "Refund a payment",
        "description": "Gives all of a paid payment back to the customer, or a part of it\n(`amount_cents`), through Stripe, on the card or bank account they paid\nwith. The payment shows the refund at once: `refunded` when all was given\nback, else `paid` with `refunded_cents`; its invoice loses the refund as\nwith a refund made in Stripe. Someone who is only an installer cannot\nrefund. 409 unless the payment was paid (a disputed payment is settled\nby the bank, not refunded).",
        "operationId": "refund_app_payment",
        "parameters": [
          {
            "name": "payment_id",
            "in": "path",
            "description": "The payment's id (`pay_...`)",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RefundPayment"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "The payment, refunded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AppPayment"
                }
              }
            }
          },
          "400": {
            "description": "The amount is 0 or more than is left to refund",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Only an installer: the office refunds",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such payment in the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "409": {
            "description": "The payment is not paid, or already refunded in full",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "502": {
            "description": "Stripe refused the refund; the message says why",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/payments/{payment_id}/links": {
      "get": {
        "tags": [
          "customer-payments"
        ],
        "summary": "Find what a payment is for",
        "description": "The deal, the project and the quotes of one payment, for the links beside\nits customer on the website's Payments page. A payment for a `QuickBooks`\ninvoice finds them through the quotes on that invoice.",
        "operationId": "get_app_payment_links",
        "parameters": [
          {
            "name": "payment_id",
            "in": "path",
            "description": "The payment's id (`pay_...`)",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Its deal, project and quotes",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PaymentLinks"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such payment in the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/users/sales-reps": {
      "get": {
        "tags": [
          "users"
        ],
        "summary": "List the company's sales reps",
        "description": "Returns the non-deleted users of the caller's company who hold the sales\nrep position. Use their ids for the `sales_rep` filter of `GET /v1/customers`.",
        "operationId": "list_sales_reps",
        "responses": {
          "200": {
            "description": "Sales reps of the current company",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/UserNameRow"
                  }
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/users/employees": {
      "get": {
        "tags": [
          "users"
        ],
        "summary": "List the company's employees",
        "description": "The non-deleted employees of the caller's company by name (\"User {id}\"\nwhen blank), e.g. to hide a calendar from one of them. Check-in kiosk\naccounts are left out.",
        "operationId": "list_employees",
        "responses": {
          "200": {
            "description": "Employees of the current company",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/UserNameRow"
                  }
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/users/activity": {
      "get": {
        "tags": [
          "users"
        ],
        "summary": "Users activity",
        "description": "The last 90 days of what the company's users did: deal activities (added,\ncompleted, deleted), notes, deal pictures and documents, deals made and\ndeleted, users and customers added, texts and emails (matched to customers\nby phone and address), newest first; the sales reps; and, while the\nleaderboard is on, everyone's calls, texts and points in the table's days.",
        "operationId": "list_users_activity",
        "parameters": [
          {
            "name": "calls_from",
            "in": "query",
            "description": "First day of the \"Calls & SMS points\" table (default: the 1st of this month, UTC).",
            "required": false,
            "schema": {
              "type": "string",
              "format": "date"
            }
          },
          {
            "name": "calls_to",
            "in": "query",
            "description": "Last day of that table, inclusive (default: today, UTC).",
            "required": false,
            "schema": {
              "type": "string",
              "format": "date"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Activity",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ActivityPage"
                }
              }
            }
          },
          "400": {
            "description": "The table's days end before they start",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/users/call-activity": {
      "get": {
        "tags": [
          "users"
        ],
        "summary": "List reps' calls",
        "description": "The `CloudTalk` and `RingCentral` calls of the given users of the caller's\ncompany over the last 90 days, and their Granite Manager calls (placed or\nanswered by them, and unanswered calls of their direct lines; `source`\n`telnyx_call`), newest first. Users without a `CloudTalk` agent or\n`RingCentral` extension, and companies without either, have no\n`CloudTalk` or `RingCentral` calls.",
        "operationId": "list_user_call_activity",
        "parameters": [
          {
            "name": "user_ids",
            "in": "query",
            "description": "Comma-separated user ids.",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Calls, newest first",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/CallActivity"
                  }
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/admin/users": {
      "get": {
        "tags": [
          "users"
        ],
        "summary": "List users",
        "description": "The live users of the caller's company (superusers: of `company_id`, or\nof every company), which of them only a superuser may change, the\ncompanies the caller may pick with their user counts and limits, and\nwhether the listed company has `CloudTalk` or `RingCentral`.",
        "operationId": "list_managed_users",
        "parameters": [
          {
            "name": "company_id",
            "in": "query",
            "description": "Superusers: one company's users (default every company's).",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The page",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UsersPage"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller may not manage users",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "post": {
        "tags": [
          "users"
        ],
        "summary": "Add a user",
        "description": "Creates a user with their email and positions in the caller's company\n(superusers: in `company_id`) and emails them an invite link (7 days) to\nset their own name, phone and password; they cannot sign in before. The\nemail must not belong to a live user; a deleted user's email is freed for\nit (the deleted row keeps its deals and emails under a renamed address,\nsee `free_deleted_email`). When the email fails the\nuser is still added: share the returned link instead.",
        "operationId": "create_managed_user",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/NewUser"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Added and invited",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CreatedUser"
                }
              }
            }
          },
          "400": {
            "description": "Invalid email, or positions that can't go together",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller may not manage users",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "409": {
            "description": "The email is taken",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/admin/users/{id}": {
      "get": {
        "tags": [
          "users"
        ],
        "summary": "Get a user to edit",
        "description": "The user with their positions, marketing and Super Admin companies, the\ncompanies the caller may pick (non-superusers: the user's own, the ones\na superuser granted marketing for and, for a Super Admin, the companies\nthey are Super Admin of) and their company's telephony.",
        "operationId": "get_managed_user",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "User id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The form",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UserForm"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller may not manage users, or only a superuser may change this one",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such live user of the caller's company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "put": {
        "tags": [
          "users"
        ],
        "summary": "Save a user",
        "description": "Saves the user's details and positions. Positions that stay keep their\nrows (Telegram lead buttons point at them). Super Admins may move the\nuser between companies they are Super Admin of; other non-superusers keep\nthe user's company. Non-superusers keep check-in; Super Admins of the\ncompany change Super Admin only in their own companies, others keep it\ncompanies as they are, and may only grant marketing for the user's own\ncompany and, as Super Admins, the companies they are Super Admin of (or\nremove companies a superuser granted). Super Admins are\nalways admins. The `RingCentral` extension follows the number. A user\nwho is no longer an employee or admin of their company (or moved to\nanother one) is signed out of Granite Manager.",
        "operationId": "update_managed_user",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "User id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UserChanges"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Saved"
          },
          "400": {
            "description": "Missing or invalid field, or positions that can't go together",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller may not manage users, or only a superuser may change this one",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such live user of the caller's company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "409": {
            "description": "The email is taken",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "delete": {
        "tags": [
          "users"
        ],
        "summary": "Delete a user",
        "description": "Soft-deletes a live user of the caller's company (superusers: any) and\nsigns them out everywhere (the website and Granite Manager apps). With\n`handover_to`, their work moves to that colleague first, in the same\ntransaction.",
        "operationId": "delete_managed_user",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "User id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "handover_to",
            "in": "query",
            "description": "A live user of the same company who takes over their customers,\ndeals, quotes, projects, upcoming events, open to-dos and waiting\nfollow-ups (see [`super::handover`]).",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Deleted"
          },
          "400": {
            "description": "The person taking over is not an active user of the same company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller may not manage users, or only a superuser may delete this one",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such live user of the caller's company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/admin/users/{id}/invite": {
      "post": {
        "tags": [
          "users"
        ],
        "summary": "Resend a user's invite",
        "description": "Emails a user who has not set up their account a new invite link (7\ndays); older links stop working. When the email fails the link is still\nanswered, to share another way.",
        "operationId": "resend_user_invite",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "User id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "A new link was made",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SentInvite"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller may not manage users, or only a superuser may change this one",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such live user of the caller's company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "409": {
            "description": "They already set up their account",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/admin/users/{id}/password-reset": {
      "post": {
        "tags": [
          "users"
        ],
        "summary": "Send a user a password reset link",
        "description": "For a user who forgot their password: makes a link that sets a new one\n(works once, for 24 hours; older links stop working), emails it to the\nuser's saved address and answers it too, so the manager can pass it on by\ntext if the email does not arrive. The current password keeps working\nuntil the link is used; using it signs the user out everywhere. Save a\ncorrected email with `PUT /v1/admin/users/{id}` first. For a user who has\nnot set up their account yet, call `POST /v1/admin/users/{id}/invite`\ninstead.",
        "operationId": "send_user_password_reset",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "User id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "A new link was made",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SentReset"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller may not manage users, or only a superuser may change this one",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such live user of the caller's company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "409": {
            "description": "They have not set up their account yet: resend the invite",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/admin/users/{id}/handover": {
      "get": {
        "tags": [
          "users"
        ],
        "summary": "What moves",
        "description": "How much of a live user's work moves to the colleague taking over when\nthey are removed.",
        "operationId": "user_handover",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "User id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "What moves",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Handover"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller may not manage users, or only a superuser may remove this one",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such live user of the caller's company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/stones": {
      "get": {
        "tags": [
          "stones"
        ],
        "summary": "List the company's stones with slab availability",
        "description": "Returns the stones of the caller's company that are on display (admins may\nadd hidden ones with `include_hidden=true`), sorted by name, each with counts of its slabs in the yard (`slabs`). Sold out stones\n(no available slab and not regular stock) are hidden unless\n`include_sold_out=true`; hidden and deleted stones are never returned.\nFilters combine with AND; list filters take the parameter repeated and\nmatch any value. Color ids come from the colors list, supplier ids from\nthe suppliers list.",
        "operationId": "list_stones",
        "parameters": [
          {
            "name": "type",
            "in": "query",
            "description": "Only stones of these types, e.g. `granite`, `quartz`, `marble`.",
            "required": false,
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              }
            }
          },
          {
            "name": "supplier_id",
            "in": "query",
            "description": "Only stones bought from this supplier (a supplier id).",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "color_id",
            "in": "query",
            "description": "Only stones tagged with at least one of these colors (color ids).",
            "required": false,
            "schema": {
              "type": "array",
              "items": {
                "type": "integer",
                "format": "int32"
              }
            }
          },
          {
            "name": "level",
            "in": "query",
            "description": "Only stones of these price levels (numbers of `GET /v1/stone-levels`).",
            "required": false,
            "schema": {
              "type": "array",
              "items": {
                "type": "integer",
                "format": "int32"
              }
            }
          },
          {
            "name": "finishing",
            "in": "query",
            "description": "Only stones with these surface finishes: `polished`, `leathered`, `honed`.",
            "required": false,
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              }
            }
          },
          {
            "name": "include_sold_out",
            "in": "query",
            "description": "`true` also returns sold out stones: no available slab and not regular\nstock. Default `false`.",
            "required": false,
            "schema": {
              "type": "boolean"
            }
          },
          {
            "name": "include_hidden",
            "in": "query",
            "description": "`true` also returns stones hidden from the catalogs (`is_display`\nfalse). Admins only (403 otherwise). Default `false`.",
            "required": false,
            "schema": {
              "type": "boolean"
            }
          },
          {
            "name": "location",
            "in": "query",
            "description": "Another location's company id: its displayed stones, look only (see\n`GET /v1/stones/settings`). Omitted: the caller's own company.",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Stones sorted by name",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/Stone"
                  }
                }
              }
            }
          },
          "400": {
            "description": "A filter has the wrong type, e.g. `supplier_id=abc`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or shop staff, asks for hidden stones without being an admin, or for a location that is not shared",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "post": {
        "tags": [
          "stones"
        ],
        "summary": "Add a stone",
        "description": "Creates a stone of the caller's company with its image (an upload to the\n`stones` folder, thumbnail made here) and colors. With `material_id` the\nstone goes into that material (folder) and takes its name; without it,\ninto the material of its name. Add its slabs with\n`POST /v1/stones/{id}/slabs`.",
        "operationId": "create_stone",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/StoneInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Stone created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CreatedStone"
                }
              }
            }
          },
          "400": {
            "description": "Missing name or image, unknown type, supplier, color or material, bad finishing, level, size or date",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database or storage error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "503": {
            "description": "Uploads are not configured",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/stones/search": {
      "get": {
        "tags": [
          "stones"
        ],
        "summary": "Search the company's stones by name, bundle or block number",
        "description": "Returns up to `limit` stones whose name, bundle number, block number or\na slab's bundle contains `name`, best matches first (exact bundle or block\nnumber, then name starts with it, then contains it as a word), each with the\nsame fields and slab counts as `GET /v1/stones`. By default only\ndisplayed stones that are regular stock or have an available whole slab;\nsee `include_sold_out` and `include_hidden`.",
        "operationId": "search_stones",
        "parameters": [
          {
            "name": "name",
            "in": "query",
            "description": "Part of the stone name, bundle number, block number or a slab's\nbundle, case-insensitive. Empty returns no stones.",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "include_sold_out",
            "in": "query",
            "description": "`true` also returns sold out stones. By default a stone is listed\nwhen it is regular stock or has an available whole slab.",
            "required": false,
            "schema": {
              "type": "boolean"
            }
          },
          {
            "name": "include_hidden",
            "in": "query",
            "description": "`true` also returns stones hidden from the catalog (`is_display`\nfalse). Default `false`.",
            "required": false,
            "schema": {
              "type": "boolean"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Most stones to return, 1 to 50. Default 25.",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int32",
              "minimum": 0
            }
          },
          {
            "name": "location",
            "in": "query",
            "description": "Another location's company id: search its displayed stones, look\nonly. Omitted: the caller's own company.",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Matching stones, best first",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/Stone"
                  }
                }
              }
            }
          },
          "400": {
            "description": "A parameter has the wrong type",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee, admin or of the shop",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/stones/settings": {
      "get": {
        "tags": [
          "stones"
        ],
        "summary": "Get the stone settings",
        "description": "What the company's Stones page shows first: `stones` (one card per stone,\nthe default) or `materials` (one card per material, then its stones), and\nwhether the staff can look at the other locations of the business (with\nthose locations). Also how many cards a row of the customer stones page\nshows on a wide screen, and the company's default for its own stones pages\n(`staff_stones_per_row`; each person may pick another on their device).",
        "operationId": "get_stone_settings",
        "responses": {
          "200": {
            "description": "The settings",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StaffStoneSettings"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee, admin or of the shop",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "put": {
        "tags": [
          "stones"
        ],
        "summary": "Save the stone settings",
        "description": "Admin › Stones › Settings. Switching to `materials` links every stone to\nthe material of its name (created when missing); `stones` keeps the\nlinks, so switching back and forth loses nothing. The other fields keep\nwhat is saved when omitted; `customer_stones_per_row` and\n`staff_stones_per_row` take 4, 6 or 7.",
        "operationId": "save_stone_settings",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SaveStoneSettings"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Saved"
          },
          "400": {
            "description": "Unknown `stone_view`, or `customer_stones_per_row` or `staff_stones_per_row` not 4, 6 or 7",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/stones/settings/slab-background": {
      "put": {
        "tags": [
          "stones"
        ],
        "summary": "Set the slab picture background",
        "description": "Admin › Stones › Settings. Saves the company's background picture (an\nupload to the `stones` folder) and the spot on it. Every stone picture\nuploaded from now on is placed in that spot; the ones already made with\nan older background are counted in `pending` and remade by\n`POST /v1/stones/settings/slab-background/apply`. Pictures uploaded\nbefore a background was set stay as they are.",
        "operationId": "save_slab_background",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SlabBackground"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Saved",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PendingPictures"
                }
              }
            }
          },
          "400": {
            "description": "Not an uploaded picture, or the corners are outside the picture, crossed or too close together",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database or storage error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "503": {
            "description": "Uploads are not configured",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "delete": {
        "tags": [
          "stones"
        ],
        "summary": "Remove the slab picture background",
        "description": "New stone pictures are stored as uploaded again. The ones on the\nbackground are counted in `pending`:\n`POST /v1/stones/settings/slab-background/apply` puts them back as they\nwere uploaded.",
        "operationId": "remove_slab_background",
        "responses": {
          "200": {
            "description": "Removed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PendingPictures"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/stones/settings/slab-background/apply": {
      "post": {
        "tags": [
          "stones"
        ],
        "summary": "Remake stone pictures for the current background",
        "description": "Remakes up to four stone pictures that were made with an older\nbackground: on the current one, or back as uploaded when the company\nremoved its background (the stone's close-up circle stays). Call it again while `pending` is above 0.",
        "operationId": "apply_slab_background",
        "responses": {
          "200": {
            "description": "A few pictures remade",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PendingPictures"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database or storage error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "503": {
            "description": "Uploads are not configured",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/stones/materials": {
      "get": {
        "tags": [
          "stones"
        ],
        "summary": "List the company's materials",
        "description": "Takes the filters of `GET /v1/stones` and returns, sorted by name, every\nmaterial that has a matching stone, with the slab counts of those stones\nsummed and how many installed project photos the material has. With\n`include_hidden` and no type, supplier, color, level or finishing filter,\nmaterials with no stone yet are listed too (`stones` 0; made with\n`POST /v1/stones/materials`). Links stones without a material first.",
        "operationId": "list_stone_materials",
        "parameters": [
          {
            "name": "type",
            "in": "query",
            "description": "Only stones of these types, e.g. `granite`, `quartz`, `marble`.",
            "required": false,
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              }
            }
          },
          {
            "name": "supplier_id",
            "in": "query",
            "description": "Only stones bought from this supplier (a supplier id).",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "color_id",
            "in": "query",
            "description": "Only stones tagged with at least one of these colors (color ids).",
            "required": false,
            "schema": {
              "type": "array",
              "items": {
                "type": "integer",
                "format": "int32"
              }
            }
          },
          {
            "name": "level",
            "in": "query",
            "description": "Only stones of these price levels (numbers of `GET /v1/stone-levels`).",
            "required": false,
            "schema": {
              "type": "array",
              "items": {
                "type": "integer",
                "format": "int32"
              }
            }
          },
          {
            "name": "finishing",
            "in": "query",
            "description": "Only stones with these surface finishes: `polished`, `leathered`, `honed`.",
            "required": false,
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              }
            }
          },
          {
            "name": "include_sold_out",
            "in": "query",
            "description": "`true` also returns sold out stones: no available slab and not regular\nstock. Default `false`.",
            "required": false,
            "schema": {
              "type": "boolean"
            }
          },
          {
            "name": "include_hidden",
            "in": "query",
            "description": "`true` also returns stones hidden from the catalogs (`is_display`\nfalse). Admins only (403 otherwise). Default `false`.",
            "required": false,
            "schema": {
              "type": "boolean"
            }
          },
          {
            "name": "location",
            "in": "query",
            "description": "Another location's company id: its displayed stones, look only (see\n`GET /v1/stones/settings`). Omitted: the caller's own company.",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Materials by name",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/StoneMaterial"
                  }
                }
              }
            }
          },
          "400": {
            "description": "A filter has the wrong type",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not staff, or asks for hidden stones without being an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "post": {
        "tags": [
          "stones"
        ],
        "summary": "Add a material",
        "description": "Creates an empty material (a folder for stones) of the caller's company,\nwith an optional photo. Admin › Stones lists it with `stones` 0 until a\nstone goes in: add one with `POST /v1/stones` and `material_id`, or with\nthe same name. Names are unique per company, any case (409).",
        "operationId": "create_stone_material",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/NewMaterial"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Material created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CreatedMaterial"
                }
              }
            }
          },
          "400": {
            "description": "Missing or too long name, unknown type, or not an uploaded photo",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "409": {
            "description": "The company has a material of that name",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database or storage error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/stones/materials/{id}": {
      "get": {
        "tags": [
          "stones"
        ],
        "summary": "Get one material",
        "description": "The material with all its stones (bundles, sold out ones included;\nhidden ones for admins only) sorted by bundle number, each with its slab\ncounts, and the installed project photos of every one of its stones.",
        "operationId": "get_stone_material",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Material id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "location",
            "in": "query",
            "description": "Another location's company id (`GET /v1/stones/settings` lists them).\nOmitted or the caller's own company: their own stones.",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The material",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MaterialDetail"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee, admin or of the shop",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such material in the caller's company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "put": {
        "tags": [
          "stones"
        ],
        "summary": "Edit a material",
        "description": "Admin › Stones (Materials first). Saves the material's name, type, level,\nfinish, colors, Regular Stock and photo; every one of its stones takes the\nname, type and Regular Stock,\nand the level and finish when the material has them. A name another\nmaterial already has puts this material's stones into that one.",
        "operationId": "save_stone_material",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Material id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SaveMaterial"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Saved",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SavedMaterial"
                }
              }
            }
          },
          "400": {
            "description": "Empty or too long name, unknown type, or not an uploaded photo",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such material in the caller's company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database or storage error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "delete": {
        "tags": [
          "stones"
        ],
        "summary": "Delete a material",
        "description": "Deletes a material of the caller's company and its own photo. A material\nthat still has stones (bundles) needs `include_bundles=true`, which hides\nthose stones and their slabs from every list (soft delete, as\n`DELETE /v1/stones/{id}`; sales history is kept); without it the answer\nis 409.",
        "operationId": "delete_stone_material",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Material id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "include_bundles",
            "in": "query",
            "description": "`true` also hides the material's bundles (stones) and their slabs,\nthe way deleting a stone with `include_slabs=true` does: nothing is\nerased. Without it, a material that still has bundles is not deleted\n(409).",
            "required": false,
            "schema": {
              "type": "boolean"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Material deleted (with its bundles and slabs when `include_bundles=true`)"
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such material in the caller's company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "409": {
            "description": "The material still has stones and `include_bundles` is not set",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database or storage error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/stones/quick": {
      "post": {
        "tags": [
          "stones"
        ],
        "summary": "Add a stone with its slabs in one step",
        "description": "Creates a displayed stone and either one leftover slab (bundle\n`LO-YYYYMMDD-XXXX`) or one slab per bundle label, all with the given\nsize. Used while selling a slab that is not in the system yet. Returns\nthe stone and the new slab ids, ready to put on a sale.",
        "operationId": "quick_add_stone",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/QuickStoneInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Stone and slabs created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/QuickStone"
                }
              }
            }
          },
          "400": {
            "description": "Missing name, non-positive price, negative size, unknown stone type, or no bundles",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/stones/{id}": {
      "get": {
        "tags": [
          "stones"
        ],
        "summary": "Get one stone",
        "description": "Returns every field of a stone of the caller's company, including hidden\n(not displayed) stones, plus the ids of its colors. Deleted stones and\nstones of other companies are 404. List its slabs with\n`GET /v1/stones/{id}/slabs`.",
        "operationId": "get_stone",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Stone id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "location",
            "in": "query",
            "description": "Another location's company id (`GET /v1/stones/settings` lists them).\nOmitted or the caller's own company: their own stones.",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The stone",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StoneDetail"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin, or the location is not shared",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such stone in the caller's company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "put": {
        "tags": [
          "stones"
        ],
        "summary": "Edit a stone",
        "description": "Saves every field of the body on a stone of the caller's company and\nreplaces its colors. With a new `image_url` the image is replaced and the\nold file deleted; with `remove_image` it goes back to the placeholder;\nwith neither the image is kept. With materials first, a stone whose\nmaterial has a level or finish keeps the material's.",
        "operationId": "update_stone",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Stone id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/StoneInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Stone saved"
          },
          "400": {
            "description": "Invalid field (see `create_stone`)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such stone in the caller's company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database or storage error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "delete": {
        "tags": [
          "stones"
        ],
        "summary": "Delete a stone",
        "description": "Hides a stone of the caller's company from every list (soft delete;\nnothing is erased). A stone that still has slabs in the yard needs\n`include_slabs=true`, which hides those slabs too.",
        "operationId": "delete_stone",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Stone id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "include_slabs",
            "in": "query",
            "description": "`true` also hides the stone's slabs in the yard. Without it, a stone\nthat still has slabs is not deleted (409).",
            "required": false,
            "schema": {
              "type": "boolean"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Stone deleted"
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such stone in the caller's company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "409": {
            "description": "The stone has slabs and `include_slabs` is not set",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/stones/{id}/slabs": {
      "get": {
        "tags": [
          "stones"
        ],
        "summary": "List a stone's slabs",
        "description": "Returns the slabs and remnants in the yard for a stone: its own plus\nthose of the stones it draws from (linked stones, marked with\n`source_stone`). Cut and deleted slabs are left out. Sold slabs carry\ntheir sale (customer, seller, date, notes, room, sinks); remnants carry\nthe sale of the slab they were cut from. Ordered by slab id; group by\n`bundle` for display. Sell an available slab with the sales routes,\nresize one with `PATCH /v1/slabs/{id}`.",
        "operationId": "list_stone_slabs",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Stone id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "location",
            "in": "query",
            "description": "Another location's company id (`GET /v1/stones/settings` lists them).\nOmitted or the caller's own company: their own stones.",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Slabs by id",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/StoneSlab"
                  }
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee, admin or of the shop, or the location is not shared",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such stone in the caller's company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "post": {
        "tags": [
          "stones"
        ],
        "summary": "Add a slab to a stone",
        "description": "Adds a slab in the yard with a bundle label, a size (the stone's size\nwhen length and width are 0 or missing) and an optional photo (an upload\nto the `stones` folder).",
        "operationId": "add_stone_slab",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Stone id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/NewSlab"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Slab added",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CreatedSlab"
                }
              }
            }
          },
          "400": {
            "description": "Empty bundle, negative size, or a photo URL that is not an upload",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such stone in the caller's company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database or storage error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/stones/{id}/samples": {
      "patch": {
        "tags": [
          "stones"
        ],
        "summary": "Set a stone's samples",
        "description": "Saves the samples on hand and/or how many to keep for a stone of the\ncaller's company.",
        "operationId": "update_stone_samples",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Stone id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SamplesInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Saved"
          },
          "400": {
            "description": "Negative amount, importance not 1-4, or nothing to save",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or shop staff",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such stone in the caller's company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/stones/names": {
      "get": {
        "tags": [
          "stones"
        ],
        "summary": "List stone names",
        "description": "Returns the live stones of the caller's company that have installed\nphotos (`has=images`) or slabs in the yard (`has=slabs`), by name: the\nchoices for linking photos or slabs.",
        "operationId": "list_stone_names",
        "parameters": [
          {
            "name": "has",
            "in": "query",
            "description": "`images` or `slabs`: only stones that have some.",
            "required": true,
            "schema": {
              "type": "string",
              "description": "What a stone must have to be listed by `GET /v1/stones/names`.",
              "enum": [
                "images",
                "slabs"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Stones by name",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/StoneRef"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Missing or unknown `has`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/stones/image-proxy": {
      "get": {
        "tags": [
          "stones"
        ],
        "summary": "Fetch a stone image through the API",
        "description": "Returns the bytes of an image in the storage bucket so the browser can\ndraw it on a canvas and crop it (the bucket sends no CORS headers): a\nstone's picture, or a slab picture in a quote layout. A crop is saved as a\nnew file, never over the original. Any employee may load one. Other URLs\nand files that are not images (or are SVG) are refused.",
        "operationId": "proxy_stone_image",
        "parameters": [
          {
            "name": "url",
            "in": "query",
            "description": "Public URL of an image in the company bucket.",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The image",
            "content": {
              "image/*": {
                "schema": {
                  "type": "array",
                  "items": {
                    "type": "integer",
                    "format": "int32",
                    "minimum": 0
                  }
                }
              }
            }
          },
          "400": {
            "description": "Not an image in the bucket",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such file",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Storage error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "503": {
            "description": "No bucket configured",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/stones/{id}/links": {
      "get": {
        "tags": [
          "stones"
        ],
        "summary": "List a stone's links",
        "description": "Returns the stones this one draws slabs from, the stones that draw slabs\nfrom it, and the stones whose photos it shows, each by name.",
        "operationId": "get_stone_links",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Stone id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Links of the stone",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StoneLinks"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such stone in the caller's company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/stones/{id}/images": {
      "get": {
        "tags": [
          "stones"
        ],
        "summary": "List a stone's installed photos",
        "description": "Returns the stone's own installed (project) photos, by id, then those of\nthe stones it links photos from, by stone name (marked with\n`source_stone`).",
        "operationId": "list_stone_images",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Stone id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Own photos, then linked ones",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/StoneImage"
                  }
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee, admin or of the shop",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such stone in the caller's company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "post": {
        "tags": [
          "stones"
        ],
        "summary": "Add installed photos to a stone",
        "description": "Saves uploads (`POST /v1/uploads`, folder `stones`) as installed photos\nof the stone and stores their thumbnails. Returns the new photos.",
        "operationId": "add_stone_images",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Stone id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AddImages"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Photos added",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/StoneImage"
                  }
                }
              }
            }
          },
          "400": {
            "description": "No URLs, more than 50, or a URL that is not an upload",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such stone in the caller's company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database or storage error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/stones/{id}/images/{image_id}": {
      "delete": {
        "tags": [
          "stones"
        ],
        "summary": "Delete an installed photo",
        "description": "Deletes one of the stone's own photos and its stored file.",
        "operationId": "delete_stone_image",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Stone id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "image_id",
            "in": "path",
            "description": "Photo id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Photo deleted"
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such photo on this stone of the caller's company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/stones/{id}/image-links": {
      "post": {
        "tags": [
          "stones"
        ],
        "summary": "Show another stone's photos on this stone",
        "description": "Links the installed photos of `source_stone_id` (same company) to the\nstone: they appear in `GET /v1/stones/{id}/images`. Linking twice is a\nno-op.",
        "operationId": "link_stone_images",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Stone id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/LinkInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Linked"
          },
          "400": {
            "description": "Unknown source stone, or the stone itself",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such stone in the caller's company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/stones/{id}/image-links/{source_stone_id}": {
      "delete": {
        "tags": [
          "stones"
        ],
        "summary": "Stop showing another stone's photos",
        "description": "Removes the photo link from `source_stone_id`; its photos stay on that\nstone.",
        "operationId": "unlink_stone_images",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Stone id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "source_stone_id",
            "in": "path",
            "description": "Stone whose photos were linked",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Unlinked (also when there was no link)"
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such stone in the caller's company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/stones/{id}/slab-links": {
      "post": {
        "tags": [
          "stones"
        ],
        "summary": "Draw slabs from another stone",
        "description": "Links `source_stone_id` (same company): its slabs count as this stone's\n(lists, slabs dialog, sales). A stone cannot draw from itself or from a\nstone that already draws from it. Linking twice is a no-op.",
        "operationId": "link_stone_slabs",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Stone id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/LinkInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Linked"
          },
          "400": {
            "description": "Unknown source stone, the stone itself, or a reverse link exists",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such stone in the caller's company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/stones/{id}/slab-links/{source_stone_id}": {
      "delete": {
        "tags": [
          "stones"
        ],
        "summary": "Stop drawing slabs from another stone",
        "description": "Removes the slab link: the source stone's slabs no longer count as this\nstone's. Sales already made are not touched.",
        "operationId": "unlink_stone_slabs",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Stone id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "source_stone_id",
            "in": "path",
            "description": "Stone the slabs came from",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Unlinked (also when there was no link)"
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such stone in the caller's company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/sinks": {
      "get": {
        "tags": [
          "sinks"
        ],
        "summary": "List the company's sink models with free units",
        "description": "Returns the non-deleted sink models of the caller's company, sorted by\nname, each with the number of units free to sell (`available`). Models\nnot on display are included (`is_display`). Sold out models (no free unit\nand not regular stock) are hidden unless `include_sold_out=true`. Filters\ncombine with AND; `type` takes the parameter repeated and matches any value.",
        "operationId": "list_sinks",
        "parameters": [
          {
            "name": "type",
            "in": "query",
            "description": "Only sink models of these types: `stainless 18 gauge`, `stainless 16 gauge`,\n`composite`, `ceramic`, `farm house`. Repeat the parameter for several.",
            "required": false,
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              }
            }
          },
          {
            "name": "supplier_id",
            "in": "query",
            "description": "Only sink models bought from this supplier (a supplier id).",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "include_sold_out",
            "in": "query",
            "description": "`true` also returns sold out models: no free unit and not regular\nstock. Default `false`.",
            "required": false,
            "schema": {
              "type": "boolean"
            }
          },
          {
            "name": "available_only",
            "in": "query",
            "description": "`true` returns only models with at least one free unit, even regular\nstock ones without units (what can be installed on a sale right now).\nOverrides `include_sold_out`. Default `false`.",
            "required": false,
            "schema": {
              "type": "boolean"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Sink models sorted by name",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/Sink"
                  }
                }
              }
            }
          },
          "400": {
            "description": "A filter has the wrong type, e.g. `supplier_id=abc`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "post": {
        "tags": [
          "sinks"
        ],
        "summary": "Add a sink model",
        "description": "Creates a sink model of the caller's company with its image (an upload\nto the `sinks` folder; the thumbnail is made here) and, with `units`,\nthat many units in stock.",
        "operationId": "create_sink",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/FixtureInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Model created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CreatedModel"
                }
              }
            }
          },
          "400": {
            "description": "Missing name or image, name over 255 characters, unknown type or supplier (a deleted supplier too), price negative or 100,000,000 and more, negative size or units",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database or storage error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "503": {
            "description": "Uploads are not configured",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/sinks/{id}": {
      "get": {
        "tags": [
          "sinks"
        ],
        "summary": "Get one sink model",
        "description": "Returns a live sink model of the caller's company with its unit counts\n(`units` includes the `installed_units` on sales).",
        "operationId": "get_sink",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Sink model id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The model",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FixtureModel"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such model in the caller's company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "put": {
        "tags": [
          "sinks"
        ],
        "summary": "Edit a sink model",
        "description": "Saves the fields of a sink model of the caller's company. A new\n`image_url` replaces the image (the old file is deleted unless another\nmodel or photo shows it). With `units`,\nfree units are added or removed to reach that total; units installed on\nsales are never removed (400 when `units` is below them).",
        "operationId": "update_sink",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Sink model id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/FixtureInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Saved"
          },
          "400": {
            "description": "Invalid field, or `units` below the installed units",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such model in the caller's company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database or storage error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "delete": {
        "tags": [
          "sinks"
        ],
        "summary": "Delete a sink model",
        "description": "Hides the model and its free units from every list. Units already\ninstalled on sales stay on those sales.",
        "operationId": "delete_sink",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Sink model id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Deleted"
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such model in the caller's company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/sinks/{id}/images": {
      "get": {
        "tags": [
          "sinks"
        ],
        "summary": "List a sink model's installed photos",
        "description": "Returns the project photos of the model, oldest first.",
        "operationId": "list_sink_images",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Sink model id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Photos",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/FixturePhoto"
                  }
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee, admin or of the shop",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such model in the caller's company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "post": {
        "tags": [
          "sinks"
        ],
        "summary": "Add installed photos to a sink model",
        "description": "Saves uploads to the `sinks` folder as project photos of the model and\nstores their thumbnails.",
        "operationId": "add_sink_images",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Sink model id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AddPhotos"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Photos added",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/FixturePhoto"
                  }
                }
              }
            }
          },
          "400": {
            "description": "No URLs, more than 50, or a URL that is not an upload",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such model in the caller's company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database or storage error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/sinks/{id}/images/{image_id}": {
      "delete": {
        "tags": [
          "sinks"
        ],
        "summary": "Delete an installed photo of a sink model",
        "description": "Deletes the photo, and its stored file unless another photo or a model\nshows it.",
        "operationId": "delete_sink_image",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Sink model id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "image_id",
            "in": "path",
            "description": "Photo id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Deleted"
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such photo on this model of the caller's company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/faucets": {
      "get": {
        "tags": [
          "faucets"
        ],
        "summary": "List the company's faucet models with free units",
        "description": "Returns the non-deleted faucet models of the caller's company, sorted by\nname, each with the number of units free to sell (`available`). Models\nnot on display are included (`is_display`). Sold out models (no free unit\nand not regular stock) are hidden unless `include_sold_out=true`. Filters\ncombine with AND; `type` takes the parameter repeated and matches any value.",
        "operationId": "list_faucets",
        "parameters": [
          {
            "name": "type",
            "in": "query",
            "description": "Only faucet models of these types: `single handle`, `double handle`.\nRepeat the parameter for several.",
            "required": false,
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              }
            }
          },
          {
            "name": "supplier_id",
            "in": "query",
            "description": "Only faucet models bought from this supplier (a supplier id).",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "include_sold_out",
            "in": "query",
            "description": "`true` also returns sold out models: no free unit and not regular\nstock. Default `false`.",
            "required": false,
            "schema": {
              "type": "boolean"
            }
          },
          {
            "name": "available_only",
            "in": "query",
            "description": "`true` returns only models with at least one free unit, even regular\nstock ones without units (what can be installed on a sale right now).\nOverrides `include_sold_out`. Default `false`.",
            "required": false,
            "schema": {
              "type": "boolean"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Faucet models sorted by name",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/Faucet"
                  }
                }
              }
            }
          },
          "400": {
            "description": "A filter has the wrong type, e.g. `supplier_id=abc`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "post": {
        "tags": [
          "faucets"
        ],
        "summary": "Add a faucet model",
        "description": "Creates a faucet model of the caller's company with its image (an upload\nto the `faucets` folder; the thumbnail is made here) and, with `units`,\nthat many units in stock.",
        "operationId": "create_faucet",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/FixtureInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Model created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CreatedModel"
                }
              }
            }
          },
          "400": {
            "description": "Missing name or image, name over 255 characters, unknown type or supplier (a deleted supplier too), price negative or 100,000,000 and more, negative size or units",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database or storage error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "503": {
            "description": "Uploads are not configured",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/faucets/{id}": {
      "get": {
        "tags": [
          "faucets"
        ],
        "summary": "Get one faucet model",
        "description": "Returns a live faucet model of the caller's company with its unit counts\n(`units` includes the `installed_units` on sales).",
        "operationId": "get_faucet",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Faucet model id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The model",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FixtureModel"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such model in the caller's company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "put": {
        "tags": [
          "faucets"
        ],
        "summary": "Edit a faucet model",
        "description": "Saves the fields of a faucet model of the caller's company. A new\n`image_url` replaces the image (the old file is deleted unless another\nmodel or photo shows it). With `units`,\nfree units are added or removed to reach that total; units installed on\nsales are never removed (400 when `units` is below them).",
        "operationId": "update_faucet",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Faucet model id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/FixtureInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Saved"
          },
          "400": {
            "description": "Invalid field, or `units` below the installed units",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such model in the caller's company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database or storage error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "delete": {
        "tags": [
          "faucets"
        ],
        "summary": "Delete a faucet model",
        "description": "Hides the model and its free units from every list. Units already\ninstalled on sales stay on those sales.",
        "operationId": "delete_faucet",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Faucet model id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Deleted"
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such model in the caller's company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/faucets/{id}/images": {
      "get": {
        "tags": [
          "faucets"
        ],
        "summary": "List a faucet model's installed photos",
        "description": "Returns the project photos of the model, oldest first.",
        "operationId": "list_faucet_images",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Faucet model id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Photos",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/FixturePhoto"
                  }
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee, admin or of the shop",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such model in the caller's company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "post": {
        "tags": [
          "faucets"
        ],
        "summary": "Add installed photos to a faucet model",
        "description": "Saves uploads to the `faucets` folder as project photos of the model and\nstores their thumbnails.",
        "operationId": "add_faucet_images",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Faucet model id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AddPhotos"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Photos added",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/FixturePhoto"
                  }
                }
              }
            }
          },
          "400": {
            "description": "No URLs, more than 50, or a URL that is not an upload",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such model in the caller's company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database or storage error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/faucets/{id}/images/{image_id}": {
      "delete": {
        "tags": [
          "faucets"
        ],
        "summary": "Delete an installed photo of a faucet model",
        "description": "Deletes the photo, and its stored file unless another photo or a model\nshows it.",
        "operationId": "delete_faucet_image",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Faucet model id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "image_id",
            "in": "path",
            "description": "Photo id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Deleted"
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such photo on this model of the caller's company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/slabs": {
      "get": {
        "tags": [
          "slabs"
        ],
        "summary": "Get slabs by id",
        "description": "Returns the slabs of the caller's company among the given ids (others are\nleft out), each with its bundle label and its stone (id, name, type).\nUse it to label slabs already chosen on a sale.",
        "operationId": "list_slabs_by_id",
        "parameters": [
          {
            "name": "id",
            "in": "query",
            "description": "Slab ids to return; repeat the parameter (`?id=1&id=2`). Required:\nwithout ids the list is empty.",
            "required": false,
            "schema": {
              "type": "array",
              "items": {
                "type": "integer",
                "format": "int64"
              }
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Slabs by id",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/SlabSummary"
                  }
                }
              }
            }
          },
          "400": {
            "description": "An id is not a number",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/slabs/{id}": {
      "delete": {
        "tags": [
          "slabs"
        ],
        "summary": "Delete a slab",
        "description": "Removes a slab of the caller's company from the yard (soft delete: it\ndisappears from every list).",
        "operationId": "delete_slab",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Slab id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Deleted"
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such slab in the caller's company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "patch": {
        "tags": [
          "slabs"
        ],
        "summary": "Change a slab's size or number",
        "description": "Sets the length and width (inches, both positive, sent together) and/or\nthe bundle label of one slab or remnant of the caller's company. Returns\nno body; reload the stone's slabs (`GET /v1/stones/{id}/slabs`) to see it.",
        "operationId": "update_slab",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Slab id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateSlab"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Saved"
          },
          "400": {
            "description": "Nothing to change, only one of length/width, a non-positive size, or an empty bundle",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such slab in the caller's company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/slabs/{id}/hold": {
      "put": {
        "tags": [
          "slabs"
        ],
        "summary": "Put a slab on hold",
        "description": "Holds an available (unsold, uncut) slab or remnant of the caller's\ncompany for 1 to 365 days from now, optionally for one customer of the\ncompany; the hold ends by itself. Holding again replaces the old hold. `GET /v1/stones/{id}/slabs` shows it\nas `hold`.",
        "operationId": "hold_slab",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Slab id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/HoldSlab"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "On hold"
          },
          "400": {
            "description": "Days is not 1 to 365, or the customer is not the company's",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such available slab in the caller's company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "delete": {
        "tags": [
          "slabs"
        ],
        "summary": "Take a slab off hold",
        "description": "Ends the hold of a slab of the caller's company now. A slab that is not\non hold stays as it is.",
        "operationId": "release_slab_hold",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Slab id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Off hold"
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such slab in the caller's company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/horus": {
      "get": {
        "tags": [
          "company"
        ],
        "summary": "Get the Horus connection",
        "description": "Whether the company reads its slabs from Horus (FusionDrive), when they\nwere last copied, why the last sync failed, and Horus's stone names with\nthe Granite stone each one's slabs go under. Superusers and company\nmanagers; superusers may pass `company_id`.",
        "operationId": "get_horus",
        "parameters": [
          {
            "name": "company_id",
            "in": "query",
            "description": "Superusers only: the company to act on (default: the caller's).",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The connection",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HorusStatus"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller does not manage the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "put": {
        "tags": [
          "company"
        ],
        "summary": "Connect Horus",
        "description": "Checks the FusionDrive key with Horus and saves it; the slabs are copied\nwithin the minute, then every 15 minutes. From then on Horus is the\ncompany's slab list: slabs typed in Granite before now are hidden\n(unless sold, cut or on hold) until Horus is disconnected.",
        "operationId": "connect_horus",
        "parameters": [
          {
            "name": "company_id",
            "in": "query",
            "description": "Superusers only: the company to act on (default: the caller's).",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ConnectHorus"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Connected",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HorusStatus"
                }
              }
            }
          },
          "400": {
            "description": "Horus refused the key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller does not manage the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "502": {
            "description": "Horus could not be reached",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "delete": {
        "tags": [
          "company"
        ],
        "summary": "Disconnect Horus",
        "description": "Stops copying slabs from Horus. The slabs typed in Granite that Horus\nhid come back; unsold Horus slabs leave the list (sold and cut ones stay\non their sales). Stone name matches are kept for a later connection.",
        "operationId": "disconnect_horus",
        "parameters": [
          {
            "name": "company_id",
            "in": "query",
            "description": "Superusers only: the company to act on (default: the caller's).",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Disconnected"
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller does not manage the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/horus/sync": {
      "post": {
        "tags": [
          "company"
        ],
        "summary": "Sync Horus now",
        "description": "The slabs are copied from Horus within the minute instead of at the next\n15-minute turn. Does nothing while a sync is running.",
        "operationId": "sync_horus",
        "parameters": [
          {
            "name": "company_id",
            "in": "query",
            "description": "Superusers only: the company to act on (default: the caller's).",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Asked for"
          },
          "400": {
            "description": "Horus is not connected",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller does not manage the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/horus/names": {
      "put": {
        "tags": [
          "company"
        ],
        "summary": "Match a Horus stone name",
        "description": "Puts the slabs of one Horus stone name under a stone of the company (or,\nwith `stone_id` null, keeps them out of Granite). The slabs move within\nthe minute.",
        "operationId": "match_horus_name",
        "parameters": [
          {
            "name": "company_id",
            "in": "query",
            "description": "Superusers only: the company to act on (default: the caller's).",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/MatchName"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Saved"
          },
          "400": {
            "description": "The stone is not the company's",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller does not manage the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "Horus has no such stone name",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/sales/{id}": {
      "get": {
        "tags": [
          "sales"
        ],
        "summary": "Get a sale for editing",
        "description": "Returns the sale's customer, seller, notes, price and its rooms, each with\nthe slabs used (`is_full` false when only part of a slab was sold), the\nsinks and faucets installed, and the room options. 404 when the sale is\nnot the company's or no slab is left on it. Save changes with\n`PUT /v1/sales/{id}`.",
        "operationId": "get_sale",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Sale id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The sale",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SaleContract"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such sale with slabs in the caller's company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "put": {
        "tags": [
          "sales"
        ],
        "summary": "Save an edited sale",
        "description": "Replaces the sale's customer, notes, price, rooms, slabs, sinks and\nfaucets with the body (the seller only when `seller_id` is given). Slabs\nmay be ones the sale already has or available ones; slabs left out are\nfreed, with their sinks and faucets, and the free remnants cut from them\nare removed. A cancelled sale is not edited (409): sell its slabs again\nwith `POST /v1/sales`. All or nothing.",
        "operationId": "update_sale",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Sale id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SaleInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Sale saved"
          },
          "400": {
            "description": "Invalid body (see `create_sale`)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such sale in the caller's company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "409": {
            "description": "The sale was cancelled",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/sales": {
      "post": {
        "tags": [
          "sales"
        ],
        "summary": "Sell slabs to a customer",
        "description": "Creates a pending sale dated now. Each room needs square feet and at least\none available slab of the company; a slab sold partially\n(`is_full: false`) leaves a remnant in the yard, and a slab used in\nseveral rooms gets a piece cut from it for each later room. Sinks and\nfaucets take one free unit of each model, installed on the room's first\nslab. A customer without a sales rep gets the seller. All or nothing: any\nerror leaves the data unchanged.",
        "operationId": "create_sale",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SaleInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Sale created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CreatedSale"
                }
              }
            }
          },
          "400": {
            "description": "Invalid body: no rooms, a room without slabs or square feet, two rooms with one `room_id`, a text or number that does not fit (see the fields), unknown customer/seller/slab/model, a slab already sold, or no free unit of a sink/faucet model",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/sales/{id}/unsell": {
      "post": {
        "tags": [
          "sales"
        ],
        "summary": "Cancel a sale",
        "description": "Marks the sale cancelled, frees its slabs and the sinks and faucets on\nthem, and removes the free remnants its partial slabs left. Remnants that\nanother sale bought are kept. Cancelling a cancelled sale again changes\nnothing: it keeps the date it was first cancelled. Returns no body.",
        "operationId": "unsell_sale",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Sale id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Sale cancelled"
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such sale in the caller's company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/sales/{id}/contract": {
      "get": {
        "tags": [
          "sales"
        ],
        "summary": "Get a sale's contract",
        "description": "The homeowner contract (or the commercial one when the customer has a\ncompany name) filled in with the sale: customer, rooms (at most three),\nstone, sinks, faucets, edges, extras and the price with its deposit.",
        "operationId": "get_sale_contract",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Sale id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The contract",
            "content": {
              "application/pdf": {
                "schema": {
                  "type": "array",
                  "items": {
                    "type": "integer",
                    "format": "int32",
                    "minimum": 0
                  }
                }
              }
            }
          },
          "400": {
            "description": "More than three rooms",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such sale (with slabs) in the caller's company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "502": {
            "description": "The template could not be read",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/sales/daily": {
      "get": {
        "tags": [
          "sales"
        ],
        "summary": "List a day's sales",
        "description": "Returns the company's sales from `from` up to `to` (not cancelled),\nnewest first: customer, sales rep, stone colors, sinks, package, amount,\ndeposit and the signed contract.",
        "operationId": "list_daily_sales",
        "parameters": [
          {
            "name": "from",
            "in": "query",
            "description": "First instant counted, e.g. the caller's local midnight in UTC\n(`2026-10-28T04:00:00Z`).",
            "required": true,
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "to",
            "in": "query",
            "description": "End of the range, not counted (the next local midnight). At most 31\ndays after `from`.",
            "required": true,
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Sales, newest first",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/DailySale"
                  }
                }
              }
            }
          },
          "400": {
            "description": "`to` is not after `from`, or more than 31 days after it",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/sales-orders": {
      "get": {
        "tags": [
          "sales"
        ],
        "summary": "List sales orders",
        "description": "The company's orders, newest first: the pending ones by default.",
        "operationId": "list_sales_orders",
        "parameters": [
          {
            "name": "status",
            "in": "query",
            "description": "`pending` (the default: still to confirm), `confirmed` or `all`\n(cancelled ones are never listed).",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The orders",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/SalesOrderRow"
                  }
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin, or has no Sales orders tab",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/sales-orders/{id}": {
      "get": {
        "tags": [
          "sales"
        ],
        "summary": "Get a sales order",
        "description": "The order with each color's rooms, square feet, the slabs the quote asks\nfor, the slabs set and, while pending, the free slabs of its stone.",
        "operationId": "get_sales_order",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Sales order id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The order",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SalesOrder"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin, or has no Sales orders tab",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such order in the caller's company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "put": {
        "tags": [
          "sales"
        ],
        "summary": "Save a sales order's slabs",
        "description": "Sets the slabs of the colors given (others keep theirs): each a free\nslab of the color's stone no other pending order holds, `is_full: false`\nfor part of one. Only a pending order changes. Returns the order.",
        "operationId": "save_sales_order",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Sales order id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SalesOrderInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Saved",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SalesOrder"
                }
              }
            }
          },
          "400": {
            "description": "Already confirmed, an unknown color, or a slab sold, held or set twice",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin, or has no Sales orders tab",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such order in the caller's company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/sales-orders/{id}/confirm": {
      "post": {
        "tags": [
          "sales"
        ],
        "summary": "Confirm a sales order",
        "description": "Saves the slabs given (as `PUT /v1/sales-orders/{id}`), then sells them\nto the order's customer as Sell slab does: one room per color, credited\nto the quote's sales rep, priced at the option's total; a slab used in\npart leaves a remnant. Colors without slabs are left out; with none at\nall, nothing is sold. All or nothing. Returns the order.",
        "operationId": "confirm_sales_order",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Sales order id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SalesOrderInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Confirmed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SalesOrder"
                }
              }
            }
          },
          "400": {
            "description": "Already confirmed, an unknown color, a slab sold, held or set twice, or the customer was deleted",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin, or has no Sales orders tab",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such order in the caller's company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/suppliers": {
      "get": {
        "tags": [
          "catalog"
        ],
        "summary": "List the company's suppliers",
        "description": "Returns every supplier of the caller's company, by name (with `has`, only\nthose the company has stones, sinks or faucets of). Stones, sinks and\nfaucets refer to them by `supplier_id`.",
        "operationId": "list_suppliers",
        "parameters": [
          {
            "name": "has",
            "in": "query",
            "description": "Only suppliers of the company's `stones`, `sinks` or `faucets`.",
            "required": false,
            "schema": {
              "type": "string",
              "description": "Items a supplier must have to be listed.",
              "enum": [
                "stones",
                "sinks",
                "faucets"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Suppliers by name",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/Supplier"
                  }
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "post": {
        "tags": [
          "catalog"
        ],
        "summary": "Add a supplier",
        "description": "Creates a supplier of the company and adds its phone number to the\ncompany's `CloudTalk` contacts. Returns its id.",
        "operationId": "create_supplier",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SupplierInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CreatedId"
                }
              }
            }
          },
          "400": {
            "description": "Missing name, a malformed website, phone or email, or a value longer than its limit",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/suppliers/directory": {
      "get": {
        "tags": [
          "catalog"
        ],
        "summary": "The supplier directory",
        "description": "Every supplier of the caller's company with its contact details and files,\nby id. The onboarding sample supplier is the page's to place.",
        "operationId": "list_supplier_directory",
        "responses": {
          "200": {
            "description": "Suppliers with files",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/SupplierEntry"
                  }
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/stone-types": {
      "get": {
        "tags": [
          "catalog"
        ],
        "summary": "List the company's stone types",
        "description": "Returns the materials stones of the company can have (`granite`,\n`quartz`...), by name. A stone's `type` must be one of them.",
        "operationId": "list_stone_types",
        "responses": {
          "200": {
            "description": "Stone types by name",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/StoneType"
                  }
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "post": {
        "tags": [
          "catalog"
        ],
        "summary": "Add a stone type",
        "description": "Creates a type for the caller's company. Names are unique per company,\nignoring case.",
        "operationId": "create_stone_type",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/StoneTypeInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Type created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StoneType"
                }
              }
            }
          },
          "400": {
            "description": "Empty or longer than 255 characters",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "409": {
            "description": "A type with this name exists",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/stone-types/{id}": {
      "delete": {
        "tags": [
          "catalog"
        ],
        "summary": "Delete a stone type",
        "description": "Deletes a type no live stone uses. When stones still use it, answers 409\nwith those stones; delete or retype them first.",
        "operationId": "delete_stone_type",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Stone type id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Type deleted"
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such type in the caller's company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "409": {
            "description": "Live stones use the type",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StoneTypeInUse"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "patch": {
        "tags": [
          "catalog"
        ],
        "summary": "Rename a stone type",
        "description": "Renames the type and sets the new name on every stone of the company that\nhad the old one.",
        "operationId": "rename_stone_type",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Stone type id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/StoneTypeInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Type renamed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StoneType"
                }
              }
            }
          },
          "400": {
            "description": "Empty or longer than 255 characters",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such type in the caller's company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "409": {
            "description": "Another type has this name",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/sink-types": {
      "get": {
        "tags": [
          "catalog"
        ],
        "summary": "List the company's sink types",
        "description": "Returns the sink types of the company (`composite`, `farm house`...), by\nname. A sink model's `type` must be one of them.",
        "operationId": "list_sink_types",
        "responses": {
          "200": {
            "description": "Sink types by name",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/StoneType"
                  }
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "post": {
        "tags": [
          "catalog"
        ],
        "summary": "Add a sink type",
        "description": "Creates a sink type for the caller's company. Names are unique per\ncompany, ignoring case.",
        "operationId": "create_sink_type",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/StoneTypeInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Type created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StoneType"
                }
              }
            }
          },
          "400": {
            "description": "Empty or longer than 255 characters",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "409": {
            "description": "A type with this name exists",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/sink-types/{id}": {
      "delete": {
        "tags": [
          "catalog"
        ],
        "summary": "Delete a sink type",
        "description": "Deletes a type no live sink model uses. When models still use it, answers\n409 with those models; delete or retype them first.",
        "operationId": "delete_sink_type",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Sink type id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Type deleted"
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such type in the caller's company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "409": {
            "description": "Live sink models use the type",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SinkTypeInUse"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "patch": {
        "tags": [
          "catalog"
        ],
        "summary": "Rename a sink type",
        "description": "Renames the type and sets the new name on every sink model of the company\nthat had the old one.",
        "operationId": "rename_sink_type",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Sink type id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/StoneTypeInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Type renamed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StoneType"
                }
              }
            }
          },
          "400": {
            "description": "Empty or longer than 255 characters",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such type in the caller's company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "409": {
            "description": "Another type has this name",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/stone-finishes": {
      "get": {
        "tags": [
          "catalog"
        ],
        "summary": "List the company's stone finishes",
        "description": "Returns the surface finishes stones of the company can have (`polished`,\n`honed`...), by name. A stone's `finishing` must be one of them.",
        "operationId": "list_stone_finishes",
        "responses": {
          "200": {
            "description": "Stone finishes by name",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/StoneType"
                  }
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "post": {
        "tags": [
          "catalog"
        ],
        "summary": "Add a stone finish",
        "description": "Creates a finish for the caller's company. Names are unique per company,\nignoring case.",
        "operationId": "create_stone_finish",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/StoneTypeInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Finish created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StoneType"
                }
              }
            }
          },
          "400": {
            "description": "Empty or longer than 255 characters",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "409": {
            "description": "A finish with this name exists",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/stone-finishes/{id}": {
      "delete": {
        "tags": [
          "catalog"
        ],
        "summary": "Delete a stone finish",
        "description": "Deletes a finish no live stone uses. When stones still use it, answers\n409 with those stones; delete or change them first.",
        "operationId": "delete_stone_finish",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Stone finish id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Finish deleted"
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such finish in the caller's company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "409": {
            "description": "Live stones use the finish",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StoneTypeInUse"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "patch": {
        "tags": [
          "catalog"
        ],
        "summary": "Rename a stone finish",
        "description": "Renames the finish and sets the new name on every stone of the company\nthat had the old one.",
        "operationId": "rename_stone_finish",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Stone finish id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/StoneTypeInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Finish renamed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StoneType"
                }
              }
            }
          },
          "400": {
            "description": "Empty or longer than 255 characters",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such finish in the caller's company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "409": {
            "description": "Another finish has this name",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/colors": {
      "get": {
        "tags": [
          "catalog"
        ],
        "summary": "List the company's stone colors",
        "description": "Returns the colors stones and materials of the caller's company can be\ntagged with, by name: the shared list until an admin edits it in\nMaterials Setup, then the company's own. Stones and materials carry them\nas `color_ids`; ids change once, on the company's first edit.",
        "operationId": "list_colors",
        "responses": {
          "200": {
            "description": "Colors by name",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/Color"
                  }
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "post": {
        "tags": [
          "catalog"
        ],
        "summary": "Add a stone color",
        "description": "Adds a color to the caller's company. The company's first add, change\nor delete copies the shared list as its own and moves its stones and\nmaterials onto the copies (their color ids change); call\n`GET /v1/colors` again afterwards. Names are unique per company,\nignoring case; 30 colors at most.",
        "operationId": "create_color",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ColorInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Color added",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Color"
                }
              }
            }
          },
          "400": {
            "description": "Bad name or shade, or 30 colors already",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "409": {
            "description": "A color with this name exists",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/colors/{id}": {
      "delete": {
        "tags": [
          "catalog"
        ],
        "summary": "Delete a stone color",
        "description": "Deletes one of the company's colors that no live stone (bundle) and no\nmaterial has. When some do, answers 409 with them: untag them first\n(Edit material / Edit stone). The company's last color cannot be deleted.",
        "operationId": "delete_color",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Color id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Color deleted"
          },
          "400": {
            "description": "It is the company's last color",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "Not one of the company's colors",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "409": {
            "description": "Live stones or materials have it",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ColorInUse"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "patch": {
        "tags": [
          "catalog"
        ],
        "summary": "Rename or recolor a stone color",
        "description": "Changes the name and shade of one of the company's colors; stones and\nmaterials keep it. A shared color's id (from before the company's first\nedit) changes the company's copy, and the answer carries the copy's id.",
        "operationId": "update_color",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Color id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ColorInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Color changed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Color"
                }
              }
            }
          },
          "400": {
            "description": "Bad name or shade",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "Not one of the company's colors",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "409": {
            "description": "Another color has this name",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/stone-levels": {
      "get": {
        "tags": [
          "catalog"
        ],
        "summary": "List the company's stone levels",
        "description": "Returns the levels stones and materials of the caller's company can\nhave, by number, with their names: 1 to 7 without names until an admin\nchanges them in Materials Setup. A stone's or material's `level` must be\none of these numbers.",
        "operationId": "list_stone_levels",
        "responses": {
          "200": {
            "description": "Levels by number",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/StoneLevel"
                  }
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "post": {
        "tags": [
          "catalog"
        ],
        "summary": "Add a stone level",
        "description": "Adds a level numbered one more than the company's highest, with an\noptional name; 20 levels at most. Levels are never renumbered, so a new\nlevel always comes last. Stones of a new level get no price-group price\nin quotes until a price group of the price list covers its number\n(Quotes › Price Lists).",
        "operationId": "create_stone_level",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/LevelInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Level added",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StoneLevel"
                }
              }
            }
          },
          "400": {
            "description": "Name too long, or 20 levels already",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/stone-levels/{number}": {
      "delete": {
        "tags": [
          "catalog"
        ],
        "summary": "Delete a stone level",
        "description": "Deletes one of the company's levels that no live stone (bundle) and no\nmaterial has; the other levels keep their numbers. When some do, answers\n409 with them: change their level first. The last level cannot be\ndeleted.",
        "operationId": "delete_stone_level",
        "parameters": [
          {
            "name": "number",
            "in": "path",
            "description": "Level number",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Level deleted"
          },
          "400": {
            "description": "It is the company's last level",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "Not one of the company's levels",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "409": {
            "description": "Live stones or materials have it",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LevelInUse"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "patch": {
        "tags": [
          "catalog"
        ],
        "summary": "Name a stone level",
        "description": "Sets or clears (null or blank) the name of one of the company's levels.\nIts number, and so its stones, prices and commissions, stay the same.",
        "operationId": "update_stone_level",
        "parameters": [
          {
            "name": "number",
            "in": "path",
            "description": "Level number",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/LevelInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Level named",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StoneLevel"
                }
              }
            }
          },
          "400": {
            "description": "Name too long",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "Not one of the company's levels",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/checklists": {
      "get": {
        "tags": [
          "checklists"
        ],
        "summary": "List the company's post-installation checklists",
        "description": "Returns every checklist of the caller's company, newest first (ties by\nid, highest first), with the installer's name and the result of each\ncheck. The customer's signature is not included; the signed PDF of a\nchecklist is at `GET /v1/checklists/{id}/pdf`.",
        "operationId": "list_checklists",
        "responses": {
          "200": {
            "description": "Checklists, newest first",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/Checklist"
                  }
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "post": {
        "tags": [
          "checklists"
        ],
        "summary": "Save a post-installation checklist",
        "description": "An installer records the customer's sign-off. Offline installers queue\nthese and send them when back online, so a `customer_id` that is not a\ncustomer of the company (deleted since) does not refuse the checklist: it\nis saved without a customer. The name and the address are 1 to 255\ncharacters, the comments 16,000 at most, the signature 65,535 bytes at\nmost; a 400 says which one does not fit.",
        "operationId": "create_checklist",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/NewChecklist"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Saved",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CreatedChecklist"
                }
              }
            }
          },
          "400": {
            "description": "Missing name, address or signature, a bad email, or a text too long for the checklist",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an installer",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/checklists/{id}/pdf": {
      "get": {
        "tags": [
          "checklists"
        ],
        "summary": "Get a checklist as a PDF",
        "description": "The checklist with its checks, comments and the customer's signature,\nunder the company logo.",
        "operationId": "get_checklist_pdf",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Checklist id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          },
          {
            "name": "samples",
            "in": "query",
            "description": "The onboarding tour is open: its sample checklist can be opened.",
            "required": false,
            "schema": {
              "type": "boolean"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The PDF",
            "content": {
              "application/pdf": {
                "schema": {
                  "type": "array",
                  "items": {
                    "type": "integer",
                    "format": "int32",
                    "minimum": 0
                  }
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such checklist in the caller's company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/installer/context": {
      "get": {
        "tags": [
          "checklists"
        ],
        "summary": "The installer portal's context",
        "description": "Returns the caller's company, its logo and whether its QuickBooks data\nis usable. Only installers may call it (403 otherwise: an employee\nbelongs in the employee pages).",
        "operationId": "get_installer_context",
        "responses": {
          "200": {
            "description": "The context",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InstallerContext"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an installer",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/uploads": {
      "post": {
        "tags": [
          "uploads"
        ],
        "summary": "Start an upload",
        "description": "Returns a presigned URL to `PUT` the file to (straight to storage, any\nsize) and the public URL the file will have. Then pass `url` to the\nrecord's route, e.g. `PUT /v1/stones/{id}` (`image_url`),\n`POST /v1/stones/{id}/images` or `POST /v1/deals/{id}/files`; that route\nalso makes the thumbnail. Inventory folders (`stones`, `sinks`,\n`faucets`) are for admins, and for someone whose position opens an admin\ninventory tab (Admin › Stones, Sinks or Faucets: an Inventory Manager by\ndefault), as that tab's routes are theirs as admin; `deals` for\n(and `events`) any employee and also take documents; `quotes` and\n`template-images` and `user-photos` (my own picture, then `PUT /v1/me/photo`)\nany employee, images only; `emails` for any employee, any\nfile, and the response has the `token` `POST /v1/emails` asks for;\n`chats` (pictures for a project chat or the support chat) for any\nemployee, images only, into a private bucket: its `url` is an `s3://`\nreference for the chat's route, never a public link. Types a\nbrowser runs script in (HTML, SVG, XML, JavaScript) are refused everywhere.",
        "operationId": "create_upload",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UploadRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Upload URL and public URL",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Upload"
                }
              }
            }
          },
          "400": {
            "description": "Content type not allowed for the folder (HTML, SVG, XML and JavaScript never are), or a malformed body",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee, or the folder is admin-only and they are not an admin (for an inventory folder, nor made one there by an admin inventory tab)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Storage error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "503": {
            "description": "Uploads (or, for `chats`, the private chat bucket) are not configured on this server",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/uploads/from-url": {
      "post": {
        "tags": [
          "uploads"
        ],
        "summary": "Copy a picture from another website",
        "description": "Downloads the picture at `url` on the server and stores a copy in\n`template-images`, for a picture pasted into a rich-text editor\n(instructions, email templates and bodies): the browser usually may not\nread another website's pictures itself. Returns the copy's public URL to\nput in the text in place of the original address. Any employee may call\nit. Only `https` addresses on the standard port of the public internet are\nfetched (never private, loopback or link-local addresses, also after up to\n3 redirects), within 20 seconds, and the answer must be a JPEG, PNG, GIF or\nWebP picture of at most 10 MB, judged by its bytes. Every failure to fetch\nanswers the same 400; keep the original address then.",
        "operationId": "copy_upload_from_url",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UploadFromUrlRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "The stored copy",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CopiedUpload"
                }
              }
            }
          },
          "400": {
            "description": "A folder other than `template-images`, an address that may not be fetched, or no picture could be copied from it",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Storage error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "503": {
            "description": "Uploads are not configured on this server",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/uploads/file": {
      "get": {
        "tags": [
          "uploads"
        ],
        "summary": "Fetch a stored file through the API",
        "description": "Returns the bytes of an image or document in the storage bucket, for the\nbrowser to attach it to an email (the bucket sends no CORS headers).\nOther URLs and other file types (SVG included) are refused. The file is\nsent as a download that never renders as a page.",
        "operationId": "fetch_uploaded_file",
        "parameters": [
          {
            "name": "url",
            "in": "query",
            "description": "Public URL of a file in the bucket.",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The file",
            "content": {
              "application/octet-stream": {
                "schema": {
                  "type": "array",
                  "items": {
                    "type": "integer",
                    "format": "int32",
                    "minimum": 0
                  }
                }
              }
            }
          },
          "400": {
            "description": "Not an image or document in the bucket",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such file",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Storage error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "503": {
            "description": "No bucket configured",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/public/companies": {
      "get": {
        "tags": [
          "public"
        ],
        "summary": "List showroom companies",
        "description": "The name and logo of each live company among `ids`, by id, for the\ncustomer portal's company chooser. No session needed.",
        "operationId": "list_public_companies",
        "parameters": [
          {
            "name": "ids",
            "in": "query",
            "description": "Company ids (repeat the parameter); at most 20.",
            "required": false,
            "schema": {
              "type": "array",
              "items": {
                "type": "integer",
                "format": "int32"
              }
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The companies",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/PublicCompanyCard"
                  }
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        }
      }
    },
    "/v1/public/companies/by-subdomain/{subdomain}": {
      "get": {
        "tags": [
          "public"
        ],
        "summary": "Find a company by its subdomain",
        "description": "Returns the id of the company whose showroom lives at\n`<subdomain>.granite-manager.com`. No session needed.",
        "operationId": "get_public_company_by_subdomain",
        "parameters": [
          {
            "name": "subdomain",
            "in": "path",
            "description": "Subdomain, e.g. `granitedepotindy`",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PublicCompany"
                }
              }
            }
          },
          "404": {
            "description": "No live company has this subdomain",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        }
      }
    },
    "/v1/public/companies/{company_id}/stones": {
      "get": {
        "tags": [
          "public"
        ],
        "summary": "List a company's showroom stones",
        "description": "Returns the company's displayed stones that are regular stock or have an\navailable whole slab, by name, with slab counts and retail prices (never\ncosts). Filters combine with AND; repeat list filters to match any value.\nNo session needed.",
        "operationId": "list_public_stones",
        "parameters": [
          {
            "name": "company_id",
            "in": "path",
            "description": "Company id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "type",
            "in": "query",
            "description": "Only these types, e.g. `granite`, `quartz`.",
            "required": false,
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              }
            }
          },
          {
            "name": "color_id",
            "in": "query",
            "description": "Only stones tagged with at least one of these colors (color ids).",
            "required": false,
            "schema": {
              "type": "array",
              "items": {
                "type": "integer",
                "format": "int32"
              }
            }
          },
          {
            "name": "level",
            "in": "query",
            "description": "Only these price levels (numbers of the frame's `stone_levels`).",
            "required": false,
            "schema": {
              "type": "array",
              "items": {
                "type": "integer",
                "format": "int32"
              }
            }
          },
          {
            "name": "finishing",
            "in": "query",
            "description": "Only these finishes: `polished`, `leathered`, `honed`.",
            "required": false,
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              }
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Stones by name",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/PublicStone"
                  }
                }
              }
            }
          },
          "400": {
            "description": "A filter has the wrong type",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        }
      }
    },
    "/v1/public/companies/{company_id}/stones/search": {
      "get": {
        "tags": [
          "public"
        ],
        "summary": "Search a company's showroom stones by name",
        "description": "Same stones as the showroom list, filtered by name, best matches first\n(name starts with it, then contains it as a word). No session needed.",
        "operationId": "search_public_stones",
        "parameters": [
          {
            "name": "company_id",
            "in": "path",
            "description": "Company id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "name",
            "in": "query",
            "description": "Part of the stone name, case-insensitive; empty returns nothing.",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Most stones to return, 1 to 50. Default 25.",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int32",
              "minimum": 0
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Matching stones, best first",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/PublicStone"
                  }
                }
              }
            }
          },
          "400": {
            "description": "A parameter has the wrong type",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        }
      }
    },
    "/v1/public/companies/{company_id}/stones/{stone_id}": {
      "get": {
        "tags": [
          "public"
        ],
        "summary": "Get one showroom stone",
        "description": "Returns a displayed stone of the company (sold out included). Hidden,\ndeleted and other companies' stones are 404. No session needed.",
        "operationId": "get_public_stone",
        "parameters": [
          {
            "name": "company_id",
            "in": "path",
            "description": "Company id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "stone_id",
            "in": "path",
            "description": "Stone id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The stone",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PublicStone"
                }
              }
            }
          },
          "404": {
            "description": "Not a displayed stone of this company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        }
      }
    },
    "/v1/public/companies/{company_id}/stones/{stone_id}/slabs": {
      "get": {
        "tags": [
          "public"
        ],
        "summary": "List a showroom stone's available slabs",
        "description": "Returns the slabs of a displayed stone (and of the stones it draws from)\nthat are in the yard and not sold, by id. No session needed.",
        "operationId": "list_public_stone_slabs",
        "parameters": [
          {
            "name": "company_id",
            "in": "path",
            "description": "Company id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "stone_id",
            "in": "path",
            "description": "Stone id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Available slabs",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/PublicSlab"
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not a displayed stone of this company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        }
      }
    },
    "/v1/public/companies/{company_id}/stones/{stone_id}/images": {
      "get": {
        "tags": [
          "public"
        ],
        "summary": "List a showroom stone's installed photos",
        "description": "Returns project photos of a displayed stone, its own first, then those of\nthe stones it shows photos from. No session needed.",
        "operationId": "list_public_stone_images",
        "parameters": [
          {
            "name": "company_id",
            "in": "path",
            "description": "Company id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "stone_id",
            "in": "path",
            "description": "Stone id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Photos",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/PublicPhoto"
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not a displayed stone of this company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        }
      }
    },
    "/v1/public/companies/{company_id}/stone-view": {
      "get": {
        "tags": [
          "public"
        ],
        "summary": "Get a company's stone view",
        "description": "What the company's Stones pages show first, set in Admin › Stones ›\nSettings: `stones` (one card per stone, the default) or `materials` (one\ncard per material, then its stones). The showroom follows it, and shows\n`customer_stones_per_row` cards per row on a wide screen. No session\nneeded.",
        "operationId": "get_public_stone_view",
        "parameters": [
          {
            "name": "company_id",
            "in": "path",
            "description": "Company id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The stone view",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StoneSettings"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        }
      }
    },
    "/v1/public/companies/{company_id}/materials/{material_id}": {
      "get": {
        "tags": [
          "public"
        ],
        "summary": "Get one showroom material",
        "description": "A material of the company (the stones of one name) with its displayed\nstones in stock, by bundle number, and the installed photos of its\ndisplayed stones. No prices: the stones' `retail_price` and\n`slab_price_per_sqft` are null. A material without a stone in the\nshowroom is 404. No session needed.",
        "operationId": "get_public_material",
        "parameters": [
          {
            "name": "company_id",
            "in": "path",
            "description": "Company id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "material_id",
            "in": "path",
            "description": "Material id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The material",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PublicMaterial"
                }
              }
            }
          },
          "404": {
            "description": "No material of this company with a stone in the showroom",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        }
      }
    },
    "/v1/public/companies/{company_id}/sinks": {
      "get": {
        "tags": [
          "public"
        ],
        "summary": "List a company's showroom sinks",
        "description": "Returns displayed sink models with a free unit or regular stock, by name.\nNo session needed.",
        "operationId": "list_public_sinks",
        "parameters": [
          {
            "name": "company_id",
            "in": "path",
            "description": "Company id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "type",
            "in": "query",
            "description": "Only these types; repeat the parameter for several.",
            "required": false,
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              }
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Sink models by name",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/PublicFixture"
                  }
                }
              }
            }
          },
          "400": {
            "description": "A filter has the wrong type",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        }
      }
    },
    "/v1/public/companies/{company_id}/faucets": {
      "get": {
        "tags": [
          "public"
        ],
        "summary": "List a company's showroom faucets",
        "description": "Returns displayed faucet models with a free unit or regular stock, by\nname. No session needed.",
        "operationId": "list_public_faucets",
        "parameters": [
          {
            "name": "company_id",
            "in": "path",
            "description": "Company id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "type",
            "in": "query",
            "description": "Only these types; repeat the parameter for several.",
            "required": false,
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              }
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Faucet models by name",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/PublicFixture"
                  }
                }
              }
            }
          },
          "400": {
            "description": "A filter has the wrong type",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        }
      }
    },
    "/v1/public/colors": {
      "get": {
        "tags": [
          "public"
        ],
        "summary": "List the shared stone colors",
        "description": "The shared color list, by name: what a company has until it edits its\ncolors in Materials Setup. No session needed. For one company's colors\n(its own once it edited them) use `colors` of\n`GET /v1/public/companies/{company_id}/frame`.",
        "operationId": "list_public_colors",
        "responses": {
          "200": {
            "description": "Colors by name",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/Color"
                  }
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        }
      }
    },
    "/v1/public/vcard": {
      "get": {
        "tags": [
          "public"
        ],
        "summary": "Download a contact card",
        "description": "A vCard 3.0 file with the given name, phone, email, company and address.",
        "operationId": "download_vcard",
        "parameters": [
          {
            "name": "name",
            "in": "query",
            "description": "Full name.",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "phone",
            "in": "query",
            "description": "Phone number.",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "email",
            "in": "query",
            "description": "Email address.",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "company",
            "in": "query",
            "description": "Company.",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "address",
            "in": "query",
            "description": "Street address, one line.",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "filename",
            "in": "query",
            "description": "Download name; `.vcf` is added. Defaults to the name.",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The card",
            "content": {
              "text/vcard": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "400": {
            "description": "No contact field",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        }
      }
    },
    "/v1/public/hold-music/{file}": {
      "get": {
        "tags": [
          "public"
        ],
        "summary": "Download a hold music track",
        "description": "The MP3 of a built-in hold music track (`calm.mp3`, `bright.mp3`,\n`ambient.mp3`; see `GET /v1/phone/hold-music`). 404 for any other name.",
        "operationId": "download_hold_music_track",
        "parameters": [
          {
            "name": "file",
            "in": "path",
            "description": "The track's id with `.mp3`, e.g. `calm.mp3`",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The MP3",
            "content": {
              "audio/mpeg": {
                "schema": {
                  "type": "array",
                  "items": {
                    "type": "integer",
                    "format": "int32",
                    "minimum": 0
                  }
                }
              }
            }
          },
          "404": {
            "description": "No such track",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        }
      }
    },
    "/v1/public/calendly-url": {
      "get": {
        "tags": [
          "public"
        ],
        "summary": "Get the demo booking page",
        "description": "The Calendly page the marketing site opens to book a demo.",
        "operationId": "get_calendly_url",
        "responses": {
          "200": {
            "description": "Booking page",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CalendlyUrl"
                }
              }
            }
          }
        }
      }
    },
    "/v1/public/companies/{company_id}/survey": {
      "get": {
        "tags": [
          "public"
        ],
        "summary": "The survey form",
        "description": "The company's name, sales reps and installers, for the customer to pick\nwho they worked with. No session needed.",
        "operationId": "get_public_survey",
        "parameters": [
          {
            "name": "company_id",
            "in": "path",
            "description": "Company id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The form",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SurveyForm"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        }
      }
    },
    "/v1/public/companies/{company_id}/surveys": {
      "post": {
        "tags": [
          "public"
        ],
        "summary": "Answer the survey",
        "description": "Saves the customer's ratings for the company, with their name only when\nthey give one (otherwise anonymous). With a valid link\n(`checklist_id` and `token`) the checklist's reminders stop, and the link\nanswers once: a second answer from it is not saved (still 201, the first\nanswer stays). A missing or forged token only skips that. No session\nneeded.",
        "operationId": "create_public_survey",
        "parameters": [
          {
            "name": "company_id",
            "in": "path",
            "description": "Company id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SurveyInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Saved, or this link was answered before (nothing saved)"
          },
          "400": {
            "description": "A rating outside 1-5, a name over 255 characters, or someone who is not the company's sales rep or installer",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        }
      }
    },
    "/v1/company/features": {
      "get": {
        "tags": [
          "company"
        ],
        "summary": "Get the company's features",
        "description": "Returns which features the company the request acts in has switched on\n(QuickBooks, guided tours, the points leaderboard) and which integrations\nit has set up (QuickBooks connection, e-signatures, inbound email,\nCloudTalk, RingCentral). Use it to decide what to offer before calling the\nroutes behind those features.",
        "operationId": "get_company_features",
        "responses": {
          "200": {
            "description": "The company's features",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CompanyFeatures"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/company/drive-miles": {
      "get": {
        "tags": [
          "company"
        ],
        "summary": "Driving miles from the company",
        "description": "Miles by car from the company's address to `address`; null when either\naddress is missing or there is no route.",
        "operationId": "get_drive_miles",
        "parameters": [
          {
            "name": "address",
            "in": "query",
            "description": "Where to drive to.",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Miles",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DriveMiles"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/company/tax-rate": {
      "get": {
        "tags": [
          "company"
        ],
        "summary": "Get the company's sales tax",
        "description": "The state sales tax the company charges, for price calculators (0 when\nnot set).",
        "operationId": "get_company_tax_rate",
        "responses": {
          "200": {
            "description": "The tax rate",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TaxRate"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/me/stats/sales": {
      "get": {
        "tags": [
          "stats"
        ],
        "summary": "Get my sales this month",
        "description": "Returns the signed-in user's deals this month so far (from the 1st through\ntoday, UTC): how many were won and lost and the amount won, how many were\ncreated, and the open pipeline (count and amount, whenever created). Only\ndeals assigned to the user, of live customers of the company and in live\ndeal lists, count.",
        "operationId": "get_my_sales_stats",
        "responses": {
          "200": {
            "description": "This month's deal numbers",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SalesStats"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/me/stats/deal-conversion": {
      "get": {
        "tags": [
          "stats"
        ],
        "summary": "Get my deal conversion",
        "description": "Returns how many of the signed-in user's deals were won out of all of\nthem, overall and by how the customer came in (leads, walk-in, call-in).\nAll time; deals of deleted customers or in deleted lists are left out.",
        "operationId": "get_my_deal_conversion",
        "responses": {
          "200": {
            "description": "Won and total deals by customer source",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DealConversion"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/me/stats/top-stones": {
      "get": {
        "tags": [
          "stats"
        ],
        "summary": "List the stones I sold most this month",
        "description": "Returns up to 3 stones the signed-in user sold the most full slabs of this\nmonth so far (sales not cancelled; remnants not counted), most slabs first,\nthen most square feet. Empty when they sold none.",
        "operationId": "list_my_top_sold_stones",
        "responses": {
          "200": {
            "description": "Top stones, best first",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/TopSoldStone"
                  }
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/me/stats/sent-emails": {
      "get": {
        "tags": [
          "stats"
        ],
        "summary": "List my sent emails per month",
        "description": "Returns how many emails the signed-in user sent in each of the current\nmonth and the two before it (UTC), oldest first. Months without emails are\nleft out. Counts emails of the company and ones with no company.",
        "operationId": "list_my_sent_emails_per_month",
        "responses": {
          "200": {
            "description": "Emails sent per month",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/MonthlyCount"
                  }
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/me/stats/sent-sms": {
      "get": {
        "tags": [
          "stats"
        ],
        "summary": "List my sent texts per month",
        "description": "Returns the company's SMS provider (RingCentral when both RingCentral and\nCloudTalk are set up) and how many texts the signed-in user sent through\nit in each of the current month and the two before it (UTC), oldest first.\nCounts sent outbound texts sent by the user or through their CloudTalk\nagent / RingCentral extension. Months without texts are left out; with no\nprovider, `provider` is null and `months` empty.",
        "operationId": "list_my_sent_sms_per_month",
        "responses": {
          "200": {
            "description": "The provider and texts sent per month",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SentSms"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/me/stats/outreach": {
      "get": {
        "tags": [
          "stats"
        ],
        "summary": "Get my outreach today",
        "description": "Returns how many outbound calls, texts and emails the signed-in user made\ntoday (midnight to midnight in the company's time zone), and the company's\ndaily minimums for each (null when not set).",
        "operationId": "get_my_outreach_today",
        "responses": {
          "200": {
            "description": "Today's calls, texts and emails",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Outreach"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/me/outreach-goals": {
      "put": {
        "tags": [
          "stats"
        ],
        "summary": "Set my daily outreach minimums",
        "description": "The signed-in user sets the minimum calls, texts and emails they want to\nmake a day. Null (or 0) clears one.",
        "operationId": "set_my_outreach_goals",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/OutreachGoals"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "The minimums as saved",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OutreachGoals"
                }
              }
            }
          },
          "400": {
            "description": "A minimum out of range",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/stats/overview": {
      "get": {
        "tags": [
          "stats"
        ],
        "summary": "The Statistics page",
        "description": "Deals by rep and by stage, customers by source and by rep, the customers\ntable with its deals, conversion by rep, lost reasons, campaigns, survey\nratings, top sold stones and emails and texts per month, for the\ncompany's admins. Deals count by their last update (conversion and the\ntable by creation), leads by assignment and other customers by creation.",
        "operationId": "get_stats_overview",
        "parameters": [
          {
            "name": "from_date",
            "in": "query",
            "description": "First day counted (`YYYY-MM-DD`); every day when empty.",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "to_date",
            "in": "query",
            "description": "Last day counted (`YYYY-MM-DD`); every day when empty.",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "sales_rep",
            "in": "query",
            "description": "A sales rep's name; everyone when empty or `All`.",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The numbers",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Overview"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/stats/widget-layout": {
      "get": {
        "tags": [
          "stats"
        ],
        "summary": "Get the Statistics widget layout",
        "description": "The widget layout this browser saved for the company (its cookie), and\nwhether a board without one starts empty.",
        "operationId": "get_statistics_widget_layout",
        "responses": {
          "200": {
            "description": "The layout",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WidgetLayout"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "put": {
        "tags": [
          "stats"
        ],
        "summary": "Save the Statistics widget layout",
        "description": "Stores the whole layout in this browser's cookie for the company.",
        "operationId": "save_statistics_widget_layout",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SaveWidgetLayout"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Saved"
          },
          "400": {
            "description": "Too big to be a layout",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/me/dashboard/widgets": {
      "get": {
        "tags": [
          "dashboard"
        ],
        "summary": "Get my dashboard layout",
        "description": "Returns the widgets the signed-in user keeps on their employee dashboard in\nthe company the request acts in, in screen order. An empty list means no\nlayout is saved (or every widget was removed). Save it with\n`PUT /v1/me/dashboard/widgets`.",
        "operationId": "get_my_dashboard_layout",
        "responses": {
          "200": {
            "description": "The saved layout",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DashboardLayout"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "put": {
        "tags": [
          "dashboard"
        ],
        "summary": "Save my dashboard layout",
        "description": "Replaces the signed-in user's dashboard layout with the whole list sent\n(always the full list, never a change), in screen order; a widget listed\ntwice keeps its first place. Each widget added or removed compared with the\nsaved layout is recorded for analytics (not on the first save, which has\nnothing to compare with). Returns the layout as saved.",
        "operationId": "save_my_dashboard_layout",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DashboardLayout"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "The layout as saved",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DashboardLayout"
                }
              }
            }
          },
          "400": {
            "description": "Not a list of known widget ids",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/me/dashboard/widget-events": {
      "post": {
        "tags": [
          "dashboard"
        ],
        "summary": "Record a dashboard widget use",
        "description": "Stores one use of a dashboard widget (a click, a changed value, an add or\nremove) for product analytics. Returns no body.",
        "operationId": "record_dashboard_widget_event",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WidgetEvent"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Recorded"
          },
          "400": {
            "description": "Unknown widget or action, or an empty or too long target",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/points-leaderboard": {
      "get": {
        "tags": [
          "leaderboard"
        ],
        "summary": "Get the points leaderboard",
        "description": "Ranks the Sales Reps of the company the request acts in by the points they\nearned: deals won, deals moved forward, calls, hand-sent texts and emails,\nand guided tours (only while the company's tours are on). `period=all`\n(default) counts everything since each source started counting,\n`period=month` this month so far. When the signed-in user is not a Sales\nRep, `viewer` holds their own unranked row. Answers 404 while the\ncompany's leaderboard is switched off (see `GET /v1/company/features`).",
        "operationId": "get_points_leaderboard",
        "parameters": [
          {
            "name": "period",
            "in": "query",
            "description": "`all` (default) or `month`.",
            "required": false,
            "schema": {
              "type": "string",
              "description": "Which points count.",
              "enum": [
                "all",
                "month"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Reps ranked by points",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PointsLeaderboard"
                }
              }
            }
          },
          "400": {
            "description": "Unknown period",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "The company's leaderboard is switched off",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/deal-groups": {
      "get": {
        "tags": [
          "deals"
        ],
        "summary": "List the deal pipelines (groups) of the board",
        "description": "Returns the company's displayed groups plus the shared default group, in\nid order. `has_overdue_activity` flags groups where one of the caller's\ndeals with the given `status` has an unfinished activity whose deadline\nday has passed. Fetch the stages with `GET /v1/deal-lists?group_id=` and\nthe cards with `GET /v1/deals?group_id=`.",
        "operationId": "list_deal_groups",
        "parameters": [
          {
            "name": "status",
            "in": "query",
            "description": "Which of the caller's deals `has_overdue_activity` looks at. Default `open`.",
            "required": false,
            "schema": {
              "$ref": "#/components/schemas/DealStatus"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Groups in id order",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/DealGroup"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Unknown `status`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/deal-lists": {
      "get": {
        "tags": [
          "deals"
        ],
        "summary": "List deal stages",
        "description": "With `group_id`: the live stages (board columns) of that group in board\norder. Without it: every live stage of every displayed group the company\ncan use, ordered by group name then position (for pickers such as the bulk\nemail \"send to a stage\" list).",
        "operationId": "list_deal_lists",
        "parameters": [
          {
            "name": "group_id",
            "in": "query",
            "description": "Only the stages of this group, in board order. Without it: every stage\nof every displayed group, ordered by group name then position.",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Stages",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/DealList"
                  }
                }
              }
            }
          },
          "400": {
            "description": "`group_id` is not an integer",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/deal-lists/{id}/recipients": {
      "get": {
        "tags": [
          "deals"
        ],
        "summary": "List the email recipients of a stage",
        "description": "Email addresses of the caller's customers (they are the sales rep) with a\nlive open deal in stage `id`; won and lost deals count when asked. Each\naddress once, lowercased, sorted.",
        "operationId": "list_deal_list_recipients",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Stage id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "include_won",
            "in": "query",
            "description": "Also customers whose deal in the stage is won.",
            "required": false,
            "schema": {
              "type": "boolean"
            }
          },
          {
            "name": "include_lost",
            "in": "query",
            "description": "Also customers whose deal in the stage is lost.",
            "required": false,
            "schema": {
              "type": "boolean"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Recipients",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/Recipient"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Malformed params",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/deals": {
      "get": {
        "tags": [
          "deals"
        ],
        "summary": "List deals on a board",
        "description": "Returns the caller's live deals (with `scope=company`, an admin gets every\nsales rep's, or `sales_rep`'s) in the live stages of `group_id` with the\ngiven `status` (default `open`), ordered by stage, then position. Each card\ncarries its customer (null when deleted), whether it has photos, emails\nand notes, its unfinished activities (count, earliest deadline, the one\ndue first) and the phone of a running SMS follow-up flow.",
        "operationId": "list_board_deals",
        "parameters": [
          {
            "name": "group_id",
            "in": "query",
            "description": "Group whose stages make the board (see `GET /v1/deal-groups`).",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "status",
            "in": "query",
            "description": "Default `open`.",
            "required": false,
            "schema": {
              "$ref": "#/components/schemas/DealStatus"
            }
          },
          {
            "name": "scope",
            "in": "query",
            "description": "`mine` (default) or `company` (every sales rep's; admins only).",
            "required": false,
            "schema": {
              "type": "string",
              "description": "Whose deals a board shows.",
              "enum": [
                "mine",
                "company"
              ]
            }
          },
          {
            "name": "sales_rep",
            "in": "query",
            "description": "With `scope=company`: only this sales rep's deals (user name).",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Deal cards",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/BoardDeal"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Missing or malformed `group_id`, unknown `status`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin, or not an admin for `scope=company`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "post": {
        "tags": [
          "deals"
        ],
        "summary": "Create a deal",
        "description": "Puts the customer in `list_id` as a new deal, even when the customer\nalready has one: existing deals are never changed. The deal\nbelongs to the customer's sales rep, or the caller when there is none; a\ncaller who is a sales rep becomes the rep of a customer without one. Drip\nemails and SMS of the stage are scheduled for lead customers (none for a\ndeal created `won` or `lost`), and the customer is pushed to the company's\nCloudTalk contacts.",
        "operationId": "create_deal",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DealCreate"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Deal created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DealCreated"
                }
              }
            }
          },
          "400": {
            "description": "Unknown stage or customer, a title or amount that is too long or too large, malformed body",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/deals/reorder": {
      "post": {
        "tags": [
          "deals"
        ],
        "summary": "Save the order of the board after a drag",
        "description": "Sets stage and position of every card sent. Cards that changed stage get\nthe same treatment as `PATCH /v1/deals/{id}` with `list_id` (history, and\ndrips for open deals; won and lost deals stay closed). Every deal and\nstage must belong to the company, otherwise nothing is saved.",
        "operationId": "reorder_deals",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ReorderBody"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Saved"
          },
          "400": {
            "description": "Empty list, unknown stage, malformed body",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "A deal is not a live deal of the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/deals/search": {
      "get": {
        "tags": [
          "deals"
        ],
        "summary": "Search the deals of a board",
        "description": "Returns at most `limit` (default and most 50) of the caller's live deals\n(with `scope=company`, an admin gets every sales rep's, or\n`sales_rep`'s) in the live stages of `group_id`, open, won and lost\ntogether, that match `q`: part of the customer's name or company name,\nthe deal's title or the sales rep's name (any case). A phone number (only\ndigits and phone punctuation, at least 4 digits) also matches either of\nthe customer's phones by digits, its last ten digits too; text with `@`\nalso matches any of the customer's email addresses. A deleted customer's\ndeals match only by title or rep. Open deals come first, then the newest.\nBlank `q` answers an empty list. Each item is the same card as\n`GET /v1/deals` (its `outcome` says open, won or lost); open one with\n`GET /v1/deals/{id}`.",
        "operationId": "search_deals",
        "parameters": [
          {
            "name": "group_id",
            "in": "query",
            "description": "Group (pipeline) to search, see `GET /v1/deal-groups`.",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "q",
            "in": "query",
            "description": "What was typed: part of a customer's name or company, the deal's\ntitle, the sales rep's name, a phone number (digits and phone\npunctuation, at least 4 digits) or part of an email (has `@`).\nBlank finds nothing.",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "scope",
            "in": "query",
            "description": "`mine` (default) or `company` (every sales rep's; admins only).",
            "required": false,
            "schema": {
              "type": "string",
              "description": "Whose deals a board shows.",
              "enum": [
                "mine",
                "company"
              ]
            }
          },
          {
            "name": "sales_rep",
            "in": "query",
            "description": "With `scope=company`: only this sales rep's deals (user name).",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "description": "At most this many deals, 1 to 50. Default 50.",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int32",
              "minimum": 0
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Matching deal cards, open first, then newest",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/BoardDeal"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Missing or malformed `group_id`, missing `q`, malformed `limit`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin, or not an admin for `scope=company`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/deals/by-customer": {
      "get": {
        "tags": [
          "deals"
        ],
        "summary": "List a customer's deals",
        "description": "Live deals of a customer of the company, found by `customer_id`, or by\nany of their email addresses or their exact name. The caller's own deals\ncome first, then newest. Each deal carries up to two notes and two\nactivities as a preview.",
        "operationId": "list_customer_deals",
        "parameters": [
          {
            "name": "customer_id",
            "in": "query",
            "description": "Customer id; wins over the other two.",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "customer_email",
            "in": "query",
            "description": "Any email address of the customer (case-insensitive).",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "customer_name",
            "in": "query",
            "description": "Exact customer name (case-insensitive).",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The customer's deals",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/CustomerDeal"
                  }
                }
              }
            }
          },
          "400": {
            "description": "None of `customer_id`, `customer_email`, `customer_name`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/deals/won": {
      "get": {
        "tags": [
          "deals"
        ],
        "summary": "List won deals with when each was sold",
        "description": "The live won deals marked won between `from` and `to` (UTC days), oldest\nfirst, each with its customer (source, walk-in, when added), sales rep,\namount and `won_at`: the moment the deal was marked won, which is when\nthe customer bought. Use it for \"when did they buy\", same-day closes and\ndays to close. Sales / transactions rows are typed in later (often the\nnext workday), so their dates are not when the customer bought. Admins\nget the whole company's deals, others their own.",
        "operationId": "list_won_deals",
        "parameters": [
          {
            "name": "from",
            "in": "query",
            "description": "First day the deal was marked won, `YYYY-MM-DD` (UTC).",
            "required": true,
            "schema": {
              "type": "string",
              "format": "date"
            }
          },
          {
            "name": "to",
            "in": "query",
            "description": "Last day the deal was marked won, `YYYY-MM-DD` (UTC), included.",
            "required": true,
            "schema": {
              "type": "string",
              "format": "date"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Won deals, oldest win first",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/WonDeal"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Missing or malformed `from` / `to`, `to` before `from`, or more than 400 days",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/deals/{id}": {
      "get": {
        "tags": [
          "deals"
        ],
        "summary": "Get one deal",
        "description": "Returns a live deal of the company: stage, group, outcome, amounts, the\ncustomer and how many deals they have, and how many files are attached.\nRelated reads: `/stage-history`, `/activities`, `/notes`.",
        "operationId": "get_deal",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Deal id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The deal",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DealDetail"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such live deal in the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "delete": {
        "tags": [
          "deals"
        ],
        "summary": "Delete a deal",
        "description": "Soft-deletes the deal and records who deleted it in the customer's history.",
        "operationId": "delete_deal",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Deal id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Deleted"
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such live deal in the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "patch": {
        "tags": [
          "deals"
        ],
        "summary": "Update a deal",
        "description": "Changes only the fields sent. Moving a deal to another stage (`list_id`,\nor `group_id` for the first stage of another pipeline) records the stage\nhistory and, for an open deal, schedules that stage's drip emails and SMS.\nA won or lost deal stays closed and keeps its close date; reopen it with\n`PUT /v1/deals/{id}/outcome`. Changing `customer_id` gives the deal to\nanother customer of the company and cancels the deal's pending drip\nemails and SMS, which were addressed to the old customer.",
        "operationId": "update_deal",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Deal id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DealPatch"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Updated"
          },
          "400": {
            "description": "Unknown stage or customer, bad date, a title or amount that is too long or too large, malformed body",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such live deal in the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/deals/{id}/outcome": {
      "put": {
        "tags": [
          "deals"
        ],
        "summary": "Close or reopen a deal",
        "description": "`won` and `lost` close the deal (clearing the expected close date; `lost`\nstores `lost_reason`) and cancel its pending drip emails and SMS. `open`\nreopens a closed deal in its stage (or its last live stage) and schedules\nthe stage's drips again. Sending the outcome the deal already has changes\nnothing, except that `lost` on a lost deal replaces its `lost_reason`.",
        "operationId": "set_deal_outcome",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Deal id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/OutcomeBody"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Saved"
          },
          "400": {
            "description": "A lost reason over 255 characters, malformed body",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such live deal in the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/deals/{id}/page": {
      "get": {
        "tags": [
          "deals"
        ],
        "summary": "Get everything the deal page shows",
        "description": "One read instead of six: the deal, its stage history, activities, notes,\nemail history and quote/contract events, each shaped like its own route.\n`emails` and `document_events` are null when they fail to load, so the\npage still opens. To refresh one part after a change, call its own route\n(`/v1/deals/{id}/notes`, `/activities`, ...).",
        "operationId": "get_deal_page",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Deal id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The deal page's data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DealPage"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such live deal in the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/deals/{id}/stage-history": {
      "get": {
        "tags": [
          "deals"
        ],
        "summary": "Get the stage history of a deal",
        "description": "Every stage the deal entered, oldest first; `exited_at` is null for the\ncurrent stay. The last entry of a closed deal tells when it was closed.",
        "operationId": "get_deal_stage_history",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Deal id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Stage visits, oldest first",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/StageVisit"
                  }
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such live deal in the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/deals/odds": {
      "get": {
        "tags": [
          "deals"
        ],
        "summary": "Get the odds that deals end in a sale",
        "description": "For each live deal of the company among `id` (comma separated, up to\n100, repeats ignored), the model's calibrated chance (0..1) that it is\nwon, a verdict (`likely` 50%+, `maybe`, `unlikely` under 10%) and up to\nthree reasons, biggest first. In the order asked; ids of other companies\nor deleted deals are left out (an empty list when none is left). The\nestimate is for now; an estimate younger than 3 hours is answered from\nthe log (`predicted_at` says when it was made) instead of asking the\nmodel again. Meant for open\ndeals; a closed deal still gets an answer but it says nothing new. One\nmodel call for the whole list, about 50 ms; 503 when deal odds are not\nset up in this environment.",
        "operationId": "get_deals_odds",
        "parameters": [
          {
            "name": "id",
            "in": "query",
            "description": "Deal ids, comma separated: `1,2,3`. Up to 100.",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The odds, in the order asked",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/DealOdds"
                  }
                }
              }
            }
          },
          "400": {
            "description": "No ids, an id that is not a number, or more than 100",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "502": {
            "description": "The prediction service failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "503": {
            "description": "Deal odds are not set up here",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/deals/{id}/activities": {
      "get": {
        "tags": [
          "deals"
        ],
        "summary": "List a deal's activities",
        "description": "Live activities of the deal, newest first.",
        "operationId": "list_deal_activities",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Deal id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Activities, newest first",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/Activity"
                  }
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such live deal in the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "post": {
        "tags": [
          "deals"
        ],
        "summary": "Add an activity to a deal",
        "description": "Creates a to-do. The customer's sales rep is notified\n(in the app and on Telegram), and a deadline with a time schedules a\nreminder for the owner at that time.",
        "operationId": "create_deal_activity",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Deal id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ActivityInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CreatedId"
                }
              }
            }
          },
          "400": {
            "description": "Empty or too long name, bad deadline, malformed body",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such live deal in the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/deals/{id}/activities/{activity_id}": {
      "delete": {
        "tags": [
          "deals"
        ],
        "summary": "Delete an activity",
        "description": "Soft-deletes it, drops its reminder and notifies the customer's sales rep.",
        "operationId": "delete_deal_activity",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Deal id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          },
          {
            "name": "activity_id",
            "in": "path",
            "description": "Activity id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Deleted"
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such activity on a live deal of the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "patch": {
        "tags": [
          "deals"
        ],
        "summary": "Update an activity",
        "description": "Changes the fields sent. Editing name, deadline or priority notifies the\ncustomer's sales rep and reschedules the reminder; `is_completed: true` marks it\ndone (and drops its reminder), `false` reopens it.",
        "operationId": "update_deal_activity",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Deal id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          },
          {
            "name": "activity_id",
            "in": "path",
            "description": "Activity id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ActivityPatch"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Updated"
          },
          "400": {
            "description": "Empty or too long name, bad deadline, malformed body",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such activity on a live deal of the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/deal-activities/suggestions": {
      "get": {
        "tags": [
          "deals"
        ],
        "summary": "List the caller's frequent activity names",
        "description": "Up to 50 names of live activities the caller created, most used first,\nthen most recently used; for the activity name input's suggestions.",
        "operationId": "list_activity_suggestions",
        "responses": {
          "200": {
            "description": "Suggestions",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/ActivitySuggestion"
                  }
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/deal-activities/suggestions/hidden": {
      "post": {
        "tags": [
          "deals"
        ],
        "summary": "Stop suggesting an activity name to the caller",
        "description": "Removes it from the caller's suggestions for good, however often they use\nit after. Hiding a hidden name again is a no-op.",
        "operationId": "hide_activity_suggestion",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SuggestionHide"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Hidden"
          },
          "400": {
            "description": "Empty or too long name, malformed body",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/deals/{id}/notes": {
      "get": {
        "tags": [
          "deals"
        ],
        "summary": "List a deal's notes",
        "description": "Live notes, newest first, each with its live comments oldest first.",
        "operationId": "list_deal_notes",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Deal id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Notes, newest first",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/Note"
                  }
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such live deal in the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "post": {
        "tags": [
          "deals"
        ],
        "summary": "Add a note to a deal",
        "description": "Up to 5000 characters. Notifies the customer's sales rep.",
        "operationId": "create_deal_note",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Deal id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ContentInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CreatedId"
                }
              }
            }
          },
          "400": {
            "description": "Empty or too long, malformed body",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such live deal in the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/deals/{id}/notes/{note_id}": {
      "delete": {
        "tags": [
          "deals"
        ],
        "summary": "Delete a note",
        "description": "Soft-deletes it. When an admin deletes it, the customer's sales rep is notified.",
        "operationId": "delete_deal_note",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Deal id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          },
          {
            "name": "note_id",
            "in": "path",
            "description": "Note id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Deleted"
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such note on a live deal of the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "patch": {
        "tags": [
          "deals"
        ],
        "summary": "Edit or pin a note",
        "description": "Changes the text (notifying the customer's sales rep) and/or pins it.",
        "operationId": "update_deal_note",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Deal id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          },
          {
            "name": "note_id",
            "in": "path",
            "description": "Note id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/NotePatch"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Updated"
          },
          "400": {
            "description": "Empty or too long, malformed body",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such note on a live deal of the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/deals/{id}/notes/{note_id}/comments": {
      "post": {
        "tags": [
          "deals"
        ],
        "summary": "Comment on a note",
        "description": "Up to 2000 characters. Only admins' comments carry their name, and only\nthose notify the customer's sales rep.",
        "operationId": "create_deal_note_comment",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Deal id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          },
          {
            "name": "note_id",
            "in": "path",
            "description": "Note id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ContentInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CreatedId"
                }
              }
            }
          },
          "400": {
            "description": "Empty or too long, malformed body",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such note on a live deal of the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/deals/{id}/notes/{note_id}/comments/{comment_id}": {
      "delete": {
        "tags": [
          "deals"
        ],
        "summary": "Delete a comment",
        "description": "Soft-deletes it. When an admin deletes it, the customer's sales rep is notified.",
        "operationId": "delete_deal_note_comment",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Deal id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          },
          {
            "name": "note_id",
            "in": "path",
            "description": "Note id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          },
          {
            "name": "comment_id",
            "in": "path",
            "description": "Comment id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Deleted"
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such comment on a live note of the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/deals/{id}/files": {
      "get": {
        "tags": [
          "deals"
        ],
        "summary": "List a deal's photos and documents",
        "description": "Newest first. Private files come with a link valid for an hour.",
        "operationId": "list_deal_files",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Deal id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Photos and documents",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DealFiles"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such live deal in the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "post": {
        "tags": [
          "deals"
        ],
        "summary": "Attach uploaded files to a deal",
        "description": "Each URL must be a file uploaded to the `deals` folder. PDFs, Word, Excel,\nCSV and text files become documents (named after `name`, without the\nupload id prefix), anything else a photo.",
        "operationId": "attach_deal_files",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Deal id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/NewFiles"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Attached",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AttachedCounts"
                }
              }
            }
          },
          "400": {
            "description": "No files, or a URL that is not an uploaded deal file",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such live deal in the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database or storage error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "503": {
            "description": "Uploads are not configured on this server",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/deals/{id}/documents/{document_id}": {
      "patch": {
        "tags": [
          "deals"
        ],
        "summary": "Rename a deal document",
        "description": "Sets the display name of a document row (`source` `documents` in\n`GET /v1/deals/{id}/files`); older documents stored with the photos\ncannot be renamed.",
        "operationId": "rename_deal_document",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Deal id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          },
          {
            "name": "document_id",
            "in": "path",
            "description": "Document id (source `documents`)",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DocumentRename"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Renamed"
          },
          "400": {
            "description": "Empty or longer than 255 characters",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such document on a live deal of the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/deals/{id}/files/{source}/{file_id}": {
      "delete": {
        "tags": [
          "deals"
        ],
        "summary": "Delete a deal file",
        "description": "Removes the row (`source` from the file listing) and the stored file.",
        "operationId": "delete_deal_file",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Deal id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          },
          {
            "name": "source",
            "in": "path",
            "description": "`images` or `documents`",
            "required": true,
            "schema": {
              "$ref": "#/components/schemas/FileSource"
            }
          },
          {
            "name": "file_id",
            "in": "path",
            "description": "Row id within `source`",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Deleted"
          },
          "400": {
            "description": "Unknown source",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such file on a live deal of the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/deals/{id}/document-events": {
      "get": {
        "tags": [
          "deals"
        ],
        "summary": "List a deal's quote and contract history",
        "description": "Quotes of the deal that were emailed or printed, and contracts sent for\nsigning (tied to the deal, or named after one of its quotes:\n`<contract form> - <quote name>.pdf`) and signed. Views are left out.\nUnsorted: the deal page merges them into its history by `at`.",
        "operationId": "list_deal_document_events",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Deal id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Quote and contract events",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/DocumentEvent"
                  }
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such live deal in the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/deal-pipelines": {
      "get": {
        "tags": [
          "deals"
        ],
        "summary": "List pipelines",
        "description": "Every pipeline of the company (shown or hidden), with their stages and\nhow many live deals (and open ones) each stage holds.",
        "operationId": "list_deal_pipelines",
        "responses": {
          "200": {
            "description": "Pipelines",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/Pipeline"
                  }
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "post": {
        "tags": [
          "deals"
        ],
        "summary": "Create a pipeline",
        "description": "Adds an empty pipeline to the company.",
        "operationId": "create_deal_pipeline",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/NameInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CreatedId"
                }
              }
            }
          },
          "400": {
            "description": "Missing name",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/deal-pipelines/{id}": {
      "delete": {
        "tags": [
          "deals"
        ],
        "summary": "Delete a pipeline",
        "description": "Deletes one of the company's pipelines and its stages. When it was the\ndefault, the company's oldest remaining pipeline becomes the default.\nDeals in it are not deleted, but they leave every board (they stay on\nthe customer's page and in totals): the stages' `deal_count` from\n`GET /v1/deal-pipelines` says how many, ask the user before deleting.",
        "operationId": "delete_deal_pipeline",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Group id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Deleted"
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such pipeline of the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "patch": {
        "tags": [
          "deals"
        ],
        "summary": "Change a pipeline",
        "description": "Renames a pipeline, shows or hides it, or makes it the company's default.",
        "operationId": "update_deal_pipeline",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Group id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PipelinePatch"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Changed"
          },
          "400": {
            "description": "An empty name",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such pipeline of the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/deal-pipelines/{id}/stages": {
      "post": {
        "tags": [
          "deals"
        ],
        "summary": "Add a stage",
        "description": "Adds a stage at the end of one of the company's pipelines.",
        "operationId": "create_deal_stage",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Group id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/NameInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CreatedId"
                }
              }
            }
          },
          "400": {
            "description": "Missing name",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such pipeline of the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/deal-pipelines/{id}/stage-order": {
      "put": {
        "tags": [
          "deals"
        ],
        "summary": "Order a pipeline's stages",
        "description": "Saves the order of the stages (every stage of the pipeline, first to last).",
        "operationId": "order_deal_stages",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Group id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/StageOrder"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Saved"
          },
          "400": {
            "description": "Not exactly the pipeline's stages",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such pipeline of the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/deal-stages/{id}": {
      "delete": {
        "tags": [
          "deals"
        ],
        "summary": "Delete a stage",
        "description": "Deletes a stage of one of the company's pipelines. Its deals are not\ndeleted, but they leave every board; its `deal_count` from\n`GET /v1/deal-pipelines` says how many, ask the user before deleting.",
        "operationId": "delete_deal_stage",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "List id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Deleted"
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such stage of the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "patch": {
        "tags": [
          "deals"
        ],
        "summary": "Rename a stage",
        "description": "Renames a stage of one of the company's pipelines. Deals stay in it.",
        "operationId": "rename_deal_stage",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "List id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/NameInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Renamed"
          },
          "400": {
            "description": "Empty name, or another list of the group has it",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such stage of the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/deal-stage-activity-rules": {
      "get": {
        "tags": [
          "deals"
        ],
        "summary": "List automatic activity rules",
        "description": "Every rule of the company, oldest first.",
        "operationId": "list_deal_stage_activity_rules",
        "responses": {
          "200": {
            "description": "Rules",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/ActivityRule"
                  }
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "post": {
        "tags": [
          "deals"
        ],
        "summary": "Add an automatic activity rule",
        "description": "From then on a deal that moves from `from_list_id` (from any list when\nnull) to `to_list_id` gets an activity named `activity_name`, due\n`due_amount` `due_unit` after the move. Both lists must be live stages of\none pipeline of the company.",
        "operationId": "create_deal_stage_activity_rule",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ActivityRuleInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CreatedId"
                }
              }
            }
          },
          "400": {
            "description": "Missing name, bad due time, unknown or mismatched lists",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/deal-stage-activity-rules/{id}": {
      "put": {
        "tags": [
          "deals"
        ],
        "summary": "Change an automatic activity rule",
        "description": "Replaces every field. Activities it already added stay.",
        "operationId": "update_deal_stage_activity_rule",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Rule id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ActivityRuleInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Changed"
          },
          "400": {
            "description": "Missing name, bad due time, unknown or mismatched lists",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such rule of the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "delete": {
        "tags": [
          "deals"
        ],
        "summary": "Delete an automatic activity rule",
        "description": "Activities it already added stay.",
        "operationId": "delete_deal_stage_activity_rule",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Rule id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Deleted"
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such rule of the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/sales-playbook/setup": {
      "get": {
        "tags": [
          "sales-playbook"
        ],
        "summary": "Get a pipeline's playbook",
        "description": "Every stage of the pipeline with its time limit, \"next touch required\",\ninstructions, sub-stages (with their instructions) and touch plans.",
        "operationId": "get_sales_playbook_setup",
        "parameters": [
          {
            "name": "group_id",
            "in": "query",
            "description": "The pipeline; missing: the company's default one.",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The pipeline's playbook",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Setup"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Not an admin, or the playbook is off",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such pipeline",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/sales-playbook/stages/{id}": {
      "put": {
        "tags": [
          "sales-playbook"
        ],
        "summary": "Save a stage's limit",
        "description": "Sets the stage's time limit (a deal idle that long is offered Lost or a\nfew more days) and whether a deal needs a next touch to leave it.",
        "operationId": "save_sales_playbook_stage",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Stage (list) id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/StageInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Saved"
          },
          "400": {
            "description": "Limit out of range",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Not an admin, or the playbook is off",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such stage",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/sales-playbook/stages/{id}/instructions": {
      "put": {
        "tags": [
          "sales-playbook"
        ],
        "summary": "Save a stage's instructions",
        "description": "Sets what the sales rep does on this stage (call scripts, what to ask,\nhow to sell more). Reps read it behind an (i) on the deal page and the\nboard, and the AI chat gets it with the deal. A sub-stage with its own\ninstructions shows those instead. Blank or null clears it.",
        "operationId": "save_sales_playbook_stage_instructions",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Stage (list) id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/InstructionsInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Saved"
          },
          "400": {
            "description": "Longer than 2000 characters",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Not an admin, or the playbook is off",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such stage",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/sales-playbook/sub-stages/{id}/instructions": {
      "put": {
        "tags": [
          "sales-playbook"
        ],
        "summary": "Save a sub-stage's instructions",
        "description": "Sets what the sales rep does on this sub-stage. Reps read it behind an\n(i) on the deal page and the board, and the AI chat gets it with the\ndeal. Blank or null clears it; the stage's instructions then apply.",
        "operationId": "save_sales_playbook_sub_stage_instructions",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Sub-stage id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/InstructionsInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Saved"
          },
          "400": {
            "description": "Longer than 2000 characters",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Not an admin, or the playbook is off",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such sub-stage",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/sales-playbook/stages/{id}/sub-stages": {
      "post": {
        "tags": [
          "sales-playbook"
        ],
        "summary": "Add a sub-stage",
        "description": "Adds a sub-stage at the end of the stage's sub-stages.",
        "operationId": "create_sales_playbook_sub_stage",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Stage (list) id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SubStageInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Added",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CreatedId"
                }
              }
            }
          },
          "400": {
            "description": "Missing name",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Not an admin, or the playbook is off",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such stage",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/sales-playbook/stages/{id}/sub-stage-order": {
      "put": {
        "tags": [
          "sales-playbook"
        ],
        "summary": "Reorder sub-stages",
        "description": "Saves the order of a stage's sub-stages; a deal not yet on a sub-stage\ncounts as on the first one.",
        "operationId": "order_sales_playbook_sub_stages",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Stage (list) id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/OrderInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Saved"
          },
          "400": {
            "description": "Not the stage's sub-stages",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Not an admin, or the playbook is off",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such stage",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/sales-playbook/sub-stages/{id}": {
      "put": {
        "tags": [
          "sales-playbook"
        ],
        "summary": "Change a sub-stage",
        "description": "Renames it, or turns its own touch plan on or off (off: deals on it\nfollow the stage plan).",
        "operationId": "update_sales_playbook_sub_stage",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Sub-stage id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SubStageInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Saved"
          },
          "400": {
            "description": "Missing name",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Not an admin, or the playbook is off",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such sub-stage",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "delete": {
        "tags": [
          "sales-playbook"
        ],
        "summary": "Delete a sub-stage",
        "description": "Its deals go to the stage's first sub-stage; its plan is deleted.\nActivities the plan already added stay.",
        "operationId": "delete_sales_playbook_sub_stage",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Sub-stage id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Deleted"
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Not an admin, or the playbook is off",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such sub-stage",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/sales-playbook/steps": {
      "post": {
        "tags": [
          "sales-playbook"
        ],
        "summary": "Add a plan step",
        "description": "Adds a step to a stage's plan or a sub-stage's own plan. Deals already in\nthe (sub-)stage get it the next time they enter it.",
        "operationId": "create_sales_playbook_step",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/StepInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Added",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CreatedId"
                }
              }
            }
          },
          "400": {
            "description": "Invalid step",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Not an admin, or the playbook is off",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such stage or sub-stage",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/sales-playbook/steps/{id}": {
      "put": {
        "tags": [
          "sales-playbook"
        ],
        "summary": "Change a plan step",
        "description": "Replaces every field of a step. Activities it already added stay.",
        "operationId": "update_sales_playbook_step",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Step id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/StepInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Saved"
          },
          "400": {
            "description": "Invalid step",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Not an admin, or the playbook is off",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such step",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "delete": {
        "tags": [
          "sales-playbook"
        ],
        "summary": "Delete a plan step",
        "description": "Activities it already added stay.",
        "operationId": "delete_sales_playbook_step",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Step id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Deleted"
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Not an admin, or the playbook is off",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such step",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/sales-playbook/template": {
      "post": {
        "tags": [
          "sales-playbook"
        ],
        "summary": "Fill from the sales instruction",
        "description": "Fills each stage of the pipeline whose name matches a stage of the\nresidential sales instruction (No Contact Yet, Contact Made, Long-Term\nContact, Visited Showroom, Short Term Quote, Long Terms Quote) with its\nsub-stages, time limit and touch plans. Stages that already have\nsub-stages or a plan are left as they are.",
        "operationId": "fill_sales_playbook_template",
        "parameters": [
          {
            "name": "group_id",
            "in": "query",
            "description": "The pipeline; missing: the company's default one.",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The stages filled",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TemplateResult"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Not an admin, or the playbook is off",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such pipeline",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/sales-playbook/kpis": {
      "get": {
        "tags": [
          "sales-playbook"
        ],
        "summary": "Sales KPIs",
        "description": "The month's leads, lead-to-quote time, quote-to-contract rate and days\nin each stage, the deals now without a next touch or past their limit,\nper rep and in total, and the reasons deals were lost.",
        "operationId": "get_sales_kpis",
        "parameters": [
          {
            "name": "month",
            "in": "query",
            "description": "`YYYY-MM`; missing: this month.",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The month's KPIs",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Kpis"
                }
              }
            }
          },
          "400": {
            "description": "Bad month",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Not an admin, or the playbook is off",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/sales-playbook/board": {
      "get": {
        "tags": [
          "sales-playbook"
        ],
        "summary": "The playbook of the board",
        "description": "The sub-stages and limits of a pipeline's stages, and each open deal's\nsub-stage (a deal not on one counts as on the stage's first), days in the\nstage and whether it is idle past the limit.",
        "operationId": "get_sales_playbook_board",
        "parameters": [
          {
            "name": "group_id",
            "in": "query",
            "description": "The pipeline; missing: the company's default one.",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The board's playbook",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Board"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Not staff, or the playbook is off",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such pipeline",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/deals/{id}/playbook": {
      "get": {
        "tags": [
          "sales-playbook"
        ],
        "summary": "A deal's playbook",
        "description": "The deal's stage and sub-stage, days in the stage and limit, objection,\nthe instructions of its stage and sub-stages, and the touch plan of its\ncurrent (sub-)stage.",
        "operationId": "get_deal_playbook",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Deal id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The deal's playbook",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DealPlaybook"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Not staff, or the playbook is off",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such deal",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/deals/{id}/sub-stage": {
      "put": {
        "tags": [
          "sales-playbook"
        ],
        "summary": "Move a deal to a sub-stage",
        "description": "Moves the deal to another sub-stage of its stage: the open steps of its\nplan are removed and the new sub-stage's plan (or the stage plan) starts.",
        "operationId": "set_deal_sub_stage",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Deal id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SubStageChoice"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Moved"
          },
          "400": {
            "description": "Not a sub-stage of the deal's stage",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Not staff, or the playbook is off",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such deal",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/deals/{id}/objection": {
      "put": {
        "tags": [
          "sales-playbook"
        ],
        "summary": "Set a deal's objection",
        "description": "The customer's objection; the deal page shows its talking point.",
        "operationId": "set_deal_objection",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Deal id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ObjectionInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Saved"
          },
          "400": {
            "description": "Unknown objection",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Not staff, or the playbook is off",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such deal",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/deals/{id}/extend-limit": {
      "post": {
        "tags": [
          "sales-playbook"
        ],
        "summary": "Keep working on a deal",
        "description": "The deal is idle past its stage limit and the rep keeps working on it:\nit is not offered for Lost again for `days` days.",
        "operationId": "extend_deal_limit",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Deal id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ExtendInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Put off"
          },
          "400": {
            "description": "Days out of range",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Not staff, or the playbook is off",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such deal",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/me/touches": {
      "get": {
        "tags": [
          "sales-playbook"
        ],
        "summary": "My touches due",
        "description": "The open touch-plan activities the caller does (theirs, or of their\ndeals when nobody else is set), due today or earlier, for the Todo List.\nEmpty while the caller has \"Sync to my Todo List\" off.",
        "operationId": "list_my_touches",
        "responses": {
          "200": {
            "description": "Touches due",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MyTouches"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Not staff, or the playbook is off",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/me/touch-sync": {
      "put": {
        "tags": [
          "sales-playbook"
        ],
        "summary": "Sync touches to my Todo List",
        "description": "The caller's \"Sync to my Todo List\": on, their touches show in the Todo\nList on their day and remind them; off, the plans stay on the deals only.",
        "operationId": "set_my_touch_sync",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SyncInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Saved"
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Not staff, or the playbook is off",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/me/deals-over-limit": {
      "get": {
        "tags": [
          "sales-playbook"
        ],
        "summary": "My deals past their limit",
        "description": "The caller's open deals idle at least their stage's limit and not put\noff: the Deals page asks, one by one, to move each to Lost or keep\nworking on it a few more days.",
        "operationId": "list_my_deals_over_limit",
        "responses": {
          "200": {
            "description": "Deals past their limit, the longest idle first",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/OverLimitDeal"
                  }
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Not staff, or the playbook is off",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/projects": {
      "get": {
        "tags": [
          "projects"
        ],
        "summary": "The board",
        "description": "The caller's projects, as columns of the stages they work on: everything\nfor admins, Managers and Sales Managers; Awaiting Template to In\nFabrication for Office Managers; Templated onward for Shop Managers; their\nown for sales reps.",
        "operationId": "list_projects",
        "parameters": [
          {
            "name": "view",
            "in": "query",
            "description": "`active` (default), `completed` or `cancelled`.",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "owner",
            "in": "query",
            "description": "An owner's user id, or `unassigned`.",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "q",
            "in": "query",
            "description": "Title, customer or address contains this.",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "hold",
            "in": "query",
            "description": "Only projects on hold.",
            "required": false,
            "schema": {
              "type": "boolean"
            }
          },
          {
            "name": "archived",
            "in": "query",
            "description": "Include archived projects.",
            "required": false,
            "schema": {
              "type": "boolean"
            }
          },
          {
            "name": "employee",
            "in": "query",
            "description": "Asked from the employee side, where being an admin counts for nothing.",
            "required": false,
            "schema": {
              "type": "boolean"
            }
          },
          {
            "name": "page",
            "in": "query",
            "description": "1-based page of 100.",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int32",
              "minimum": 0
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The board",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProjectsBoard"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "The caller's position has no Projects board",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "Projects is off for the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/projects/payments": {
      "get": {
        "tags": [
          "projects"
        ],
        "summary": "Projects' payments",
        "description": "Whether each asked project is paid, with what was paid toward it and what\nit still owes: the same amounts the customer's Projects tab shows\n(`GET /v1/customers/{id}/job-money`). Projects the caller doesn't see are\nleft out; when `QuickBooks` is the company's books and does not answer,\nall are. A project's stage follows its payment only for a company\nconnected to `QuickBooks`.",
        "operationId": "list_project_payments",
        "parameters": [
          {
            "name": "ids",
            "in": "query",
            "description": "Project ids (`ids=1&ids=2`), at most 200.",
            "required": false,
            "schema": {
              "type": "array",
              "items": {
                "type": "integer",
                "format": "int32"
              }
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Payments",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProjectPayments"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "Projects is off for the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/projects/{id}": {
      "get": {
        "tags": [
          "projects"
        ],
        "summary": "Get a project",
        "description": "The project, its tasks, notes, files, stage history, appointments and the\ncustomer's transactions it may link to. Anyone with an open task on it may\nopen it too.",
        "operationId": "get_project",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Project id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The project",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProjectWorkspace"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such project the caller may see, or Projects is off",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "delete": {
        "tags": [
          "projects"
        ],
        "summary": "Delete a project",
        "description": "Deletes the project for good, with its tasks, notes, files and history.\nIts calendar events and the deal stay. Admins, Managers and Sales Managers.",
        "operationId": "delete_project",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Project id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Deleted"
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Only Managers and Sales Managers delete projects",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such project in the company, or Projects is off",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/projects/{id}/actions": {
      "post": {
        "tags": [
          "projects"
        ],
        "summary": "Act on a project",
        "description": "Moves it forward, links its transaction, confirms payment, picks the\nowner, puts it on hold, cancels, archives, or corrects its stage or\npayment with a reason. A stale `version` gets a 409 saying to refresh.",
        "operationId": "act_on_project",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Project id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ProjectAction"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "The project after the action",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Project"
                }
              }
            }
          },
          "400": {
            "description": "Bad date, missing reason, or a move with its own button",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "The caller's position can't do this",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such project the caller may see",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "409": {
            "description": "Changed since the page loaded, or not possible now (the message says why)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/projects/reorder": {
      "post": {
        "tags": [
          "projects"
        ],
        "summary": "Save a column's manual order",
        "description": "Numbers the projects sent from 0, in the order sent. Only the order\nchanges, so a page already open can still act on them. Every project must\nbelong to the company, otherwise nothing is saved.",
        "operationId": "reorder_projects",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ReorderProjects"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Saved"
          },
          "400": {
            "description": "No projects, or more than a page of them",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "The caller's position can't move projects",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "A project is not one of the company's",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/deals/{id}/project": {
      "get": {
        "tags": [
          "projects"
        ],
        "summary": "A deal's project",
        "description": "The won deal's project, if any, and whether the caller may start one.",
        "operationId": "get_deal_project",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Deal id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The deal's project",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DealProject"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "Projects is off for the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "post": {
        "tags": [
          "projects"
        ],
        "summary": "Start a deal's project",
        "description": "Turns a won deal into a project (Awaiting Template). Won deals start one\non their own; this is for deals won before Projects was on. Answers the\nexisting project when the deal has one.",
        "operationId": "create_deal_project",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Deal id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The deal's project",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ConvertedDeal"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "The caller's position can't start projects",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such deal the caller may see, or Projects is off",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "409": {
            "description": "The deal is lost",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/projects/{id}/tasks": {
      "post": {
        "tags": [
          "projects"
        ],
        "summary": "Add a task",
        "description": "A task on the project for anyone in the company (or nobody). The person\ngets a notification now and, with a due date, another when it is due (9 AM\nstore time on a date with no time).",
        "operationId": "create_project_task",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Project id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TaskInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CreatedId"
                }
              }
            }
          },
          "400": {
            "description": "Empty name, bad date or priority, or someone outside the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such project the caller may see",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/projects/{id}/tasks/{task_id}": {
      "put": {
        "tags": [
          "projects"
        ],
        "summary": "Edit a task",
        "description": "Its creator or a project manager changes its name, person, due date and\npictures. A new person is told; a changed date or person moves the due\nreminder. A to-do list keeps its items.",
        "operationId": "edit_project_task",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Project id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "task_id",
            "in": "path",
            "description": "Task id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TaskEdit"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Saved"
          },
          "400": {
            "description": "Empty name, bad date, too many pictures, or someone outside the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Not the task's creator or a manager",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such task the caller may see",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "delete": {
        "tags": [
          "projects"
        ],
        "summary": "Delete a task",
        "description": "Its creator or a project manager.",
        "operationId": "delete_project_task",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Project id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "task_id",
            "in": "path",
            "description": "Task id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Deleted"
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Not the task's creator or a manager",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such task the caller may see",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "patch": {
        "tags": [
          "projects"
        ],
        "summary": "Complete or reopen a task",
        "description": "Its creator, the person it is for, or a project manager. A done task's\ndue reminder leaves the bell; reopening brings it back.",
        "operationId": "update_project_task",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Project id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "task_id",
            "in": "path",
            "description": "Task id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TaskUpdate"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Saved"
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Not the task's creator, its person or a manager",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such task the caller may see",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/projects/{id}/task-times/reset": {
      "post": {
        "tags": [
          "projects"
        ],
        "summary": "Forget a task's remembered time",
        "description": "Its earlier uses stop counting; the next one starts the average again.",
        "operationId": "reset_project_task_time",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Project id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TaskTimeReset"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Forgotten"
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such project the caller may see",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/projects/{id}/notes": {
      "post": {
        "tags": [
          "projects"
        ],
        "summary": "Add a note",
        "description": "A note on the project, for everyone who can open it.",
        "operationId": "create_project_note",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Project id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/NoteInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CreatedId"
                }
              }
            }
          },
          "400": {
            "description": "Empty note",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such project the caller may see",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/projects/{id}/notes/{note_id}": {
      "delete": {
        "tags": [
          "projects"
        ],
        "summary": "Delete a note",
        "description": "Its author or a project manager.",
        "operationId": "delete_production_project_note",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Project id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "note_id",
            "in": "path",
            "description": "Note id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Deleted"
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Not the note's author or a manager",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such note the caller may see",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/projects/{id}/files": {
      "post": {
        "tags": [
          "projects"
        ],
        "summary": "Attach files",
        "description": "Files already uploaded with `POST /v1/uploads` (folder `deals`).",
        "operationId": "attach_project_files",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Project id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/NewProjectFiles"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Attached"
          },
          "400": {
            "description": "No files, or a URL that isn't the company's upload",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such project the caller may see",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database or storage error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/projects/{id}/files/{file_id}": {
      "delete": {
        "tags": [
          "projects"
        ],
        "summary": "Delete a file",
        "description": "Whoever attached it or a project manager.",
        "operationId": "delete_project_file",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Project id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "file_id",
            "in": "path",
            "description": "File id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Deleted"
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Not the file's uploader or a manager",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such file the caller may see",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/projects/columns": {
      "get": {
        "tags": [
          "projects"
        ],
        "summary": "The board's columns",
        "description": "Every column of the Projects board in order: the stages, with the company's\nnames for them, and the columns it added. Any employee.",
        "operationId": "list_project_board_columns",
        "responses": {
          "200": {
            "description": "The columns, in board order",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/BoardColumn"
                  }
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "post": {
        "tags": [
          "projects"
        ],
        "summary": "Add a column of the company's own",
        "description": "A new column after `after_id` (or first in its stage), within a stage\nbefore Paid & Completed. Admins only.",
        "operationId": "create_project_board_column",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/BoardColumnInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Added",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CreatedId"
                }
              }
            }
          },
          "400": {
            "description": "Missing or long name, or Paid & Completed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "The column to follow is not one of the stage's",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/projects/columns/{column_id}": {
      "delete": {
        "tags": [
          "projects"
        ],
        "summary": "Delete a column of the company's own",
        "description": "Its projects, parts and steps move to the column before it (another of\nthe company's, or the stage's built-in column); nothing a project did is lost.",
        "operationId": "delete_project_board_column",
        "parameters": [
          {
            "name": "column_id",
            "in": "path",
            "description": "Column id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Deleted"
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such column in the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "patch": {
        "tags": [
          "projects"
        ],
        "summary": "Rename a column of the company's own",
        "description": "A new name for one of the company's columns (trimmed, not empty). Admins only.",
        "operationId": "rename_project_board_column",
        "parameters": [
          {
            "name": "column_id",
            "in": "path",
            "description": "Column id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/BoardColumnName"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Renamed"
          },
          "400": {
            "description": "Missing or long name",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such column in the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/projects/stages/{stage}/name": {
      "put": {
        "tags": [
          "projects"
        ],
        "summary": "Rename a built-in stage's column",
        "description": "An empty name brings back its usual one.",
        "operationId": "rename_project_stage",
        "parameters": [
          {
            "name": "stage",
            "in": "path",
            "description": "The stage: new, templated, fabrication, installed or completed",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/BoardColumnName"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Saved"
          },
          "400": {
            "description": "Long name",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such stage",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/projects/process-steps": {
      "get": {
        "tags": [
          "projects"
        ],
        "summary": "The company's process steps",
        "description": "Every step of every stage, in order, with its rule and the people it\ntells. Admins only.",
        "operationId": "list_project_process_steps",
        "responses": {
          "200": {
            "description": "The steps, in process order",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/ProcessStep"
                  }
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "post": {
        "tags": [
          "projects"
        ],
        "summary": "Add a process step",
        "description": "Goes last in its stage. Paid & Completed has nothing after it, so it takes none.",
        "operationId": "create_project_process_step",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ProcessStepInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Added",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CreatedId"
                }
              }
            }
          },
          "400": {
            "description": "Missing or long name, or Paid & Completed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/projects/process-steps/{step_id}": {
      "delete": {
        "tags": [
          "projects"
        ],
        "summary": "Delete a process step",
        "description": "Gone from every project, with its check-offs.",
        "operationId": "delete_project_process_step",
        "parameters": [
          {
            "name": "step_id",
            "in": "path",
            "description": "Step id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Deleted"
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such step in the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "patch": {
        "tags": [
          "projects"
        ],
        "summary": "Rename a process step",
        "description": "A new name for the step (trimmed, not empty). Admins only.",
        "operationId": "rename_project_process_step",
        "parameters": [
          {
            "name": "step_id",
            "in": "path",
            "description": "Step id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ProcessStepName"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Renamed"
          },
          "400": {
            "description": "Missing or long name",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such step in the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/projects/process-steps/reorder": {
      "post": {
        "tags": [
          "projects"
        ],
        "summary": "Save a stage's order of steps",
        "description": "`ids` in their new order; steps of another company are left alone.\nAdmins only.",
        "operationId": "reorder_project_process_steps",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ProcessStepOrder"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Saved"
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/projects/process-steps/{step_id}/notify": {
      "put": {
        "tags": [
          "projects"
        ],
        "summary": "Set who is told when a step is checked off",
        "description": "Replaces the list. Each person gets a bell notification and a phone push\nwhen someone checks the step off a project (not when they do it themselves).",
        "operationId": "set_project_process_step_notify",
        "parameters": [
          {
            "name": "step_id",
            "in": "path",
            "description": "Step id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ProcessStepNotify"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Saved"
          },
          "400": {
            "description": "Someone outside the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such step in the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/projects/process-steps/positions": {
      "get": {
        "tags": [
          "projects"
        ],
        "summary": "The positions Notify can pick from",
        "description": "Every position that has a Projects board, with the company's people in it,\nso a step can tell specific Sales Reps, Shop Managers, Scheduling Managers\nand so on.",
        "operationId": "list_project_step_positions",
        "responses": {
          "200": {
            "description": "The positions and their people",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/NotifyPosition"
                  }
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/projects/process-stages": {
      "get": {
        "tags": [
          "projects"
        ],
        "summary": "Who is told when a project moves on from each stage",
        "description": "Deprecated: no longer used. Each stage now ends with an ordinary step\n(see `GET /v1/projects/process-steps`) whose own Notify,\nSchedule and Auto replaced these settings; what is saved here does nothing.\n\nThe built-in line at the end of each stage (\"Then: Start fabrication\")\ntakes Notify like a step does.",
        "operationId": "list_project_process_stages",
        "responses": {
          "200": {
            "description": "Who is told, per stage",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/ProcessStage"
                  }
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/projects/process-stages/{stage}/notify": {
      "put": {
        "tags": [
          "projects"
        ],
        "summary": "Set who is told when a project moves on from a stage",
        "description": "Deprecated: no longer used. Each stage now ends with an ordinary step\n(see `GET /v1/projects/process-steps`) whose own Notify,\nSchedule and Auto replaced these settings; what is saved here does nothing.\n\nReplaces the list. Each person gets a bell notification and a phone push\nwhen someone moves a project on from the stage (not when they do it\nthemselves), by hand, by checking its last step or from a booking.",
        "operationId": "set_project_process_stage_notify",
        "parameters": [
          {
            "name": "stage",
            "in": "path",
            "description": "The stage: new, templated, fabrication or installed",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ProcessStepNotify"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Saved"
          },
          "400": {
            "description": "Someone outside the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such stage",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/projects/process-stages/{stage}/auto": {
      "put": {
        "tags": [
          "projects"
        ],
        "summary": "Set what moves a project on from a stage by itself",
        "description": "Deprecated: no longer used. Each stage now ends with an ordinary step\n(see `GET /v1/projects/process-steps`) whose own Notify,\nSchedule and Auto replaced these settings; what is saved here does nothing.\n\nThe built-in line at the end of a stage takes Auto like a step: when the\naction happens (after the stage's own steps are done), the project moves\non to the next stage. Only Awaiting Template and Templated can do this:\ninstallation and payment are confirmed with their own buttons.",
        "operationId": "set_project_process_stage_auto",
        "parameters": [
          {
            "name": "stage",
            "in": "path",
            "description": "The stage: new or templated",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ProcessStepAuto"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Saved"
          },
          "400": {
            "description": "Unknown trigger or template",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such stage, or one that can't move on by itself",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/projects/process-stages/{stage}/events": {
      "put": {
        "tags": [
          "projects"
        ],
        "summary": "Set what moving a project on from a stage does to its events",
        "description": "Deprecated: no longer used. Each stage now ends with an ordinary step\n(see `GET /v1/projects/process-steps`) whose own Notify,\nSchedule and Auto replaced these settings; what is saved here does nothing.\n\nThe built-in line at the end of a stage takes Schedule rules like a step.\nThey run when a project moves on from the stage (and, for Fabrication,\nwhen a part is marked fabricated).",
        "operationId": "set_project_process_stage_events",
        "parameters": [
          {
            "name": "stage",
            "in": "path",
            "description": "The stage: new, templated, fabrication or installed",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ProcessStepEvents"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Saved"
          },
          "400": {
            "description": "Unknown event, readiness or shop status",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such stage",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/projects/process-steps/{step_id}/auto": {
      "put": {
        "tags": [
          "projects"
        ],
        "summary": "Set what checks a step off by itself",
        "description": "Replaces the step's rule; `null` turns it off. Only what happens after it is\nset counts, and only once the step before it is done. `stage_moved` checks\nit off when the project moves on to the next stage. `moves` (Awaiting\nTemplate and Templated only) also moves the project on when the rule fires.",
        "operationId": "set_project_process_step_auto",
        "parameters": [
          {
            "name": "step_id",
            "in": "path",
            "description": "Step id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ProcessStepAuto"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Saved"
          },
          "400": {
            "description": "Unknown action, or a missing template, task name or days",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such step in the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/projects/process-steps/{step_id}/condition": {
      "put": {
        "tags": [
          "projects"
        ],
        "summary": "Set a process step's question and what it depends on",
        "description": "`ask_question` is asked (Yes or No) when a project checks the step off.\n`only_if_step_id` names another step with a question: this step happens\nonly if that answer is Yes, and a No marks it Not needed on the project.",
        "operationId": "set_project_process_step_condition",
        "parameters": [
          {
            "name": "step_id",
            "in": "path",
            "description": "Step id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ProcessStepCondition"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Saved"
          },
          "400": {
            "description": "Long question, or a step to depend on that asks nothing",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such step in the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/projects/process-steps/{step_id}/events": {
      "put": {
        "tags": [
          "projects"
        ],
        "summary": "Set what checking a step off does to the project's events",
        "description": "Replaces the step's rules. Each names one kind of the project's events\n(Template, Installation or one of the event templates) and the readiness\n(Not ready, Ready, Confirmed) and/or shop status (Cut, Complete) to set.",
        "operationId": "set_project_process_step_events",
        "parameters": [
          {
            "name": "step_id",
            "in": "path",
            "description": "Step id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ProcessStepEvents"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Saved"
          },
          "400": {
            "description": "Unknown event, readiness or shop status",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such step in the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/projects/{id}/steps/{step_id}": {
      "put": {
        "tags": [
          "projects"
        ],
        "summary": "Check a step off a project, or undo it",
        "description": "Anyone who can see the project, while it is not archived or cancelled.\nChecking it off tells whoever gave the step to its person\n(`PUT .../steps/{step_id}/owner`), unless that is the caller.",
        "operationId": "set_project_step_done",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Project id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "step_id",
            "in": "path",
            "description": "Step id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/StepDone"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Saved"
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such project the caller may see, or step in the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "409": {
            "description": "The project is archived or cancelled",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/projects/event-links/{event_id}": {
      "get": {
        "tags": [
          "projects"
        ],
        "summary": "The project an event is for, and what it can be linked to",
        "description": "The project the event is linked to, if any, and the projects of its\ncustomer it could be linked to instead.",
        "operationId": "get_event_project_link",
        "parameters": [
          {
            "name": "event_id",
            "in": "path",
            "description": "Event id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The link and the choices",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EventProjectLink"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such event in the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "put": {
        "tags": [
          "projects"
        ],
        "summary": "Link an event, and the customer's other events picked, to a project",
        "description": "Null unlinks them. The events must be this event's customer's; each one\nleaves the part of its old project.",
        "operationId": "set_event_project_link",
        "parameters": [
          {
            "name": "event_id",
            "in": "path",
            "description": "Event id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/EventProjectLinkInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Saved"
          },
          "400": {
            "description": "An event that is not the customer's",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "The caller's position can't change projects",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such event, or project the caller may see",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "409": {
            "description": "The project is archived or cancelled",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/projects/{id}/event-links": {
      "get": {
        "tags": [
          "projects"
        ],
        "summary": "The events a project can take, from the project's side",
        "description": "The events of the project's customer, each with the project it is linked\nto, and the customer's projects to choose from.",
        "operationId": "get_project_event_links",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Project id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The customer's events",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProjectEventLinks"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such project the caller may see",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "put": {
        "tags": [
          "projects"
        ],
        "summary": "Pick the events that are a project's",
        "description": "The picked events (the customer's, or already this project's) are linked\nto it and leave their old project; this project's other events are\nunlinked.",
        "operationId": "set_project_event_links",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Project id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ProjectEventLinksInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Saved"
          },
          "400": {
            "description": "An event that is not the customer's",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "The caller's position can't change projects",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such project the caller may see",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "409": {
            "description": "The project is archived or cancelled",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/projects/part-types": {
      "get": {
        "tags": [
          "projects"
        ],
        "summary": "The company's part types",
        "description": "What a project's parts can be, and the stages each one uses. A company\nstarts with Countertops, Backsplash and Cabinets.",
        "operationId": "list_project_part_types",
        "responses": {
          "200": {
            "description": "The part types, in order",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/PartType"
                  }
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "post": {
        "tags": [
          "projects"
        ],
        "summary": "Add a part type",
        "description": "A new type of part (its name and whether it is templated and\nfabricated), last in the company's list. Admins only.",
        "operationId": "create_project_part_type",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PartTypeInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Added",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CreatedId"
                }
              }
            }
          },
          "400": {
            "description": "Missing or long name",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/projects/part-types/{type_id}": {
      "delete": {
        "tags": [
          "projects"
        ],
        "summary": "Delete a part type",
        "description": "It can no longer be picked; the parts that already have it keep it.",
        "operationId": "delete_project_part_type",
        "parameters": [
          {
            "name": "type_id",
            "in": "path",
            "description": "Part type id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Deleted"
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such part type in the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "409": {
            "description": "It is the company's last part type",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "patch": {
        "tags": [
          "projects"
        ],
        "summary": "Change a part type",
        "description": "Its name and the stages it uses; every part of that type follows.",
        "operationId": "update_project_part_type",
        "parameters": [
          {
            "name": "type_id",
            "in": "path",
            "description": "Part type id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PartTypeInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Saved"
          },
          "400": {
            "description": "Missing or long name",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such part type in the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/projects/{id}/parts": {
      "post": {
        "tags": [
          "projects"
        ],
        "summary": "Add a part to a project",
        "description": "The part starts at the first stage its type uses, so the project goes back\nthere. The first time, the work the project already has becomes its first\npart (`first_type_id`, else the company's first type), in the stage the\nproject is in, with the steps it has done and its jobs.",
        "operationId": "add_project_part",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Project id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PartInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Added",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CreatedId"
                }
              }
            }
          },
          "400": {
            "description": "Unknown part type, or a long name",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "The caller's position can't change a project's parts",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such project the caller may see",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "409": {
            "description": "The project is archived or cancelled",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/projects/{id}/parts/{part_id}": {
      "delete": {
        "tags": [
          "projects"
        ],
        "summary": "Remove a part from a project",
        "description": "With the steps checked off for it. A part with jobs on the schedule stays\nuntil they are moved to another part or deleted, and a project keeps its\nlast part.",
        "operationId": "delete_project_part",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Project id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "part_id",
            "in": "path",
            "description": "Part id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Removed"
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "The caller's position can't change a project's parts",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such project the caller may see, or part on it",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "409": {
            "description": "It has jobs, is the last part, or the project is archived or cancelled",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "patch": {
        "tags": [
          "projects"
        ],
        "summary": "Rename a part, or change its type",
        "description": "Either field left out stays as it is; for those who may edit the project.",
        "operationId": "update_project_part",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Project id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "part_id",
            "in": "path",
            "description": "Part id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PartUpdate"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Saved"
          },
          "400": {
            "description": "Unknown part type, or a missing or long name",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "The caller's position can't change a project's parts",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such project the caller may see, or part on it",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "409": {
            "description": "The project is archived or cancelled",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/projects/{id}/appointments/{event_id}/part": {
      "put": {
        "tags": [
          "projects"
        ],
        "summary": "Say which part a template or installation is for",
        "description": "Links one of the project's jobs to one of its parts, for those who\nmay edit the project.",
        "operationId": "set_project_appointment_part",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Project id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "event_id",
            "in": "path",
            "description": "The template or installation (event id)",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AppointmentPart"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Saved"
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "The caller's position can't change a project's parts",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such project the caller may see, part or job on it",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "409": {
            "description": "The project is archived or cancelled",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/projects/{id}/issues": {
      "post": {
        "tags": [
          "projects"
        ],
        "summary": "Report an issue on a project",
        "description": "For a problem with no job on the schedule: a description and, optionally,\npictures uploaded to the `events` folder first. Anyone who can see the\nproject, while it is not archived or cancelled.",
        "operationId": "report_project_issue",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Project id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ProjectIssueInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Reported"
          },
          "400": {
            "description": "No description, one over 2000 characters, over 20 pictures, or a URL that was not uploaded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such project the caller may see, or part on it",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "409": {
            "description": "The project is archived or cancelled",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database or storage error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/projects/{id}/issues/{issue_id}": {
      "put": {
        "tags": [
          "projects"
        ],
        "summary": "Set a project issue in progress, solved, or open again",
        "description": "Any issue on the project, the crew's included. Anyone who can see it.",
        "operationId": "set_project_issue_solved",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Project id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "issue_id",
            "in": "path",
            "description": "Issue id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/IssueSolvedInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Saved"
          },
          "400": {
            "description": "Neither status nor solved sent",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such project the caller may see, or issue on it",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "delete": {
        "tags": [
          "projects"
        ],
        "summary": "Delete an issue reported on the project",
        "description": "Only the project's own issues (a job's are deleted on the job), by their\nreporter, an admin or a superuser; its pictures go from storage.",
        "operationId": "delete_project_issue",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Project id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "issue_id",
            "in": "path",
            "description": "Issue id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Deleted"
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "Not an issue on this project the caller may delete",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/issues/people": {
      "get": {
        "tags": [
          "schedule"
        ],
        "summary": "Who a comment can mark",
        "description": "The company's people (not deleted, no check-in kiosk), by name: the\noffice and the crew.",
        "operationId": "list_issue_people",
        "responses": {
          "200": {
            "description": "The company's people",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/Person"
                  }
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee, admin or shop manager or worker",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/issues/{issue_id}/comments": {
      "post": {
        "tags": [
          "schedule"
        ],
        "summary": "Add a comment under an issue",
        "description": "Anyone who sees the issue: the office on the project or schedule, the\ncrew on the job. Each person in `mention_ids` (of the caller's company,\nnot the caller) gets a bell notification of type `issue_comment` and a\nphone push: \"Name mentioned you on an issue: comment\".",
        "operationId": "add_issue_comment",
        "parameters": [
          {
            "name": "issue_id",
            "in": "path",
            "description": "Issue id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/IssueCommentInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Added",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/IssueComment"
                }
              }
            }
          },
          "400": {
            "description": "Empty, over 2000 characters, or over 20 people marked",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee, admin or shop manager or worker",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such issue in the caller's company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/issues/{issue_id}/comments/{comment_id}": {
      "delete": {
        "tags": [
          "schedule"
        ],
        "summary": "Delete a comment",
        "description": "Only its writer, an admin or a superuser.",
        "operationId": "delete_issue_comment",
        "parameters": [
          {
            "name": "issue_id",
            "in": "path",
            "description": "Issue id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "comment_id",
            "in": "path",
            "description": "Comment id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Deleted"
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee, admin or shop manager or worker",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "Not a comment the caller may delete",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/projects/{id}/tasks/{task_id}/items/{item_id}": {
      "put": {
        "tags": [
          "projects"
        ],
        "summary": "Tick a to-do list item off, or open it again",
        "description": "Its task's creator, the person it is for, or a project manager. Ticking\nthe last open item finishes the task (its giver is told); opening one\nagain reopens it.",
        "operationId": "set_project_task_item_done",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Project id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "task_id",
            "in": "path",
            "description": "Task id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "item_id",
            "in": "path",
            "description": "Item id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ItemDone"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Saved"
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Not the task's creator, its person or a manager",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such item the caller may see",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/projects/lists": {
      "get": {
        "tags": [
          "projects"
        ],
        "summary": "The company's lists",
        "description": "The lists that fill a new to-do list task, in order. Anyone in the company.",
        "operationId": "list_project_lists",
        "responses": {
          "200": {
            "description": "The lists",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/ProjectList"
                  }
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "post": {
        "tags": [
          "projects"
        ],
        "summary": "Add a list",
        "description": "Admins. Returns every list.",
        "operationId": "create_project_list",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ProjectListInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Created; every list",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/ProjectList"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Missing or long name, or a long item",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/projects/lists/{list_id}": {
      "put": {
        "tags": [
          "projects"
        ],
        "summary": "Change a list",
        "description": "Admins. Replaces its name and items; to-do lists already made from it\nstay as they are. Returns every list.",
        "operationId": "update_project_list",
        "parameters": [
          {
            "name": "list_id",
            "in": "path",
            "description": "List id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ProjectListInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Saved; every list",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/ProjectList"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Missing or long name, or a long item",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such list in the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "delete": {
        "tags": [
          "projects"
        ],
        "summary": "Delete a list",
        "description": "Admins. To-do lists already made from it stay.",
        "operationId": "delete_project_list",
        "parameters": [
          {
            "name": "list_id",
            "in": "path",
            "description": "List id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Deleted"
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such list in the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/projects/process-steps/{step_id}/setup": {
      "put": {
        "tags": [
          "projects"
        ],
        "summary": "Set who does a step, when it is due, and its own to-do list",
        "description": "Admins. `responsible_sales_rep` makes it the project's sales rep's;\notherwise `responsible_user_id` (or nobody). Items keep their ticks when\nsent back with their `id`.",
        "operationId": "set_project_process_step_setup",
        "parameters": [
          {
            "name": "step_id",
            "in": "path",
            "description": "Step id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/StepSetup"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Saved"
          },
          "400": {
            "description": "Someone outside the company, bad days, or a long item",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such step in the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/projects/{id}/steps/{step_id}/owner": {
      "put": {
        "tags": [
          "projects"
        ],
        "summary": "Pick who does a step on this project",
        "description": "Anyone who can open the project. `null` goes back to the company's rule.\nThe person gets a bell notification and a phone push (unless it is the caller).\nThe caller is remembered as the step's giver: when someone else checks the\nstep off (by hand or with its last to-do item), the giver is told\n(\"Finished a Step\").",
        "operationId": "set_project_step_owner",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Project id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "step_id",
            "in": "path",
            "description": "Step id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/StepOwnerInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Saved"
          },
          "400": {
            "description": "Someone outside the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such project the caller may see, or step in the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/projects/{id}/step-items/{item_id}": {
      "put": {
        "tags": [
          "projects"
        ],
        "summary": "Tick a step's to-do list item off, or open it again",
        "description": "Anyone who can see the project, while it is not archived or cancelled.\nTicking the step's last open item checks the step off; opening one again\nopens the step again.",
        "operationId": "set_project_step_item_done",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Project id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "item_id",
            "in": "path",
            "description": "Step item id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ItemDone"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Saved"
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such project the caller may see, or item in the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "409": {
            "description": "The project is archived or cancelled",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/projects/{id}/steps/{step_id}/note": {
      "put": {
        "tags": [
          "projects"
        ],
        "summary": "Write a step's note on a project",
        "description": "Optional, like the step's files (owner, 2026-11-18). Anyone who can see\nthe project, while it is not archived or cancelled. An empty note removes it.",
        "operationId": "set_project_step_note",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Project id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "step_id",
            "in": "path",
            "description": "Step id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/StepNoteInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Saved"
          },
          "400": {
            "description": "A note over 5,000 characters, or a part not on the project",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such project the caller may see, or step in the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "409": {
            "description": "The project is archived or cancelled",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/projects/{id}/questions": {
      "get": {
        "tags": [
          "projects"
        ],
        "summary": "A project's chats",
        "description": "Anyone who can open the project, the crew on its jobs, and anyone in one\nof its chats.",
        "operationId": "list_project_questions",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Project id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The project's chats",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ChatList"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such project the caller may use",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "post": {
        "tags": [
          "projects"
        ],
        "summary": "Ask a question",
        "description": "Anyone who can open the project. Only the people in `to` (or, with\n`everyone`, everyone involved in the project) are in it and told.",
        "operationId": "ask_project_question",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Project id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/QuestionInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Asked",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CreatedId"
                }
              }
            }
          },
          "400": {
            "description": "Empty or long text with no picture, more than 10 pictures, nobody picked, or someone outside the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such project the caller may see",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/events/{id}/chats": {
      "get": {
        "tags": [
          "projects"
        ],
        "summary": "The chats of a job's project",
        "description": "For the job's crew and anyone who can use its project's chats;\n`project_id` is null when the job is on no project the caller may use.",
        "operationId": "event_project_chats",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Event id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Its project's chats",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ChatList"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/projects/{id}/questions/{question_id}": {
      "get": {
        "tags": [
          "projects"
        ],
        "summary": "A question and its messages",
        "description": "Anyone who can open the project. Reading it marks it read for someone in it.",
        "operationId": "get_project_question",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Project id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "question_id",
            "in": "path",
            "description": "Question id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The question",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/QuestionThread"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such question the caller may see",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "put": {
        "tags": [
          "projects"
        ],
        "summary": "Add or remove people of a question, join it, or mark it answered",
        "description": "Anyone who can open the project. People added are told; joining or\nremoving tells nobody. The person who started it can't be removed.",
        "operationId": "change_project_question",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Project id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "question_id",
            "in": "path",
            "description": "Question id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/QuestionChange"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Saved"
          },
          "400": {
            "description": "Someone outside the company, or removing the person who started it",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such question the caller may see",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/projects/{id}/questions/{question_id}/messages": {
      "post": {
        "tags": [
          "projects"
        ],
        "summary": "Answer in a question",
        "description": "Anyone who can open the project; someone not in it joins it. The others\nin it are told.",
        "operationId": "reply_project_question",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Project id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "question_id",
            "in": "path",
            "description": "Question id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/QuestionReply"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Sent"
          },
          "400": {
            "description": "Empty or long text",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such question the caller may see",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/projects/{id}/questions/{question_id}/messages/{message_id}": {
      "put": {
        "tags": [
          "projects"
        ],
        "summary": "Change my message",
        "description": "Only the one who wrote it. Nobody is told.",
        "operationId": "edit_project_question_message",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Project id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "question_id",
            "in": "path",
            "description": "Chat id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "message_id",
            "in": "path",
            "description": "Message id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/MessageEdit"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Saved"
          },
          "400": {
            "description": "Empty or long text",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such message of the caller",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "delete": {
        "tags": [
          "projects"
        ],
        "summary": "Delete my message",
        "description": "Only the one who wrote it; its pictures go too. A chat left with no\nmessage is removed.",
        "operationId": "delete_project_question_message",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Project id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "question_id",
            "in": "path",
            "description": "Chat id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "message_id",
            "in": "path",
            "description": "Message id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Deleted"
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such message of the caller",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/calendars": {
      "get": {
        "tags": [
          "schedule"
        ],
        "summary": "List the calendars on the caller's schedule",
        "description": "The company's live calendars except those hidden for everyone or from\nthe caller in Admin > Schedule. The built-in Templates, Installations and\nEstimates calendars come first and are created on the fly when a company\nlacks them (so every company has them). No two calendars of a company\nshare a color: Templates is green, Installations red, and a calendar\nwhose color another one took gets the first free one (saved). With `all=true` (admins), every\nlive calendar, hidden ones too, for Admin > Schedule.",
        "operationId": "list_calendars",
        "parameters": [
          {
            "name": "all",
            "in": "query",
            "description": "Every live calendar, hidden ones too (admins only).",
            "required": false,
            "schema": {
              "type": "boolean"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Calendars",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/Calendar"
                  }
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee, admin or shop manager or worker (`all`: not an admin)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "post": {
        "tags": [
          "schedule"
        ],
        "summary": "Add a calendar",
        "description": "The built-in calendars' names are reserved. No color picked: the first\ncolor no calendar of the company has; a color another calendar has is\nrefused (two calendars never share a color).",
        "operationId": "create_calendar",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CalendarInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Added",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CreatedCalendar"
                }
              }
            }
          },
          "400": {
            "description": "Missing or reserved name, bad color, or a color another calendar has",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/calendars/{id}": {
      "put": {
        "tags": [
          "schedule"
        ],
        "summary": "Edit a calendar",
        "description": "Saves the name and color; a built-in calendar only changes color.\nTemplates is always green and Installations always red, and a color\nanother calendar of the company has is refused.",
        "operationId": "update_calendar",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Calendar id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CalendarInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Saved"
          },
          "400": {
            "description": "Missing name or bad color, a color another calendar has, or a new color for Templates or Installations",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such calendar in the caller's company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "delete": {
        "tags": [
          "schedule"
        ],
        "summary": "Delete a calendar",
        "description": "Removes a calendar the company added; built-in ones stay.",
        "operationId": "delete_calendar",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Calendar id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Deleted"
          },
          "400": {
            "description": "A built-in calendar",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such calendar in the caller's company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/calendars/{id}/hidden": {
      "put": {
        "tags": [
          "schedule"
        ],
        "summary": "Hide or show a calendar",
        "description": "A hidden calendar is left off everyone's schedule.",
        "operationId": "set_calendar_hidden",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Calendar id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CalendarHidden"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Saved"
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such calendar in the caller's company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/calendars/hidden-users": {
      "get": {
        "tags": [
          "schedule"
        ],
        "summary": "Who each calendar is hidden from",
        "description": "Every (calendar, user) pair an admin hid in Admin > Schedule.",
        "operationId": "list_calendar_hidden_users",
        "responses": {
          "200": {
            "description": "Pairs",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/HiddenUser"
                  }
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/calendars/{id}/hidden-users/{user_id}": {
      "put": {
        "tags": [
          "schedule"
        ],
        "summary": "Hide a calendar from one user, or show it again",
        "description": "A calendar hidden from a user is left off their schedule, with its events.",
        "operationId": "set_calendar_hidden_for_user",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Calendar id.",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "user_id",
            "in": "path",
            "description": "User id.",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CalendarHidden"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Saved"
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such calendar or user in the caller's company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/questionnaires": {
      "get": {
        "tags": [
          "questionnaires"
        ],
        "summary": "List the caller's own questionnaires",
        "description": "Questionnaires the caller made (for an admin also the company-wide\nones), newest first, each with its live questions in creation order.\nOnly these can be renamed, deleted or have questions changed.",
        "operationId": "list_own_questionnaires",
        "responses": {
          "200": {
            "description": "Questionnaires, newest first",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/OwnQuestionnaire"
                  }
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "post": {
        "tags": [
          "questionnaires"
        ],
        "summary": "Create a questionnaire",
        "description": "A questionnaire of the caller's own with at least one question (admins\nmay start with none and add them with `POST .../questions`).",
        "operationId": "create_questionnaire",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/NewQuestionnaire"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CreatedId"
                }
              }
            }
          },
          "400": {
            "description": "Empty or too long name or question, no questions (employees)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/questionnaires/{id}": {
      "delete": {
        "tags": [
          "questionnaires"
        ],
        "summary": "Delete a questionnaire",
        "description": "Soft-deletes one of the caller's questionnaires with its questions, and\nunsets it as the caller's default.",
        "operationId": "delete_questionnaire",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Questionnaire id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Deleted"
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "Not one of the caller's questionnaires",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "patch": {
        "tags": [
          "questionnaires"
        ],
        "summary": "Rename a questionnaire",
        "description": "Only the caller's own questionnaires.",
        "operationId": "rename_questionnaire",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Questionnaire id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/NameInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Renamed"
          },
          "400": {
            "description": "Empty or too long name",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "Not one of the caller's questionnaires",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/questionnaires/{id}/questions": {
      "post": {
        "tags": [
          "questionnaires"
        ],
        "summary": "Add a question to a questionnaire",
        "description": "Appends a question to one of the caller's own questionnaires.",
        "operationId": "add_questionnaire_question",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Questionnaire id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/QuestionInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Added",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CreatedId"
                }
              }
            }
          },
          "400": {
            "description": "Empty or too long question",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "Not one of the caller's questionnaires",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/questionnaires/{id}/questions/{question_id}": {
      "delete": {
        "tags": [
          "questionnaires"
        ],
        "summary": "Delete a question",
        "description": "Soft-deletes a question of one of the caller's own questionnaires.",
        "operationId": "delete_questionnaire_question",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Questionnaire id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "question_id",
            "in": "path",
            "description": "Question id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Deleted"
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such live question in one of the caller's questionnaires",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "patch": {
        "tags": [
          "questionnaires"
        ],
        "summary": "Edit a question",
        "description": "Rewrites a live question of one of the caller's own questionnaires;\nanswers already given stay attached to it.",
        "operationId": "update_questionnaire_question",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Questionnaire id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "question_id",
            "in": "path",
            "description": "Question id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/QuestionInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Updated"
          },
          "400": {
            "description": "Empty or too long question",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such live question in one of the caller's questionnaires",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/deals/{id}/questionnaires": {
      "get": {
        "tags": [
          "questionnaires"
        ],
        "summary": "List the questionnaires of a deal with its answers",
        "description": "The company's shared questionnaires and the caller's own (those with\nquestions), by id, each question with the deal's answer (empty when not\nanswered).",
        "operationId": "list_deal_questionnaires",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Deal id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Questionnaires with answers",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/DealQuestionnaire"
                  }
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such live deal in the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/deals/{id}/questionnaire-answers": {
      "put": {
        "tags": [
          "questionnaires"
        ],
        "summary": "Save a deal's questionnaire answers",
        "description": "Upserts each answer (questions of questionnaires the caller cannot use\nare ignored). With `create_note`, the non-empty answers are also added to\nthe deal as a note (which notifies the customer's sales rep); that needs at\nleast one answer and fits 5000 characters.",
        "operationId": "save_deal_questionnaire_answers",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Deal id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AnswersInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Saved",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AnswersSaved"
                }
              }
            }
          },
          "400": {
            "description": "Answer too long, or a note without answers or over 5000 characters",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such live deal in the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/me/default-questionnaire": {
      "get": {
        "tags": [
          "questionnaires"
        ],
        "summary": "Get the caller's default questionnaire",
        "description": "The questionnaire the deal Questionnaire tab opens first; null when unset.",
        "operationId": "get_default_questionnaire",
        "responses": {
          "200": {
            "description": "The default",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DefaultQuestionnaire"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "put": {
        "tags": [
          "questionnaires"
        ],
        "summary": "Set the caller's default questionnaire",
        "description": "Any live questionnaire the caller can use (shared or their own).",
        "operationId": "set_default_questionnaire",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DefaultQuestionnaire"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Saved",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DefaultQuestionnaire"
                }
              }
            }
          },
          "400": {
            "description": "Missing questionnaire id",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such questionnaire the caller can use",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/emails/threads": {
      "get": {
        "tags": [
          "emails"
        ],
        "summary": "List the caller's email threads",
        "description": "One page (25 threads) of a folder: `inbox` (mail addressed to the caller,\nranked by the latest message to them), `sent`, `trash` (deleted mail the\ncaller received or sent, ranked by deletion) or `drafts`. Every message of each listed thread comes back,\nwith names, attachment flags and the recipient's last open. `search`\nmatches subject, text, addresses, and the addresses of customers whose\nname matches; in the inbox it matches any message of the thread.\n`unread=true` keeps only the inbox threads still unread for the caller\n(those `GET /v1/emails/folder-counts` counts as `inbox_unread`), and in\nthe inbox every row says whether its thread is one of them\n(`thread_unread`): show that, don't work it out from the messages. Open a\nthread with `GET /v1/emails/threads/{thread_id}`.\n\n`scope=admin` (admins only) lists every employee's mail of the company\ninstead, optionally only one user's (`sales_rep`); drafts read as the\ninbox there.",
        "operationId": "list_email_threads",
        "parameters": [
          {
            "name": "folder",
            "in": "query",
            "description": "Default `inbox`.",
            "required": false,
            "schema": {
              "type": "string",
              "description": "A mailbox folder.",
              "enum": [
                "inbox",
                "sent",
                "trash",
                "drafts"
              ]
            }
          },
          {
            "name": "page",
            "in": "query",
            "description": "1-based page of 25 threads. Default 1.",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          },
          {
            "name": "search",
            "in": "query",
            "description": "Words to find in subject, text and addresses, or a customer name\n(whose addresses then match; not in the admin scope).",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "unread",
            "in": "query",
            "description": "`true`: only the inbox conversations still unread for the caller (the\nones `inbox_unread` of `GET /v1/emails/folder-counts` counts), paged and\ncounted the same way. Inbox only; ignored for other folders and the\nadmin scope. Default `false`.",
            "required": false,
            "schema": {
              "type": "boolean"
            }
          },
          {
            "name": "scope",
            "in": "query",
            "description": "Default `employee`; `admin` lists the whole company's mail (admins\nonly, no drafts).",
            "required": false,
            "schema": {
              "type": "string",
              "description": "Whose mail the suggestions search.",
              "enum": [
                "employee",
                "admin"
              ]
            }
          },
          {
            "name": "sales_rep",
            "in": "query",
            "description": "Admin scope: only mail sent by or to this user.",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "A page of the folder",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MailboxPage"
                }
              }
            }
          },
          "400": {
            "description": "Unknown folder or malformed page",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Not an employee, or the admin scope without being an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/superuser/sales-emails": {
      "get": {
        "tags": [
          "superuser"
        ],
        "summary": "List the sales mailbox",
        "description": "A page (50 threads) of the sales mailbox's inbox (mail to it, not from it)\nor sent folder, across every company, ranked by each thread's latest\nmessage in the folder. Super admins only.",
        "operationId": "list_sales_mailbox",
        "parameters": [
          {
            "name": "folder",
            "in": "query",
            "description": "`inbox` (default) or `sent`.",
            "required": false,
            "schema": {
              "type": "string",
              "description": "A folder of the mailbox.",
              "enum": [
                "inbox",
                "sent"
              ]
            }
          },
          {
            "name": "page",
            "in": "query",
            "description": "Page, from 1.",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          },
          {
            "name": "search",
            "in": "query",
            "description": "Matches subject, text and addresses.",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "A page of threads",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SalesPage"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not a super admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/superuser/sales-emails/{thread_id}": {
      "get": {
        "tags": [
          "superuser"
        ],
        "summary": "Open a sales mailbox conversation",
        "description": "Every message of a thread that has mail to or from the sales mailbox,\nwith attachments and addresses, and who it is with. Read only: opening\nit marks nothing read. Super admins only.",
        "operationId": "get_sales_mailbox_thread",
        "parameters": [
          {
            "name": "thread_id",
            "in": "path",
            "description": "Conversation id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The conversation",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ThreadDetail"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not a super admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No sales mailbox mail in the thread",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/superuser/sales-emails/{thread_id}/reply": {
      "post": {
        "tags": [
          "superuser"
        ],
        "summary": "Answer a sales mailbox conversation",
        "description": "Sends the text from `sales@granite-manager.com` (\"Granite Manager\") to\nthe conversation's other party as a reply in the same thread\n(`In-Reply-To`/`References`), and records it in the conversation.\nSuper admins only.",
        "operationId": "reply_sales_mailbox_thread",
        "parameters": [
          {
            "name": "thread_id",
            "in": "path",
            "description": "Conversation id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SalesReplyRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Sent",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SalesReplyResult"
                }
              }
            }
          },
          "400": {
            "description": "Empty or too long text, no one to answer, or SES refused the address",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not a super admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No sales mailbox mail in the thread",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error, or sent but not recorded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "502": {
            "description": "Sending failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/emails/folder-counts": {
      "get": {
        "tags": [
          "emails"
        ],
        "summary": "Count the caller's email folders",
        "description": "Unread inbox threads (customer mail to the caller or on their deals, and\ncoworkers' mail to them), threads in the trash and drafts. `scope=admin`\n(admins only) counts the whole company's unread inbox and trash\n(`sales_rep`: one user's), with no drafts.",
        "operationId": "count_email_folders",
        "parameters": [
          {
            "name": "scope",
            "in": "query",
            "description": "Default `employee`; `admin` counts the whole company's mail.",
            "required": false,
            "schema": {
              "type": "string",
              "description": "Whose mail the suggestions search.",
              "enum": [
                "employee",
                "admin"
              ]
            }
          },
          {
            "name": "sales_rep",
            "in": "query",
            "description": "Admin scope: only mail sent by or to this user.",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Counts",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FolderCounts"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Not an employee, or the admin scope without being an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/emails/unread": {
      "get": {
        "tags": [
          "emails"
        ],
        "summary": "Get the inbox badge",
        "description": "Unread inbox threads and the newest unread message id (to notice new\nmail between polls). Always 0 when the company has no inbound email.",
        "operationId": "get_unread_email_count",
        "responses": {
          "200": {
            "description": "The badge",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UnreadCount"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/emails/threads/{thread_id}": {
      "get": {
        "tags": [
          "emails"
        ],
        "summary": "Get an email conversation",
        "description": "The thread's messages oldest first (on a deal: that deal's messages and\nunassigned ones), attachments with links, header participants, who it is\nwith, and the caller's signature and sending address. `folder=trash`\nshows the deleted messages. With `deal_id` the conversation is opened on\nthat deal: only its (and unassigned) messages, the deal's customer, and an\nempty conversation for a thread id that has no mail yet (composing a new\none). Any thread of the caller's company can be read, except another\nuser's unsent draft (404). Opening it does not mark it read: call\n`POST /v1/emails/threads/{thread_id}/read`.",
        "operationId": "get_email_thread",
        "parameters": [
          {
            "name": "thread_id",
            "in": "path",
            "description": "Conversation id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "folder",
            "in": "query",
            "description": "`trash` shows the deleted messages of the thread instead.",
            "required": false,
            "schema": {
              "type": "string",
              "description": "A mailbox folder.",
              "enum": [
                "inbox",
                "sent",
                "trash",
                "drafts"
              ]
            }
          },
          {
            "name": "deal_id",
            "in": "query",
            "description": "Open it on this deal: only the deal's (and unassigned) messages, the\ndeal's customer, and an empty conversation for a new thread id.",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The conversation",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ThreadDetail"
                }
              }
            }
          },
          "400": {
            "description": "Unknown folder",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such thread (or deal) in the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/emails/threads/{thread_id}/read": {
      "post": {
        "tags": [
          "emails"
        ],
        "summary": "Mark an open conversation read",
        "description": "Stamps every unread live message of the thread that the caller did not\nsend (what opening the conversation used to do). Any thread of the\ncaller's company.",
        "operationId": "read_email_thread",
        "parameters": [
          {
            "name": "thread_id",
            "in": "path",
            "description": "Conversation id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Marked"
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such thread in the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/emails/threads/mark-read": {
      "post": {
        "tags": [
          "emails"
        ],
        "summary": "Mark conversations read",
        "description": "Stamps unread live messages the caller did not send, in the caller's own threads (threads they are on or of their deals).",
        "operationId": "mark_email_threads_read",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ThreadIds"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Done"
          },
          "400": {
            "description": "No thread ids, or too many",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/emails/threads/mark-unread": {
      "post": {
        "tags": [
          "emails"
        ],
        "summary": "Mark conversations unread",
        "description": "Clears the read stamp of every message of the caller's own threads.",
        "operationId": "mark_email_threads_unread",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ThreadIds"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Done"
          },
          "400": {
            "description": "No thread ids, or too many",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/emails/threads/delete": {
      "post": {
        "tags": [
          "emails"
        ],
        "summary": "Move conversations to the trash",
        "description": "Soft-deletes every message of the caller's own threads, at most 50 threads.",
        "operationId": "delete_email_threads",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ThreadIds"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Done"
          },
          "400": {
            "description": "No thread ids, or too many",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/emails/threads/restore": {
      "post": {
        "tags": [
          "emails"
        ],
        "summary": "Restore conversations from the trash",
        "description": "Undeletes every message of the caller's own threads.",
        "operationId": "restore_email_threads",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ThreadIds"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Done"
          },
          "400": {
            "description": "No thread ids, or too many",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/emails/threads/purge": {
      "post": {
        "tags": [
          "emails"
        ],
        "summary": "Erase conversations from the trash",
        "description": "Permanently deletes the trashed messages of the caller's own threads\n(at most 50 threads) and their open tracking. Live messages are kept.",
        "operationId": "purge_email_threads",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ThreadIds"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Erased",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Purged"
                }
              }
            }
          },
          "400": {
            "description": "No thread ids, or too many",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/emails/{id}": {
      "delete": {
        "tags": [
          "emails"
        ],
        "summary": "Move one message to the trash",
        "description": "Soft-deletes the message `id` (a message `id` of\n`GET /v1/emails/threads/{thread_id}`) of one of the caller's own threads\n(threads they are on or of their deals); the rest of the conversation\nstays. Drafts are deleted with `DELETE /v1/emails/drafts/{id}`. Bring it\nback with `POST /v1/emails/threads/restore` (that restores the whole\nconversation).",
        "operationId": "delete_email_message",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Message id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Moved to the trash"
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such live message in the caller's own threads",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/emails/search-suggestions": {
      "get": {
        "tags": [
          "emails"
        ],
        "summary": "Suggest conversations while typing a search",
        "description": "The newest matching message of up to 8 conversations of a folder\n(needs 2 or more characters). `scope=admin` searches the whole company's\nmail (admins only; `sales_rep` narrows it to one user's mail).",
        "operationId": "suggest_email_threads",
        "parameters": [
          {
            "name": "term",
            "in": "query",
            "description": "What the user typed; fewer than 2 characters returns nothing.",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "folder",
            "in": "query",
            "description": "Default `inbox` (`drafts` is `inbox` for the admin scope).",
            "required": false,
            "schema": {
              "type": "string",
              "description": "A mailbox folder.",
              "enum": [
                "inbox",
                "sent",
                "trash",
                "drafts"
              ]
            }
          },
          {
            "name": "scope",
            "in": "query",
            "description": "Default `employee`.",
            "required": false,
            "schema": {
              "type": "string",
              "description": "Whose mail the suggestions search.",
              "enum": [
                "employee",
                "admin"
              ]
            }
          },
          {
            "name": "sales_rep",
            "in": "query",
            "description": "Admin scope: only mail sent by or to this user.",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Up to 8 conversations, newest first",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/SuggestionRow"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Missing term, unknown folder or scope",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Not an employee, or the admin scope without being an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/deals/{id}/emails": {
      "get": {
        "tags": [
          "emails"
        ],
        "summary": "Get a deal's email history",
        "description": "The deal's conversations and every conversation with its customer, plus\n(when the customer has no other deal) any mail to or from the customer's\naddresses; `customer_emails` lists the address mail when some of it is\nnot in `emails`. Unsent drafts are never listed. Messages carry real open\ncounts. Before reading, sent list drips missing from the history are\nrecorded (so the page always shows them). Open a conversation with\n`GET /v1/emails/threads/{thread_id}`.",
        "operationId": "list_deal_emails",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Deal id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The history",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DealEmails"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such live deal in the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/emails": {
      "post": {
        "tags": [
          "emails"
        ],
        "summary": "Send an email",
        "description": "Sends the email now, or schedules it with `send_at`. Recipients are\nlower-cased and deduplicated (`cc` drops `to` addresses, `bcc` drops\nboth). Several `to` recipients without `cc`, `bcc`, `thread_id` or\n`send_together` each get their own message and conversation. Each message\nis recorded with its participants and attachments, and the deal's\ncustomer gets the recipients' new addresses (not a coworker's: an address\nof a user of the sender's company stays off the customer).",
        "operationId": "send_email",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SendEmailRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Sent, or scheduled",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SendEmailResult"
                }
              }
            }
          },
          "400": {
            "description": "Invalid recipients, empty email, a subject or file name over 255 characters, a note over 65,535 bytes, unknown deal, bad send time, an attachment the caller may not use, or an address SES refused",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "`thread_id` is a conversation of another company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error, or sent but not recorded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "502": {
            "description": "Sending failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/emails/drafts": {
      "post": {
        "tags": [
          "emails"
        ],
        "summary": "Save a new draft",
        "description": "Stores an unsent email in the caller's Drafts folder.",
        "operationId": "create_email_draft",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DraftInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Saved",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SavedDraft"
                }
              }
            }
          },
          "400": {
            "description": "No subject and no note, a subject or file name over 255 characters, a note over 65,535 bytes, an unknown deal, or a file the caller may not attach",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/email-attachments/{id}/deal": {
      "post": {
        "tags": [
          "emails"
        ],
        "summary": "Save an attachment to a deal",
        "description": "Adds the attachment to the deal's photos (images) or documents (other\nfiles), once: saving it again changes nothing.",
        "operationId": "add_email_attachment_to_deal",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Attachment id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AddToDeal"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Saved on the deal"
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such attachment the caller may read, or no such deal in the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/deals/file-urls": {
      "get": {
        "tags": [
          "deals"
        ],
        "summary": "List a deal's file URLs",
        "description": "URLs of the photos and documents of the deal, or of every deal of the\ncustomer (by address or name). Attachments whose URL is listed are\nalready saved.",
        "operationId": "list_deal_file_urls",
        "parameters": [
          {
            "name": "deal_id",
            "in": "query",
            "description": "The deal; wins over the customer.",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          },
          {
            "name": "customer_email",
            "in": "query",
            "description": "Without `deal_id`: any address of the customer.",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "customer_name",
            "in": "query",
            "description": "Without `deal_id`: the customer's exact name.",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "File URLs",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DealFileUrls"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such deal in the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/emails/{id}/images": {
      "get": {
        "tags": [
          "emails"
        ],
        "summary": "List an email's pictures",
        "description": "Image attachments (HEIC included) of one of the company's emails, for the\nphoto viewer.",
        "operationId": "list_email_images",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Email id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Pictures (none for another company's email or another user's draft)",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/EmailImage"
                  }
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/emails/{id}/reads": {
      "get": {
        "tags": [
          "emails"
        ],
        "summary": "List every open of a sent email",
        "description": "Each time the recipient opened one of the company's emails, newest\nfirst (at most 200). Opens in the first 5 seconds after sending are left\nout: those are mail scanners and image proxies, not the client. The\nlatest of these is the `client_read_at` the mailbox lists show.",
        "operationId": "list_email_reads",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Email id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Opens, newest first (empty when never opened)",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/EmailRead"
                  }
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such email in the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/email-attachments/{id}/preview": {
      "get": {
        "tags": [
          "emails"
        ],
        "summary": "Show an image attachment",
        "description": "For an `<img>`: a JPEG of the attachment's picture. HEIC photos are\nconverted (and kept for later views) and the answer redirects to the\nJPEG; other pictures redirect to the stored file. With `icon=true` the\nanswer is a small JPEG (fits 320 x 320) itself; with `link=true` it is\nthe picture's URL as JSON instead of a redirect.",
        "operationId": "preview_email_attachment",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Attachment id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "icon",
            "in": "query",
            "description": "`true` for a small JPEG (fits 320 x 320) instead of the full picture.",
            "required": false,
            "schema": {
              "type": "boolean"
            }
          },
          {
            "name": "link",
            "in": "query",
            "description": "`true` to answer `{\"url\": ...}` (where the picture is, valid an\nhour) instead of redirecting there, for scripts that read the bytes.",
            "required": false,
            "schema": {
              "type": "boolean"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The thumbnail (`icon=true`), or where the picture is (`link=true`)",
            "content": {
              "image/jpeg": {
                "schema": {
                  "type": "array",
                  "items": {
                    "type": "integer",
                    "format": "int32",
                    "minimum": 0
                  }
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PictureLink"
                }
              }
            }
          },
          "302": {
            "description": "Redirect to the picture"
          },
          "400": {
            "description": "Not an image",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such attachment the caller may read",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "The picture could not be converted",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "502": {
            "description": "The stored file could not be read",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/email-attachments/{id}/open": {
      "get": {
        "tags": [
          "emails"
        ],
        "summary": "Open an attachment",
        "description": "Redirects to the stored file through a link signed now (valid an hour),\nwhatever kind of file it is. Use this for links people tap: the\n`signed_url` in a conversation dies an hour after the conversation was\nloaded. Pictures for an `<img>` go through `/preview` instead (HEIC\nbecomes a JPEG there).",
        "operationId": "open_email_attachment",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Attachment id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "302": {
            "description": "Redirect to the file"
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such attachment the caller may read",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/email-attachments/{id}/file": {
      "get": {
        "tags": [
          "emails"
        ],
        "summary": "Fetch an attachment's bytes",
        "description": "The stored file itself, for the browser to attach it to another text or\nemail. Sent as a download that never renders as a page. Call it on the\nstreaming Function URL: big files pass API Gateway's 6 MB limit.",
        "operationId": "fetch_email_attachment",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Attachment id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The file",
            "content": {
              "application/octet-stream": {
                "schema": {
                  "type": "array",
                  "items": {
                    "type": "integer",
                    "format": "int32",
                    "minimum": 0
                  }
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such attachment the caller may read",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "502": {
            "description": "The stored file could not be read",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/emails/{id}/conversation": {
      "get": {
        "tags": [
          "emails"
        ],
        "summary": "Get an email's conversation",
        "description": "The email and the other messages of its thread (the latest 50), with\ntheir files, for an email of the caller's company. An unsent draft is\nnever shown (404).",
        "operationId": "get_email_conversation",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Email id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Conversation",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Conversation"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such email in the caller's company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/emails/inbound-push": {
      "post": {
        "tags": [
          "emails"
        ],
        "summary": "Push a new inbound email to its recipients' phones",
        "description": "Called by the `webhooks` Lambda (job key), not by the CRM or the app:\nafter it stored an email SES received, it sends the new email's id. The\nemail is pushed to the signed-in phones of the users whose inbox shows it\nunread (as `GET /v1/emails/unread` counts it) as data\n`{granite: \"1\", type: \"email\", emailId, threadId}`: ids only, never the\nsubject, sender or text. The app opens it with\n`GET /v1/emails/threads/{thread_id}`. Nothing is pushed (`pushed: 0`) for\nan unknown, deleted or draft email, one sent by an employee, a company\nwithout inbound email, or when nobody's inbox shows it. Calling it again\npushes again.",
        "operationId": "push_inbound_email",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/InboundPush"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Phones told",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InboundPushSent"
                }
              }
            }
          },
          "400": {
            "description": "Invalid body",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "Missing or wrong key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "job_key": []
          }
        ]
      }
    },
    "/v1/emails/drafts/{id}": {
      "get": {
        "tags": [
          "emails"
        ],
        "summary": "Get a draft",
        "description": "One of the caller's drafts, to reopen in the compose page.",
        "operationId": "get_email_draft",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Draft id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The draft",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EmailDraft"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such draft of the caller's",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "put": {
        "tags": [
          "emails"
        ],
        "summary": "Update a draft",
        "description": "Replaces the content, recipients and files of one of the caller's drafts\nand moves it to the top of Drafts.",
        "operationId": "update_email_draft",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Draft id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DraftInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Saved",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SavedDraft"
                }
              }
            }
          },
          "400": {
            "description": "No subject and no note, a subject or file name over 255 characters, a note over 65,535 bytes, an unknown deal, or a file the caller may not attach",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such draft of the caller's",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "delete": {
        "tags": [
          "emails"
        ],
        "summary": "Delete a draft",
        "description": "Discards one of the caller's drafts (after it was sent, or emptied).",
        "operationId": "delete_email_draft",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Draft id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Deleted"
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such draft of the caller's",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/email-templates": {
      "get": {
        "tags": [
          "templates"
        ],
        "summary": "List email templates",
        "description": "The company's templates and the caller's own, sorted by the caller's\npicker order (most used first unless they saved a custom order; then\ncompany templates first, newest first), with their attachments.",
        "operationId": "list_email_templates",
        "responses": {
          "200": {
            "description": "Templates",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/EmailTemplate"
                  }
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "post": {
        "tags": [
          "templates"
        ],
        "summary": "Create an email template",
        "description": "`scope: company` (admins only) makes it the whole company's; otherwise\nit is the caller's own. Either may send automatically: `lead_list_id` +\n`hour_delay` schedule it for deals entering that list — a company\ntemplate for the reps who use the company's automations, a personal one\nfor the caller's own deals once they use their own\n(`PUT /v1/me/lead-automation`).",
        "operationId": "create_email_template",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/EmailTemplateInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EmailTemplate"
                }
              }
            }
          },
          "400": {
            "description": "Missing name, subject or body, a body over 65,535 bytes, unpaired braces, or a bad automation",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee, or not an admin for a company template",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "409": {
            "description": "Another template of the same owner sends on this list after this delay",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/email-templates/{id}": {
      "put": {
        "tags": [
          "templates"
        ],
        "summary": "Edit an email template",
        "description": "The caller's own templates, and (admins) the company's, with their\nautomation (`lead_list_id`, `hour_delay`; `sales_rep_ids` only for a\ncompany template); removing the automation calls off the template's\npending sends, and moving it to another list calls off those for deals\nwaiting on the old list.",
        "operationId": "update_email_template",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Template id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/EmailTemplateInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Updated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EmailTemplate"
                }
              }
            }
          },
          "400": {
            "description": "Missing name, subject or body, a body over 65,535 bytes, unpaired braces, or a bad automation",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such template the caller may edit",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "409": {
            "description": "Another template of the same owner sends on this list after this delay",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "delete": {
        "tags": [
          "templates"
        ],
        "summary": "Delete an email template",
        "description": "Soft-deletes one of the caller's own templates or (admins) a company\ntemplate, with its attachments; its pending automatic sends are called off.",
        "operationId": "delete_email_template",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Template id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Deleted"
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such template the caller may delete",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/email-templates/{id}/attachments": {
      "post": {
        "tags": [
          "templates"
        ],
        "summary": "Attach a file to an email template",
        "description": "Adds a file uploaded to the `email-templates` folder (`POST /v1/uploads`)\nafter the template's other attachments. Emails made from the template\ncarry it.",
        "operationId": "add_email_template_attachment",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Template id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TemplateAttachmentInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Attached",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TemplateAttachment"
                }
              }
            }
          },
          "400": {
            "description": "Not an uploaded template file, no file name or type, or a name over 255 characters",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such template the caller may edit",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/email-templates/{id}/attachments/{attachment_id}": {
      "delete": {
        "tags": [
          "templates"
        ],
        "summary": "Remove a file from an email template",
        "description": "Emails made from the template no longer carry it.",
        "operationId": "delete_email_template_attachment",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Template id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "attachment_id",
            "in": "path",
            "description": "Attachment id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Removed"
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such template the caller may edit, or no such attachment on it",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/me/template-order/{type}": {
      "get": {
        "tags": [
          "templates"
        ],
        "summary": "Get a template picker's order",
        "description": "Whether the caller's picker of this type sorts automatically (most used\nfirst) or in their saved order.",
        "operationId": "get_template_order",
        "parameters": [
          {
            "name": "type",
            "in": "path",
            "description": "`sms`, `email` or `quote`.",
            "required": true,
            "schema": {
              "type": "string",
              "description": "Which template picker an order belongs to.",
              "enum": [
                "sms",
                "email",
                "quote"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Mode",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TemplateOrder"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "put": {
        "tags": [
          "templates"
        ],
        "summary": "Save a template picker's order",
        "description": "Saves the dragged order (every template the picker shows, first to\nlast) and switches the picker to it.",
        "operationId": "save_template_order",
        "parameters": [
          {
            "name": "type",
            "in": "path",
            "description": "`sms`, `email` or `quote`.",
            "required": true,
            "schema": {
              "type": "string",
              "description": "Which template picker an order belongs to.",
              "enum": [
                "sms",
                "email",
                "quote"
              ]
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SaveOrder"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Saved"
          },
          "400": {
            "description": "No ids, or an id that is not positive",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "delete": {
        "tags": [
          "templates"
        ],
        "summary": "Reset a template picker's order",
        "description": "Forgets the saved order: the picker sorts by use again.",
        "operationId": "reset_template_order",
        "parameters": [
          {
            "name": "type",
            "in": "path",
            "description": "`sms`, `email` or `quote`.",
            "required": true,
            "schema": {
              "type": "string",
              "description": "Which template picker an order belongs to.",
              "enum": [
                "sms",
                "email",
                "quote"
              ]
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Reset"
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/templates/fill": {
      "post": {
        "tags": [
          "templates"
        ],
        "summary": "Fill template variables",
        "description": "Fills `{{user.*}}`, `{{customer.*}}`, `{{company.*}}`, `{{deal.*}}` and\n`{{current_date}}` for the caller, the deal and the customer (given, or\nfound by `recipient_email`). Keys match case-insensitively:\n`user.name`, `user.first_name`, `user.last_name`, `user.email`,\n`user.phone_number`; `customer.name`, `customer.first_name`,\n`customer.last_name`, `customer.email`, `customer.phone`,\n`customer.address`, `customer.inventory_link`; `company.name`,\n`company.address`, `company.hours_of_operation`, `company.domain`,\n`company.subdomain`, `company.id`; `deal.name` and `deal.amount`\n(e.g. `$4,500.00`, only with `deal_id`). `{{quote.*}}` are filled only\nwhen a quote is emailed (`POST /v1/quotes/{id}/emails`). Variables\nwithout a value, and unknown ones, are left as they are.",
        "operationId": "fill_template",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/FillRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Filled text",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Filled"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/sms-templates": {
      "get": {
        "tags": [
          "templates"
        ],
        "summary": "List SMS templates",
        "description": "The company's templates and the caller's own, in the caller's picker\norder (most used first unless they saved a custom order; then company\ntemplates first, by position, newest first). With `scope=company`\n(admins): only the company's, with the deal lists drips can start from.",
        "operationId": "list_sms_templates",
        "parameters": [
          {
            "name": "scope",
            "in": "query",
            "description": "`company`: only the company's templates, for admins to manage, with\nthe deal lists drips can use.",
            "required": false,
            "schema": {
              "type": "string",
              "description": "Who sees a template.",
              "enum": [
                "company",
                "personal"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Templates",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SmsTemplates"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "No SMS provider, or not an admin for the company scope",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "post": {
        "tags": [
          "templates"
        ],
        "summary": "Create an SMS template",
        "description": "`scope: company` (admins only) makes it the company's; otherwise it is\nthe caller's own. Either can drip (`drip`): a company template for the\nreps who use the company's automations, a personal one for the caller's\ndeals once they use their own (`PUT /v1/me/lead-automation`). It goes\nlast.",
        "operationId": "create_sms_template",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/NewSmsTemplate"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SmsTemplate"
                }
              }
            }
          },
          "400": {
            "description": "Missing name or body, unpaired braces, a drip list that is not a live list of the company, or a drip already taken",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "No SMS provider, or not an admin for a company template",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/sms-templates/{id}": {
      "put": {
        "tags": [
          "templates"
        ],
        "summary": "Edit an SMS template",
        "description": "The caller's own template, or (admins) a company one. Leaving out\n`drip` keeps the drip; a template that stops dripping cancels its\npending drip texts, and one whose drip moves to another list cancels\nthose for deals waiting on the old list.",
        "operationId": "update_sms_template",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Template id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SmsTemplateUpdate"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Saved",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SmsTemplate"
                }
              }
            }
          },
          "400": {
            "description": "Missing name or body, unpaired braces, a drip list that is not a live list of the company, or a drip already taken",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "No SMS provider",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such template the caller may change",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "delete": {
        "tags": [
          "templates"
        ],
        "summary": "Delete an SMS template",
        "description": "The caller's own template, or (admins) a company one; its pending drip\ntexts are cancelled.",
        "operationId": "delete_sms_template",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Template id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Deleted"
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "No SMS provider",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such template the caller may change",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/me/lead-automation": {
      "get": {
        "tags": [
          "templates"
        ],
        "summary": "Get whose automations the caller's deals get",
        "description": "`company` (the default): when a deal of the caller lands on a list (e.g.\nNot Contacted Yet), the company's automated email and SMS templates for\nthat list go out (Admin › Automations; those naming no sales reps, or\nnaming the caller). `own`: only the caller's own automated templates do —\npersonal templates with a `lead_list_id` (`GET /v1/email-templates`,\n`GET /v1/sms-templates`, `scope: personal`).",
        "operationId": "get_lead_automation",
        "responses": {
          "200": {
            "description": "The caller's choice",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LeadAutomation"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "put": {
        "tags": [
          "templates"
        ],
        "summary": "Choose whose automations the caller's deals get",
        "description": "`company` or `own` (see `GET /v1/me/lead-automation`). Changing it calls\noff the pending automatic sends of the side left behind (the company's on\nthe caller's deals, or the caller's own); deals already on a list get\nnothing new, the choice applies to deals that land on a list from now on.\nReturns the saved choice.",
        "operationId": "set_lead_automation",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/LeadAutomation"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Saved",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LeadAutomation"
                }
              }
            }
          },
          "400": {
            "description": "Unknown mode",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/me/lead-automation/items": {
      "get": {
        "tags": [
          "templates"
        ],
        "summary": "List the automations of the caller's deals",
        "description": "Every automated email and text (a template with a deal list) that can go\nout for the caller's deals, on both sides: `company`, the company's ones\nthat reach the caller (Admin › Automations, naming no sales reps or naming\nthe caller), and `own`, the caller's personal ones. Which side is in use is\n`GET /v1/me/lead-automation`. Texts are left out until the company has a\ntexting provider. Deleted templates and templates without a list are\nhidden. Edit or delete one with the email or SMS template routes named by\n`channel` and `template_id`.",
        "operationId": "list_lead_automation_items",
        "responses": {
          "200": {
            "description": "The caller's automations on each side",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LeadAutomationItems"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/sms/all/threads": {
      "get": {
        "tags": [
          "sms"
        ],
        "summary": "List conversations over every provider",
        "description": "A page of the company's SMS conversations through any provider, merged by\nphone, latest first — by the latest text, sent or received, when narrowed\nto one rep (`agent_id` = the rep's user id from `/v1/sms/all/sales-reps`).\nA search matches phone digits, message text and customer or supplier names.",
        "operationId": "list_all_sms_threads",
        "parameters": [
          {
            "name": "search",
            "in": "query",
            "description": "Phone digits, message text, or a customer's or supplier's name.",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Page size, 1 to 100 (default 20).",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          },
          {
            "name": "offset",
            "in": "query",
            "description": "Threads to skip.",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          },
          {
            "name": "scope",
            "in": "query",
            "description": "`all` for the whole company (admins only).",
            "required": false,
            "schema": {
              "type": "string",
              "description": "Whose conversations to list.",
              "enum": [
                "mine",
                "all"
              ]
            }
          },
          {
            "name": "agent_id",
            "in": "query",
            "description": "With `scope=all`, one rep's conversations (their agent id).",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "line_id",
            "in": "query",
            "description": "`/v1/sms/mine/threads`: only the texts on this line of the caller's\n(a `number_id` of `/v1/sms/mine/lines`; any other id filters nothing).",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "A page of conversations",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ThreadList"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/sms/all/threads/{phone}": {
      "get": {
        "tags": [
          "sms"
        ],
        "summary": "Get a conversation over every provider",
        "description": "The newest messages with one phone through any provider, oldest first\n(page back by raising `limit`; `before_id` is ignored), the customer or\nsupplier it belongs to and the SMS flow running on it. `agent_id` reads\nas one rep (their user id). Never sendable: the admin inbox is read-only.",
        "operationId": "get_all_sms_thread",
        "parameters": [
          {
            "name": "phone",
            "in": "path",
            "description": "The other party's phone digits",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Messages, 1 to 200 (default 30), newest first before reversing.",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          },
          {
            "name": "before_id",
            "in": "query",
            "description": "Only messages older than this one (paging back).",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          },
          {
            "name": "scope",
            "in": "query",
            "description": "`all` to read as an admin (anyone else reads their own).",
            "required": false,
            "schema": {
              "type": "string",
              "description": "Whose conversations to list.",
              "enum": [
                "mine",
                "all"
              ]
            }
          },
          {
            "name": "agent_id",
            "in": "query",
            "description": "With `scope=all`, read as one rep (their agent id).",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "line_id",
            "in": "query",
            "description": "`/v1/sms/mine/threads/{phone}`: only the texts on this line of the\ncaller's (any other id filters nothing).",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The conversation",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ThreadDetail"
                }
              }
            }
          },
          "400": {
            "description": "Not a phone number",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "The onboarding sample",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/sms/all/sales-reps": {
      "get": {
        "tags": [
          "sms"
        ],
        "summary": "List reps who text through any provider",
        "description": "The company's users with an agent or extension id on any provider, for\nthe admin inbox's rep filter; `agent_id` is the user's id.",
        "operationId": "list_all_sms_sales_reps",
        "responses": {
          "200": {
            "description": "Reps by name",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/SalesRep"
                  }
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/sms/mine/lines": {
      "get": {
        "tags": [
          "sms"
        ],
        "summary": "List the lines I text from",
        "description": "The Telnyx lines the caller may text from, for switching the inbox and\nthe line a text goes out from; empty when the company does not text\nthrough Telnyx.",
        "operationId": "list_my_sms_lines",
        "responses": {
          "200": {
            "description": "The lines",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/SmsLine"
                  }
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/sms/mine/threads": {
      "get": {
        "tags": [
          "sms"
        ],
        "summary": "List my conversations over every provider",
        "description": "The caller's own SMS conversations through every provider they text\nthrough or have texted through (a `CloudTalk` agent id, a `RingCentral`\nextension, a Telnyx line), merged by phone: the latest text first, sent\nor received.\nEach provider's part is what its own inbox shows the caller. A search\nmatches phone digits, message text and customer or supplier names.\n`line_id` keeps only the texts on that line.",
        "operationId": "list_my_sms_threads",
        "parameters": [
          {
            "name": "search",
            "in": "query",
            "description": "Phone digits, message text, or a customer's or supplier's name.",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Page size, 1 to 100 (default 20).",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          },
          {
            "name": "offset",
            "in": "query",
            "description": "Threads to skip.",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          },
          {
            "name": "scope",
            "in": "query",
            "description": "`all` for the whole company (admins only).",
            "required": false,
            "schema": {
              "type": "string",
              "description": "Whose conversations to list.",
              "enum": [
                "mine",
                "all"
              ]
            }
          },
          {
            "name": "agent_id",
            "in": "query",
            "description": "With `scope=all`, one rep's conversations (their agent id).",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "line_id",
            "in": "query",
            "description": "`/v1/sms/mine/threads`: only the texts on this line of the caller's\n(a `number_id` of `/v1/sms/mine/lines`; any other id filters nothing).",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "A page of conversations",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ThreadList"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/sms/mine/threads/{phone}": {
      "get": {
        "tags": [
          "sms"
        ],
        "summary": "Get my conversation over every provider",
        "description": "The newest messages with one phone through every provider the caller\ntexts through (as `GET /v1/sms/mine/threads`), oldest first, each with\nthe provider that carried it (page back by raising `limit`;\n`before_id` is ignored); the customer or supplier it belongs to and the\nSMS flow running on it. `replyProvider` is the provider to answer\nthrough: the one of the latest message the caller can text through,\nelse the first they can; `canSend` is false when they can text through\nnone. Opening it in the caller's own inbox marks it read (`unreadCount`\nis 0). `line_id` keeps only the texts on that line.",
        "operationId": "get_my_sms_thread",
        "parameters": [
          {
            "name": "phone",
            "in": "path",
            "description": "The other party's phone digits",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Messages, 1 to 200 (default 30), newest first before reversing.",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          },
          {
            "name": "before_id",
            "in": "query",
            "description": "Only messages older than this one (paging back).",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          },
          {
            "name": "scope",
            "in": "query",
            "description": "`all` to read as an admin (anyone else reads their own).",
            "required": false,
            "schema": {
              "type": "string",
              "description": "Whose conversations to list.",
              "enum": [
                "mine",
                "all"
              ]
            }
          },
          {
            "name": "agent_id",
            "in": "query",
            "description": "With `scope=all`, read as one rep (their agent id).",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "line_id",
            "in": "query",
            "description": "`/v1/sms/mine/threads/{phone}`: only the texts on this line of the\ncaller's (any other id filters nothing).",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The conversation",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ThreadDetail"
                }
              }
            }
          },
          "400": {
            "description": "Not a phone number",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "The onboarding sample",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/sms/mine/threads/{phone}/read": {
      "post": {
        "tags": [
          "sms"
        ],
        "summary": "Mark my conversation read",
        "description": "As `POST /v1/sms/{provider}/threads/{phone}/read` on every provider of\nthe caller's (as `GET /v1/sms/mine/threads`).",
        "operationId": "mark_my_sms_thread_read",
        "parameters": [
          {
            "name": "phone",
            "in": "path",
            "description": "The other party's phone digits",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Marked (or not visible to the caller)"
          },
          "400": {
            "description": "Not a phone number",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/sms/mine/threads/{phone}/unread": {
      "post": {
        "tags": [
          "sms"
        ],
        "summary": "Mark my conversation unread",
        "description": "As `POST /v1/sms/{provider}/threads/{phone}/unread` on every provider of\nthe caller's (as `GET /v1/sms/mine/threads`).",
        "operationId": "mark_my_sms_thread_unread",
        "parameters": [
          {
            "name": "phone",
            "in": "path",
            "description": "The other party's phone digits",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Marked (or not visible to the caller)"
          },
          "400": {
            "description": "Not a phone number",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/sms/mine/unread-count": {
      "get": {
        "tags": [
          "sms"
        ],
        "summary": "Count my unread conversations over every provider",
        "description": "The caller's own conversations with unread messages through every\nprovider they text through (as `GET /v1/sms/mine/threads`), for the\nsidebar badge. A phone with unread texts through two providers counts\ntwice.",
        "operationId": "count_my_unread_sms_threads",
        "responses": {
          "200": {
            "description": "The count",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UnreadCount"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/sms/mine/desktop-alerts": {
      "get": {
        "tags": [
          "sms"
        ],
        "summary": "My unread texts to alert about, over every provider",
        "description": "As `GET /v1/sms/{provider}/desktop-alerts` for every provider the caller\ntexts through: one alert per phone (the latest), newest first, at most\n50, each opening the conversation on the caller's `inbox` page.",
        "operationId": "list_my_sms_desktop_alerts",
        "parameters": [
          {
            "name": "inbox",
            "in": "query",
            "description": "The SMS page the alerts open (the caller's inbox); default `telnyx`.",
            "required": false,
            "schema": {
              "type": "string",
              "description": "The SMS provider a company texts through: `cloudtalk`, `ringcentral`, or\n`telnyx` (Granite Manager: texts from the company's Telnyx numbers).",
              "enum": [
                "cloudtalk",
                "ringcentral",
                "telnyx"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Alerts",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DesktopAlerts"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/sms/{provider}/threads": {
      "get": {
        "tags": [
          "sms"
        ],
        "summary": "List conversations",
        "description": "A page of the caller's SMS conversations (`scope=all`: the company's, for\nadmins), latest first — by the latest text, sent or received, when\nnarrowed to one rep. A search matches phone digits, message text and\ncustomer or supplier names.",
        "operationId": "list_sms_threads",
        "parameters": [
          {
            "name": "provider",
            "in": "path",
            "description": "SMS provider",
            "required": true,
            "schema": {
              "$ref": "#/components/schemas/SmsProvider"
            }
          },
          {
            "name": "search",
            "in": "query",
            "description": "Phone digits, message text, or a customer's or supplier's name.",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Page size, 1 to 100 (default 20).",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          },
          {
            "name": "offset",
            "in": "query",
            "description": "Threads to skip.",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          },
          {
            "name": "scope",
            "in": "query",
            "description": "`all` for the whole company (admins only).",
            "required": false,
            "schema": {
              "type": "string",
              "description": "Whose conversations to list.",
              "enum": [
                "mine",
                "all"
              ]
            }
          },
          {
            "name": "agent_id",
            "in": "query",
            "description": "With `scope=all`, one rep's conversations (their agent id).",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "line_id",
            "in": "query",
            "description": "`/v1/sms/mine/threads`: only the texts on this line of the caller's\n(a `number_id` of `/v1/sms/mine/lines`; any other id filters nothing).",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "A page of conversations",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ThreadList"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/sms/{provider}/unread-count": {
      "get": {
        "tags": [
          "sms"
        ],
        "summary": "Count unread conversations",
        "description": "Conversations with unread messages, for the sidebar badge.",
        "operationId": "count_unread_sms_threads",
        "parameters": [
          {
            "name": "provider",
            "in": "path",
            "description": "SMS provider",
            "required": true,
            "schema": {
              "$ref": "#/components/schemas/SmsProvider"
            }
          },
          {
            "name": "scope",
            "in": "query",
            "description": "`all` for the whole company (admins only).",
            "required": false,
            "schema": {
              "type": "string",
              "description": "Whose conversations to list.",
              "enum": [
                "mine",
                "all"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The count",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UnreadCount"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/sms/{provider}/desktop-alerts": {
      "get": {
        "tags": [
          "sms"
        ],
        "summary": "Unread texts to alert about",
        "description": "Up to 50 unread conversations whose latest message came from the\ncustomer, for desktop notifications. Empty for a user without an agent id\n(Telnyx: without a line) or a company without the provider.",
        "operationId": "list_sms_desktop_alerts",
        "parameters": [
          {
            "name": "provider",
            "in": "path",
            "description": "SMS provider",
            "required": true,
            "schema": {
              "$ref": "#/components/schemas/SmsProvider"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Alerts",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DesktopAlerts"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/sms/{provider}/sales-reps": {
      "get": {
        "tags": [
          "sms"
        ],
        "summary": "List reps who text",
        "description": "The company's users with an agent (`CloudTalk`) or extension\n(`RingCentral`) id, or with a Telnyx line (`agent_id` = their user id),\nfor the admin inbox's rep filter. On Telnyx the list starts with\n`schedule` (named \"Schedule\") when the company has a Scheduling Manager:\ntheir shared inbox, the Notification number's texts included.",
        "operationId": "list_sms_sales_reps",
        "parameters": [
          {
            "name": "provider",
            "in": "path",
            "description": "SMS provider",
            "required": true,
            "schema": {
              "$ref": "#/components/schemas/SmsProvider"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Reps by name",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/SalesRep"
                  }
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/sms/{provider}/threads/{phone}": {
      "get": {
        "tags": [
          "sms"
        ],
        "summary": "Get a conversation",
        "description": "The newest messages with one phone (page back with `before_id`), the\ncustomer or supplier it belongs to and the SMS flow running on it. A\nconversation the caller may not see comes back without messages. The\nonboarding tour's sample phone is not a real conversation (404).",
        "operationId": "get_sms_thread",
        "parameters": [
          {
            "name": "provider",
            "in": "path",
            "description": "SMS provider",
            "required": true,
            "schema": {
              "$ref": "#/components/schemas/SmsProvider"
            }
          },
          {
            "name": "phone",
            "in": "path",
            "description": "The other party's phone digits",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Messages, 1 to 200 (default 30), newest first before reversing.",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          },
          {
            "name": "before_id",
            "in": "query",
            "description": "Only messages older than this one (paging back).",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          },
          {
            "name": "scope",
            "in": "query",
            "description": "`all` to read as an admin (anyone else reads their own).",
            "required": false,
            "schema": {
              "type": "string",
              "description": "Whose conversations to list.",
              "enum": [
                "mine",
                "all"
              ]
            }
          },
          {
            "name": "agent_id",
            "in": "query",
            "description": "With `scope=all`, read as one rep (their agent id).",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "line_id",
            "in": "query",
            "description": "`/v1/sms/mine/threads/{phone}`: only the texts on this line of the\ncaller's (any other id filters nothing).",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The conversation",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ThreadDetail"
                }
              }
            }
          },
          "400": {
            "description": "Not a phone number",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "The onboarding sample",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/sms/{provider}/threads/{phone}/read": {
      "post": {
        "tags": [
          "sms"
        ],
        "summary": "Mark a conversation read",
        "description": "Clears the conversation's unread messages for the caller.",
        "operationId": "mark_sms_thread_read",
        "parameters": [
          {
            "name": "provider",
            "in": "path",
            "description": "SMS provider",
            "required": true,
            "schema": {
              "$ref": "#/components/schemas/SmsProvider"
            }
          },
          {
            "name": "phone",
            "in": "path",
            "description": "The other party's phone digits",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Marked (or not visible to the caller)"
          },
          "400": {
            "description": "Not a phone number",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/sms/{provider}/threads/{phone}/unread": {
      "post": {
        "tags": [
          "sms"
        ],
        "summary": "Mark a conversation unread",
        "description": "Keeps the conversation unread for the caller until it is opened again.",
        "operationId": "mark_sms_thread_unread",
        "parameters": [
          {
            "name": "provider",
            "in": "path",
            "description": "SMS provider",
            "required": true,
            "schema": {
              "$ref": "#/components/schemas/SmsProvider"
            }
          },
          {
            "name": "phone",
            "in": "path",
            "description": "The other party's phone digits",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Marked (or not visible to the caller)"
          },
          "400": {
            "description": "Not a phone number",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/sms/{provider}/messages": {
      "post": {
        "tags": [
          "sms"
        ],
        "summary": "Send a text",
        "description": "Sends a text (with photos or files uploaded beforehand) to a phone\nthrough the caller's agent (`CloudTalk`), extension (`RingCentral`) or\nTelnyx line, or schedules it with `send_at`. `CloudTalk` texts carry\nlinks to the files; `RingCentral` sends them as MMS, split into several\ntexts when large; Telnyx sends pictures and PDFs as MMS of up to 1 MB\neach (split likewise) and bigger or other files as links, to US and\nCanadian numbers only, never to a phone that texted STOP (`opted_out`).\nOpening the conversation counts as read. Errors come back as a token in\n`error`.",
        "operationId": "send_sms",
        "parameters": [
          {
            "name": "provider",
            "in": "path",
            "description": "SMS provider",
            "required": true,
            "schema": {
              "$ref": "#/components/schemas/SmsProvider"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SendSmsRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Sent or scheduled",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SentSms"
                }
              }
            }
          },
          "400": {
            "description": "Invalid text or attachment",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SmsSendError"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller has no agent id for the provider",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SmsSendError"
                }
              }
            }
          },
          "429": {
            "description": "Over ten texts a minute",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SmsSendError"
                }
              }
            }
          },
          "502": {
            "description": "The provider refused or failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SmsSendError"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/sms/{provider}/messages/{id}/retry": {
      "post": {
        "tags": [
          "sms"
        ],
        "summary": "Retry a failed text",
        "description": "Sends one of the caller's failed texts again, with its files, through\nthe provider the caller texts through now (`provider` names where the\nfailed text is stored), and replaces it with the new attempt: the sent\ntext, or the new failure.\nErrors come back as a token in `error`, as when sending.",
        "operationId": "retry_sms",
        "parameters": [
          {
            "name": "provider",
            "in": "path",
            "description": "SMS provider",
            "required": true,
            "schema": {
              "$ref": "#/components/schemas/SmsProvider"
            }
          },
          {
            "name": "id",
            "in": "path",
            "description": "The failed message",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Sent",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SentSms"
                }
              }
            }
          },
          "400": {
            "description": "The stored text cannot be sent",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SmsSendError"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller has no agent id for the provider",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SmsSendError"
                }
              }
            }
          },
          "404": {
            "description": "Not a failed text of the caller's",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "429": {
            "description": "Over ten texts a minute",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SmsSendError"
                }
              }
            }
          },
          "502": {
            "description": "The provider refused or failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SmsSendError"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/sms/{provider}/messages/{id}": {
      "delete": {
        "tags": [
          "sms"
        ],
        "summary": "Delete a failed text",
        "description": "Removes one of the caller's own failed outbound texts (`provider` names\nwhere it is stored) from the conversation, with its files.",
        "operationId": "delete_failed_sms",
        "parameters": [
          {
            "name": "provider",
            "in": "path",
            "description": "SMS provider",
            "required": true,
            "schema": {
              "$ref": "#/components/schemas/SmsProvider"
            }
          },
          {
            "name": "id",
            "in": "path",
            "description": "The failed message",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Deleted"
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "Not a failed text of the caller's",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/sms/attachments": {
      "post": {
        "tags": [
          "sms"
        ],
        "summary": "Prepare files for a text",
        "description": "Turns files uploaded to `sms-uploads/` into attachments ready to send:\npictures upright, at most 1600 px and about 480 KB (HEIC, WebP and PNG\nphotos become JPEG; PNGs that fit or are see-through, and GIF, stay),\ndocuments (PDF, Word, Excel, text, CSV) as they are. The uploads are\nremoved. Each file succeeds or fails on its own.",
        "operationId": "prepare_sms_attachments",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PrepareAttachments"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Prepared and failed files",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PreparedAttachments"
                }
              }
            }
          },
          "400": {
            "description": "No files, more than ten, or pictures switched off",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "503": {
            "description": "No bucket configured",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/sms/ringcentral/inbound-media": {
      "post": {
        "tags": [
          "sms"
        ],
        "summary": "Store an inbound MMS's files",
        "description": "Called by the `webhooks` Lambda (job key), not by the CRM: after it saved an\ninbound `RingCentral` text, it sends the message's file ids. Each file is\ndownloaded with the company's `RingCentral` login, stored under\n`sms-attachments/<company id>/` and shown with the text in the conversation.\nReturns how many were stored; 404 when the text is not the company's.",
        "operationId": "store_ringcentral_inbound_media",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/InboundMedia"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Files stored",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InboundMediaStored"
                }
              }
            }
          },
          "400": {
            "description": "Invalid body",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "Missing or wrong key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such message in the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "job_key": []
          }
        ]
      }
    },
    "/v1/sms/inbound-push": {
      "post": {
        "tags": [
          "sms"
        ],
        "summary": "Push a new `RingCentral` or `CloudTalk` text to phones",
        "description": "Called by the `webhooks` Lambda (job key) once it stored an inbound\ntext (and its pictures). Pushed as data `{granite: \"1\", type:\n\"crm_text\", provider, smsId}` (ids only: never the number, the name or\nthe text) to the signed-in phones of the company's users whose own\ninbox shows the conversation, as `GET /v1/sms/mine/threads` lists it.\nThe app then reads `GET /v1/sms/mine/messages/{provider}/{id}`. Nothing\nis pushed (`pushed: 0`) for an unknown or outbound text or when nobody\nhas it. Calling it again pushes again.",
        "operationId": "push_inbound_sms",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/InboundTextPush"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Phones told",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InboundTextPushed"
                }
              }
            }
          },
          "400": {
            "description": "Invalid body or provider",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "Missing or wrong key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "job_key": []
          }
        ]
      }
    },
    "/v1/sms/mine/messages/{provider}/{id}": {
      "get": {
        "tags": [
          "sms"
        ],
        "summary": "Read a new text for its notification",
        "description": "Who wrote the inbound `RingCentral` or `CloudTalk` text `id` and what,\nfor the phone's notification after a `crm_text` push: the conversation's\nphone (open it with `GET /v1/sms/mine/threads/{phone}`), the customer's\nname and the text. 404 unless the text is in the caller's own inbox.",
        "operationId": "get_my_sms_notice",
        "parameters": [
          {
            "name": "provider",
            "in": "path",
            "description": "`ringcentral` or `cloudtalk`",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "id",
            "in": "path",
            "description": "The text's id from the push",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The text",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TextNotice"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "Not a text of the caller's inbox",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/sms/{provider}/history": {
      "get": {
        "tags": [
          "sms"
        ],
        "summary": "List a customer's texts",
        "description": "With `deal_id`: texts with the deal's customer since the deal was made\n(none for a deal of another company). With `phone`: every text with\nthose phones (at most 50). Echoes of the company's own sends and unsent\ntexts are left out.",
        "operationId": "list_sms_history",
        "parameters": [
          {
            "name": "provider",
            "in": "path",
            "description": "SMS provider",
            "required": true,
            "schema": {
              "$ref": "#/components/schemas/SmsProvider"
            }
          },
          {
            "name": "deal_id",
            "in": "query",
            "description": "The deal's customer's texts since the deal was created.",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          },
          {
            "name": "phone",
            "in": "query",
            "description": "Or: every text with these phones (repeat the parameter, at most 50).",
            "required": false,
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              }
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Texts",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/History"
                }
              }
            }
          },
          "400": {
            "description": "More than 50 phones (`too_many_phones`)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/sms-flows": {
      "get": {
        "tags": [
          "sms"
        ],
        "summary": "List SMS flows",
        "description": "The company's flows and the caller's own (not the per-customer AI flows),\ncompany flows first, newest first.",
        "operationId": "list_sms_flows",
        "responses": {
          "200": {
            "description": "Flows",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Flows"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "post": {
        "tags": [
          "sms"
        ],
        "summary": "Create an SMS flow",
        "description": "Errors come back as a token: `validation_failed`,\n`step_needs_template_or_text`, `invalid_template_body`,\n`template_has_custom_variables`, `sms_text_too_long`,\n`template_not_found`.",
        "operationId": "create_sms_flow",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/NewFlow"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CreatedFlow"
                }
              }
            }
          },
          "400": {
            "description": "Invalid flow (see the token)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Not an employee, or not an admin for a company flow",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/sms-flows/{id}": {
      "get": {
        "tags": [
          "sms"
        ],
        "summary": "Get an SMS flow",
        "description": "One of the company's flows or the caller's own, including an AI flow\nthe caller confirmed for a customer.",
        "operationId": "get_sms_flow",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Flow id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The flow",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Flow"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such flow the caller may see",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "put": {
        "tags": [
          "sms"
        ],
        "summary": "Edit an SMS flow",
        "description": "Replaces the name and steps of the caller's flow (admins: a company\nflow); customers already in it keep their place, on the new timing.",
        "operationId": "update_sms_flow",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Flow id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/FlowUpdate"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Saved"
          },
          "400": {
            "description": "Invalid flow (see the token)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "The flow is not the caller's to change",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such flow",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "delete": {
        "tags": [
          "sms"
        ],
        "summary": "Delete an SMS flow",
        "description": "Customers in it stop receiving it.",
        "operationId": "delete_sms_flow",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Flow id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Deleted"
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "The flow is not the caller's to delete",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such flow",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/stones/attachable": {
      "get": {
        "tags": [
          "stones"
        ],
        "summary": "List stones to attach",
        "description": "Displayed stones of the company with an image that are regular stock or\nhave a free slab, by name (at most 200), with their installed photos'\ncount.",
        "operationId": "list_attachable_stones",
        "parameters": [
          {
            "name": "name",
            "in": "query",
            "description": "Part of the name.",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "type",
            "in": "query",
            "description": "Only these types (repeat the parameter).",
            "required": false,
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              }
            }
          },
          {
            "name": "finishing",
            "in": "query",
            "description": "Only these finishes (repeat the parameter).",
            "required": false,
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              }
            }
          },
          {
            "name": "level",
            "in": "query",
            "description": "Only these price levels (repeat the parameter).",
            "required": false,
            "schema": {
              "type": "array",
              "items": {
                "type": "integer",
                "format": "int32"
              }
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Stones by name",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/AttachableStone"
                  }
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/images": {
      "get": {
        "tags": [
          "catalog"
        ],
        "summary": "List the image library",
        "description": "The company's images by name (at most 200 matching `name`, else the\nwhole library).",
        "operationId": "list_images",
        "parameters": [
          {
            "name": "name",
            "in": "query",
            "description": "Part of the name.",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Images by name",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/LibraryFile"
                  }
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "post": {
        "tags": [
          "catalog"
        ],
        "summary": "Add an image",
        "description": "Puts a picture uploaded to the `images` folder (`POST /v1/uploads`) in\nthe library (its thumbnail is made now), in `folder_id` when that is a\nlive folder of the company.",
        "operationId": "create_image",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/NewImage"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Added",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LibraryImage"
                }
              }
            }
          },
          "400": {
            "description": "No name, or not an uploaded image",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/documents": {
      "get": {
        "tags": [
          "catalog"
        ],
        "summary": "List the documents",
        "description": "The company's documents by name (at most 200 matching `name`, else the\nwhole library).",
        "operationId": "list_documents",
        "parameters": [
          {
            "name": "name",
            "in": "query",
            "description": "Part of the name.",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Documents by name",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/LibraryFile"
                  }
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "post": {
        "tags": [
          "catalog"
        ],
        "summary": "Add a document",
        "description": "Puts a file uploaded to the `documents` folder (`POST /v1/uploads`) in the\ncompany's library under `name`.",
        "operationId": "create_document",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/NewDocument"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Added",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LibraryFile"
                }
              }
            }
          },
          "400": {
            "description": "No name or one over 100 characters, or not an uploaded document",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/documents/{id}": {
      "put": {
        "tags": [
          "catalog"
        ],
        "summary": "Edit a document",
        "description": "Renames it; with `url`, its file is replaced by a new upload. The old\nfile (and its page preview) stays in storage: emails sent with it still\nshow it.",
        "operationId": "update_document",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Document id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DocumentUpdate"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Saved",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LibraryFile"
                }
              }
            }
          },
          "400": {
            "description": "No name or one over 100 characters, or not an uploaded document",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such document in the caller's company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "delete": {
        "tags": [
          "catalog"
        ],
        "summary": "Delete a document",
        "description": "Takes it out of the library. The file stays in storage: emails may\nalready carry it.",
        "operationId": "delete_document",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Document id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Deleted"
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such document in the caller's company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/documents/{id}/preview": {
      "get": {
        "tags": [
          "catalog"
        ],
        "summary": "Show a PDF's first page",
        "description": "Redirects to a picture (WebP, 400 px wide) of the first page of a PDF in\nthe company's document library, drawing it on first use. For an `<img>`.",
        "operationId": "preview_document",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Document id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "302": {
            "description": "Redirect to the page picture"
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such PDF in the library, or no picture could be drawn",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database or storage error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/image-library": {
      "get": {
        "tags": [
          "catalog"
        ],
        "summary": "Get the image library",
        "description": "Every image of the company: the live folders by name, each with its\nimages by name, and the images in no folder. Images of a deleted folder\nare not shown.",
        "operationId": "get_image_library",
        "responses": {
          "200": {
            "description": "The library",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ImageLibrary"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/images/{id}": {
      "delete": {
        "tags": [
          "catalog"
        ],
        "summary": "Delete an image",
        "description": "Takes it out of the library; the file stays in storage (emails and\nquotes may show it).",
        "operationId": "delete_image",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Image id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Deleted"
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such image in the caller's company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "patch": {
        "tags": [
          "catalog"
        ],
        "summary": "Edit an image",
        "description": "Renames it, replaces its file with a new upload, and/or moves it to\nanother folder. The old file stays in storage (emails and texts sent with\nit still show it).",
        "operationId": "update_image",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Image id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ImageChanges"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Saved",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LibraryImage"
                }
              }
            }
          },
          "400": {
            "description": "Empty name, or not an uploaded image",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such image or folder in the caller's company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/image-folders": {
      "post": {
        "tags": [
          "catalog"
        ],
        "summary": "Add an image folder",
        "description": "An empty folder at the top of the library; images go in with\n`PATCH /v1/images/{id}`.",
        "operationId": "create_image_folder",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/FolderInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Added",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Folder"
                }
              }
            }
          },
          "400": {
            "description": "No name",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/image-folders/{id}": {
      "delete": {
        "tags": [
          "catalog"
        ],
        "summary": "Delete an image folder",
        "description": "Soft-deletes it; its images stay in the database but are no longer\nlisted.",
        "operationId": "delete_image_folder",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Folder id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Deleted"
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such live folder in the caller's company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "patch": {
        "tags": [
          "catalog"
        ],
        "summary": "Rename an image folder",
        "description": "Its images stay in it.",
        "operationId": "update_image_folder",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Folder id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/FolderInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Renamed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Folder"
                }
              }
            }
          },
          "400": {
            "description": "No name",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such live folder in the caller's company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/supports": {
      "get": {
        "tags": [
          "catalog"
        ],
        "summary": "List the supports",
        "description": "The company's supports with their pictures (thumbnails have `-icon`\nbefore the extension), by name.",
        "operationId": "list_supports",
        "responses": {
          "200": {
            "description": "Supports by name",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/LibraryFile"
                  }
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "post": {
        "tags": [
          "catalog"
        ],
        "summary": "Add a support",
        "description": "A picture uploaded to the `supports` folder (`POST /v1/uploads`) under\n`name`; its thumbnail is made now.",
        "operationId": "create_support",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/NewSupport"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Added",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LibraryFile"
                }
              }
            }
          },
          "400": {
            "description": "No name, or not an uploaded picture",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/supports/{id}": {
      "put": {
        "tags": [
          "catalog"
        ],
        "summary": "Edit a support",
        "description": "Renames it; with `url`, its picture is replaced by a new upload and the\nold picture and thumbnail are deleted from storage, unless another support\nshows that picture.",
        "operationId": "update_support",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Support id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SupportUpdate"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Saved",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LibraryFile"
                }
              }
            }
          },
          "400": {
            "description": "No name, or not an uploaded picture",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such support in the caller's company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "delete": {
        "tags": [
          "catalog"
        ],
        "summary": "Delete a support",
        "description": "Removes it from the company's supports.",
        "operationId": "delete_support",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Support id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Deleted"
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such support in the caller's company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/invoice-queue": {
      "get": {
        "tags": [
          "quickbooks"
        ],
        "summary": "List sales to invoice",
        "description": "The company's sales with no QuickBooks invoice yet, newest first.",
        "operationId": "list_invoice_queue",
        "responses": {
          "200": {
            "description": "Sales without an invoice",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/QueuedSale"
                  }
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/invoice-queue/{sale_id}": {
      "get": {
        "tags": [
          "quickbooks"
        ],
        "summary": "Get a sale to invoice",
        "description": "One sale of the company with its customer's email, phone, address and\nQuickBooks link, to review before invoicing.",
        "operationId": "get_invoice_queue_sale",
        "parameters": [
          {
            "name": "sale_id",
            "in": "path",
            "description": "Sale id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The sale",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/QueuedSaleDetail"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such sale in the caller's company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/invoices": {
      "get": {
        "tags": [
          "invoices"
        ],
        "summary": "List the company's invoices",
        "description": "Returns the invoices the CRM keeps itself (not QuickBooks invoices, which\nare at `GET /v1/customers/{id}/qbo-invoices`), highest number first, at\nmost 500, with `next_number`: the number a new invoice gets. Filters\ncombine: `customer_id`, `quote_id`, `status`, and `search` (an invoice\nnumber, or part of the bill-to name, email or project address). Open one\nwith `GET /v1/invoices/{id}`.",
        "operationId": "list_invoices",
        "parameters": [
          {
            "name": "customer_id",
            "in": "query",
            "description": "Only this customer's invoices.",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "quote_id",
            "in": "query",
            "description": "Only invoices made from this quote.",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "status",
            "in": "query",
            "description": "Only invoices with this status.",
            "required": false,
            "schema": {
              "$ref": "#/components/schemas/InvoiceStatus"
            }
          },
          {
            "name": "search",
            "in": "query",
            "description": "Matches the invoice number exactly, or part of the bill-to name,\nemail or project address.",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Matching invoices and the next number",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InvoiceList"
                }
              }
            }
          },
          "400": {
            "description": "A filter is not valid (unknown status, non-numeric id)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "post": {
        "tags": [
          "invoices"
        ],
        "summary": "Create an invoice",
        "description": "Saves a new invoice as a `draft`, for companies that invoice without\nQuickBooks. Line amounts, the subtotal and the total (subtotal + tax)\nare computed here. Without `invoice_number` it takes the company's next\nnumber. With a `quote_id` and no `customer_id`, the quote's customer is\nbilled. Nothing is sent: email it to the customer with `POST /v1/emails`\n(the invoice PDF attached), then mark it sent with\n`PUT /v1/invoices/{id}/status`.",
        "operationId": "create_invoice",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/InvoiceInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "The new invoice",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CrmInvoice"
                }
              }
            }
          },
          "400": {
            "description": "Missing name, bad date or email, no priced line, or an unknown customer or quote",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "409": {
            "description": "The invoice number is taken",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/invoices/{id}": {
      "get": {
        "tags": [
          "invoices"
        ],
        "summary": "Get one invoice",
        "description": "Returns the whole invoice: its lines, totals, status, customer and\nquote. Only the caller's company's invoices are found.",
        "operationId": "get_invoice",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Invoice id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The invoice",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CrmInvoice"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such invoice in the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "put": {
        "tags": [
          "invoices"
        ],
        "summary": "Edit an invoice",
        "description": "Replaces the invoice's number, customer, quote, dates, bill-to, lines,\ntax and notes with the body (same rules as `POST /v1/invoices`; leaving\nout `invoice_number` keeps the current one). The status is not changed:\nuse `PUT /v1/invoices/{id}/status`. Returns the saved invoice.",
        "operationId": "update_invoice",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Invoice id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/InvoiceInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "The saved invoice",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CrmInvoice"
                }
              }
            }
          },
          "400": {
            "description": "Missing name, bad date or email, no priced line, or an unknown customer or quote",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such invoice in the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "409": {
            "description": "The invoice number is taken",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/invoices/{id}/status": {
      "put": {
        "tags": [
          "invoices"
        ],
        "summary": "Change an invoice's status",
        "description": "Marks the invoice `draft`, `sent`, `paid` or `void`. `partial` is never\nset by hand: it follows the invoice's recorded payments, and an invoice\nthey cover cannot be reopened (409). `sent` (and `paid`)\nrecord when it was first sent; `paid` records when it was paid, and any\nother status clears that. Call it with `sent` after emailing the invoice\nto the customer. Returns the invoice.",
        "operationId": "set_invoice_status",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Invoice id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/InvoiceStatusInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "The invoice with its new status",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CrmInvoice"
                }
              }
            }
          },
          "400": {
            "description": "Unknown status",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such invoice in the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "409": {
            "description": "Its recorded payments cover it: delete a payment to reopen it",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/invoices/{id}/qbo-copy": {
      "put": {
        "tags": [
          "invoices"
        ],
        "summary": "Save the invoice's `QuickBooks` copy",
        "description": "Remembers the `QuickBooks` invoice that copies this one and when it last\nmatched ours (now). Null forgets it.",
        "operationId": "set_invoice_qbo_copy",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Invoice id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/QboCopyInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Saved"
          },
          "400": {
            "description": "Not a QuickBooks invoice id",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such invoice in the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/shop/maintenance": {
      "get": {
        "tags": [
          "shop"
        ],
        "summary": "Shop maintenance",
        "description": "The company's equipment, checks, their conditions and completions.",
        "operationId": "get_shop_maintenance",
        "responses": {
          "200": {
            "description": "The maintenance page",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Maintenance"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not of the shop or an employee",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/shop/maintenance/items": {
      "post": {
        "tags": [
          "shop"
        ],
        "summary": "Add equipment",
        "description": "Adds a piece of equipment. Shop managers only.",
        "operationId": "create_maintenance_item",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/EquipmentInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Added"
          },
          "400": {
            "description": "Invalid field",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not a shop manager",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/shop/maintenance/items/{id}": {
      "put": {
        "tags": [
          "shop"
        ],
        "summary": "Save equipment",
        "description": "Saves a piece of equipment. Shop managers only.",
        "operationId": "update_maintenance_item",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Equipment id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/EquipmentInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Saved"
          },
          "400": {
            "description": "Invalid field",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not a shop manager",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such equipment",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "delete": {
        "tags": [
          "shop"
        ],
        "summary": "Delete equipment",
        "description": "Deletes a piece of equipment with its checks and conditions. Shop\nmanagers only.",
        "operationId": "delete_maintenance_item",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Equipment id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Deleted"
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not a shop manager",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such equipment",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/shop/maintenance/checks": {
      "post": {
        "tags": [
          "shop"
        ],
        "summary": "Add a check",
        "description": "Adds a check to a piece of equipment with its conditions, due from\ntoday. Hour conditions need usage per day and days per month (the\ncheck's own or the equipment's). Shop managers only.",
        "operationId": "create_maintenance_check",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CheckInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Added",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CreatedCheck"
                }
              }
            }
          },
          "400": {
            "description": "Invalid field or no usage for hour conditions",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not a shop manager",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such equipment",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/shop/maintenance/checks/{id}": {
      "put": {
        "tags": [
          "shop"
        ],
        "summary": "Save a check",
        "description": "Saves a check and replaces its conditions (due again from today). Shop\nmanagers only.",
        "operationId": "update_maintenance_check",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Check id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CheckInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Saved"
          },
          "400": {
            "description": "Invalid field or no usage for hour conditions",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not a shop manager",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such check",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "delete": {
        "tags": [
          "shop"
        ],
        "summary": "Delete a check",
        "description": "Deletes a check and its conditions. Shop managers only.",
        "operationId": "delete_maintenance_check",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Check id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Deleted"
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not a shop manager",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such check",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/shop/maintenance/checks/{id}/complete": {
      "post": {
        "tags": [
          "shop"
        ],
        "summary": "Mark a check done",
        "description": "Records a completion, starts every condition of the check over from\ntoday and, with a meter reading, saves it as the new starting reading.",
        "operationId": "complete_maintenance_check",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Check id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CompletionInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Recorded"
          },
          "400": {
            "description": "Invalid field, or hour conditions without usage numbers",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not of the shop or an employee",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such check",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/shop/maintenance/conditions/{id}/hours": {
      "put": {
        "tags": [
          "shop"
        ],
        "summary": "Record hours used",
        "description": "Sets the hours used on an hour condition and moves its due day.",
        "operationId": "update_maintenance_hours",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Condition id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/HoursInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Saved"
          },
          "400": {
            "description": "Not an hour condition, invalid hours, or no usage numbers",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not of the shop or an employee",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such condition",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/marketing/{company_id}/leads": {
      "get": {
        "tags": [
          "marketing"
        ],
        "summary": "List the leads",
        "description": "The company's leads (or walk-ins) created in the range, newest first,\nwith their live deals, the company's stages and invalid / lost counts.",
        "operationId": "list_marketing_leads",
        "parameters": [
          {
            "name": "company_id",
            "in": "path",
            "description": "Company id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "view",
            "in": "query",
            "description": "`leads` (default; web and ad leads), `walkins` (check-ins) or `all`.",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "channel",
            "in": "query",
            "description": "`all` (default), `facebook` or `website`.",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "from",
            "in": "query",
            "description": "Created on or after this day, `YYYY-MM-DD`.",
            "required": false,
            "schema": {
              "type": "string",
              "format": "date"
            }
          },
          {
            "name": "to",
            "in": "query",
            "description": "Created on or before this day, `YYYY-MM-DD`. Swapped with `from`\nwhen before it.",
            "required": false,
            "schema": {
              "type": "string",
              "format": "date"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The leads page",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LeadsPage"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not on the company's marketing team",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "post": {
        "tags": [
          "marketing"
        ],
        "summary": "Add a lead",
        "description": "Saves a lead (source `leads`, created by \"Marketing team\") with its\nemails, then hands it to the lead pipeline, which opens its deal and\ntells the sales team.",
        "operationId": "create_marketing_lead",
        "parameters": [
          {
            "name": "company_id",
            "in": "path",
            "description": "Company id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/LeadInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Added",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CreatedLead"
                }
              }
            }
          },
          "400": {
            "description": "No name, or an unknown referral source",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not on the company's marketing team",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "409": {
            "description": "A phone or email belongs to another customer",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/marketing/{company_id}/leads/{id}": {
      "get": {
        "tags": [
          "marketing"
        ],
        "summary": "Get a lead",
        "description": "A live lead of the company, for its edit form.",
        "operationId": "get_marketing_lead",
        "parameters": [
          {
            "name": "company_id",
            "in": "path",
            "description": "Company id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "id",
            "in": "path",
            "description": "Customer id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The lead",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EditableLead"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not on the company's marketing team",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such live lead in the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "put": {
        "tags": [
          "marketing"
        ],
        "summary": "Edit a lead",
        "description": "Saves the name, phones, address, message and emails of a live lead.",
        "operationId": "update_marketing_lead",
        "parameters": [
          {
            "name": "company_id",
            "in": "path",
            "description": "Company id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "id",
            "in": "path",
            "description": "Customer id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/LeadInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Saved"
          },
          "400": {
            "description": "No name",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not on the company's marketing team",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such live lead in the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "409": {
            "description": "A phone or email belongs to another customer",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "delete": {
        "tags": [
          "marketing"
        ],
        "summary": "Delete a lead",
        "description": "Deletes a live lead and its deals, and removes the Telegram messages\nabout it.",
        "operationId": "delete_marketing_lead",
        "parameters": [
          {
            "name": "company_id",
            "in": "path",
            "description": "Company id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "id",
            "in": "path",
            "description": "Customer id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Deleted"
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not on the company's marketing team",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such live lead in the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/marketing/{company_id}/leads/{id}/info": {
      "get": {
        "tags": [
          "marketing"
        ],
        "summary": "A lead's card",
        "description": "A live lead of the company with its deals and reassignments.",
        "operationId": "get_marketing_lead_card",
        "parameters": [
          {
            "name": "company_id",
            "in": "path",
            "description": "Company id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "id",
            "in": "path",
            "description": "Customer id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The card",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LeadCard"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not on the company's marketing team",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such live lead in the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/marketing/{company_id}/leads/{id}/projects": {
      "get": {
        "tags": [
          "marketing"
        ],
        "summary": "A lead's projects",
        "description": "The lead's business (its parent, or itself) and every project under\nit, by name, with their sales.",
        "operationId": "list_marketing_lead_projects",
        "parameters": [
          {
            "name": "company_id",
            "in": "path",
            "description": "Company id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "id",
            "in": "path",
            "description": "Customer id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Projects by name",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/LeadProject"
                  }
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not on the company's marketing team",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such live lead in the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/marketing/{company_id}/uploads": {
      "post": {
        "tags": [
          "marketing"
        ],
        "summary": "Upload a lead picture",
        "description": "A presigned `PUT` URL for a picture to attach to a new lead, and the\npublic URL to send as its `file_url`.",
        "operationId": "create_marketing_upload",
        "parameters": [
          {
            "name": "company_id",
            "in": "path",
            "description": "Company id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/LeadUploadRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Upload URL and public URL",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Upload"
                }
              }
            }
          },
          "400": {
            "description": "Not an image",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not on the company's marketing team",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Storage error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "503": {
            "description": "Uploads are not configured on this server",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/marketing/{company_id}/customers/search": {
      "get": {
        "tags": [
          "marketing"
        ],
        "summary": "Search the company's customers",
        "description": "The employee customer search (`GET /v1/customers/search`) for the\nmarketing team's \"find a customer\" box.",
        "operationId": "search_marketing_customers",
        "parameters": [
          {
            "name": "company_id",
            "in": "path",
            "description": "Company id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "term",
            "in": "query",
            "description": "What the user typed. Required (may be empty for phone search).",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "by",
            "in": "query",
            "description": "Which field to match: `name` (default), `phone`, `email`, `company`, `address`.",
            "required": false,
            "schema": {
              "type": "string",
              "description": "How `GET /v1/customers/search` matches `term`.",
              "enum": [
                "name",
                "phone",
                "email",
                "company",
                "address"
              ]
            }
          },
          {
            "name": "own_only",
            "in": "query",
            "description": "`true` returns only customers assigned to the caller or unassigned.",
            "required": false,
            "schema": {
              "type": "boolean"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Matching customers, best first",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/CustomerSearchRow"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Missing `term` or unknown `by`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not on the company's marketing team",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/marketing/{company_id}/referral-sources": {
      "get": {
        "tags": [
          "marketing"
        ],
        "summary": "List referral sources",
        "description": "The company's referral sources, by name: the choices for a new lead.",
        "operationId": "list_marketing_referral_sources",
        "parameters": [
          {
            "name": "company_id",
            "in": "path",
            "description": "Company id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Sources by name",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/ReferralSource"
                  }
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not on the company's marketing team",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "post": {
        "tags": [
          "marketing"
        ],
        "summary": "Add a referral source",
        "description": "Adds a source the company's leads can come from.",
        "operationId": "create_marketing_referral_source",
        "parameters": [
          {
            "name": "company_id",
            "in": "path",
            "description": "Company id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ReferralSourceInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Added",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ReferralSource"
                }
              }
            }
          },
          "400": {
            "description": "Empty or longer than 255 characters",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not on the company's marketing team",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "409": {
            "description": "A source with this name exists",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/marketing/{company_id}/referral-sources/{id}": {
      "delete": {
        "tags": [
          "marketing"
        ],
        "summary": "Delete a referral source",
        "description": "Hides a source from the add-lead form; leads keep it.",
        "operationId": "delete_marketing_referral_source",
        "parameters": [
          {
            "name": "company_id",
            "in": "path",
            "description": "Company id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "id",
            "in": "path",
            "description": "Source id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Deleted"
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not on the company's marketing team",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such source",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "patch": {
        "tags": [
          "marketing"
        ],
        "summary": "Rename a referral source",
        "description": "Renames a source; leads keep the name they were saved with.",
        "operationId": "rename_marketing_referral_source",
        "parameters": [
          {
            "name": "company_id",
            "in": "path",
            "description": "Company id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "id",
            "in": "path",
            "description": "Source id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ReferralSourceInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Renamed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ReferralSource"
                }
              }
            }
          },
          "400": {
            "description": "Empty or longer than 255 characters",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not on the company's marketing team",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such source",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "409": {
            "description": "Another source has this name",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/quote-tax-rates": {
      "get": {
        "tags": [
          "quotes"
        ],
        "summary": "List quote tax rates",
        "description": "The company's tax rates, by sequence then name.",
        "operationId": "list_quote_tax_rates",
        "responses": {
          "200": {
            "description": "Tax rates",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/QuoteTaxRate"
                  }
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "post": {
        "tags": [
          "quotes"
        ],
        "summary": "Add a quote tax rate",
        "description": "Adds a tax rate quotes can pick.",
        "operationId": "create_quote_tax_rate",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/QuoteTaxRateInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Added",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/QuoteTaxRate"
                }
              }
            }
          },
          "400": {
            "description": "No name, or a percent outside 0-100",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/quote-tax-rates/{id}": {
      "put": {
        "tags": [
          "quotes"
        ],
        "summary": "Save a quote tax rate",
        "description": "Saves the name, sequence and percent of a tax rate.",
        "operationId": "update_quote_tax_rate",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Tax rate id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/QuoteTaxRateInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Saved"
          },
          "400": {
            "description": "No name, or a percent outside 0-100",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such tax rate in the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "delete": {
        "tags": [
          "quotes"
        ],
        "summary": "Delete a quote tax rate",
        "description": "Removes a tax rate from the lists; quotes keep what they saved.",
        "operationId": "delete_quote_tax_rate",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Tax rate id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Deleted"
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such tax rate in the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/quote-payment-terms": {
      "get": {
        "tags": [
          "quotes"
        ],
        "summary": "List quote payment terms",
        "description": "The company's payment terms, by sequence then name.",
        "operationId": "list_quote_payment_terms",
        "responses": {
          "200": {
            "description": "Payment terms",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/QuotePaymentTerm"
                  }
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "post": {
        "tags": [
          "quotes"
        ],
        "summary": "Add quote payment terms",
        "description": "Adds payment terms quotes can pick.",
        "operationId": "create_quote_payment_term",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/QuotePaymentTermInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Added",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/QuotePaymentTerm"
                }
              }
            }
          },
          "400": {
            "description": "No name or no terms",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/quote-payment-terms/{id}": {
      "put": {
        "tags": [
          "quotes"
        ],
        "summary": "Save quote payment terms",
        "description": "Saves the name, sequence and text of payment terms.",
        "operationId": "update_quote_payment_term",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Payment terms id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/QuotePaymentTermInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Saved"
          },
          "400": {
            "description": "No name or no terms",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such payment terms in the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "delete": {
        "tags": [
          "quotes"
        ],
        "summary": "Delete quote payment terms",
        "description": "Removes payment terms from the lists; quotes keep what they saved.",
        "operationId": "delete_quote_payment_term",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Payment terms id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Deleted"
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such payment terms in the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/online-quote-options": {
      "get": {
        "tags": [
          "quotes"
        ],
        "summary": "List online quote options",
        "description": "The extras the company's online quote can offer, by sequence then name:\neach one of the company's extras (Admin > Quotes > Extras).",
        "operationId": "list_online_quote_options",
        "responses": {
          "200": {
            "description": "Options",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/OnlineQuoteOption"
                  }
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "post": {
        "tags": [
          "quotes"
        ],
        "summary": "Add an online quote option",
        "description": "Offers one of the company's extras on the online quote.",
        "operationId": "create_online_quote_option",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/OnlineQuoteOptionInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Added",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OnlineQuoteOption"
                }
              }
            }
          },
          "400": {
            "description": "Not one of the company's extras",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "409": {
            "description": "That extra is already an option",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/online-quote-options/{id}": {
      "put": {
        "tags": [
          "quotes"
        ],
        "summary": "Save an online quote option",
        "description": "Saves which extra it offers, its sequence and whether customers are offered it.",
        "operationId": "update_online_quote_option",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Option id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/OnlineQuoteOptionInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Saved"
          },
          "400": {
            "description": "Not one of the company's extras",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such option in the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "409": {
            "description": "That extra is already an option",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "delete": {
        "tags": [
          "quotes"
        ],
        "summary": "Delete an online quote option",
        "description": "Removes the option; quotes keep the extras they got.",
        "operationId": "delete_online_quote_option",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Option id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Deleted"
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such option in the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/quote-settings": {
      "get": {
        "tags": [
          "quotes"
        ],
        "summary": "Get the quote settings",
        "description": "The company's measurement defaults for new quotes (defaults when none\nare saved).",
        "operationId": "get_quote_settings",
        "responses": {
          "200": {
            "description": "The settings",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/QuoteSettings"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "put": {
        "tags": [
          "quotes"
        ],
        "summary": "Save the quote settings",
        "description": "Saves the company's measurement rounding and default counter depth.",
        "operationId": "save_quote_settings",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/QuoteSettingsInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Saved"
          },
          "400": {
            "description": "Depth not in (0, 120]",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/quote-email-templates": {
      "get": {
        "tags": [
          "quotes"
        ],
        "summary": "List quote email templates",
        "description": "The company's templates by sequence, then the caller's own (`personal`).",
        "operationId": "list_quote_email_templates",
        "responses": {
          "200": {
            "description": "Templates",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/QuoteEmailTemplate"
                  }
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "post": {
        "tags": [
          "quotes"
        ],
        "summary": "Add a quote email template",
        "description": "Adds a company template every sales rep can use, at `sequence`.",
        "operationId": "create_quote_email_template",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/QuoteEmailTemplateInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Added"
          },
          "400": {
            "description": "No name or no subject",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/quote-email-templates/{id}": {
      "put": {
        "tags": [
          "quotes"
        ],
        "summary": "Save a quote email template",
        "description": "Saves a company template and moves it to `sequence`.",
        "operationId": "update_quote_email_template",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Template id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/QuoteEmailTemplateInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Saved"
          },
          "400": {
            "description": "No name or no subject",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such company template",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "delete": {
        "tags": [
          "quotes"
        ],
        "summary": "Delete a quote email template",
        "description": "Deletes a company template and renumbers the others.",
        "operationId": "delete_quote_email_template",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Template id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Deleted"
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such company template",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/quote-email-templates/order": {
      "put": {
        "tags": [
          "quotes"
        ],
        "summary": "Reorder the quote email templates",
        "description": "Saves a drag on the templates table: each company template's sequence\nbecomes its place in `ids` (1 = first, the default). Other ids are\nignored; templates left out go after the given ones, in their old order.",
        "operationId": "reorder_quote_email_templates",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/QuoteEmailTemplateOrder"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Saved"
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/quote-extras": {
      "get": {
        "tags": [
          "quotes"
        ],
        "summary": "List the extras catalog",
        "description": "In order, with how many extras the price lists still keep themselves.",
        "operationId": "list_quote_extras",
        "responses": {
          "200": {
            "description": "The catalog",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ExtrasCatalog"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "put": {
        "tags": [
          "quotes"
        ],
        "summary": "Save the extras catalog",
        "description": "Each extra's content and order; extras left out are deleted (price lists\nstop offering them). Names must be unique.",
        "operationId": "save_quote_extras",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/EditedCatalog"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Saved"
          },
          "400": {
            "description": "A name is listed twice",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "post": {
        "tags": [
          "quotes"
        ],
        "summary": "Add an extra",
        "description": "Every price list offers it, except `off_list_ids`, which each get a\nrevision that switches it off.",
        "operationId": "create_quote_extra",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/NewExtra"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Added",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CreatedId"
                }
              }
            }
          },
          "400": {
            "description": "No name",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "409": {
            "description": "The name is taken",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/quote-extras/moves": {
      "post": {
        "tags": [
          "quotes"
        ],
        "summary": "Move the lists' own extras into the catalog",
        "description": "Once: extras with the same name become one catalog extra (the first\nlist's version wins), and each list links to them, keeping its own\nprices where they differ.",
        "operationId": "move_quote_list_extras",
        "responses": {
          "200": {
            "description": "Moved",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MovedExtras"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/quote-sale-events": {
      "get": {
        "tags": [
          "quotes"
        ],
        "summary": "List the extra events a quote's sale can add to the schedule",
        "description": "Returns the company's event templates (Admin > Quotes > Automation), in\nthe order they were added: the checkboxes under Mark as Sold › Extra\nevents. One starts ticked when the quote has a line of one of its\n`trigger_extra_ids` extras, or one of its `trigger_options`. Pass the ticked ones as `extra_events` to\n`POST /v1/quotes/{id}/sale`. A template whose calendar was deleted is left\nout. Any employee may read them; admins change them with\n`POST /v1/quote-sale-events` and `PUT|DELETE /v1/quote-sale-events/{id}`.",
        "operationId": "list_quote_sale_events",
        "responses": {
          "200": {
            "description": "The company's event templates",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/QuoteSaleEvent"
                  }
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "post": {
        "tags": [
          "quotes"
        ],
        "summary": "Add an extra event a quote's sale can add to the schedule",
        "description": "From then on, Mark as Sold › Extra events offers it as a checkbox; ticked,\nthe sale adds one unscheduled, Not ready event to `calendar_id`, titled\nwith the variable and the text (e.g. \"Ostrom Kitchen - Plumbing\"), at the\ncustomer's address, for the schedule manager to give a day. Quotes sold\nbefore are not changed.",
        "operationId": "create_quote_sale_event",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/QuoteSaleEventInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Added",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CreatedSaleEvent"
                }
              }
            }
          },
          "400": {
            "description": "Text too long, or no such calendar in the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/quote-sale-events/{id}": {
      "put": {
        "tags": [
          "quotes"
        ],
        "summary": "Edit an extra event a quote's sale can add to the schedule",
        "description": "Quotes sold from then on get the new calendar, title and trigger extras;\nevents already added stay as they are.",
        "operationId": "update_quote_sale_event",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Event template id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/QuoteSaleEventInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Saved"
          },
          "400": {
            "description": "Text too long, or no such calendar in the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such template in the caller's company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "delete": {
        "tags": [
          "quotes"
        ],
        "summary": "Delete an extra event a quote's sale can add to the schedule",
        "description": "Mark as Sold no longer offers it; events already added stay.",
        "operationId": "delete_quote_sale_event",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Event template id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Deleted"
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such template in the caller's company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/quote-sale-built-in-titles": {
      "get": {
        "tags": [
          "quotes"
        ],
        "summary": "How the sale's template and installation events are named",
        "description": "Admin › Quotes › Automation › Event templates: each built-in event's title\nis the text before, the variable and the text after, joined by \" - \"\n(default: the quote's name alone). Any employee may read them (Mark as\nSold shows the titles); admins change them with `PUT`.",
        "operationId": "get_quote_sale_built_in_titles",
        "responses": {
          "200": {
            "description": "The company's built-in event names",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BuiltInTitles"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "put": {
        "tags": [
          "quotes"
        ],
        "summary": "Rename the sale's template and installation events",
        "description": "Quotes sold from then on get the new titles; events already added stay\nas they are.",
        "operationId": "save_quote_sale_built_in_titles",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/BuiltInTitles"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Saved"
          },
          "400": {
            "description": "A text is too long",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/quotes/{id}/invoice-sync": {
      "get": {
        "tags": [
          "quotes"
        ],
        "summary": "Get a quote's invoice sync",
        "description": "The quote's invoice kept in step with it; null when it has none.",
        "operationId": "get_quote_invoice_sync",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Quote id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The link, or null",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/InvoiceSync"
                    },
                    {
                      "type": "null"
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such quote in the caller's company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "put": {
        "tags": [
          "quotes"
        ],
        "summary": "Link a quote's invoice to the quote",
        "description": "Saves the quote's invoice and how it is kept in step: after it is created\nwith \"Keep in sync with the quote\" ticked, after each sync (the new\n`source_hash`), and with `enabled` off to stop. A quote has one; saving\nreplaces it.",
        "operationId": "save_quote_invoice_sync",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Quote id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/InvoiceSync"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Saved"
          },
          "400": {
            "description": "Invalid kind, invoice ids, hash or detail",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such quote in the caller's company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/payment-options": {
      "get": {
        "tags": [
          "invoices"
        ],
        "summary": "Payment methods and deposit accounts",
        "description": "What the Record payment dialog and Admin > Company list. Every company\ngets its own list of method names (ACH, Cash, Card, Check and Zelle until it\nchanges it). A company connected to `QuickBooks` also gets its bank\naccounts plus Undeposited Funds, with the default deposit account it\nchose; a method picked from the list is matched to (or made as) the\n`QuickBooks` method of that name when the payment is saved there.",
        "operationId": "get_payment_options",
        "responses": {
          "200": {
            "description": "The lists",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PaymentOptions"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "409": {
            "description": "QuickBooks needs to be reconnected",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "502": {
            "description": "QuickBooks failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/payment-options/methods": {
      "put": {
        "tags": [
          "invoices"
        ],
        "summary": "Replace the company's own payment methods",
        "description": "Saves the company's own list (renaming, removing or reordering methods),\n`QuickBooks` or not. Admins only.",
        "operationId": "save_payment_methods",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PaymentMethodsInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "The saved list",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PaymentOptions"
                }
              }
            }
          },
          "400": {
            "description": "A blank or too long name, or too many",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "409": {
            "description": "QuickBooks needs to be reconnected",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "post": {
        "tags": [
          "invoices"
        ],
        "summary": "Add a payment method",
        "description": "Adds it to the company's own list (`QuickBooks` gets it when a payment\nfirst uses it). Admins only.\nReturns the lists as `GET /v1/payment-options` does.",
        "operationId": "add_payment_method",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PaymentMethodInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "The lists with the new method",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PaymentOptions"
                }
              }
            }
          },
          "400": {
            "description": "No name, a name too long, or QuickBooks refused it",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "409": {
            "description": "The method is already in the list, or QuickBooks needs to be reconnected",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "502": {
            "description": "QuickBooks failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/payment-options/deposit-account": {
      "put": {
        "tags": [
          "invoices"
        ],
        "summary": "Choose the default deposit account",
        "description": "The `QuickBooks` account the Record payment dialog starts with, one of\n`accounts` of `GET /v1/payment-options`; null clears it. Companies\nconnected to `QuickBooks` only. Admins only.",
        "operationId": "save_deposit_account",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DepositAccountInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "The lists with the new default",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PaymentOptions"
                }
              }
            }
          },
          "400": {
            "description": "Not one of the company's deposit accounts",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "409": {
            "description": "QuickBooks is not connected, or needs to be reconnected",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "502": {
            "description": "QuickBooks failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/customers/{id}/qbo-invoices/{invoice_id}/payments": {
      "get": {
        "tags": [
          "quickbooks"
        ],
        "summary": "List a QuickBooks invoice's payments",
        "description": "The payments `QuickBooks` has for the invoice, newest first, with the\ninvoice's total, open balance and tax. Payments entered in `QuickBooks`\nitself are listed too, with `recorded_by` null.",
        "operationId": "list_qbo_invoice_payments",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Customer id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "invoice_id",
            "in": "path",
            "description": "QuickBooks invoice id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The invoice's payments",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InvoicePayments"
                }
              }
            }
          },
          "400": {
            "description": "Invalid invoice id",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Not an invoice of this customer",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such customer, or it is not linked to QuickBooks",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "409": {
            "description": "QuickBooks is not connected, or the invoice was deleted there",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "502": {
            "description": "QuickBooks failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "post": {
        "tags": [
          "quickbooks"
        ],
        "summary": "Record a payment on a QuickBooks invoice",
        "description": "Creates a `QuickBooks` Payment for the invoice's customer, linked to the\ninvoice, with the amount, date, payment method, deposit account,\nreference and memo. An amount above the invoice's open balance is\nrefused. Granite Manager keeps only who recorded it. Returns the\ninvoice's payments and new balance.",
        "operationId": "create_qbo_invoice_payment",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Customer id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "invoice_id",
            "in": "path",
            "description": "QuickBooks invoice id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PaymentInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "The invoice's payments with the new one",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InvoicePayments"
                }
              }
            }
          },
          "400": {
            "description": "No amount, an amount above the open balance, a bad date, or QuickBooks refused it",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Not an invoice of this customer",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such customer, or it is not linked to QuickBooks",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "409": {
            "description": "QuickBooks is not connected, or the invoice was deleted there",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "502": {
            "description": "QuickBooks failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/customers/{id}/qbo-invoices/{invoice_id}/payments/{payment_id}": {
      "put": {
        "tags": [
          "quickbooks"
        ],
        "summary": "Edit a payment of a QuickBooks invoice",
        "description": "Updates the `QuickBooks` Payment: amount, date, method, account,\nreference and memo. The new amount may not exceed the invoice's open\nbalance plus what this payment already covers. A payment that also covers\nother invoices, or is partly unapplied, is changed in `QuickBooks`.",
        "operationId": "update_qbo_invoice_payment",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Customer id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "invoice_id",
            "in": "path",
            "description": "QuickBooks invoice id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "payment_id",
            "in": "path",
            "description": "QuickBooks payment id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PaymentInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "The invoice's payments",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InvoicePayments"
                }
              }
            }
          },
          "400": {
            "description": "A bad amount or date, a payment covering other invoices, or QuickBooks refused it",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Not an invoice of this customer",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such customer, or it is not linked to QuickBooks",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "409": {
            "description": "QuickBooks is not connected, or the invoice was deleted there",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "502": {
            "description": "QuickBooks failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "delete": {
        "tags": [
          "quickbooks"
        ],
        "summary": "Delete a payment of a QuickBooks invoice",
        "description": "Deletes the `QuickBooks` Payment, all of it: when it also covers other\ninvoices, their balances open again too. Returns the invoice's payments\nand new balance.",
        "operationId": "delete_qbo_invoice_payment",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Customer id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "invoice_id",
            "in": "path",
            "description": "QuickBooks invoice id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "payment_id",
            "in": "path",
            "description": "QuickBooks payment id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The invoice's payments without it",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InvoicePayments"
                }
              }
            }
          },
          "400": {
            "description": "Not a payment of this invoice, or QuickBooks refused it",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Not an invoice of this customer",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such customer, or it is not linked to QuickBooks",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "409": {
            "description": "QuickBooks is not connected, or the invoice was deleted there",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "502": {
            "description": "QuickBooks failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/invoices/{id}/payments": {
      "get": {
        "tags": [
          "invoices"
        ],
        "summary": "List an invoice's payments",
        "description": "The payments recorded on one of Granite Manager's own invoices, newest\nfirst, with its total and open balance. An invoice marked paid by hand\nowes nothing even with no payment recorded.",
        "operationId": "list_invoice_payments",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Invoice id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The invoice's payments",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InvoicePayments"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such invoice in the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "post": {
        "tags": [
          "invoices"
        ],
        "summary": "Record a payment on an invoice",
        "description": "Records a payment on one of Granite Manager's own invoices: amount, date,\nmethod (a name from `GET /v1/payment-options`), reference and memo. An\namount above the open balance is refused, as is a payment on a void\ninvoice. The invoice becomes `partial`, or `paid` when nothing is owed.",
        "operationId": "create_invoice_payment",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Invoice id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PaymentInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "The invoice's payments with the new one",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InvoicePayments"
                }
              }
            }
          },
          "400": {
            "description": "No amount, an amount above the open balance, a bad date, or a void invoice",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such invoice in the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/invoices/{id}/payments/{payment_id}": {
      "put": {
        "tags": [
          "invoices"
        ],
        "summary": "Edit a payment of an invoice",
        "description": "Changes a recorded payment. The new amount may not exceed the invoice's\nopen balance plus what this payment already covers. The invoice's status\nfollows the new balance. A payment that came from a payment link cannot\nbe edited.",
        "operationId": "update_invoice_payment",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Invoice id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "payment_id",
            "in": "path",
            "description": "Payment id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64",
              "minimum": 0
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PaymentInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "The invoice's payments",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InvoicePayments"
                }
              }
            }
          },
          "400": {
            "description": "A bad amount or date, or a payment link's payment",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such invoice or payment in the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "delete": {
        "tags": [
          "invoices"
        ],
        "summary": "Delete a payment of an invoice",
        "description": "Removes a recorded payment; the invoice's balance opens again and its\nstatus follows (`partial`, or back to `sent` or `draft` with none left).\nA payment that came from a payment link cannot be deleted.",
        "operationId": "delete_invoice_payment",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Invoice id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "payment_id",
            "in": "path",
            "description": "Payment id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64",
              "minimum": 0
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The invoice's payments without it",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InvoicePayments"
                }
              }
            }
          },
          "400": {
            "description": "A payment link's payment",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such invoice or payment in the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/quotes/{id}/deposits": {
      "get": {
        "tags": [
          "quotes"
        ],
        "summary": "List a quote's deposits",
        "description": "The deposits taken on the quote that are on no invoice yet, newest first.\nOnce an invoice is made they are on it and listed with its payments.",
        "operationId": "list_quote_deposits",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Quote id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The waiting deposits",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/RecordedPayment"
                  }
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such quote in the caller's company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "409": {
            "description": "QuickBooks needs to be reconnected",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "502": {
            "description": "QuickBooks failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "post": {
        "tags": [
          "quotes"
        ],
        "summary": "Record a deposit on a quote",
        "description": "Records money received before the quote has an invoice. A company\nconnected to `QuickBooks` gets an unapplied `QuickBooks` payment on the\ncustomer (matched or created there), remembered against the quote; any\nother company keeps it on the quote. When Create invoice (or a split)\nmakes the invoices it is applied to the first invoice, then the next. A\nquote that already has an invoice is refused: record the payment on the\ninvoice.",
        "operationId": "create_quote_deposit",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Quote id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PaymentInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "The quote's waiting deposits with the new one",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/RecordedPayment"
                  }
                }
              }
            }
          },
          "400": {
            "description": "No amount, a bad date, a quote without a customer or with an invoice, or QuickBooks refused it",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such quote in the caller's company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "409": {
            "description": "QuickBooks needs to be reconnected",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "502": {
            "description": "QuickBooks failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/quotes/{id}/deposits/{payment_id}": {
      "put": {
        "tags": [
          "quotes"
        ],
        "summary": "Edit a quote's deposit",
        "description": "Changes a deposit that is on no invoice yet: amount, date, method,\naccount, reference and memo (the `QuickBooks` payment is updated for a\ncompany connected to `QuickBooks`).",
        "operationId": "update_quote_deposit",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Quote id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "payment_id",
            "in": "path",
            "description": "The deposit's id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PaymentInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "The quote's waiting deposits",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/RecordedPayment"
                  }
                }
              }
            }
          },
          "400": {
            "description": "A bad amount or date, or QuickBooks refused it",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such quote or waiting deposit",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "409": {
            "description": "QuickBooks needs to be reconnected",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "502": {
            "description": "QuickBooks failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "delete": {
        "tags": [
          "quotes"
        ],
        "summary": "Delete a quote's deposit",
        "description": "Removes a deposit that is on no invoice yet (and deletes its\n`QuickBooks` payment for a company connected to `QuickBooks`).",
        "operationId": "delete_quote_deposit",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Quote id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "payment_id",
            "in": "path",
            "description": "The deposit's id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The quote's waiting deposits without it",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/RecordedPayment"
                  }
                }
              }
            }
          },
          "400": {
            "description": "QuickBooks refused it",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such quote or waiting deposit",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "409": {
            "description": "QuickBooks needs to be reconnected",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "502": {
            "description": "QuickBooks failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/qbo-invoices/{invoice_id}/payment-method": {
      "get": {
        "tags": [
          "quickbooks"
        ],
        "summary": "A QuickBooks invoice's payment method",
        "description": "What the invoice editor picked for the `QuickBooks` invoice; null when\nnothing was.",
        "operationId": "get_qbo_invoice_payment_method",
        "parameters": [
          {
            "name": "invoice_id",
            "in": "path",
            "description": "QuickBooks invoice id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The invoice's payment method",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InvoicePaymentMethod"
                }
              }
            }
          },
          "400": {
            "description": "Invalid invoice id",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Installers cannot see invoices",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "put": {
        "tags": [
          "quickbooks"
        ],
        "summary": "Set a QuickBooks invoice's payment method",
        "description": "Keeps how the customer will pay the `QuickBooks` invoice (`QuickBooks`\ninvoices have no such field); empty or null clears it.",
        "operationId": "set_qbo_invoice_payment_method",
        "parameters": [
          {
            "name": "invoice_id",
            "in": "path",
            "description": "QuickBooks invoice id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/InvoicePaymentMethod"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "The payment method kept",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InvoicePaymentMethod"
                }
              }
            }
          },
          "400": {
            "description": "Invalid invoice id",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Installers cannot change invoices",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/quotes/money": {
      "get": {
        "tags": [
          "quotes"
        ],
        "summary": "Invoiced, Paid and Due of quotes",
        "description": "For the quotes list: each asked quote's invoices added up. A company\nconnected to `QuickBooks` reads them there in one request per 50\ninvoices, never one per quote; any other company reads Granite Manager's\nown invoices (an invoice marked paid by hand owes nothing). A quote with\nno invoice is left out.",
        "operationId": "list_quotes_money",
        "parameters": [
          {
            "name": "ids",
            "in": "query",
            "description": "Quote ids (`ids=1&ids=2`), at most 200.",
            "required": false,
            "schema": {
              "type": "array",
              "items": {
                "type": "integer",
                "format": "int32"
              }
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The quotes' invoices added up",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/QuotesMoney"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/customers/{id}/job-money": {
      "get": {
        "tags": [
          "customers"
        ],
        "summary": "Paid and Balance of a customer's jobs",
        "description": "What each of the customer's jobs was invoiced, what was paid toward it\nand what it still owes, counted once across recorded payments, payments\nentered in `QuickBooks`, deposits and payment links: the amounts the\nproject page shows too (`GET /v1/projects/payments`). Paid payment links\nthat are on no invoice yet are recorded on the job's invoices first.",
        "operationId": "list_customer_job_money",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Customer id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The jobs' money",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/JobMoneyList"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such customer in the caller's company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/quotes/{id}/invoice-problems": {
      "get": {
        "tags": [
          "quotes"
        ],
        "summary": "List a quote's invoice problems",
        "description": "What `QuickBooks` refused for this quote with nobody watching: the\nautomatic sync of its invoice, a deposit not put on its invoice, a\npayment link not recorded. Each says what happened and how to fix it,\nand stays until it is fixed. Empty when all is well.",
        "operationId": "list_quote_invoice_problems",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Quote id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The problems, newest first",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/InvoiceProblem"
                  }
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such quote in the caller's company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/quotes/{id}/invoice-problems/sync": {
      "put": {
        "tags": [
          "quotes"
        ],
        "summary": "Keep a failed invoice sync on the quote",
        "description": "The quote page rebuilds the quote's invoice by itself when the quote\nchanges. When that fails, the page saves why here, so the next person to\nopen the quote sees it. Saving again replaces the last one.",
        "operationId": "report_quote_invoice_sync_problem",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Quote id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SyncProblemInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Kept"
          },
          "400": {
            "description": "No message",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such quote in the caller's company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "delete": {
        "tags": [
          "quotes"
        ],
        "summary": "The invoice sync works again",
        "description": "Removes the quote's kept sync failure after a sync went through.",
        "operationId": "clear_quote_invoice_sync_problem",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Quote id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Removed (or there was none)"
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such quote in the caller's company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/quotes/{id}/invoice-problems/{problem_id}/retry": {
      "post": {
        "tags": [
          "quotes"
        ],
        "summary": "Try a failed deposit or payment link again",
        "description": "Runs what failed once more: a deposit is put on the quote's invoices, a\npayment link is recorded in `QuickBooks`. Returns the quote's problems\nafterwards: the one tried is gone when it worked, and says why when it\nfailed again. A `sync` problem is tried by the quote page itself and is\nrefused here.",
        "operationId": "retry_quote_invoice_problem",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Quote id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "problem_id",
            "in": "path",
            "description": "Problem id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64",
              "minimum": 0
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The quote's problems now",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/InvoiceProblem"
                  }
                }
              }
            }
          },
          "400": {
            "description": "A sync problem: the quote page syncs it",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such quote or problem",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "409": {
            "description": "QuickBooks needs to be reconnected",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "502": {
            "description": "QuickBooks failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/qbo/invoices/{invoice_id}/crew-payment": {
      "get": {
        "tags": [
          "quickbooks"
        ],
        "summary": "What the installer can record on a job's invoice",
        "description": "The invoice's open balance and the company's `QuickBooks` payment\nmethods, for the crew's Paid step. Installers only for an invoice linked\nto one of their jobs.",
        "operationId": "get_crew_payment_form",
        "parameters": [
          {
            "name": "invoice_id",
            "in": "path",
            "description": "QuickBooks invoice id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Balance and payment methods",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CrewPaymentForm"
                }
              }
            }
          },
          "400": {
            "description": "Invalid invoice id",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Not linked to one of the installer's jobs",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "409": {
            "description": "QuickBooks is not connected",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "502": {
            "description": "QuickBooks failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "post": {
        "tags": [
          "quickbooks"
        ],
        "summary": "Record what the installer collected",
        "description": "Makes a `QuickBooks` Payment on the job's invoice with the amount (left\nout: the whole open balance), the\npicked payment method and an optional check number, deposited to the\ncompany's default account, and notes it on the deal. An amount above the\nopen balance is refused. The same `request_id` sent again makes no second\npayment.",
        "operationId": "record_crew_payment",
        "parameters": [
          {
            "name": "invoice_id",
            "in": "path",
            "description": "QuickBooks invoice id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CrewPaymentInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Recorded; the balance now",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CrewPaymentSaved"
                }
              }
            }
          },
          "400": {
            "description": "No amount or method, an amount above the balance, or QuickBooks refused it",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Not linked to one of the installer's jobs",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "409": {
            "description": "QuickBooks is not connected, or the invoice was deleted there",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "502": {
            "description": "QuickBooks failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/quotes/{id}/drawing": {
      "put": {
        "tags": [
          "quotes"
        ],
        "summary": "Save the drawing",
        "description": "A new immutable revision (with each option's total) that becomes the\nquote's drawing; the caller's unsaved drawing is dropped. A sold-out color\nsaves too (the customer cannot accept that option until it is changed).",
        "operationId": "save_quote_drawing",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Quote id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SavedDrawing"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Saved",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SavedRevision"
                }
              }
            }
          },
          "400": {
            "description": "Not a drawing: `error` is \"The drawing could not be read.\" and then the first thing wrong and where (area, counter, row)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such quote",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/quotes/{id}/autosave": {
      "put": {
        "tags": [
          "quotes"
        ],
        "summary": "Keep an unsaved drawing",
        "description": "The caller's work in progress, offered back when they open the editor.",
        "operationId": "autosave_quote_drawing",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Quote id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UnsavedDrawing"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Kept"
          },
          "400": {
            "description": "Not a drawing: `error` is \"The drawing could not be read.\" and then the first thing wrong and where (area, counter, row)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such quote",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "delete": {
        "tags": [
          "quotes"
        ],
        "summary": "Drop the unsaved drawing",
        "description": "The caller's work in progress on this quote.",
        "operationId": "discard_quote_autosave",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Quote id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Dropped"
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such quote",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/quotes/{id}/editing": {
      "post": {
        "tags": [
          "quotes"
        ],
        "summary": "I am working on this quote",
        "description": "The editor checks in about every 15 seconds while it is open; a check-in\ncounts for 45 seconds. Answers who else has the quote open in the editor\nright now, so two people do not change the same quote at once.",
        "operationId": "check_in_quote_editor",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Quote id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Noted; the others working on it now",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/QuoteEditors"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such quote",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "delete": {
        "tags": [
          "quotes"
        ],
        "summary": "I left the quote",
        "description": "The editor closed: the others stop seeing the caller on it at once.",
        "operationId": "leave_quote_editor",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Quote id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Left"
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such quote",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/quotes/{id}/revisions/{revision_id}": {
      "get": {
        "tags": [
          "quotes"
        ],
        "summary": "Get a revision's drawing",
        "description": "To load into the editor.",
        "operationId": "get_quote_revision",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Quote id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "revision_id",
            "in": "path",
            "description": "Revision id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The drawing",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RevisionDrawing"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such quote or revision",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/quotes/{id}/prices": {
      "post": {
        "tags": [
          "quotes"
        ],
        "summary": "Move a quote to today's prices",
        "description": "The price list's newest revision and today's prices; sinks placed from\na sink model take its current type and shape.",
        "operationId": "update_quote_prices",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Quote id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Updated"
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such quote",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/quotes/{id}/sale": {
      "post": {
        "tags": [
          "quotes"
        ],
        "summary": "Mark a quote sold",
        "description": "The quote keeps the option sold and its deal is won with that option's\ntotal (a won deal is made when the customer has none). With the company's\nJobs to Unscheduled switch on, it adds the template and installation jobs\nto the schedule's Unscheduled list; each of `extra_events` adds one more\nevent there. Selling a quote again adds no events.",
        "operationId": "mark_quote_sold",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Quote id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Sale"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Sold",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SaleResult"
                }
              }
            }
          },
          "400": {
            "description": "Not an option of the quote",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such quote",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "delete": {
        "tags": [
          "quotes"
        ],
        "summary": "Undo a sale",
        "description": "The quote is active again (no option, no signature), its deal reopens,\nthe template and installation jobs and extra events the sale added are\ndeleted, its sales orders are cancelled (a confirmed one's slabs go back\nto stock), its Order is deleted, its invoices are voided (ours and in\n`QuickBooks`), and the project and deal the sale made new are deleted.\nRefused (409) once the Order has a change order.",
        "operationId": "undo_quote_sale",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Quote id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Undone"
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such quote",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "409": {
            "description": "The quote's Order has change orders",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/quotes/{id}/copies": {
      "post": {
        "tags": [
          "quotes"
        ],
        "summary": "Duplicate a quote",
        "description": "A new draft for the same customer and deal with the quote's notes, tax,\ndiscounts and terms, optionally its address and drawing.",
        "operationId": "copy_quote",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Quote id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/QuoteCopy"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CreatedId"
                }
              }
            }
          },
          "400": {
            "description": "No name",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such quote",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/quotes/{id}/emails": {
      "post": {
        "tags": [
          "quotes"
        ],
        "summary": "Email the quote",
        "description": "Sends the customer a link to the quote (from the caller's sending\naddress, replies to the caller), records it with the revision and\nexpiration, and moves the deal to \"Got a Quote\".",
        "operationId": "email_quote",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Quote id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/QuoteEmail"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Sent"
          },
          "400": {
            "description": "No recipient or subject, or a `{{quote.*}}`/`{{deal.*}}` variable the quote or its deal has no value for yet (the message names it)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such quote",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "502": {
            "description": "The email could not be sent",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/quotes/{id}/emails/{email_id}": {
      "patch": {
        "tags": [
          "quotes"
        ],
        "summary": "Switch an email's link off or on",
        "description": "The customer link from that email stops (or starts again) opening the quote.",
        "operationId": "set_quote_email_link",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Quote id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "email_id",
            "in": "path",
            "description": "Quote email id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/EmailLink"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Saved"
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such quote",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/quotes/{id}/portal-token": {
      "post": {
        "tags": [
          "quotes"
        ],
        "summary": "Get the customer link",
        "description": "Made the first time it is asked for.",
        "operationId": "quote_portal_token",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Quote id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PortalToken"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such quote",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/quotes/{id}/view-link": {
      "get": {
        "tags": [
          "quotes"
        ],
        "summary": "Get a link to look at the quote",
        "description": "The page the customer gets, without Accept & Sign. A `GET` so the app's\ndevice token may ask; the customer link is made the first time, as the\n`POST` does.",
        "operationId": "quote_view_link",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Quote id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The link",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/QuoteViewLink"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such quote",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/quotes/{id}/prints": {
      "post": {
        "tags": [
          "quotes"
        ],
        "summary": "Record a print",
        "description": "Shown in the deal's history as \"Quote printed\"; the deal moves to \"Got a\nQuote\". Never blocks the print.",
        "operationId": "record_quote_print",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Quote id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/QuotePrint"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Recorded"
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such quote",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/me/quote-email-templates": {
      "get": {
        "tags": [
          "quotes"
        ],
        "summary": "List the Email dialog's templates",
        "description": "The company's quote email templates and the caller's own, in the\ncaller's order, with the one to start with.",
        "operationId": "list_my_quote_email_templates",
        "responses": {
          "200": {
            "description": "The templates",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MyEmailTemplates"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "post": {
        "tags": [
          "quotes"
        ],
        "summary": "Save a template of my own",
        "description": "Only the caller sees it.",
        "operationId": "create_my_quote_email_template",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/MyTemplateInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Saved",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CreatedId"
                }
              }
            }
          },
          "400": {
            "description": "No name or subject",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/me/quote-email-templates/{id}": {
      "put": {
        "tags": [
          "quotes"
        ],
        "summary": "Edit a template of my own",
        "description": "Never a company template.",
        "operationId": "update_my_quote_email_template",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Template id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/MyTemplateInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Saved"
          },
          "400": {
            "description": "No name or subject",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "Not one of the caller's templates",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "delete": {
        "tags": [
          "quotes"
        ],
        "summary": "Delete a template of my own",
        "description": "Never a company template.",
        "operationId": "delete_my_quote_email_template",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Template id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Deleted"
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/quotes/{id}/order": {
      "get": {
        "tags": [
          "quotes"
        ],
        "summary": "Get a quote's Order",
        "description": "The Order made when the quote was sold, with its change orders (newest\nfirst); null when the quote has none.",
        "operationId": "get_quote_order",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Quote id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The Order, or null",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/Order"
                    },
                    {
                      "type": "null"
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such quote in the caller's company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "post": {
        "tags": [
          "quotes"
        ],
        "summary": "Make a sold quote's Order",
        "description": "For a quote sold before Orders: its first Change order makes the Order\nfrom the quote as it is now. A quote that has one gets it back.",
        "operationId": "make_quote_order",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Quote id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The Order",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Order"
                }
              }
            }
          },
          "400": {
            "description": "The quote is not sold with an option, or has no drawing",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin, or lacks the Edit quotes skill",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such quote in the caller's company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/quotes/{id}/order-changes": {
      "post": {
        "tags": [
          "quotes"
        ],
        "summary": "Save a change order",
        "description": "The Order's drawing becomes `doc` (a new revision of the quote), and the\nchange order keeps what changed, the Order's total before and after, the\nnote and what was picked for the invoice. A change of stone or slabs\nsends the sales order back to the Inventory Manager.",
        "operationId": "save_quote_order_change",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Quote id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/NewOrderChange"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Saved",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SavedOrderChange"
                }
              }
            }
          },
          "400": {
            "description": "Not a drawing (\"The drawing could not be read.\" and then the first thing wrong and where), nothing changed, or the quote has no order",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin, or lacks the Edit quotes skill",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such quote in the caller's company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/quotes/{id}/order-changes/{number}": {
      "patch": {
        "tags": [
          "quotes"
        ],
        "summary": "Save a change order's invoice",
        "description": "After the CRM updated the quote's invoice or made the new one for the\ndifference: what was done, and the new invoice's number.",
        "operationId": "update_quote_order_change",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Quote id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "number",
            "in": "path",
            "description": "Change order number",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/OrderChangeInvoice"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Saved"
          },
          "400": {
            "description": "Invalid invoice action or number",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin, or lacks the Edit quotes skill",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such change order in the caller's company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/quotes/suggestions": {
      "get": {
        "tags": [
          "quotes"
        ],
        "summary": "List remembered area names and items",
        "description": "Area names and miscellaneous / text items (description, last price,\nquantity and Hide On Quote / Allow Discount / Taxable flags) typed on the\ncompany's 500 most recently changed, not deleted quotes, to offer them\nagain while a quote is drawn. A name or item is offered only when quotes\nof at least 2 different customers use it (a quote with no customer counts\nby its deal, else on its own), so names typed for one job are not. Each\ncomes once (compared ignoring case and spaces), with the values of the\nlatest quote; used by most customers first, then most recent. Default area\nnames (`Area #1`, `Area #2`, ...) are left out. At most 60 names and 150\nitems. Suggestions taken out with `POST /v1/quotes/suggestions/hide` are\nleft out and listed in `hidden`, until quotes of 2 different customers\nchanged after that use them again.",
        "operationId": "list_quote_suggestions",
        "responses": {
          "200": {
            "description": "Remembered names and items",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/QuoteSuggestions"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/quotes/suggestions/hide": {
      "post": {
        "tags": [
          "quotes"
        ],
        "summary": "Take a suggestion out of the list",
        "description": "The x next to an area name or a custom item's description in the quote\neditor: `GET /v1/quotes/suggestions` stops offering it to everyone in the\ncompany (it is listed in `hidden` instead). Quotes that use it are not\nchanged. It is offered again once quotes of 2 different customers, changed\nafter this, use it. Hiding the same text again moves that time to now.\nBefore the `quote_suggestion_hidden` table exists nothing is stored and it\nstill answers 204.",
        "operationId": "hide_quote_suggestion",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/HideSuggestionInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Hidden"
          },
          "400": {
            "description": "Unknown kind, or no text",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/quotes/stone-image": {
      "get": {
        "tags": [
          "quotes"
        ],
        "summary": "Get a color's stone photo",
        "description": "The catalog photo of one color as the quote shows it on the customer's\npreview: the company's in-stock stone with this name (regular stock, or a\nslab not sold, cut or deleted; a stone of the given product type first,\none with free slabs first). Returns `{\"image\": null}` when no stone of\nthat name is in stock or `color` is empty. The editor uses\nit to paint the area's pieces in the Color & Edge preview.",
        "operationId": "get_quote_stone_image",
        "parameters": [
          {
            "name": "color",
            "in": "query",
            "description": "Color name as picked on the quote (any case), e.g. `Calacatta Laza`.",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "product",
            "in": "query",
            "description": "Product (material) it was picked under (any case); a stone of this\ntype is preferred, any type is used otherwise. May be empty.",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The photo, or null",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StoneImageLookup"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/public/quote-portal/{token}": {
      "get": {
        "tags": [
          "quotes"
        ],
        "summary": "Open a customer's quote link",
        "description": "The quote with its prices, drawing (no supplier costs), color photos\nand, when it was emailed with a company form, that form. An emailed\nlink (`e`) counts as a view, and each view is kept with its time, IP\naddress and browser (listed on the quote's emails). A switched-off link\nanswers `inactive`.",
        "operationId": "get_quote_portal",
        "parameters": [
          {
            "name": "token",
            "in": "path",
            "description": "The quote's link token",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "e",
            "in": "query",
            "description": "The quote email's token.",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The quote",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PortalQuote"
                }
              }
            }
          },
          "404": {
            "description": "No such quote",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        }
      }
    },
    "/v1/public/quote-portal/{token}/acceptance": {
      "post": {
        "tags": [
          "quotes"
        ],
        "summary": "Accept and sign a quote",
        "description": "Records the option and the signature and sets the quote's status to\n`accepted`; it does not mark the quote sold or win its deal (staff do\nthat). The quote's sales rep (else its creator) is then emailed the\ncustomer, the option, each area's material, color and edges, and the\ntotal, and notified in the app when the quote has a deal; the customer is\nemailed their own copy with a link back to the quote. Refused once signed,\nfor an option with a sold-out color, when the link is switched off, or\nwhen the company has \"Sign on the quote link\" off.",
        "operationId": "accept_quote_portal",
        "parameters": [
          {
            "name": "token",
            "in": "path",
            "description": "The quote's link token",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Acceptance"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Signed"
          },
          "400": {
            "description": "No such option, no signature, or a sold-out color",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such quote",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "409": {
            "description": "Already signed, the link is off, or signing on the link is off",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        }
      }
    },
    "/v1/public/companies/{company_id}/online-quote": {
      "get": {
        "tags": [
          "public"
        ],
        "summary": "Start an online quote",
        "description": "What the company's online quote builder offers: the colors (stones in\nstock with a photo that its default price list prices, never their\nprices), the sinks on display with a photo, the cooktop cutout and the\ncounter depth to start with. `available` is false when the company has no\nprice list with prices or no color to offer. Next, price the drawing with\n`POST .../online-quote/prices`. No session needed.",
        "operationId": "get_online_quote_setup",
        "parameters": [
          {
            "name": "company_id",
            "in": "path",
            "description": "Company id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "What the builder offers",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OnlineQuoteSetup"
                }
              }
            }
          },
          "404": {
            "description": "No such company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        }
      }
    },
    "/v1/public/companies/{company_id}/online-quote/prices": {
      "post": {
        "tags": [
          "public"
        ],
        "summary": "Price an online quote",
        "description": "The total with tax of each color for the drawing, priced like the quote\npage prices a quote made now with the company's default price list. A\ncolor's total is null when the list cannot price all of it. Nothing is\nsaved; save and email it with `POST .../online-quotes`. No session needed.",
        "operationId": "price_online_quote",
        "parameters": [
          {
            "name": "company_id",
            "in": "path",
            "description": "Company id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/OnlineDrawing"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Each color's total",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OnlinePrices"
                }
              }
            }
          },
          "400": {
            "description": "A piece the builder does not draw (more than 3 sides, corners that are not square, sizes out of range, unknown fields), more than 6 cutouts, a sink or color it does not offer, or not 1 to 10 colors",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "409": {
            "description": "The company has no prices for online quotes",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        }
      }
    },
    "/v1/public/companies/{company_id}/online-quotes": {
      "post": {
        "tags": [
          "public"
        ],
        "summary": "Send an online quote",
        "description": "Saves the drawing as a quote of the customer (active, revision 1, priced\nlike `POST .../online-quote/prices`, the price list's tax, payment terms\nand expiration), emails the customer a link to it and tells the team. A\ncustomer the company does not know by this email or phone (last 10\ndigits) becomes a lead (source `leads`, from the `website`) and the quote\nhas no sales rep; the sales managers get it in Telegram (lead alerts) with\na button per sales rep to assign it. A known customer's quote gets their\nsales rep, who is told in Telegram or by email; a known customer without\none goes to the managers. When the email cannot be sent the quote is still\nsaved (`emailed` false) and the team is told. At most 3 quotes an address\na day. No session needed.",
        "operationId": "create_online_quote",
        "parameters": [
          {
            "name": "company_id",
            "in": "path",
            "description": "Company id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/OnlineQuoteInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Saved (and emailed unless `emailed` is false)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OnlineQuoteSent"
                }
              }
            }
          },
          "400": {
            "description": "No name, an email that is not one, a phone without 10 digits, or a drawing or color `POST .../online-quote/prices` refuses",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "409": {
            "description": "The company has no prices for online quotes",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "429": {
            "description": "This address already got 3 online quotes today, or the company 30 this hour",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        }
      }
    },
    "/v1/customers/{id}/online-quote-notice": {
      "get": {
        "tags": [
          "online-quotes"
        ],
        "summary": "Get what the team was told about a customer's online quote",
        "description": "The lines of the lead message (Telegram's) for the customer's newest\nquote made with the online quote: the customer's name, phone and email,\neach color's price as priced now, and the customer's notes. The phone\napp shows them in its \"online quote\" notification, as Telegram does.",
        "operationId": "get_customer_online_quote_notice",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Customer id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The lines",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OnlineQuoteNotice"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such customer in the caller's company, or no online quote of theirs",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/commission-rules": {
      "get": {
        "tags": [
          "commissions"
        ],
        "summary": "List commission rules",
        "description": "The company's rules, highest priority first.",
        "operationId": "list_commission_rules",
        "responses": {
          "200": {
            "description": "The rules",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/CommissionRule"
                  }
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "post": {
        "tags": [
          "commissions"
        ],
        "summary": "Add a commission rule",
        "description": "It applies from the next sync.",
        "operationId": "create_commission_rule",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RuleInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Added",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CreatedId"
                }
              }
            }
          },
          "400": {
            "description": "Check the rule",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/commission-rules/{id}": {
      "put": {
        "tags": [
          "commissions"
        ],
        "summary": "Save a commission rule",
        "description": "Replaces the whole rule; it applies from the next sync.",
        "operationId": "update_commission_rule",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Rule id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RuleInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Saved"
          },
          "400": {
            "description": "Check the rule",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such rule",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "delete": {
        "tags": [
          "commissions"
        ],
        "summary": "Delete a commission rule",
        "description": "Commissions already worked out keep what they earned.",
        "operationId": "delete_commission_rule",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Rule id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Deleted"
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/commission-settings": {
      "get": {
        "tags": [
          "commissions"
        ],
        "summary": "Get the commission settings",
        "description": "Friday payroll until saved.",
        "operationId": "get_commission_settings",
        "responses": {
          "200": {
            "description": "The settings",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CommissionSettings"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "put": {
        "tags": [
          "commissions"
        ],
        "summary": "Save the commission settings",
        "description": "The weekday is kept within 0 to 6.",
        "operationId": "save_commission_settings",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CommissionSettings"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Saved"
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/commission-base-pay": {
      "get": {
        "tags": [
          "commissions"
        ],
        "summary": "List base pay",
        "description": "The base pay schedules: one person's, or everyone's with a position.",
        "operationId": "list_commission_base_pay",
        "responses": {
          "200": {
            "description": "The base pay",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/BasePay"
                  }
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "post": {
        "tags": [
          "commissions"
        ],
        "summary": "Add base pay",
        "description": "A base pay for one person or for everyone with a position: an amount\nevery week, two weeks or month from the first payday (monthly: on that\nday of the month), until an optional last day. It shows in the paychecks\non those days; a person's own base pay replaces their position's.",
        "operationId": "create_commission_base_pay",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/BasePayInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Added",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CreatedId"
                }
              }
            }
          },
          "400": {
            "description": "Check the base pay",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/commission-base-pay/{id}": {
      "put": {
        "tags": [
          "commissions"
        ],
        "summary": "Save base pay",
        "description": "Replaces the whole base pay; past paychecks follow it too.",
        "operationId": "update_commission_base_pay",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Base pay id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/BasePayInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Saved"
          },
          "400": {
            "description": "Check the base pay",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such base pay",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "delete": {
        "tags": [
          "commissions"
        ],
        "summary": "Delete base pay",
        "description": "Its paydays leave the paychecks, past ones too; to stop it from a day\non, set its last day instead.",
        "operationId": "delete_commission_base_pay",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Base pay id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Deleted"
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/commissions": {
      "get": {
        "tags": [
          "commissions"
        ],
        "summary": "List commissions",
        "description": "The caller's (`mine`) or, for admins, everyone's (`company`) signed\nquotes with what they earn, and the paychecks: paid commissions, monthly\ngoal bonuses (by every quote sold that month, stone and cabinets) and base pay (their\nown, or their positions') per payroll date.",
        "operationId": "list_commissions",
        "parameters": [
          {
            "name": "scope",
            "in": "query",
            "description": "`mine` (default) or `company` (admins).",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The commissions",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Commissions"
                }
              }
            }
          },
          "400": {
            "description": "Unknown scope",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee, or not an admin for `company`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/commissions/sync": {
      "post": {
        "tags": [
          "commissions"
        ],
        "summary": "Sync commissions with QuickBooks",
        "description": "Works out what every sales rep's sold quote earns, whether its customer\npaid (the matching `QuickBooks` invoice) and when it was installed. A quote\nnobody marked sold counts too once an invoice was made from it, or one for\nits price was made by hand in `QuickBooks`.\n`QuickBooks` is asked for all the customers' invoices together, a few\nrequests in all. Commissions already added to the salary are left alone;\nones of quotes no longer sold, or of someone who is not a Sales\nRepresentative, go (unless an admin set their amounts).",
        "operationId": "sync_commissions",
        "responses": {
          "200": {
            "description": "Synced",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SyncResult"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/commissions/{id}/payroll": {
      "post": {
        "tags": [
          "commissions"
        ],
        "summary": "Add a commission to the salary",
        "description": "A sold quote's commission once its customer paid and the job was\ninstalled (a row with no quote at any time). It is paid on the first\npayday on or after the day it was paid and installed, or the next payday\nwhen that one has gone by.",
        "operationId": "add_commission_to_payroll",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Commission row id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Added",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AddedToPayroll"
                }
              }
            }
          },
          "400": {
            "description": "Not paid and installed yet, or already in the salary",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such commission",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/commissions/{id}": {
      "put": {
        "tags": [
          "commissions"
        ],
        "summary": "Change a commission",
        "description": "Sets the contract and commission by hand (they win over the calculated\nones and the sync keeps them) and the payroll date. No payroll date takes\nit out of the salary.",
        "operationId": "update_commission",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Commission row id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CommissionEdit"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Saved"
          },
          "400": {
            "description": "A negative amount or a bad date",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such commission",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "delete": {
        "tags": [
          "commissions"
        ],
        "summary": "Delete a commission",
        "description": "Only rows with no quote (a rep's sheet, a bonus); a sold quote's\ncommission goes when the quote is no longer sold.",
        "operationId": "delete_commission",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Commission row id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Deleted"
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such row with no quote",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/commissions/extras": {
      "post": {
        "tags": [
          "commissions"
        ],
        "summary": "Add an extra",
        "description": "Pays a rep a review, gas, an unused vacation day or another extra, or\ntakes a deduction off, on a payday: it shows in the paycheck's Extras\ncolumn and never counts as a sale.",
        "operationId": "add_commission_extra",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/NewExtra"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Added",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AddedExtra"
                }
              }
            }
          },
          "400": {
            "description": "Bad kind, amount, rep or payday",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/commissions/payouts": {
      "post": {
        "tags": [
          "commissions"
        ],
        "summary": "Mark commissions paid to the rep",
        "description": "Marks them paid out today; one not in the salary yet goes into today's\npaycheck. With `paid: false` they are not paid out any more (and keep\ntheir payroll date).",
        "operationId": "pay_out_commissions",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Payout"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Marked"
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/feature-sales": {
      "get": {
        "tags": [
          "quotes"
        ],
        "summary": "List feature sales",
        "description": "The caller's (`mine`) or everyone's (`company`) sold quotes\nin the dates, each with the dollars of every extra on its accepted option,\nworked out from the quote as it is now.",
        "operationId": "list_feature_sales",
        "parameters": [
          {
            "name": "scope",
            "in": "query",
            "description": "`mine` (default) or `company` (every rep).",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "from",
            "in": "query",
            "description": "First sold day (YYYY-MM-DD); none: no limit.",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "to",
            "in": "query",
            "description": "Last sold day (YYYY-MM-DD); none: no limit.",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Sold quotes' extras",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FeatureSales"
                }
              }
            }
          },
          "400": {
            "description": "Unknown scope or bad date",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/job-pay-rules": {
      "get": {
        "tags": [
          "commissions"
        ],
        "summary": "List the template and install pay rules",
        "description": "Templates first, then installs; the per sq ft rules before the extras.",
        "operationId": "list_job_pay_rules",
        "responses": {
          "200": {
            "description": "The rules",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/JobPayRule"
                  }
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "post": {
        "tags": [
          "commissions"
        ],
        "summary": "Add a template or install pay rule",
        "description": "It applies from the next sync. The company's first rule starts the\ncount: jobs finished from that day on are paid (`jobPayFrom` in the\ncommission settings).",
        "operationId": "create_job_pay_rule",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/JobPayRuleInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Added",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CreatedId"
                }
              }
            }
          },
          "400": {
            "description": "Check the rule",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/job-pay-rules/{id}": {
      "put": {
        "tags": [
          "commissions"
        ],
        "summary": "Save a template or install pay rule",
        "description": "Replaces the whole rule; it applies from the next sync.",
        "operationId": "update_job_pay_rule",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Rule id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/JobPayRuleInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Saved"
          },
          "400": {
            "description": "Check the rule",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such rule",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "delete": {
        "tags": [
          "commissions"
        ],
        "summary": "Delete a template or install pay rule",
        "description": "Jobs already worked out keep what they pay.",
        "operationId": "delete_job_pay_rule",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Rule id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Deleted"
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/job-pay": {
      "get": {
        "tags": [
          "commissions"
        ],
        "summary": "List template and install pay",
        "description": "Every finished template and install since the company's first pay rule,\nper person who did it, newest first, with what it pays.",
        "operationId": "list_job_pay",
        "responses": {
          "200": {
            "description": "The jobs",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/JobPayRow"
                  }
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/job-pay/{id}": {
      "put": {
        "tags": [
          "commissions"
        ],
        "summary": "Set a job's sq ft, amount, extras and payroll date",
        "description": "Null `sqFt` and `amount` go back to the quote's sq ft and to sq ft × rate.\n`extras` replaces the job's extras (a repair, a tear-out). Taking the\npayroll date away also takes \"paid out\" away.",
        "operationId": "update_job_pay",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Job pay row id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/JobPayEdit"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Saved"
          },
          "400": {
            "description": "A negative number, an extra with no name or a bad date",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such job",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/job-pay/{id}/payroll": {
      "post": {
        "tags": [
          "commissions"
        ],
        "summary": "Add a job to the salary",
        "description": "A finished template or install goes into the payroll the company's\ncommission settings say: the payroll day of the week after the one it\nwas finished in, or (`jobPaySameWeek`) the first payroll day on or after\nthe day it was finished. When that payroll has gone by, the next one.",
        "operationId": "add_job_pay_to_payroll",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Job pay row id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Added",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/JobPayAdded"
                }
              }
            }
          },
          "400": {
            "description": "Already in the salary",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such job",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/job-pay/payouts": {
      "post": {
        "tags": [
          "commissions"
        ],
        "summary": "Mark jobs paid to the person",
        "description": "Marks them paid out today; one not in the salary yet goes into today's\npaycheck. With `paid: false` they are not paid out any more (and keep\ntheir payroll date).",
        "operationId": "pay_out_job_pay",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Payout"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Marked"
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/public/companies/{company_id}/frame": {
      "get": {
        "tags": [
          "public"
        ],
        "summary": "Get a company's page frame",
        "description": "Its name and logo, and its catalog's filters: stone and sink types, the\nsuppliers of its stones, sinks and faucets, and its stone colors and\nlevels. Unknown companies get an empty frame (shared colors, levels 1\nto 7).",
        "operationId": "get_company_frame",
        "parameters": [
          {
            "name": "company_id",
            "in": "path",
            "description": "Company id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The frame",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CompanyFrame"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        }
      }
    },
    "/v1/public/companies/{company_id}/lens-hint": {
      "post": {
        "tags": [
          "public"
        ],
        "summary": "Claim the magnifier highlight",
        "description": "The customer stones page highlights its magnifier (lens) button once per\nvisitor IP address: the first call from an address answers `show: true`,\nevery later one `false`.",
        "operationId": "claim_lens_hint",
        "parameters": [
          {
            "name": "company_id",
            "in": "path",
            "description": "Company id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Whether to highlight",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LensHint"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        }
      }
    },
    "/v1/company/setup-checklist": {
      "get": {
        "tags": [
          "company"
        ],
        "summary": "Get what the company still has to set up",
        "description": "The dashboard's \"Finish setting up\" checklist: the team, the logo and\nsales tax, the web address, the phone line, the texting registration\n(once there is a phone line), the email domain (or the user's Gmail\nmeanwhile), the website contact form, the stones on the website and\nQuickBooks (when switched on). Each item is done when the company's data\nshows it or a manager ticked it. Items with `how: contact` are done by\nGranite Manager: the page says to contact them at `contact_email`.\nManagers and superusers only.",
        "operationId": "get_company_setup_checklist",
        "responses": {
          "200": {
            "description": "The checklist",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SetupChecklist"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not a manager of the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/company/setup-checklist/{key}": {
      "put": {
        "tags": [
          "company"
        ],
        "summary": "Tick a setup item by hand",
        "description": "Marks the item done (or not needed) for the whole company, or takes the\ntick off; an item the company's data shows done stays done. Answers the\nchecklist. 404 for an unknown key. Managers and superusers only.",
        "operationId": "tick_company_setup_item",
        "parameters": [
          {
            "name": "key",
            "in": "path",
            "description": "Item key, e.g. `lead_form`",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SetupTick"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Saved; the checklist",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SetupChecklist"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not a manager of the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "Unknown item",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/quote-forms": {
      "get": {
        "tags": [
          "quotes"
        ],
        "summary": "List quote forms",
        "description": "The company's forms by sequence; `active=true` for the ones quotes offer.",
        "operationId": "list_quote_forms",
        "parameters": [
          {
            "name": "active",
            "in": "query",
            "description": "Only active forms (what quotes offer).",
            "required": false,
            "schema": {
              "type": "boolean"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The forms",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/QuoteFormSummary"
                  }
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "post": {
        "tags": [
          "quotes"
        ],
        "summary": "Add a quote form",
        "description": "Last in order.",
        "operationId": "create_quote_form",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/NewQuoteForm"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CreatedId"
                }
              }
            }
          },
          "400": {
            "description": "No name, or the layout cannot be read",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/quote-forms/order": {
      "put": {
        "tags": [
          "quotes"
        ],
        "summary": "Reorder quote forms",
        "description": "Sequence 1, 2, 3… in this order: the order the print and send dialogs\nlist them in.",
        "operationId": "reorder_quote_forms",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/FormOrder"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Saved"
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/quote-forms/letterhead": {
      "get": {
        "tags": [
          "quotes"
        ],
        "summary": "Get the form letterhead",
        "description": "The company name, address, website and logo a printed form shows.",
        "operationId": "get_quote_form_letterhead",
        "responses": {
          "200": {
            "description": "The letterhead",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Letterhead"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/quote-forms/images": {
      "post": {
        "tags": [
          "quotes"
        ],
        "summary": "Finish a form image",
        "description": "Checks an image uploaded to `quote-forms/` and, for a header logo, cuts\noff its blank border.",
        "operationId": "finish_quote_form_image",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/FormImage"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "The image",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FinishedImage"
                }
              }
            }
          },
          "400": {
            "description": "Not an uploaded form image",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Storage error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/quote-forms/{id}": {
      "get": {
        "tags": [
          "quotes"
        ],
        "summary": "Get a quote form",
        "description": "With its layout (for printing and the editor).",
        "operationId": "get_quote_form",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Form id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The form",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/QuoteForm"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such form",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "put": {
        "tags": [
          "quotes"
        ],
        "summary": "Save a quote form",
        "description": "Name, status, sequence and layout, as the editor stores every change.",
        "operationId": "save_quote_form",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Form id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SavedQuoteForm"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Saved"
          },
          "400": {
            "description": "No name, or the layout cannot be read",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such form",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "delete": {
        "tags": [
          "quotes"
        ],
        "summary": "Delete a quote form",
        "description": "It is no longer offered; quotes printed with it are unchanged.",
        "operationId": "delete_quote_form",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Form id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Deleted"
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "patch": {
        "tags": [
          "quotes"
        ],
        "summary": "Activate or deactivate a quote form",
        "description": "Inactive forms are not offered on quotes.",
        "operationId": "set_quote_form_status",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Form id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/FormStatus"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Saved"
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/quote-forms/{id}/copies": {
      "post": {
        "tags": [
          "quotes"
        ],
        "summary": "Duplicate a quote form",
        "description": "A copy named \"… (copy)\", last in order.",
        "operationId": "copy_quote_form",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Form id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CreatedId"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such form",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/quote-price-lists": {
      "get": {
        "tags": [
          "quotes"
        ],
        "summary": "List price lists",
        "description": "Every list of the company, with the one new quotes get.",
        "operationId": "list_quote_price_lists",
        "responses": {
          "200": {
            "description": "The lists",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PriceLists"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "post": {
        "tags": [
          "quotes"
        ],
        "summary": "Create a price list",
        "description": "An empty list (list-wide settings only), last in order.",
        "operationId": "create_quote_price_list",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/NewPriceList"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CreatedId"
                }
              }
            }
          },
          "400": {
            "description": "No name",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "409": {
            "description": "The name is taken",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/quote-price-lists/default": {
      "put": {
        "tags": [
          "quotes"
        ],
        "summary": "Choose the default price list",
        "description": "New quotes get this list; it is activated. The lists keep their order.",
        "operationId": "set_default_quote_price_list",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DefaultPriceList"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Saved"
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such list",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/quote-price-lists/order": {
      "put": {
        "tags": [
          "quotes"
        ],
        "summary": "Reorder the price lists",
        "description": "Saves a drag on the lists table: each list's sequence becomes its place\nin `ids` (1 = first). Other companies' ids are ignored; lists left out go\nafter the given ones, in their old order.",
        "operationId": "reorder_quote_price_lists",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PriceListOrder"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Saved"
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/quote-price-lists/{id}": {
      "get": {
        "tags": [
          "quotes"
        ],
        "summary": "Open a price list",
        "description": "Its prices as saved and as matched to today's inventory, the stones and\nsinks in stock, and its history.",
        "operationId": "get_quote_price_list",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Price list id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The list",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PriceListEditor"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such list",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "put": {
        "tags": [
          "quotes"
        ],
        "summary": "Save a price list",
        "description": "The name and status, and, with `info`, the prices as a new revision:\nsinks' cutouts and colors' display are saved onto the inventory, the\nlist is matched to the inventory, keeps only its own extras, and must be\nunambiguous (else 422 with every problem).",
        "operationId": "save_quote_price_list",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Price list id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SavedPriceList"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Saved"
          },
          "400": {
            "description": "No name, or the prices could not be read",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such list",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "409": {
            "description": "The name is taken",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "422": {
            "description": "The prices are ambiguous",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PriceListProblems"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "delete": {
        "tags": [
          "quotes"
        ],
        "summary": "Delete a price list",
        "description": "Quotes made with it keep their prices; it can no longer be picked.",
        "operationId": "delete_quote_price_list",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Price list id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Deleted"
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "patch": {
        "tags": [
          "quotes"
        ],
        "summary": "Rename or (de)activate a price list",
        "description": "Without a new revision.",
        "operationId": "update_quote_price_list",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Price list id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PriceListMeta"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Saved"
          },
          "400": {
            "description": "Empty name",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "409": {
            "description": "The name is taken",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/quote-price-lists/{id}/copies": {
      "post": {
        "tags": [
          "quotes"
        ],
        "summary": "Duplicate a price list",
        "description": "A copy named \"… (copy)\" with the current prices, right after it.",
        "operationId": "copy_quote_price_list",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Price list id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CreatedId"
                }
              }
            }
          },
          "400": {
            "description": "Nothing to copy",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/quote-price-lists/{id}/revisions/{revision_id}/restore": {
      "post": {
        "tags": [
          "quotes"
        ],
        "summary": "Restore a revision",
        "description": "The revision's prices become a new revision.",
        "operationId": "restore_quote_price_list_revision",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Price list id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "revision_id",
            "in": "path",
            "description": "Revision id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Restored",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RestoredRevision"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such list or revision",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/reports/cut-slabs": {
      "get": {
        "tags": [
          "reports"
        ],
        "summary": "Cut slabs report",
        "description": "Whole slabs (not remnants) of the caller's company that were cut, with\ntheir stone, the stone's supplier and the sale, newest cut first. Slabs\nof stones without a supplier are left out.",
        "operationId": "get_cut_slabs_report",
        "parameters": [
          {
            "name": "from",
            "in": "query",
            "description": "Cut on or after this day, `YYYY-MM-DD`.",
            "required": false,
            "schema": {
              "type": "string",
              "format": "date"
            }
          },
          {
            "name": "to",
            "in": "query",
            "description": "Cut on or before this day, `YYYY-MM-DD`.",
            "required": false,
            "schema": {
              "type": "string",
              "format": "date"
            }
          },
          {
            "name": "supplier_id",
            "in": "query",
            "description": "Only stones of this supplier.",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "stone_id",
            "in": "query",
            "description": "Only this stone.",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Cut slabs",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/CutSlab"
                  }
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/reports/slabs": {
      "get": {
        "tags": [
          "reports"
        ],
        "summary": "Slabs by status report",
        "description": "Slabs and remnants of the caller's company (deleted ones left out) with\nthe given status: `available` (in the yard, unsold, not on hold),\n`on_hold` (unsold, hold not ended yet) or `sold` (part of a sale, cut or\nnot). `from`/`to` filter on the day the slab was added, put on hold or\nsold. Newest first.",
        "operationId": "get_slabs_by_status_report",
        "parameters": [
          {
            "name": "status",
            "in": "query",
            "description": "Which slabs: `available`, `on_hold` or `sold`.",
            "required": true,
            "schema": {
              "type": "string",
              "description": "Which slabs `GET /v1/reports/slabs` lists.",
              "enum": [
                "available",
                "on_hold",
                "sold"
              ]
            }
          },
          {
            "name": "from",
            "in": "query",
            "description": "On or after this day, `YYYY-MM-DD`: the day the slab was added\n(available), put on hold (on hold) or sold (sold).",
            "required": false,
            "schema": {
              "type": "string",
              "format": "date"
            }
          },
          {
            "name": "to",
            "in": "query",
            "description": "On or before this day, `YYYY-MM-DD`; same day as `from`.",
            "required": false,
            "schema": {
              "type": "string",
              "format": "date"
            }
          },
          {
            "name": "supplier_id",
            "in": "query",
            "description": "Only stones of this supplier.",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "stone_id",
            "in": "query",
            "description": "Only this stone.",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Slabs",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/StatusSlab"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Missing or unknown status",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/shop/cut-stats": {
      "get": {
        "tags": [
          "shop"
        ],
        "summary": "Cut square feet per day",
        "description": "Square feet of fully cut rooms, by the day the room's last slab was cut\nand by stone type, for the caller's company. A room counts once: the\nroom's square feet (every slab of a room carries the same `square_feet`),\nelse its slabs' length × width / 144 added up. Rooms with any uncut slab\nare left out.",
        "operationId": "get_shop_cut_stats",
        "parameters": [
          {
            "name": "start",
            "in": "query",
            "description": "First day, `YYYY-MM-DD`; default 29 days before `end`.",
            "required": false,
            "schema": {
              "type": "string",
              "format": "date"
            }
          },
          {
            "name": "end",
            "in": "query",
            "description": "Last day, `YYYY-MM-DD`; default today (UTC).",
            "required": false,
            "schema": {
              "type": "string",
              "format": "date"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Cutting by day and material",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CutStats"
                }
              }
            }
          },
          "400": {
            "description": "`start` after `end`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not of the shop or an employee",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/survey-results": {
      "get": {
        "tags": [
          "surveys"
        ],
        "summary": "Get survey results",
        "description": "The post-install survey answers of the last `days` days with the\ninvitation count, the answer count, each sales rep's average and the\ninvitations sent per day.",
        "operationId": "get_survey_results",
        "parameters": [
          {
            "name": "days",
            "in": "query",
            "description": "30, 90 (default) or 365 days back; other values read as 90.",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Results",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SurveyResults"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/teach-mode": {
      "get": {
        "tags": [
          "company"
        ],
        "summary": "The employee test",
        "description": "The company's questions visible to employees with their answers, and the\ninstructions they test, each marked completed when the caller once\nanswered all its questions right in one try.",
        "operationId": "get_teach_mode",
        "responses": {
          "200": {
            "description": "The test",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EmployeeTest"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/teach-mode/attempts": {
      "post": {
        "tags": [
          "company"
        ],
        "summary": "Submit a test",
        "description": "Grades the caller's answers (a skipped question is wrong) and saves them as\ntheir next try at those questions.",
        "operationId": "submit_teach_mode_attempt",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AttemptInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Graded and saved",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AttemptResult"
                }
              }
            }
          },
          "400": {
            "description": "No answers, or a question that is not the company's visible one",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/teach-mode/questions": {
      "get": {
        "tags": [
          "company"
        ],
        "summary": "List the questions",
        "description": "Every question of the company, published or draft, with its answers.",
        "operationId": "list_teach_mode_questions",
        "responses": {
          "200": {
            "description": "Questions",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AdminQuestions"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "post": {
        "tags": [
          "company"
        ],
        "summary": "Add a question",
        "description": "A published multiple-choice question on one of the company's instructions.",
        "operationId": "create_teach_mode_question",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/NewQuestion"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Added",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CreatedId"
                }
              }
            }
          },
          "400": {
            "description": "Unknown instruction, or not two answers with one right",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/teach-mode/questions/{id}": {
      "put": {
        "tags": [
          "company"
        ],
        "summary": "Edit a question",
        "description": "Saves the text and the answers: listed answers with an id are updated,\nthose without are added, and the question's other answers are deleted.",
        "operationId": "update_teach_mode_question",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Question id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/QuestionUpdate"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Saved"
          },
          "400": {
            "description": "Not two answers with one right",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such question in the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "delete": {
        "tags": [
          "company"
        ],
        "summary": "Delete a question",
        "description": "Soft-deletes one of the company's questions; past answers stay.",
        "operationId": "delete_teach_mode_question",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Question id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Deleted"
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such question in the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/teach-mode/questions/{id}/visibility": {
      "put": {
        "tags": [
          "company"
        ],
        "summary": "Publish or hide a question",
        "description": "Shows the question to employees, or moves it back to the drafts.",
        "operationId": "set_teach_mode_question_visibility",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Question id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Visibility"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Saved"
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such question in the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/teach-mode/instructions/{id}/publish": {
      "post": {
        "tags": [
          "company"
        ],
        "summary": "Publish an instruction's drafts",
        "description": "Shows every draft question of the instruction to employees.",
        "operationId": "publish_teach_mode_instruction",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Instruction id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Drafts published",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/QuestionCount"
                }
              }
            }
          },
          "400": {
            "description": "Instruction not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/teach-mode/instructions/{id}/generate": {
      "post": {
        "tags": [
          "company"
        ],
        "summary": "Generate questions",
        "description": "Asks the AI for a multiple-choice test covering the instruction (up to 30\nquestions, avoiding the existing ones) and adds them published.",
        "operationId": "generate_teach_mode_questions",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Instruction id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Questions added",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/QuestionCount"
                }
              }
            }
          },
          "400": {
            "description": "Instruction not found or empty",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "502": {
            "description": "The AI failed or returned no usable questions",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/teach-mode/progress": {
      "get": {
        "tags": [
          "company"
        ],
        "summary": "Training progress",
        "description": "The company's sales reps and every answer they gave to the training\nquestions.",
        "operationId": "get_teach_progress",
        "responses": {
          "200": {
            "description": "Reps and their answers",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TeachProgress"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/bug-reports": {
      "get": {
        "tags": [
          "support"
        ],
        "summary": "List bug reports",
        "description": "Every company's reports, newest first, with the reporter, the company\nand the files. Super admins only.",
        "operationId": "list_bug_reports",
        "responses": {
          "200": {
            "description": "Reports",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/BugReport"
                  }
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not a super admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "post": {
        "tags": [
          "support"
        ],
        "summary": "Report a bug",
        "description": "Saves the report with its files and emails it to the team (replies go to\nthe reporter). When the email fails the report is still saved and\n`notified` is false. The description is 1 to 16,000 characters. Up to 20\nfiles: get each one's address from `POST /v1/uploads` (folder\n`bug-reports`), send the file there, then pass its `url` here; a file\nthat was not sent is refused.",
        "operationId": "create_bug_report",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/NewBugReport"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Filed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FiledBugReport"
                }
              }
            }
          },
          "400": {
            "description": "No description or one over 16,000 characters, more than 20 files, or a file not uploaded for bug reports",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/superuser/onboarding-feedbacks": {
      "get": {
        "tags": [
          "superuser"
        ],
        "summary": "List onboarding feedback",
        "description": "Every company's guided-tour ratings, newest first. Super admins only.",
        "operationId": "list_onboarding_feedbacks",
        "responses": {
          "200": {
            "description": "Ratings",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/OnboardingFeedback"
                  }
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not a super admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/superuser/signature-access": {
      "get": {
        "tags": [
          "superuser"
        ],
        "summary": "List signature access",
        "description": "Every company and its users with whether each may send documents for\nsignature (eSignatures are given per user, with no company switch);\n`company_id` narrows the users to one company. Super admins only.",
        "operationId": "list_signature_access",
        "parameters": [
          {
            "name": "company_id",
            "in": "query",
            "description": "Only this company's users (ignored unless it has signatures).",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Companies and users",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SignatureAccess"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not a super admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/superuser/users/{id}/signature-access": {
      "put": {
        "tags": [
          "superuser"
        ],
        "summary": "Set a user's signature access",
        "description": "Lets a live user send documents for signature, or stops them. Super\nadmins only.",
        "operationId": "set_signature_access",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "User id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SignatureAccessInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Saved"
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not a super admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such live user",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/superuser/widget-analytics": {
      "get": {
        "tags": [
          "superuser"
        ],
        "summary": "Dashboard widget analytics",
        "description": "How every company's users use their dashboard widgets: uses per widget,\nall events and the widgets each dashboard has. Super admins only.",
        "operationId": "get_widget_analytics",
        "responses": {
          "200": {
            "description": "The analytics",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WidgetAnalytics"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not a super admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/superuser/emails": {
      "post": {
        "tags": [
          "superuser"
        ],
        "summary": "Send an email",
        "description": "Sends a plain-text email from `noreply@granite-manager.com` through the\nwebhooks Lambda. Super admins only.",
        "operationId": "send_superuser_email",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PlainEmail"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Sent"
          },
          "400": {
            "description": "Bad address, or no subject or body",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not a super admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "502": {
            "description": "Sending failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/transactions": {
      "get": {
        "tags": [
          "sales"
        ],
        "summary": "List transactions",
        "description": "The company's sales, newest first, with their bundles, stones, sinks,\ncut progress and a status. `employee` and `shop` views filter by\n`status`, `sales_rep` and `search`; the `admin` view lists every sale of\nlive sellers.\n\nWithout `page` every matching sale comes back at once. With `page` (from\n1) and `page_size` (default 50, at most 500) only that page comes back,\nin the same order and the same shape (a plain list, no total): a page\nwith fewer than `page_size` sales is the last; ask for `page + 1` until\nthen. Open a sale with `GET /v1/transactions/{id}`.",
        "operationId": "list_transactions",
        "parameters": [
          {
            "name": "view",
            "in": "query",
            "description": "Default `employee`; `admin` needs an admin.",
            "required": false,
            "schema": {
              "type": "string",
              "description": "Which Transactions page asks.",
              "enum": [
                "employee",
                "shop",
                "admin"
              ]
            }
          },
          {
            "name": "status",
            "in": "query",
            "description": "Default `all`.",
            "required": false,
            "schema": {
              "type": "string",
              "description": "Which sales.",
              "enum": [
                "all",
                "in_progress",
                "finished",
                "sold",
                "cut"
              ]
            }
          },
          {
            "name": "sales_rep",
            "in": "query",
            "description": "Only sales of this seller (by name).",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "search",
            "in": "query",
            "description": "Customer, seller, bundle or stone name containing this.",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "page",
            "in": "query",
            "description": "The page to return, from 1. Without it every matching sale comes back\nat once (the website and the apps from before the list was paged).\nThe answer stays a plain list: a page shorter than `page_size` is the\nlast one.",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int32",
              "minimum": 0
            }
          },
          {
            "name": "page_size",
            "in": "query",
            "description": "Sales a page when `page` is sent: 50 when absent, from 1 to 500.\nNot read without `page`.",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int32",
              "minimum": 0
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Sales",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/TransactionRow"
                  }
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or of the shop, or the admin view without being an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/transactions/sales-reps": {
      "get": {
        "tags": [
          "sales"
        ],
        "summary": "List the sellers to filter by",
        "description": "Names of everyone who sold something in the company.",
        "operationId": "list_transaction_sellers",
        "responses": {
          "200": {
            "description": "Seller names",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "type": "string"
                  }
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or of the shop",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/transactions/{id}/installed": {
      "post": {
        "tags": [
          "sales"
        ],
        "summary": "Mark a sale installed",
        "description": "Sets the installed date (and, when `paid`, the paid date) of a sale of\nthe company whose slabs are all cut. A cancelled sale is refused (409).",
        "operationId": "mark_sale_installed",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Sale id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Installed"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Marked installed"
          },
          "400": {
            "description": "Already installed, no slabs, not all slabs cut, or a bad date",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or of the shop",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such sale in the caller's company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "409": {
            "description": "The sale was cancelled",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/transactions/{id}": {
      "get": {
        "tags": [
          "sales"
        ],
        "summary": "Get a transaction",
        "description": "The sale with its customer and seller, its slabs (with their cut state,\nsize, room and remnants) and its sinks.",
        "operationId": "get_transaction",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Sale id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The transaction",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TransactionDetail"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or of the shop",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such sale (with a customer and seller) in the caller's company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/transactions/{id}/slabs/{slab_id}/cut": {
      "post": {
        "tags": [
          "sales"
        ],
        "summary": "Mark a slab cut",
        "description": "Stamps the slab's cut date (once) and updates the sale's status; with\n`with_remnants` (admins and the shop) its unsold remnants are deleted.",
        "operationId": "cut_sale_slab",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Sale id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "slab_id",
            "in": "path",
            "description": "Slab id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CutOptions"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Cut"
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or of the shop (`with_remnants`: an admin or of the shop)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such slab on a sale of the caller's company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/transactions/{id}/slabs/{slab_id}/uncut": {
      "post": {
        "tags": [
          "sales"
        ],
        "summary": "Mark a slab uncut",
        "description": "Clears the slab's cut date and updates the sale's status. With\n`with_remnants` (admins and the shop) the slab's full size (its own when\nit is a remnant, else its stone's) goes back to its parent and to its\npieces: sold pieces take it and unsold ones are deleted, or else the\nfirst unsold piece takes it and the others are deleted.",
        "operationId": "uncut_sale_slab",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Sale id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "slab_id",
            "in": "path",
            "description": "Slab id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CutOptions"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Uncut"
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or of the shop (`with_remnants`: an admin or of the shop)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such slab on a sale of the caller's company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/transactions/{id}/slabs/{slab_id}/partial-cut": {
      "post": {
        "tags": [
          "sales"
        ],
        "summary": "Record a cut piece",
        "description": "Records the size of a piece cut from the slab (the\n`admin|shop.transactions.edit` `partial-cut` bookkeeping): it resizes the\nfirst piece with `replace_first`, else (or when the slab has no piece)\nadds a free piece of the slab's stone and bundle; unless `add_another`,\nthe slab is then marked cut. The sold slab keeps its own size.",
        "operationId": "partial_cut_sale_slab",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Sale id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "slab_id",
            "in": "path",
            "description": "Slab id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PartialCut"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Recorded"
          },
          "400": {
            "description": "Length or width not above zero",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin or of the shop",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such slab on a sale of the caller's company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/transactions/{id}/slabs/{slab_id}/remove": {
      "post": {
        "tags": [
          "sales"
        ],
        "summary": "Take a slab off a sale",
        "description": "Deletes the slab's unsold remnants and frees it (its room and sale\ndetails are cleared).",
        "operationId": "remove_sale_slab",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Sale id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "slab_id",
            "in": "path",
            "description": "Slab id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Removed"
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin or of the shop",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such slab on a sale of the caller's company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/transactions/{id}/slabs/{slab_id}/replace": {
      "post": {
        "tags": [
          "sales"
        ],
        "summary": "Swap a slab",
        "description": "Puts a free slab on the sale with the old slab's room and sale details\n(and cut state) and its sinks and faucets, deletes the old slab's unsold\nremnants and frees it. A cancelled sale gets no slab (409): sell the\nslabs again as a new sale.",
        "operationId": "replace_sale_slab",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Sale id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "slab_id",
            "in": "path",
            "description": "Slab id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Replacement"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Swapped"
          },
          "400": {
            "description": "The new slab is not a free slab of the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin or of the shop",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such slab on a sale of the caller's company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "409": {
            "description": "The sale was cancelled",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/transactions/{id}/slabs/{slab_id}/square-feet": {
      "put": {
        "tags": [
          "sales"
        ],
        "summary": "Set a slab's square feet",
        "description": "The square feet of the room the slab is in, as the shop measured it.",
        "operationId": "set_sale_slab_square_feet",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Sale id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "slab_id",
            "in": "path",
            "description": "Slab id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SquareFeet"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Saved"
          },
          "400": {
            "description": "Not a number, negative, or over 99,999,999.99",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin or of the shop",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such slab on a sale of the caller's company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/transactions/{id}/slabs": {
      "post": {
        "tags": [
          "sales"
        ],
        "summary": "Add a slab to a room",
        "description": "Puts a free slab on the sale in the room, with the details of the\nroom's first slab (its seam, edge, price...). A cancelled sale gets no\nslab (409): sell the slabs again as a new sale.",
        "operationId": "add_sale_slab",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Sale id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AddedSlab"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Added"
          },
          "400": {
            "description": "No room, a bad room id, or not a free slab of the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin or of the shop",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such sale in the caller's company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "409": {
            "description": "The sale was cancelled",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/instructions": {
      "get": {
        "tags": [
          "instructions"
        ],
        "summary": "List instructions",
        "description": "The rows of the company's (or the general) instruction tree; the client\nbuilds the tree from `parent_id` and `after_id`. An instruction limited to\nsome positions is left out unless the caller holds one of them, except\nwith `manage` (admins), which returns every row with its positions.",
        "operationId": "list_instructions",
        "parameters": [
          {
            "name": "scope",
            "in": "query",
            "description": "`company` (default) or `general` (shared by every company).",
            "required": false,
            "schema": {
              "type": "string",
              "description": "Which instructions to reorder.",
              "enum": [
                "company",
                "general"
              ]
            }
          },
          {
            "name": "manage",
            "in": "query",
            "description": "Admins: every row with its access, for editing (general rows only for\nsuper admins). Otherwise only the rows the caller's positions open.",
            "required": false,
            "schema": {
              "type": "boolean"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Instructions",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/Instruction"
                  }
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee, or `manage` without being an admin (`general`: super admin)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "post": {
        "tags": [
          "instructions"
        ],
        "summary": "Add an instruction",
        "description": "Puts it in the caller's company tree (a super admin's `scope=general`:\nthe general one) under `parent_id`, right after `after_id` (the sibling\nthat followed `after_id` now follows it).",
        "operationId": "create_instruction",
        "parameters": [
          {
            "name": "scope",
            "in": "query",
            "description": "`company` (default) or `general` (shared by every company; super\nadmins only, others get `company`).",
            "required": false,
            "schema": {
              "type": "string",
              "description": "Which instructions to reorder.",
              "enum": [
                "company",
                "general"
              ]
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/InstructionInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Added",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CreatedInstruction"
                }
              }
            }
          },
          "400": {
            "description": "No title, or a parent or sibling outside the tree",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/instructions/{id}": {
      "put": {
        "tags": [
          "instructions"
        ],
        "summary": "Edit an instruction",
        "description": "Saves its title, place (`parent_id`, `after_id`), text and the positions\nthat may read it.",
        "operationId": "update_instruction",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Instruction id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/InstructionInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Saved"
          },
          "400": {
            "description": "No title, or a parent or sibling outside the tree",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such instruction the caller may edit",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "delete": {
        "tags": [
          "instructions"
        ],
        "summary": "Delete an instruction",
        "description": "Removes it and its access rows. Its children take its place among its\nsiblings, in their order; every other instruction keeps its place.",
        "operationId": "delete_instruction",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Instruction id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Deleted"
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such instruction the caller may delete",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/instructions/order": {
      "put": {
        "tags": [
          "instructions"
        ],
        "summary": "Order instructions",
        "description": "Saves the order of one parent's children; the list must hold each of\nthem exactly once.",
        "operationId": "order_instructions",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/InstructionOrder"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Saved"
          },
          "400": {
            "description": "Empty, repeated, missing or foreign ids",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/instructions/ai-placement": {
      "post": {
        "tags": [
          "instructions"
        ],
        "summary": "Find the place for a note with AI",
        "description": "Reads the company's instruction tree (a super admin's `scope=general`:\nthe general one) and answers where the note belongs: an existing page and\nthe part of it the note follows, or the title and parent of a new page\nwhen no page covers the subject. `text` is the note with spelling and\npunctuation fixed, in the admin's own words only. Nothing is saved.",
        "operationId": "place_instruction_note",
        "parameters": [
          {
            "name": "scope",
            "in": "query",
            "description": "`company` (default) or `general` (shared by every company; super\nadmins only, others get `company`).",
            "required": false,
            "schema": {
              "type": "string",
              "description": "Which instructions to reorder.",
              "enum": [
                "company",
                "general"
              ]
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PlacementInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Where the note belongs",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Placement"
                }
              }
            }
          },
          "400": {
            "description": "Empty or longer than 4000 characters",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "502": {
            "description": "The AI failed or picked no place",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/instructions/ai-help": {
      "get": {
        "tags": [
          "instructions"
        ],
        "summary": "Should Add with AI offer help",
        "description": "True the first time the admin opens Add with AI, then after the 5th,\n10th, 15th, 20th and 25th request; never once the admin took it or said not to ask.",
        "operationId": "get_instruction_ai_help",
        "responses": {
          "200": {
            "description": "Whether to offer help",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HelpState"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/instructions/ai-help/offered": {
      "post": {
        "tags": [
          "instructions"
        ],
        "summary": "Help was offered",
        "description": "The chat showed the offer (taken or not): the next one comes at the\nnext 5th request, up to the 25th.",
        "operationId": "mark_instruction_ai_help_offered",
        "responses": {
          "204": {
            "description": "Saved"
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/instructions/ai-help/stop": {
      "post": {
        "tags": [
          "instructions"
        ],
        "summary": "Never offer help again",
        "description": "The admin pressed \"Don't ask again\" or \"Stop suggestions\": the chat no\nlonger offers help planning or next subjects (the admin can still ask\nfor ideas).",
        "operationId": "stop_instruction_ai_help",
        "responses": {
          "204": {
            "description": "Saved"
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/instructions/ai-ideas": {
      "post": {
        "tags": [
          "instructions"
        ],
        "summary": "Suggest what to add to the instructions",
        "description": "Reads the company's instruction tree (a super admin's `scope=general`:\nthe general one) and suggests the subjects it does not cover yet, each\nwith the questions the admin answers to write it. Writes nothing.",
        "operationId": "suggest_instruction_ideas",
        "parameters": [
          {
            "name": "scope",
            "in": "query",
            "description": "`company` (default) or `general` (shared by every company; super\nadmins only, others get `company`).",
            "required": false,
            "schema": {
              "type": "string",
              "description": "Which instructions to reorder.",
              "enum": [
                "company",
                "general"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Subjects to add",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Ideas"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "502": {
            "description": "The AI failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/events": {
      "post": {
        "tags": [
          "schedule"
        ],
        "summary": "Add an event",
        "description": "Puts an event on one of the company's calendars, optionally copying\ncomments and attachments from another event. Whoever creates it is in\nit: with `people_ids` left out, the caller is saved as its one person\n(when they are one of the company's people, see `GET /v1/schedule/team`).",
        "operationId": "create_event",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/EventInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Added",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CreatedEvent"
                }
              }
            }
          },
          "400": {
            "description": "Invalid field, or unknown calendar or customer",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee, admin or shop manager or worker",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/events/{id}": {
      "put": {
        "tags": [
          "schedule"
        ],
        "summary": "Edit an event, or some repeats of a repeating one",
        "description": "Saves every field, logs what changed in the event's history, and\nre-times its appointment reminders when it moved. For a repeating event,\n`scope=one` with `date` takes that repeat off it (`recurrence_exdates`)\nand saves the input as its own event that doesn't repeat; and\n`scope=following` with `start` ends the repeats just before that one\n(`recurrence_until`) and saves the input as a new event from it on. Both\nanswer 200 with the new event's id; it keeps the people, notifications,\ninvoice, comments and photos the input leaves out.",
        "operationId": "update_event",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Event id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "scope",
            "in": "query",
            "description": "`all` (the default): the event and, if it repeats, every repeat.\n`one`: only the repeat on `date`. `following`: the repeat that starts\nat `start` and every later one. On an event that does not repeat,\nevery scope edits the event.",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "date",
            "in": "query",
            "description": "With `scope=one`: the repeat's day, `YYYY-MM-DD`, as the calendar shows\nit (the shop's wall-clock date, like `recurrence_exdates`).",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "start",
            "in": "query",
            "description": "With `scope=following`: the repeat's start, UTC ISO 8601. The repeat\nat or before the first one edits the whole event.",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/EventInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Some repeats changed: their new event",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EditedRepeats"
                }
              }
            }
          },
          "204": {
            "description": "Saved"
          },
          "400": {
            "description": "Invalid field, or unknown calendar or customer",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee, admin or shop manager or worker",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such event in the caller's company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "delete": {
        "tags": [
          "schedule"
        ],
        "summary": "Delete an event, or some repeats of a repeating one",
        "description": "`scope=all` (the default) hides the event and cancels its pending\nappointment reminders. For a repeating event (`rrule` set), `scope=one`\nwith `date` skips that one repeat (it is added to `recurrence_exdates`),\nand `scope=following` with `start` ends the repeats just before that one\n(`recurrence_until`); both keep the event and its earlier repeats. The\nschedule (`GET /v1/schedule/events`) then shows the change.",
        "operationId": "delete_event",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Event id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "scope",
            "in": "query",
            "description": "`all` (the default): the event and, if it repeats, every repeat.\n`one`: only the repeat on `date`. `following`: the repeat that starts\nat `start` and every later one. On an event that does not repeat,\nevery scope deletes the whole event.",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "date",
            "in": "query",
            "description": "With `scope=one`: the repeat's day, `YYYY-MM-DD`, as the calendar shows\nit (the shop's wall-clock date, like `recurrence_exdates`).",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "start",
            "in": "query",
            "description": "With `scope=following`: the repeat's start, UTC ISO 8601 (the\n`start_date` of that repeat). The repeat at or before the first one\ndeletes the whole event.",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Deleted"
          },
          "400": {
            "description": "Unknown scope, or a missing or unreadable `date` / `start`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee, admin or shop manager or worker",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such event in the caller's company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/events/{id}/confirmation": {
      "post": {
        "tags": [
          "schedule"
        ],
        "summary": "Send a confirmation now",
        "description": "Sends one of the company's templates to the event's customer right\naway, whenever the appointment is, and notes it in the event's history.\nThe event form offers the `confirmation` templates; any kind is accepted.",
        "operationId": "send_event_confirmation",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Event id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ConfirmationInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Sent",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ConfirmationSent"
                }
              }
            }
          },
          "400": {
            "description": "Unscheduled, no customer, unknown template, or the customer cannot be reached",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee, admin or shop manager or worker",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such event in the caller's company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "502": {
            "description": "The text or email failed to send",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/events/{id}/scheduling-texts": {
      "get": {
        "tags": [
          "schedule"
        ],
        "summary": "List an event's scheduling texts",
        "description": "The company's scheduling texts (`confirmation` templates sent by text)\nfor the event's calendar, each filled in for this event, for the event\ndetails' Send SMS. They go out from the Scheduling Manager's line with\n`POST /v1/events/{id}/confirmation`.",
        "operationId": "list_event_scheduling_texts",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Event id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "start",
            "in": "query",
            "description": "The planned start, as an event's `start_date`.",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "end",
            "in": "query",
            "description": "The planned end, as an event's `end_date`.",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "all_day",
            "in": "query",
            "description": "Whether the planned time is all day.",
            "required": false,
            "schema": {
              "type": "boolean"
            }
          },
          {
            "name": "assigned_user_id",
            "in": "query",
            "description": "The person who would get the job.",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The texts",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SchedulingTexts"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee, admin or shop manager or worker",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such event in the caller's company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/events/{id}/confirmation-call": {
      "post": {
        "tags": [
          "schedule"
        ],
        "summary": "Call the customer to confirm",
        "description": "Places one automatic call to the event's customer from the Scheduling\nManager's line. A voice reads the auto-confirm text (without its \"reply\nYES\" sentence) and asks for a yes or a no: \"yes\" or 1 turns the job\nConfirmed and tells the Scheduling Managers, \"no\" or 2 tells them the\ncustomer said no, \"repeat\" reads it again, anything else is asked again\n(3 tries). The job turns Awaiting confirmation. When the call brings no\nyes or no, the same text is sent to the customer as a scheduling text.",
        "operationId": "call_event_confirmation",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Event id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CallInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "The call is ringing",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CallPlaced"
                }
              }
            }
          },
          "400": {
            "description": "Unscheduled, no customer or phone, not an auto-confirm text, calls are not set up, or a call is already going",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee, admin or shop manager or worker",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such event in the caller's company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "502": {
            "description": "The call could not be placed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/events/{id}/crew-status": {
      "post": {
        "tags": [
          "schedule"
        ],
        "summary": "Tap On my way or Completed",
        "description": "On my way (today's jobs, before arriving) marks the job and tells the\ncustomer once with the company's On my way message: a text, or an email\nwhen the company cannot text. The status is saved even when the message\ncannot go; `message_error` says why. Completed marks the job done; on an\ninstallation its sales rep is told (unless Admin > Schedule turned it\noff). For the\njob's installer or template maker, or an admin.",
        "operationId": "set_crew_status",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Event id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CrewStatusInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Saved",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CrewStatusSaved"
                }
              }
            }
          },
          "400": {
            "description": "Unscheduled, repeating, not today, already arrived, or not started yet",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Not the job's crew or an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such event in the caller's company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/me/location": {
      "post": {
        "tags": [
          "schedule"
        ],
        "summary": "Report the crew's position",
        "description": "The crew's phone says where it is. Reaching one of today's jobs (its\naddress within 0.1 mi) marks it Arrived; getting 0.5 mi away from the\nshop or the job they were at marks the first of today's jobs with no\nstatus yet On my way. Nothing is sent to customers, and no job is marked\nCompleted. Positions less accurate than 200 m are ignored. Only\ninstallers and template makers report.",
        "operationId": "report_crew_location",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/LocationInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "What changed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LocationResult"
                }
              }
            }
          },
          "400": {
            "description": "Not a position on Earth",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Not an installer or template maker",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "device_token": []
          },
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/events/{id}/shop-status": {
      "post": {
        "tags": [
          "schedule"
        ],
        "summary": "Mark a job Cut or Complete",
        "description": "Sets the shop's progress on a job (`cut`, then `complete`), or clears it\nwith null. Everyone sees it on the schedule. For Shop Managers and Shop\nWorkers.",
        "operationId": "set_shop_status",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Event id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ShopStatusInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Saved",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ShopStatusSaved"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Not a Shop Manager or Shop Worker",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such event in the caller's company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/events/estimates": {
      "post": {
        "tags": [
          "schedule"
        ],
        "summary": "Book an in-home estimate",
        "description": "Puts the estimate on the Estimates calendar with the user the deal is\nassigned to as its person (the booker when the deal has none), texts the customer from the\noffice manager's line (else emails them from their sales rep), and\nschedules the customer's and the rep's reminders. The customer needs a\nphone or an email.",
        "operationId": "book_estimate",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/EstimateInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Booked",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BookedEstimate"
                }
              }
            }
          },
          "400": {
            "description": "Invalid field, not the Estimates calendar, or a customer without phone or email",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee, admin or shop manager or worker",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such customer in the caller's company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/events/search": {
      "get": {
        "tags": [
          "schedule"
        ],
        "summary": "Search events",
        "description": "The company's events where every word of `q` is in the title, customer's\nname, location or notes; with `calendar_ids`, only those\ncalendars' events. With `id`, just that event.\n\nA word of 4+ letters also finds a title or customer name that has it with\none typo (\"deborh\" finds \"Deborah\").\n\nSmart order: the caller's own first (for their customer or assigned to\nthem), then ones they only made (a scheduler makes everyone's), then the\nrest. In each: a title or customer-name word starting with the search,\nthen containing it, then hits only in the place or notes, then typo\nhits; open jobs before ones the crew finished; then the nearest to now,\nupcoming before past (past distance counts double); unscheduled last.",
        "operationId": "search_events",
        "parameters": [
          {
            "name": "q",
            "in": "query",
            "description": "Words, each in the title, customer name, location or\nnotes (any of them, in any order).",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "description": "At most this many, 1 to 50 (default 25).",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          },
          {
            "name": "calendar_ids",
            "in": "query",
            "description": "Only these calendars, comma-separated ids; empty means events with no\ncalendar. Left out: every calendar.",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "id",
            "in": "query",
            "description": "Just this event (a job a notification is about), whatever `q` says:\nit alone, or none when it is deleted or not the caller's to see.",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Events",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/FoundEvent"
                  }
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee, admin or shop manager or worker",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/events/{id}/details": {
      "get": {
        "tags": [
          "schedule"
        ],
        "summary": "Get an event's comments, files and history",
        "description": "Everything the event panel shows besides the event itself, oldest first.",
        "operationId": "get_event_details",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Event id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Details",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EventDetails"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee, admin or shop manager or worker",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such event in the caller's company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/events/{id}/comments": {
      "post": {
        "tags": [
          "schedule"
        ],
        "summary": "Comment on an event",
        "description": "Adds a comment signed with the caller's name.",
        "operationId": "add_event_comment",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Event id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CommentInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Added"
          },
          "400": {
            "description": "Empty or too long",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee, admin or shop manager or worker",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such event in the caller's company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/events/{id}/comments/{comment_id}": {
      "put": {
        "tags": [
          "schedule"
        ],
        "summary": "Edit my comment",
        "description": "Only the author can edit a comment.",
        "operationId": "edit_event_comment",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Event id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "comment_id",
            "in": "path",
            "description": "Comment id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CommentInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Saved"
          },
          "400": {
            "description": "Empty or too long",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee, admin or shop manager or worker",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "Not the caller's comment on this event",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "delete": {
        "tags": [
          "schedule"
        ],
        "summary": "Delete my comment",
        "description": "Only the author can delete a comment.",
        "operationId": "delete_event_comment",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Event id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "comment_id",
            "in": "path",
            "description": "Comment id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Deleted"
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee, admin or shop manager or worker",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "Not the caller's comment on this event",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/events/{id}/photos": {
      "post": {
        "tags": [
          "schedule"
        ],
        "summary": "Post files in an event's comments",
        "description": "Files already uploaded with `POST /v1/uploads` (folder `events`). With\n`for_customer` they are job photos the customer also sees.",
        "operationId": "add_event_photos",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Event id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PhotosInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Posted"
          },
          "400": {
            "description": "No files, or a URL that was not uploaded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee, admin or shop manager or worker",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such event in the caller's company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database or storage error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/events/{id}/photos/{photo_id}": {
      "delete": {
        "tags": [
          "schedule"
        ],
        "summary": "Delete my comment file",
        "description": "Only the poster can delete it; the stored file goes once nothing uses it.",
        "operationId": "delete_event_photo",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Event id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "photo_id",
            "in": "path",
            "description": "File id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Deleted"
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee, admin or shop manager or worker",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "Not the caller's file on this event",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/events/{id}/attachments": {
      "post": {
        "tags": [
          "schedule"
        ],
        "summary": "Attach files to an event",
        "description": "Files already uploaded with `POST /v1/uploads` (folder `events`); the\nkind comes from the extension.",
        "operationId": "add_event_attachments",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Event id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AttachmentsInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Attached"
          },
          "400": {
            "description": "No files, an unsupported type, or a URL that was not uploaded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee, admin or shop manager or worker",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such event in the caller's company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database or storage error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/events/{id}/attachments/{attachment_id}": {
      "delete": {
        "tags": [
          "schedule"
        ],
        "summary": "Remove an attachment",
        "description": "Any employee may remove one; the stored file goes once nothing uses it.",
        "operationId": "delete_event_attachment",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Event id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "attachment_id",
            "in": "path",
            "description": "Attachment id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Removed"
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee, admin or shop manager or worker",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such attachment on this event",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/events/{id}/issues": {
      "post": {
        "tags": [
          "schedule"
        ],
        "summary": "Report an issue on an event",
        "description": "Files a problem with the job (the app's Issue tab, for the crew and\nanyone else on the schedule): a description and, optionally, pictures\nuploaded to the `events` folder first. The job's sales rep (the sale's\nseller, else the deal's owner, else the customer's sales rep, else\nwhoever made the event) gets a bell notification of type `event_issue`\nand a phone push, unless they reported it themselves. `GET\n/v1/events/{id}/details` lists the event's issues.",
        "operationId": "report_event_issue",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Event id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/IssueInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Reported"
          },
          "400": {
            "description": "No description, one over 2000 characters, over 20 pictures, or a URL that was not uploaded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee, admin or shop manager or worker",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such event in the caller's company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database or storage error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/events/{id}/issues/{issue_id}": {
      "put": {
        "tags": [
          "schedule"
        ],
        "summary": "Set an issue in progress, solved, or open again",
        "description": "Anyone who can see the job: the crew on the job card, the office on the\nschedule. In progress and solved keep who did it first and when; taking\nan issue on adds a line to the job's history.",
        "operationId": "set_event_issue_solved",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Event id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "issue_id",
            "in": "path",
            "description": "Issue id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/IssueSolved"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Saved"
          },
          "400": {
            "description": "Neither status nor solved sent",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee, admin or shop manager or worker",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such issue on this event in the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "delete": {
        "tags": [
          "schedule"
        ],
        "summary": "Delete an issue I reported",
        "description": "Only the reporter, an admin or a superuser can delete it; its pictures\ngo from storage. The sales rep's notification stays.",
        "operationId": "delete_event_issue",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Event id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "issue_id",
            "in": "path",
            "description": "Issue id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Deleted"
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee, admin or shop manager or worker",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "Not an issue on this event the caller may delete",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/events/{id}/project-notes": {
      "get": {
        "tags": [
          "schedule"
        ],
        "summary": "List the project's notes",
        "description": "The notes on the event's sale, oldest first.",
        "operationId": "list_project_notes",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Event id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Notes",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/ProjectNote"
                  }
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee, admin or shop manager or worker",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such event with a sale in the caller's company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "post": {
        "tags": [
          "schedule"
        ],
        "summary": "Leave a note on the project",
        "description": "Signed with the caller; every event of the sale shows it.",
        "operationId": "add_project_note",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Event id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ProjectNoteInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Added"
          },
          "400": {
            "description": "Empty, too long or an unknown audience",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee, admin or shop manager or worker",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such event with a sale in the caller's company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/events/{id}/sale": {
      "get": {
        "tags": [
          "schedule"
        ],
        "summary": "The event's project",
        "description": "The sales the event's project view shows: the event's own sale, else the\ncustomer's sales at the event's address, with the other sales at that\naddress. A customer with one project lends it when there is no street to\ncompare; a builder's other jobs never show.",
        "operationId": "get_event_sale",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Event id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The sale, or null",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EventSale"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee, admin or shop manager or worker",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such event in the caller's company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/events/{id}/job-photos": {
      "get": {
        "tags": [
          "schedule"
        ],
        "summary": "List the project's job photos",
        "description": "The crew's Before and Installed photos from the job pages of every event\nof the event's project (its template, its install), oldest first.",
        "operationId": "list_event_job_photos",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Event id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Photos",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/EventPhoto"
                  }
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee, admin or shop manager or worker",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such event in the caller's company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/events/{id}/job-issues": {
      "get": {
        "tags": [
          "schedule"
        ],
        "summary": "List the project's issues",
        "description": "The problems the crew reported on every event of the event's project\n(its template, its install), oldest first.",
        "operationId": "list_event_job_issues",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Event id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Issues",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/EventIssue"
                  }
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee, admin or shop manager or worker",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such event in the caller's company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/events/{id}/project-notes/{note_id}": {
      "delete": {
        "tags": [
          "schedule"
        ],
        "summary": "Delete my project note",
        "description": "Only the author can delete a note.",
        "operationId": "delete_project_note",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Event id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "note_id",
            "in": "path",
            "description": "Note id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Deleted"
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee, admin or shop manager or worker",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "Not the caller's note on this project",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/schedule/day-map": {
      "get": {
        "tags": [
          "schedule"
        ],
        "summary": "Map a day's stops",
        "description": "A map with the company address and the stops numbered in order, joined by\na line. Null image without Google Maps or when no address is found.",
        "operationId": "get_schedule_day_map",
        "parameters": [
          {
            "name": "address",
            "in": "query",
            "description": "The day's stops in order (repeat the parameter; at most 20 drawn).",
            "required": false,
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              }
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Map",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DayMap"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee, admin or shop manager or worker",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/schedule/drive-time": {
      "get": {
        "tags": [
          "schedule"
        ],
        "summary": "A day's total drive",
        "description": "How long one person's day of driving takes: from the company address\n(the shop) to the first stop, then from stop to stop in the order asked,\nnot counting the drive back. Ask with the stops of one installer's or\ntemplate maker's day (repeat `address`; at most 20 used).",
        "operationId": "get_schedule_drive_time",
        "parameters": [
          {
            "name": "address",
            "in": "query",
            "description": "The day's stops in order (repeat the parameter; at most 20 drawn).",
            "required": false,
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              }
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Drive time",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DriveTime"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee, admin or shop manager or worker",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/schedule/optimize-route": {
      "post": {
        "tags": [
          "schedule"
        ],
        "summary": "Optimize a day's route",
        "description": "Orders the events from the farthest stop back toward the company address\n(or in the approved `order` from the preview) and hands the day's existing start\ntimes out in that order (each event keeps its length). All-day and\nrepeating events are ordered but keep their times. Moved events get a\nhistory line and re-timed reminders.",
        "operationId": "optimize_schedule_route",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RouteInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Route",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OptimizedRoute"
                }
              }
            }
          },
          "400": {
            "description": "Fewer than 2 or more than 20 events, events without an address, an order that is not those events, or no company address",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee, admin or shop manager or worker",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "502": {
            "description": "Google Maps could not build the route",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/schedule/route-preview": {
      "post": {
        "tags": [
          "schedule"
        ],
        "summary": "Preview a day's route",
        "description": "The order from the farthest stop back toward the company address and the\nnew times the timed events would get, without saving anything. Send the\norder back to `optimize-route` to apply it.",
        "operationId": "preview_schedule_route",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RouteInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Proposed route",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RoutePreview"
                }
              }
            }
          },
          "400": {
            "description": "Fewer than 2 or more than 20 events, events without an address, or no company address",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee, admin or shop manager or worker",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "502": {
            "description": "Google Maps could not build the route",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/schedule/best-days": {
      "post": {
        "tags": [
          "schedule"
        ],
        "summary": "Best days for a waiting job",
        "description": "Miles and driving minutes from the job to every one-off event of its\ncalendar with an address between now (or the range start, if later) and\nthe range end. The app lights up the closest events while the job is\ndragged. Template and installation jobs; any other job gets no stops.",
        "operationId": "schedule_best_days",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/BestDaysInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Distances",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BestDays"
                }
              }
            }
          },
          "400": {
            "description": "The range ends before it starts",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin, or lacks the Best days while dragging skill",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such event in the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/schedule/geocode": {
      "post": {
        "tags": [
          "schedule"
        ],
        "summary": "Place addresses on the map",
        "description": "Where each address is, for the pins of the schedule's events map.",
        "operationId": "schedule_geocode",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/GeocodeInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "The places",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Geocoded"
                }
              }
            }
          },
          "400": {
            "description": "More than 50 addresses",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller lacks the Events map skill",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/schedule/events": {
      "get": {
        "tags": [
          "schedule"
        ],
        "summary": "The schedule's events",
        "description": "One-off events overlapping the range and repeating events that started\nbefore its end and repeat past its start (the page expands them), with\ntheir customers' names and QuickBooks invoices. Events of calendars\nhidden for everyone or from the caller are left out.",
        "operationId": "list_schedule_events",
        "parameters": [
          {
            "name": "start",
            "in": "query",
            "description": "Range start (ISO 8601).",
            "required": true,
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "end",
            "in": "query",
            "description": "Range end (ISO 8601).",
            "required": true,
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Events",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ScheduleEvents"
                }
              }
            }
          },
          "400": {
            "description": "Missing or invalid range",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee, admin or shop manager or worker",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/schedule/unscheduled": {
      "get": {
        "tags": [
          "schedule"
        ],
        "summary": "Events waiting for their day",
        "description": "The company's unscheduled events (kept off the calendar until someone\npicks the date), oldest first, with their customers' names and, while\nQuickBooks is on and connected, their QuickBooks invoices (so an edit\nthat sends `qbo_invoice` back keeps the link). Their dates are only when\nthey were made. Events of calendars hidden for the caller are left out.\nGive one a day with `PUT /v1/events/{id}` and `unscheduled: false`.",
        "operationId": "list_unscheduled_events",
        "responses": {
          "200": {
            "description": "Events",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/ScheduleEvent"
                  }
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee, admin or shop manager or worker",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/me/schedule": {
      "get": {
        "tags": [
          "schedule"
        ],
        "summary": "A personal schedule",
        "description": "The events assigned to the caller or that they were added to (an\ninstaller's or template maker's own day), on any calendar, with their customers' names. An\nadmin or superuser may read an installer's or template maker's schedule\nwith `user_id`.",
        "operationId": "get_my_schedule",
        "parameters": [
          {
            "name": "start",
            "in": "query",
            "description": "Range start (ISO 8601).",
            "required": true,
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "end",
            "in": "query",
            "description": "Range end (ISO 8601).",
            "required": true,
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "user_id",
            "in": "query",
            "description": "Admins and superusers only: whose schedule, an installer or template\nmaker of the company. The caller's own when left out.",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Events",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ScheduleEvents"
                }
              }
            }
          },
          "400": {
            "description": "Missing or invalid range, or not an installer or template maker of the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Another person's schedule, and the caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/schedule/people": {
      "get": {
        "tags": [
          "schedule"
        ],
        "summary": "The schedule's people",
        "description": "The company's installers and template makers (one entry per role a user\nholds), by name, with their schedule colors.",
        "operationId": "list_schedule_people",
        "responses": {
          "200": {
            "description": "People",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/SchedulePerson"
                  }
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee, admin or shop manager or worker",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/schedule/team": {
      "get": {
        "tags": [
          "schedule"
        ],
        "summary": "People who can be added to an event",
        "description": "The company's live employees and admins by name, with their pictures\n(check-in kiosks left out). Send their ids as `people_ids` with\n`POST /v1/events` or `PUT /v1/events/{id}`.",
        "operationId": "list_schedule_team",
        "responses": {
          "200": {
            "description": "People",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/EventPerson"
                  }
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee, admin or shop manager or worker",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/schedule/activity": {
      "get": {
        "tags": [
          "schedule"
        ],
        "summary": "The schedule's activity",
        "description": "The company's events, most recently changed or commented first, each with\nits last three history lines and comments. Deleted events and events of\ncalendars hidden from the caller are left out.",
        "operationId": "list_schedule_activity",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "description": "At most this many events, 1 to 50 (default 20).",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          },
          {
            "name": "offset",
            "in": "query",
            "description": "Skip this many events (the next page).",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Activity",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ScheduleActivity"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee, admin or shop manager or worker",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/schedule/crew-positions": {
      "get": {
        "tags": [
          "schedule"
        ],
        "summary": "Where the crew is",
        "description": "Every installer and template maker of the company with their phone's\nlatest position (Granite Manager sends it from 5 AM until 9 PM), and the\nshop or job they are at. Any signed-in user of the company; the schedule's\nmap of today shows it.",
        "operationId": "get_crew_positions",
        "responses": {
          "200": {
            "description": "The crew, by name",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/CrewPosition"
                  }
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/schedule/people/{user_id}/color": {
      "put": {
        "tags": [
          "schedule"
        ],
        "summary": "Set a person's schedule color",
        "description": "Their events on the Installations or Templates calendar show in it.",
        "operationId": "set_schedule_person_color",
        "parameters": [
          {
            "name": "user_id",
            "in": "path",
            "description": "User id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PersonColor"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Saved"
          },
          "400": {
            "description": "Not a schedule color, or not an installer or template maker of the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/schedule/settings": {
      "get": {
        "tags": [
          "schedule"
        ],
        "summary": "Get the schedule settings",
        "description": "The day the caller's schedule starts its weeks on (their own choice, else\nthe company's: Sunday unless an admin picked Monday), whether they show\n24-hour times, the maps app their addresses open in (null: the device's\nown), whether the Schedule already asked them for those two, the calendar estimates are booked on, and the label color\nthey use most.",
        "operationId": "get_schedule_settings",
        "responses": {
          "200": {
            "description": "Settings",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ScheduleSettings"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "put": {
        "tags": [
          "schedule"
        ],
        "summary": "Set the schedule settings",
        "description": "Saves the day the company's schedule starts its weeks on, the calendar\nestimates are booked on, and whether the sales rep is told when the\ninstaller taps Completed on an installation, for everyone.",
        "operationId": "set_schedule_settings",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ScheduleSettingsInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Saved"
          },
          "400": {
            "description": "Not `sunday` or `monday`, or not a calendar of the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/schedule/settings/me": {
      "put": {
        "tags": [
          "schedule"
        ],
        "summary": "Set my schedule settings",
        "description": "Saves the day the caller's own schedule starts its weeks on, whether it\nshows 24-hour times, the maps app their addresses open in, and that the\nSchedule asked them for those (`prefs_asked`). Only the caller sees them.",
        "operationId": "set_my_schedule_settings",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/MyScheduleSettingsInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Saved"
          },
          "400": {
            "description": "Not `sunday` or `monday`, or not `google` or `apple`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/schedule/statuses": {
      "get": {
        "tags": [
          "schedule"
        ],
        "summary": "Get the job statuses",
        "description": "The company's job statuses in order, and the automations that move jobs\nbetween them.",
        "operationId": "get_job_statuses",
        "responses": {
          "200": {
            "description": "Statuses",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/JobStatuses"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "post": {
        "tags": [
          "schedule"
        ],
        "summary": "Add a job status",
        "description": "A new status of a type (stage), with a name and a palette color, last\nin the company's list. Admins only.",
        "operationId": "create_job_status",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/JobStatusInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Added",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/JobStatus"
                }
              }
            }
          },
          "400": {
            "description": "Missing or long name, or not a palette color",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/schedule/statuses/{key}": {
      "delete": {
        "tags": [
          "schedule"
        ],
        "summary": "Delete a job status",
        "description": "Any status but the last one. Its jobs move to another status of its type\n(else the first one that isn't Confirmed), and automations that moved\njobs to it go back to their usual status.",
        "operationId": "delete_job_status",
        "parameters": [
          {
            "name": "key",
            "in": "path",
            "description": "The status key",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Deleted"
          },
          "400": {
            "description": "The company's last status",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such status at the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "patch": {
        "tags": [
          "schedule"
        ],
        "summary": "Change a job status",
        "description": "Its name, color or type. A starting status given another type becomes a\nnew status (its jobs and automations move with it).",
        "operationId": "update_job_status",
        "parameters": [
          {
            "name": "key",
            "in": "path",
            "description": "The status key",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/JobStatusPatch"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Saved"
          },
          "400": {
            "description": "Missing or long name, or not a palette color",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such status at the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/schedule/statuses/automations": {
      "put": {
        "tags": [
          "schedule"
        ],
        "summary": "Save the status automations",
        "description": "Only the automations sent change; each one's status must be one of the\ncompany's.",
        "operationId": "set_job_status_automations",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AutomationsInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Saved"
          },
          "400": {
            "description": "Not a status of the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/schedule/time-rules": {
      "get": {
        "tags": [
          "schedule"
        ],
        "summary": "Get the job time rules",
        "description": "How long the company's installations and templates take (per square\nfoot, waterfall, sink...) and the work day the Auto-plan fills. Unsaved\nkinds come back with no lengths, 9:00 to 17:00, Monday to Friday.",
        "operationId": "get_schedule_time_rules",
        "responses": {
          "200": {
            "description": "Rules",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CompanyTimeRules"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "put": {
        "tags": [
          "schedule"
        ],
        "summary": "Set the job time rules",
        "description": "Saves how long one kind of job takes and the work day, for everyone.",
        "operationId": "set_schedule_time_rules",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TimeRulesInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Saved"
          },
          "400": {
            "description": "A length over a day, a work day ending before it starts, or no work days",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/schedule/job-time": {
      "get": {
        "tags": [
          "schedule"
        ],
        "summary": "A job's length",
        "description": "How long an installation or template takes, from the company's job time\nrules and the sale (else the customer's latest sale not yet installed).\nNull when the calendar is not Installations or Templates, its rules set\nno lengths, or there is no sale.",
        "operationId": "get_schedule_job_time",
        "parameters": [
          {
            "name": "calendar_id",
            "in": "query",
            "description": "The event's calendar: Installations or Templates.",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "sale_id",
            "in": "query",
            "description": "The event's sale.",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "customer_id",
            "in": "query",
            "description": "The event's customer: their latest sale is used without `sale_id`.",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Length, or null",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/JobTime"
                    },
                    {
                      "type": "null"
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/schedule/auto-plan": {
      "post": {
        "tags": [
          "schedule"
        ],
        "summary": "Auto-plan one person's unscheduled jobs",
        "description": "Proposes a day and time for the unscheduled events of the Templates\ncalendar (templates only for now: installations are scheduled by hand)\nwith one of the statuses that are the person's or\nno one's, around the person's other events (on any calendar). Each job's\nlength comes from its sale and the job time rules (else the event's own\nlength). The person leaves the shop when the work day starts; a free day\nopens with the oldest job, then the nearest job by Google drive time goes\nnext, keeping the drive between stops. Nothing is saved: save the kept\nones with `PUT /v1/events/{id}`.",
        "operationId": "auto_plan_schedule",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AutoPlanInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Plan",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AutoPlan"
                }
              }
            }
          },
          "400": {
            "description": "Not the Templates calendar (installations are not auto-planned for now), days not 1 to 30, or no template maker picked",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/schedule/notifications": {
      "get": {
        "tags": [
          "schedule"
        ],
        "summary": "List the customer notification templates and flows",
        "description": "Texts are left out while the company has no `CloudTalk` or `RingCentral`.",
        "operationId": "list_schedule_notifications",
        "responses": {
          "200": {
            "description": "Templates and flows",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/NotificationSettings"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/schedule/notifications/on-my-way": {
      "put": {
        "tags": [
          "schedule"
        ],
        "summary": "Save the installer's On my way message",
        "description": "What the customer gets when the installer taps On my way (any job not on\nthe Templates calendar): a text, or an email when the company cannot\ntext. An empty message turns it off. The template technician's message is\nsaved with `PUT /v1/schedule/notifications/on-my-way/technician`.",
        "operationId": "set_on_my_way_message",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/OnMyWayMessage"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Saved"
          },
          "400": {
            "description": "Too long",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/schedule/notifications/on-my-way/technician": {
      "put": {
        "tags": [
          "schedule"
        ],
        "summary": "Save the template technician's On my way message",
        "description": "What the customer gets when the template technician taps On my way (a\nTemplates calendar job): a text, or an email when the company cannot\ntext. An empty message turns it off. The installer's message is saved\nwith `PUT /v1/schedule/notifications/on-my-way`.",
        "operationId": "set_technician_on_my_way_message",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/OnMyWayMessage"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Saved"
          },
          "400": {
            "description": "Too long",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/schedule/notifications/lists": {
      "post": {
        "tags": [
          "schedule"
        ],
        "summary": "Add a list of customer messages",
        "description": "A list groups the company's reminders and scheduling texts under Customer\nmessages (e.g. \"Reminders\"); it sends nothing itself. It goes last. Put a\ntemplate in it with `list_id` on `POST`/`PUT /v1/schedule/notifications/templates`.",
        "operationId": "create_schedule_notification_list",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/NotificationListInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Added",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Created"
                }
              }
            }
          },
          "400": {
            "description": "Name missing or too long",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/schedule/notifications/lists/{id}": {
      "put": {
        "tags": [
          "schedule"
        ],
        "summary": "Rename a list of customer messages",
        "description": "Its templates stay in it.",
        "operationId": "update_schedule_notification_list",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "List id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/NotificationListInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Saved"
          },
          "400": {
            "description": "Name missing or too long",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such list in the caller's company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "delete": {
        "tags": [
          "schedule"
        ],
        "summary": "Delete a list of customer messages",
        "description": "Refused while it still holds templates: delete them or move them to\nanother list first, so no message is lost.",
        "operationId": "delete_schedule_notification_list",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "List id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Deleted"
          },
          "400": {
            "description": "It still holds templates",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such list in the caller's company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/schedule/notifications/scheduling": {
      "put": {
        "tags": [
          "schedule"
        ],
        "summary": "Save the scheduling texts' settings",
        "description": "\"Mark Ready when the customer agrees\" and the texting hours follow-ups\nkeep to.",
        "operationId": "set_scheduling_text_settings",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SchedulingSettings"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Saved"
          },
          "400": {
            "description": "No texting day, or the hours end before they start",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/schedule/notifications/caller-id": {
      "get": {
        "tags": [
          "schedule"
        ],
        "summary": "The caller ID name of the Scheduling call",
        "description": "The name the phone companies show when the Scheduling call rings: the one\nlisted (CNAM) for the Scheduling Manager's line on Telnyx.",
        "operationId": "get_scheduling_caller_id",
        "responses": {
          "200": {
            "description": "The line and its caller ID name",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SchedulingCallerId"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "502": {
            "description": "Telnyx did not answer",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "put": {
        "tags": [
          "schedule"
        ],
        "summary": "Set the caller ID name of the Scheduling call",
        "description": "Lists the name (CNAM) for the Scheduling Manager's line on Telnyx, so the\npeople it calls see it instead of a bare number; empty stops listing one.\nThe phone companies take a few days to show a new name.",
        "operationId": "set_scheduling_caller_id",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SchedulingCallerIdInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Saved on Telnyx",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SchedulingCallerId"
                }
              }
            }
          },
          "400": {
            "description": "Too long, a character the phone companies do not take, or no Scheduling Manager line",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "502": {
            "description": "Telnyx did not take it",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/schedule/notifications/scheduling/replies": {
      "put": {
        "tags": [
          "schedule"
        ],
        "summary": "Save the auto-confirm replies",
        "description": "The texts the customer gets back once AI reads their reply to an\nauto-confirm text: `yes_reply` after a clear YES turned the job\nConfirmed, `no_reply` after a NO or a request for another day. An empty\ntext turns that reply off. Read them back with `GET\n/v1/schedule/notifications` (`auto_confirm_replies`).",
        "operationId": "set_auto_confirm_replies",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AutoConfirmReplies"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Saved"
          },
          "400": {
            "description": "A text is over 1600 characters",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/schedule/notifications/templates": {
      "post": {
        "tags": [
          "schedule"
        ],
        "summary": "Add a customer notification template",
        "description": "A text needs `CloudTalk` or `RingCentral`; an email needs a subject.",
        "operationId": "create_schedule_notification_template",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/NotificationTemplateInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Added",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Created"
                }
              }
            }
          },
          "400": {
            "description": "Invalid field, or texting not set up",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/schedule/notifications/templates/order": {
      "put": {
        "tags": [
          "schedule"
        ],
        "summary": "Put customer notification templates in order",
        "description": "The admin's drag order in Admin > Schedule; the event form lists\nconfirmations the same way.",
        "operationId": "order_schedule_notification_templates",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TemplateOrderInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Saved"
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/schedule/notifications/templates/{id}": {
      "put": {
        "tags": [
          "schedule"
        ],
        "summary": "Edit a customer notification template",
        "description": "The flows using it send the new text from then on. It can't become a\nconfirmation while a flow uses it.",
        "operationId": "update_schedule_notification_template",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Template id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/NotificationTemplateInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Saved"
          },
          "400": {
            "description": "Invalid field, texting not set up, or a confirmation a flow uses",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such template in the caller's company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "delete": {
        "tags": [
          "schedule"
        ],
        "summary": "Delete a customer notification template",
        "description": "Refused while a flow uses it.",
        "operationId": "delete_schedule_notification_template",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Template id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Deleted"
          },
          "400": {
            "description": "A flow uses it",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such template in the caller's company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/schedule/notifications/flows": {
      "post": {
        "tags": [
          "schedule"
        ],
        "summary": "Add a customer notification flow",
        "description": "Making it the default unsets the calendar's other default.",
        "operationId": "create_schedule_notification_flow",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/NotificationFlowInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Added",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Created"
                }
              }
            }
          },
          "400": {
            "description": "Invalid field, unknown calendar or template, or texting not set up",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/schedule/notifications/flows/{id}": {
      "put": {
        "tags": [
          "schedule"
        ],
        "summary": "Edit a customer notification flow",
        "description": "Steps sent in `steps` with their id are kept (and not sent again); the\nothers are added, and steps left out are deleted.",
        "operationId": "update_schedule_notification_flow",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Flow id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/NotificationFlowInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Saved"
          },
          "400": {
            "description": "Invalid field, unknown calendar or template, or texting not set up",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such flow in the caller's company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "delete": {
        "tags": [
          "schedule"
        ],
        "summary": "Delete a customer notification flow",
        "description": "Events that had it get none of its messages from then on.",
        "operationId": "delete_schedule_notification_flow",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Flow id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Deleted"
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such flow in the caller's company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/schedule/notifications/active": {
      "get": {
        "tags": [
          "schedule"
        ],
        "summary": "List the notification flows for the event form",
        "description": "Every calendar's flows turned on: the default an event gets, and the\nothers it can pick instead or as well; with `event_id`, whether it turned\nthe default off and which others it picked. Texts are left out while\ntexting is not set up.",
        "operationId": "list_active_schedule_notifications",
        "parameters": [
          {
            "name": "event_id",
            "in": "query",
            "description": "An event of the company whose choices to include.",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The flows",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ActiveFlows"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee, admin or shop manager or worker",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/schedule/booking-hours": {
      "get": {
        "tags": [
          "schedule"
        ],
        "summary": "Get the online booking hours",
        "description": "When customers can book an in-home estimate or a showroom visit from\ntheir customer page: the time zone and the open time ranges per weekday\n(0 = Sunday). Until an admin saves hours, Monday to Friday 9:00 to 18:00\nand Saturday 10:00 to 15:00 in the company's time zone (`is_default`).\nVisits go to the company's Sales Reps and Sales Managers who are free\nthen. Change them with `PUT /v1/schedule/booking-hours`.",
        "operationId": "get_booking_hours",
        "responses": {
          "200": {
            "description": "The hours",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BookingHours"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee, admin or shop manager or worker",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "put": {
        "tags": [
          "schedule"
        ],
        "summary": "Set the online booking hours",
        "description": "Saves when customers can book visits online, for the whole company:\nan IANA time zone and the open time ranges (`HH:MM`, 24-hour, start\nbefore end; `24:00` ends at midnight; at most 28). A weekday without a\nrange is closed; no ranges at all turns online booking off. Returns the\nsaved hours.",
        "operationId": "set_booking_hours",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/BookingHoursInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Saved",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BookingHours"
                }
              }
            }
          },
          "400": {
            "description": "Unknown time zone or an invalid range",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/public/companies/{company_id}/visits/options": {
      "get": {
        "tags": [
          "public"
        ],
        "summary": "Get the visits anyone can book",
        "description": "The kinds of visit (`estimate`: a salesperson comes to the visitor's\naddress; `showroom`: the visitor comes to the showroom), each an hour,\nand the open start times of the next 30 days by local day (ISO 8601 UTC,\nevery 30 minutes, at least 2 hours ahead), as on a customer's page: a\ntime is open inside the company's booking hours when a Sales Rep or\nSales Manager is free then; `salespeople` and each day's `people` say who.\n`address` and `email` are always null here.\nNothing is open while Admin › Stones › Settings hides Schedule a visit.\nBook one with `POST /v1/public/companies/{company_id}/visits`. No session.",
        "operationId": "get_public_visit_options",
        "parameters": [
          {
            "name": "company_id",
            "in": "path",
            "description": "Company id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The kinds and open times",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/VisitOptions"
                }
              }
            }
          },
          "404": {
            "description": "No such company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        }
      }
    },
    "/v1/public/companies/{company_id}/visits": {
      "post": {
        "tags": [
          "public"
        ],
        "summary": "Book a visit from the stones page",
        "description": "Books the kind of visit at one of the open `times` for a visitor who\ngives their name, email, phone (and, for an in-home estimate, the\naddress). A customer the company knows by that email or phone (last 10\ndigits) gets the visit; anyone else becomes a lead (source `leads`, from\nthe `website`). Either way the customer gets an open deal (a new one in\nthe first stage when none is open) with their sales rep, else the\nsalesperson of the visit: the `salesperson_id` picked, else one at random\namong the Sales Reps and Sales Managers free then. The visit lands on the Estimates calendar,\nthe confirmation goes to the email given, and the usual reminders are\nset. At most 3 visits coming per customer and 20 visitor bookings a\ncompany an hour. No session.",
        "operationId": "book_public_visit",
        "parameters": [
          {
            "name": "company_id",
            "in": "path",
            "description": "Company id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PublicBookVisitInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Booked",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BookedVisit"
                }
              }
            }
          },
          "400": {
            "description": "No name, an email that is not one, a phone without 10 digits, no address for an estimate, not a time, or no Estimates calendar",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "409": {
            "description": "The time is no longer open, 3 visits are already coming, or Schedule a visit is hidden in the stone settings",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "429": {
            "description": "20 visitor bookings this hour already",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        }
      }
    },
    "/v1/places/autocomplete": {
      "get": {
        "tags": [
          "places"
        ],
        "summary": "Suggest addresses",
        "description": "US addresses for typed text (3 characters or more), with their parts,\nclosest to the company's address first. A suggestion whose text has no\nZIP has one only when the place was picked before; `GET /v1/places/{place_id}`\ngives the picked suggestion's ZIP.",
        "operationId": "autocomplete_address",
        "parameters": [
          {
            "name": "q",
            "in": "query",
            "description": "Typed text; under 3 characters gives no suggestions.",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Suggestions",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/Suggestion"
                  }
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "502": {
            "description": "Google refused",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/places/{place_id}": {
      "get": {
        "tags": [
          "places"
        ],
        "summary": "Get a place's address",
        "description": "The address parts of a suggestion picked from the autocomplete.",
        "operationId": "get_place",
        "parameters": [
          {
            "name": "place_id",
            "in": "path",
            "description": "Google place id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Place",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PlaceDetails"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "502": {
            "description": "Google refused",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/places/check": {
      "get": {
        "tags": [
          "places"
        ],
        "summary": "Check a street address",
        "description": "Whether Google Maps finds the address as a house number on a street, so a\nquote is not printed or sent as a contract to an address that does not exist.",
        "operationId": "check_address",
        "parameters": [
          {
            "name": "address",
            "in": "query",
            "description": "e.g. `123 Main St, Indianapolis` (state and ZIP optional).",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Result",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AddressCheck"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/calls/{provider}": {
      "get": {
        "tags": [
          "calls"
        ],
        "summary": "List calls with a customer",
        "description": "With `deal_id`: calls with the deal's customer since the deal was created\n(none for another company's deal). With `customer_id`: calls with the\ncustomer's numbers (none for another company's customer). With\n`phone`/`phone2`: every call with those numbers in the date range.\n`cloudtalk` and `ringcentral` add the calls saved from either provider,\nalso one the company no longer uses (only those when it has not set up\nthe provider). `telnyx` reads the\ncompany's Granite Manager call log (ended calls, newest first, at most\n200; calls logged to the customer count too; recordings and AI notes\nonly of the calls the caller may hear, `Telnyx.may_hear`): call the\nrecording route with `Cdr.recording_link` and `POST /v1/call-transcripts`\nwith `Cdr.id`.",
        "operationId": "list_calls",
        "parameters": [
          {
            "name": "provider",
            "in": "path",
            "description": "Telephony provider: `cloudtalk`, `ringcentral` or `telnyx`",
            "required": true,
            "schema": {
              "type": "string",
              "description": "A telephony provider of the call routes: `cloudtalk`, `ringcentral`, or\n`telnyx` (Granite Manager, whose calls are in our own call log).",
              "enum": [
                "cloudtalk",
                "ringcentral",
                "telnyx"
              ]
            }
          },
          {
            "name": "deal_id",
            "in": "query",
            "description": "Calls with the deal's customer since the deal was created.",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          },
          {
            "name": "customer_id",
            "in": "query",
            "description": "Or: calls with this customer of the company (their phone and phone\n2, plus `phone`/`phone2` when sent; `telnyx` also counts calls\nlogged to them). None for another company's customer.",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "phone",
            "in": "query",
            "description": "Or: calls with this phone.",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "phone2",
            "in": "query",
            "description": "And this one.",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "date_from",
            "in": "query",
            "description": "From this day (`YYYY-MM-DD`, UTC for `telnyx`), with `phone` or\n`customer_id`.",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "date_to",
            "in": "query",
            "description": "To this day (included), with `phone` or `customer_id`.",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Calls",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Calls"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "429": {
            "description": "RingCentral is rate limiting; try again in a minute",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "502": {
            "description": "The provider failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "post": {
        "tags": [
          "calls"
        ],
        "summary": "Call a number",
        "description": "`CloudTalk` rings the caller's agent (`CloudTalk` app or phone), then dials\nthe number once they answer. `RingCentral` rings the caller's own line,\nthen connects the number. Errors are tokens the page explains:\n`cloudtalk_not_configured`, `agent_not_linked`, `agent_not_online`,\n`ringcentral_not_configured`, `my_line_missing`,\n`ringcentral_no_call_permission`, `invalid_phone`, `rate_limited`.",
        "operationId": "start_call",
        "parameters": [
          {
            "name": "provider",
            "in": "path",
            "description": "Telephony provider",
            "required": true,
            "schema": {
              "$ref": "#/components/schemas/SmsProvider"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CallInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Ringing",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StartedCall"
                }
              }
            }
          },
          "400": {
            "description": "Not a phone number",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Provider not set up, or the caller has no agent or line",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "429": {
            "description": "More than 10 calls a minute",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "502": {
            "description": "The provider refused",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/call-transcripts": {
      "post": {
        "tags": [
          "calls"
        ],
        "summary": "Transcribe a call",
        "description": "Downloads the call's recording from the provider and transcribes it.\n`RingCentral` voicemail reuses `RingCentral`'s own transcript. A Granite\nPhone call (`tx_<id>`) answers the transcript kept on the call (speaker\nturns as `Speaker A: ...` lines), else transcribes our copy of its\nrecording and keeps it. 404 when the call has no recording to be had\n(none was kept, it is empty, the call is another company's, or it was a\n`CloudTalk` call while `CloudTalk` is switched off), 403 (before anything\nis transcribed) when the caller may not hear it (only the call's user, the users of its direct line, for an\nunanswered incoming call the users its line rings, its deal's owner,\nadmins and sales managers may).",
        "operationId": "transcribe_call",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TranscriptInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Transcript",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CallTranscript"
                }
              }
            }
          },
          "400": {
            "description": "Invalid call id",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin, or may not hear this Granite Manager call",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "The call has no recording to be had: none, empty, another company's call, or a CloudTalk call while CloudTalk is switched off",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "422": {
            "description": "No speech in the recording",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "The recording could not be fetched or transcribed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/calls/{provider}/{media_id}/recording": {
      "get": {
        "tags": [
          "calls"
        ],
        "summary": "Load a call's recording",
        "description": "A link (an hour) to the audio of a recorded call or voicemail: a\n`CloudTalk` call id, or a `RingCentral` media token (`rec_<id>`,\n`vm_<extension>_<message>_<attachment>`) as the call lists give them.\nFor `telnyx`, a Granite Manager call `tx_<id>` of the caller's company\n(`Cdr.recording_link` of `GET /v1/calls/telnyx`): a 5-minute link to our\nprivate copy; 404 for another company's call or one not recorded, 403\nwhen the caller may not hear it (only the call's user, the users of its\ndirect line, for an unanswered incoming call the users its line rings,\nits deal's owner, admins and sales managers may).",
        "operationId": "get_call_recording",
        "parameters": [
          {
            "name": "provider",
            "in": "path",
            "description": "`cloudtalk`, `ringcentral` or `telnyx`",
            "required": true,
            "schema": {
              "type": "string",
              "description": "A telephony provider of the call routes: `cloudtalk`, `ringcentral`, or\n`telnyx` (Granite Manager, whose calls are in our own call log).",
              "enum": [
                "cloudtalk",
                "ringcentral",
                "telnyx"
              ]
            }
          },
          {
            "name": "media_id",
            "in": "path",
            "description": "CloudTalk call id, RingCentral media token, or Granite Manager call `tx_<id>`",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Where to load the audio",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CallRecording"
                }
              }
            }
          },
          "400": {
            "description": "Not a call id or media token of the provider",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin, or may not hear this Granite Manager call",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "The call has no recording (or is not the company's)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "502": {
            "description": "The provider could not be reached",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "503": {
            "description": "No bucket (or no recordings bucket) configured",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/quotes": {
      "get": {
        "tags": [
          "quotes"
        ],
        "summary": "List the company's quotes",
        "description": "The quotes of the caller's company that are not deleted (only one\ncustomer's with `customer_id`), newest first, with their customer, price\nlist and when their email was last viewed. With `page`, one page of\nthose `q` and `show` match, sorted as asked, and `total`; without it,\nevery quote at once.",
        "operationId": "list_quotes",
        "parameters": [
          {
            "name": "customer_id",
            "in": "query",
            "description": "Only this customer's quotes; every quote when absent.",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          },
          {
            "name": "id",
            "in": "query",
            "description": "Only this quote (the delete dialog names it).",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "page",
            "in": "query",
            "description": "The page to return, from 1. Without it the whole list comes back at\nonce and `q`, `show`, `sort` and `dir` are not read (the apps from\nbefore the list was paged search and page it themselves).",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int32",
              "minimum": 0
            }
          },
          {
            "name": "page_size",
            "in": "query",
            "description": "Quotes a page: 20 when absent, at most 500.",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int32",
              "minimum": 0
            }
          },
          {
            "name": "q",
            "in": "query",
            "description": "Search: every word must be in the quote's name, `#id`, customer,\naddress, phone, email, salesperson, price list, or be `sold` or\n`signed` for such a quote; three or more digits also match the\nphone's digits. Matches are ranked: the caller's own first, and\nwithin them and the rest a name starting with the search, then a\nname holding every word, then the others.",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "show",
            "in": "query",
            "description": "`mine`, `all` or `rep:<salesperson's name>`; `default_show` when absent.",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "kind",
            "in": "query",
            "description": "`orders` (sold quotes) or `quotes` (the rest); both when absent.",
            "required": false,
            "schema": {
              "type": "string",
              "description": "Which quotes `GET /v1/quotes` lists: sold ones (orders) or the rest.",
              "enum": [
                "quotes",
                "orders"
              ]
            }
          },
          {
            "name": "sort",
            "in": "query",
            "description": "The column to sort by; newest first (after the search's ranks) when absent.",
            "required": false,
            "schema": {
              "type": "string",
              "description": "A column `GET /v1/quotes` sorts by.",
              "enum": [
                "quote_name",
                "created_date",
                "sales_rep",
                "email_viewed_at"
              ]
            }
          },
          {
            "name": "dir",
            "in": "query",
            "description": "Which way `sort` goes: `asc` when absent.",
            "required": false,
            "schema": {
              "type": "string",
              "description": "Ascending or descending.",
              "enum": [
                "asc",
                "desc"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Quotes",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/QuoteList"
                }
              }
            }
          },
          "400": {
            "description": "Unknown `sort` or `dir`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "post": {
        "tags": [
          "quotes"
        ],
        "summary": "Create a quote",
        "description": "An empty drawing (the company's counter depth and rounding) with the\nprice list's \"always include\" extras, the caller as salesperson when they\nare a sales rep (else the customer's assigned person, whatever their\nposition; else the caller), the customer's address,\nphone and email copied, and the price list's default tax rate and payment\nterms (else the company's first payment terms).",
        "operationId": "create_quote",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/NewQuote"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CreatedId"
                }
              }
            }
          },
          "400": {
            "description": "No customer",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/quotes/{id}": {
      "get": {
        "tags": [
          "quotes"
        ],
        "summary": "Open a quote",
        "description": "The quote, its drawing (a saved revision's with `revision`), its prices\n(the snapshot it was made with plus today's choices, and today's list),\nrevisions, emails, contracts, the sales reps, color photos, the sender\naddress and the caller's unsaved drawing.",
        "operationId": "get_quote",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Quote id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "revision",
            "in": "query",
            "description": "Revision id.",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The quote",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/QuoteDetail"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such quote",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "delete": {
        "tags": [
          "quotes"
        ],
        "summary": "Delete a quote",
        "description": "Soft-deletes one of the company's quotes: it leaves the list, its rows stay.",
        "operationId": "delete_quote",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Quote id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Deleted"
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such quote in the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "patch": {
        "tags": [
          "quotes"
        ],
        "summary": "Change a quote",
        "description": "Its info (name, notes, contact, terms, sales rep, customer), settings\n(tax, discounts, expiration) and price list. A new price list or its\nnewest revision gives the quote today's prices on its next load.",
        "operationId": "update_quote",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Quote id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/QuoteChanges"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Saved"
          },
          "400": {
            "description": "Customer not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such quote",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/quotes/inventory-slabs": {
      "get": {
        "tags": [
          "quotes"
        ],
        "summary": "List a stone's free slabs",
        "description": "Slabs not sold, cut or deleted of the company's stones with this name\n(and type), and of the stones they show slabs from, for a quote's slab\nlayout. What is left of a partly sold slab is marked `leftover`.\n`stone_url` is the photo of such a stone that is in stock (regular\nstock or a free slab), null when none is.",
        "operationId": "list_quote_inventory_slabs",
        "parameters": [
          {
            "name": "name",
            "in": "query",
            "description": "Stone name (any case).",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "type",
            "in": "query",
            "description": "Stone type (any case); any type when empty.",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Slabs",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InventorySlabs"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or shop staff",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/quotes/square-feet": {
      "get": {
        "tags": [
          "quotes"
        ],
        "summary": "List quotes' countertop square feet",
        "description": "The countertop sq ft of each of these quotes of the company, as the quote\npage shows it: every area of the drawing, rounded as the quote's prices\nround material (its price snapshot, else its price list revision), times\nthe area's quantity. For a day's total on the schedule, where opening\nevery quote (`GET /v1/quotes/{id}`) to add them up is far too much.\nDeleted quotes and other companies' are left out; a quote with no drawing\nhas 0. Ordered by id.",
        "operationId": "list_quote_square_feet",
        "parameters": [
          {
            "name": "ids",
            "in": "query",
            "description": "Quote ids (`ids=1&ids=2`), at most 200.",
            "required": false,
            "schema": {
              "type": "array",
              "items": {
                "type": "integer",
                "format": "int32"
              }
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Each quote's sq ft",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/QuoteSquareFeet"
                  }
                }
              }
            }
          },
          "400": {
            "description": "More than 200 quotes asked for",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/quotes/print-previews": {
      "post": {
        "tags": [
          "quotes"
        ],
        "summary": "Open a printed quote",
        "description": "The quote page draws the PDF in the browser; this gives it a place in the\nbucket (`quote-previews/`) and a link to open it under its file name in\nthe print window. Replaces the CRM's in-memory preview (10 minutes);\nthe bucket's lifecycle rule removes old previews.",
        "operationId": "create_quote_print_preview",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PrintPreviewInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Upload and open links",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrintPreview"
                }
              }
            }
          },
          "400": {
            "description": "Not a PDF file name",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "503": {
            "description": "No bucket configured",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/schedule/job-chips": {
      "get": {
        "tags": [
          "schedule"
        ],
        "summary": "List schedule jobs' stones and sq ft",
        "description": "For each of these events of the company, what its card on \"My schedule\"\nshows: the stones of its project's sales and its sq ft. The project is the\nevent's sales as `GET /v1/events/{id}/sale` finds them. The sq ft is that\nof the customer's sold quotes at the event's address (a customer whose\nsold quotes are all one job lends them when there is no street to\ncompare), else the rooms of the project's sales. Events of other\ncompanies, deleted ones and unknown ids are left out. Open one job's\nwhole project with `GET /v1/events/{id}/sale` and `GET /v1/sales/{id}`.",
        "operationId": "list_schedule_job_chips",
        "parameters": [
          {
            "name": "ids",
            "in": "query",
            "description": "Event ids (`ids=1&ids=2`), at most 100.",
            "required": false,
            "schema": {
              "type": "array",
              "items": {
                "type": "integer",
                "format": "int32"
              }
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Each found event's stones and sq ft, in id order",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/JobChips"
                  }
                }
              }
            }
          },
          "400": {
            "description": "More than 100 events asked for",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/delayed/sms": {
      "get": {
        "tags": [
          "delayed"
        ],
        "summary": "List my scheduled texts to a phone",
        "description": "Sends the caller's due messages first.",
        "operationId": "list_delayed_sms",
        "parameters": [
          {
            "name": "phone_digits",
            "in": "query",
            "description": "The thread's phone, 5 to 15 digits.",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Scheduled texts, soonest first",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/Pending"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Not a thread phone",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/delayed/emails": {
      "get": {
        "tags": [
          "delayed"
        ],
        "summary": "List my scheduled emails in a conversation or to a customer",
        "description": "Sends the caller's due messages first; empty without a thread or customer.",
        "operationId": "list_delayed_emails",
        "parameters": [
          {
            "name": "thread_id",
            "in": "query",
            "description": "The conversation.",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "customer_id",
            "in": "query",
            "description": "Or the customer.",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Scheduled emails, soonest first",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/Pending"
                  }
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/delayed/{kind}/{id}": {
      "put": {
        "tags": [
          "delayed"
        ],
        "summary": "Edit a scheduled message",
        "description": "Replaces the text (an email's body) and the send time.",
        "operationId": "edit_delayed",
        "parameters": [
          {
            "name": "kind",
            "in": "path",
            "description": "`sms` or `emails`",
            "required": true,
            "schema": {
              "type": "string",
              "description": "Which scheduled messages.",
              "enum": [
                "sms",
                "emails"
              ]
            }
          },
          {
            "name": "id",
            "in": "path",
            "description": "Row id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/EditPending"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Saved"
          },
          "400": {
            "description": "Past or too far send time",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "Not the caller's pending message",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "delete": {
        "tags": [
          "delayed"
        ],
        "summary": "Cancel a scheduled message",
        "description": "It will not be sent.",
        "operationId": "cancel_delayed",
        "parameters": [
          {
            "name": "kind",
            "in": "path",
            "description": "`sms` or `emails`",
            "required": true,
            "schema": {
              "type": "string",
              "description": "Which scheduled messages.",
              "enum": [
                "sms",
                "emails"
              ]
            }
          },
          {
            "name": "id",
            "in": "path",
            "description": "Row id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Cancelled"
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "Not the caller's pending message",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/delayed/{kind}/{id}/send-now": {
      "post": {
        "tags": [
          "delayed"
        ],
        "summary": "Send a scheduled message now",
        "description": "Sends it right away, even if the customer has written since.",
        "operationId": "send_delayed_now",
        "parameters": [
          {
            "name": "kind",
            "in": "path",
            "description": "`sms` or `emails`",
            "required": true,
            "schema": {
              "type": "string",
              "description": "Which scheduled messages.",
              "enum": [
                "sms",
                "emails"
              ]
            }
          },
          {
            "name": "id",
            "in": "path",
            "description": "Row id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Sent (or failed; the row says which)"
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "Not the caller's pending message",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/ai-usage/overview": {
      "get": {
        "tags": [
          "ai-usage"
        ],
        "summary": "AI usage overview",
        "description": "Spend this month, last month to date, ever and in the range; calls, cost,\nsuccess and models by feature; models logged at $0 without a price; and a\npage of the range's calls. Optionally one company. Super users only.",
        "operationId": "get_ai_usage_overview",
        "parameters": [
          {
            "name": "from_date",
            "in": "query",
            "description": "First day of the range.",
            "required": true,
            "schema": {
              "type": "string",
              "format": "date"
            }
          },
          {
            "name": "to_date",
            "in": "query",
            "description": "Last day of the range.",
            "required": true,
            "schema": {
              "type": "string",
              "format": "date"
            }
          },
          {
            "name": "company_id",
            "in": "query",
            "description": "Only this company.",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "page",
            "in": "query",
            "description": "Calls page, from 1 (past the last page: the last page).",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          },
          {
            "name": "page_size",
            "in": "query",
            "description": "Calls per page: 10, 20 (default), 50, 100, 200 or 500.",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          },
          {
            "name": "tz",
            "in": "query",
            "description": "The viewer's IANA time zone (`Europe/Kyiv`): the range's days and\nthis / last month are that zone's. Missing or unknown: UTC.",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Usage",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UsageOverview"
                }
              }
            }
          },
          "400": {
            "description": "Missing or invalid days",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not a super user",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/ai-usage/feature": {
      "get": {
        "tags": [
          "ai-usage"
        ],
        "summary": "Get one AI feature's usage",
        "description": "Totals, the five costliest users and the latest calls of a feature in\na date range (optionally one company). Super users only.",
        "operationId": "get_ai_feature_usage",
        "parameters": [
          {
            "name": "feature",
            "in": "query",
            "description": "Feature key, up to 50 of `a-z 0-9 _ . : -`.",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "from_date",
            "in": "query",
            "description": "First day (default: all time).",
            "required": false,
            "schema": {
              "type": "string",
              "format": "date"
            }
          },
          {
            "name": "to_date",
            "in": "query",
            "description": "Last day.",
            "required": false,
            "schema": {
              "type": "string",
              "format": "date"
            }
          },
          {
            "name": "company_id",
            "in": "query",
            "description": "Only this company.",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "call_limit",
            "in": "query",
            "description": "Recent calls shown, 1 to 200 (default 20).",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          },
          {
            "name": "tz",
            "in": "query",
            "description": "The viewer's IANA time zone (`Europe/Kyiv`): the days are that\nzone's. Missing or unknown: UTC.",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Usage",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FeatureUsage"
                }
              }
            }
          },
          "400": {
            "description": "Not a feature key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not a super user",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/ai-models": {
      "get": {
        "tags": [
          "ai-usage"
        ],
        "summary": "List the AI steps and their models",
        "description": "Every AI step whose model can be changed without a new build: its\nfeature, what it does, the model the code asks for, the model picked for\nevery company and the companies with their own pick, and the feature's\ncalls of the last 7 days by model. Also the models that can be picked\n(OpenAI models with a price in force today, with their prices) and the\nreasoning efforts. Change one with `POST /v1/ai-models/settings`. Super\nusers only.",
        "operationId": "list_ai_models",
        "responses": {
          "200": {
            "description": "The steps and the models",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AiModelsPage"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not a super user",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/ai-models/settings": {
      "post": {
        "tags": [
          "ai-usage"
        ],
        "summary": "Pick the model of an AI step",
        "description": "Sets the model (and optionally the reasoning effort) a step uses, for\nevery company or for one company, whose own pick wins. A null model puts\nthe step back on the code's default. It takes effect within 10 minutes,\nwith no deploy. When the picked model does not answer (OpenAI refuses the\nmodel or effort or is busy, the request fails, the answer is empty), the\ncall is made again on the code's model, so a wrong pick slows the feature\ninstead of breaking it; check the step's `recent` calls in\n`GET /v1/ai-models`. A pick that timed out is not asked again for a step\nwith `effort_locked` (suggestions while typing) or a call that waits more\nthan 2 minutes. The model must be one of `GET /v1/ai-models` `models` of\nthe step's kind. Refused with 400: an effort on a step with\n`effort_locked`, and a sol model without an effort (or with `none`) on a\nstep whose `note` says it is asked with no thinking.\nSuper users only.",
        "operationId": "set_ai_model",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SetAiModel"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Saved"
          },
          "400": {
            "description": "No such step or company, a model of another kind or without a price, a model or effort the step cannot run (see its `note`), or an effort without a model, on a non-text step or not one of the efforts",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not a super user",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/ai-models/history": {
      "get": {
        "tags": [
          "ai-usage"
        ],
        "summary": "List changes of AI models",
        "description": "Who picked which model for which step and company, and when, newest\nfirst; a null model is a step put back on its default. Super users only.",
        "operationId": "list_ai_model_changes",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "description": "Most changes to return, 1 to 200; 100 by default.",
            "required": false,
            "schema": {
              "type": [
                "integer",
                "null"
              ],
              "format": "int32",
              "minimum": 0
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The changes",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/AiModelChange"
                  }
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not a super user",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/auth/login": {
      "post": {
        "tags": [
          "auth"
        ],
        "summary": "Sign in",
        "description": "Checks the email and password; on success creates a session (it lasts\nuntil sign-out: never by time),\nsets it as the `__session` cookie (HttpOnly, SameSite=Lax, Secure in\nproduction) and says where the user starts. Too many failed attempts\nfor the email (or from the address for every email) answer 429 until the\n15-minute window passes. A wrong email and a wrong password answer the\nsame 401. The page's robot check (`turnstile_token`) is only logged.\n\nWhen the account needs another step first, answers 202 with a\n`LoginChallenge` instead and sets no cookie: `code` (two-step sign-in is\non: `POST /v1/auth/login/code`), `new_password` (the password is 1111:\n`POST /v1/auth/login/password`) or `setup_authenticator` (superusers must\nturn on two-step sign-in: `POST /v1/auth/login/authenticator`). The last\nstep signs in as this route would.",
        "operationId": "sign_in",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/LoginInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Signed in; the session cookie is set",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AuthSession"
                }
              }
            }
          },
          "202": {
            "description": "Right password; another step is needed first",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LoginChallenge"
                }
              }
            }
          },
          "400": {
            "description": "Email or password missing",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "Incorrect email or password",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "The user has no position, or the password is 1111",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "429": {
            "description": "Too many failed attempts",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        }
      }
    },
    "/v1/auth/logout": {
      "post": {
        "tags": [
          "auth"
        ],
        "summary": "Sign out",
        "description": "Ends the request's session (it no longer signs anyone in, even if the\ncookie is replayed) and clears the cookie. The browser phone of the\nsession (Granite Manager in the CRM) is signed out too: its Telnyx\ncredential is deleted. Always answers 204.",
        "operationId": "sign_out",
        "responses": {
          "204": {
            "description": "Signed out; the cookie is cleared"
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        }
      }
    },
    "/v1/auth/session": {
      "get": {
        "tags": [
          "auth"
        ],
        "summary": "The current session",
        "description": "The signed-in user (for a super admin, in the company they act in), the\npath they start at, the acting company's subdomain and the companies a\nsuper admin can switch to. 401 when signed out.\n\nThe CRM asks this as every page opens, so it also sets the cookie again\nfor its full 400 days (sessions never end by time; one from before that\nstops ending here). The CRM's own hosts answer this path too (their\nCloudFront passes it here): Safari keeps a cookie set by a server on\nanother IP range than the page (this API) for 7 days only, but not one\nset by the page's own host.",
        "operationId": "get_auth_session",
        "responses": {
          "200": {
            "description": "Signed in",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AuthSession"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/auth/active-company": {
      "put": {
        "tags": [
          "auth"
        ],
        "summary": "Act in another company",
        "description": "A super admin picks which of their companies requests act in; the\nchoice is kept in the session cookie (its other contents stay).",
        "operationId": "set_active_company",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ActiveCompany"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Switched; the cookie is updated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AuthSession"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Not a super admin of that company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/auth/password-reset": {
      "post": {
        "tags": [
          "auth"
        ],
        "summary": "Email a password reset link",
        "description": "When the email belongs to an account (and none was sent to it in the last\nminute), stores a new one-hour link (older ones stop working) and emails\nit. Always answers 202 the same way, so it does not tell which emails\nhave accounts. The page's robot check (`turnstile_token`) is only logged.",
        "operationId": "request_password_reset",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ResetRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "202": {
            "description": "If the account exists, a link is on its way"
          },
          "400": {
            "description": "Not an email address",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "502": {
            "description": "The email could not be sent",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        }
      }
    },
    "/v1/auth/password-reset/{token}": {
      "get": {
        "tags": [
          "auth"
        ],
        "summary": "Check a reset link",
        "description": "204 while the link can still set a password, 404 when it is unknown,\nused or expired.",
        "operationId": "check_password_reset",
        "parameters": [
          {
            "name": "token",
            "in": "path",
            "description": "The token from the emailed link",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "The link works"
          },
          "404": {
            "description": "Invalid or expired link",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "auth"
        ],
        "summary": "Set a new password",
        "description": "Uses a reset link once: sets the password (bcrypt), spends the link and\nends every session of the user, Granite Manager sign-ins included.",
        "operationId": "reset_password",
        "parameters": [
          {
            "name": "token",
            "in": "path",
            "description": "The token from the emailed link",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/NewPassword"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Password set; sign in again"
          },
          "400": {
            "description": "Password too short",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "Invalid or expired link",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        }
      }
    },
    "/v1/auth/invite/{token}": {
      "get": {
        "tags": [
          "auth"
        ],
        "summary": "Check an invite link",
        "description": "Whose invite it is while the link can still set up the account; 404 when\nit is unknown, used or expired, or the account already has a password.",
        "operationId": "check_invite",
        "parameters": [
          {
            "name": "token",
            "in": "path",
            "description": "The token from the emailed link",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The link works",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InviteDetails"
                }
              }
            }
          },
          "404": {
            "description": "Invalid or expired link",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "auth"
        ],
        "summary": "Set up an invited account",
        "description": "Uses an invite link once: saves the user's name, phone and password\n(bcrypt), spends the link and signs in as `POST /v1/auth/login` does.",
        "operationId": "accept_invite",
        "parameters": [
          {
            "name": "token",
            "in": "path",
            "description": "The token from the emailed link",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/JoinInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Set up and signed in; the session cookie is set",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AuthSession"
                }
              }
            }
          },
          "400": {
            "description": "Name missing, phone or password too short",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "Invalid or expired link",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        }
      }
    },
    "/v1/auth/login/code": {
      "post": {
        "tags": [
          "auth"
        ],
        "summary": "Send the authenticator code of a sign-in",
        "description": "The `code` step: checks the 6-digit code of the user's authenticator\napp (the current one, or the one just before or after). A code works\nonce. Answers the next step (202 `StepDone`) or signs in: 200\n`AuthSession` with the session cookie for a CRM sign-in, 201\n`DeviceSession` for the app's. A wrong code is 400; the fifth wrong code\nends the sign-in (401), and wrong codes count with wrong passwords for\nthe 429 limits.",
        "operationId": "submit_sign_in_code",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CodeInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Signed in (CRM); the session cookie is set",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AuthSession"
                }
              }
            }
          },
          "201": {
            "description": "Signed in (app); the device token is in the body",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DeviceSession"
                }
              }
            }
          },
          "202": {
            "description": "Another step is needed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StepDone"
                }
              }
            }
          },
          "400": {
            "description": "Wrong code",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "The sign-in expired or had too many wrong codes",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "409": {
            "description": "This step is not the one the sign-in needs",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "429": {
            "description": "Too many failed attempts",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        }
      }
    },
    "/v1/auth/login/password": {
      "post": {
        "tags": [
          "auth"
        ],
        "summary": "Choose a new password at sign-in",
        "description": "The `new_password` step (the password was 1111): sets the new password\n(8 characters or more, not 1111), then answers the next step (202\n`StepDone`) or signs in: 200 `AuthSession` with the session cookie for a\nCRM sign-in, 201 `DeviceSession` for the app's. Other sessions of the\nuser stay signed in.",
        "operationId": "set_sign_in_password",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PasswordInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Signed in (CRM); the session cookie is set",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AuthSession"
                }
              }
            }
          },
          "201": {
            "description": "Signed in (app); the device token is in the body",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DeviceSession"
                }
              }
            }
          },
          "202": {
            "description": "Another step is needed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StepDone"
                }
              }
            }
          },
          "400": {
            "description": "Password too short, or 1111",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "The sign-in expired",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "409": {
            "description": "This step is not the one the sign-in needs",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        }
      }
    },
    "/v1/auth/login/authenticator": {
      "post": {
        "tags": [
          "auth"
        ],
        "summary": "Get the authenticator QR code at sign-in",
        "description": "The `setup_authenticator` step (superusers must use two-step sign-in):\nthe secret to add to an authenticator app, as a QR code to scan, an\n`otpauth://` link to open on the phone that has the app, and the secret\nto type in. Asking again within 10 minutes answers the same secret.\nNext: `POST /v1/auth/login/authenticator/confirm` with the code the app\nthen shows.",
        "operationId": "start_sign_in_authenticator",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TokenInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "What to add to the authenticator app",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AuthenticatorSetup"
                }
              }
            }
          },
          "401": {
            "description": "The sign-in expired",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "409": {
            "description": "This step is not the one the sign-in needs",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        }
      }
    },
    "/v1/auth/login/authenticator/confirm": {
      "post": {
        "tags": [
          "auth"
        ],
        "summary": "Turn on two-step sign-in at sign-in",
        "description": "The `setup_authenticator` step's end: the first code the authenticator\napp shows for the secret of `POST /v1/auth/login/authenticator`. Turns\ntwo-step sign-in on (every later sign-in asks for a code) and signs in:\n200 `AuthSession` with the session cookie for a CRM sign-in, 201\n`DeviceSession` for the app's. A wrong code is 400; the fifth ends the\nsign-in (401).",
        "operationId": "confirm_sign_in_authenticator",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CodeInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Signed in (CRM); the session cookie is set",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AuthSession"
                }
              }
            }
          },
          "201": {
            "description": "Signed in (app); the device token is in the body",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DeviceSession"
                }
              }
            }
          },
          "202": {
            "description": "Another step is needed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StepDone"
                }
              }
            }
          },
          "400": {
            "description": "Wrong code",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "The sign-in expired or had too many wrong codes",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "409": {
            "description": "This step is not the one the sign-in needs",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "429": {
            "description": "Too many failed attempts",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        }
      }
    },
    "/v1/auth/password-reset-code": {
      "post": {
        "tags": [
          "auth"
        ],
        "summary": "Email a password reset code",
        "description": "When the email belongs to an account (and no code or link was sent to it\nin the last minute), stores a new 15-minute code (older codes and links\nstop working) and emails it. Always answers 202 the same way, so it does\nnot tell which emails have accounts.",
        "operationId": "request_password_reset_code",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ResetCodeRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "202": {
            "description": "If the account exists, a code is on its way"
          },
          "400": {
            "description": "Not an email address",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "502": {
            "description": "The email could not be sent",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        }
      }
    },
    "/v1/auth/password-reset-code/confirm": {
      "post": {
        "tags": [
          "auth"
        ],
        "summary": "Set a new password with an emailed code",
        "description": "Uses a code once: sets the password (bcrypt), spends the code and ends\nevery session of the user. Then the app signs in with the new password\n(and its two-step sign-in, when on, asks for a code again). When the user\nhas two-step sign-in on, `authenticator_code` must be a current code of\ntheir authenticator app: without one a right email code answers 409\n`authenticator_code_required` (the email code stays good); a wrong one\ncounts as a failure.",
        "operationId": "confirm_password_reset_code",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ResetCodeConfirm"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Password set; sign in with it"
          },
          "400": {
            "description": "Wrong or expired code, wrong authenticator code, or password too short",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "409": {
            "description": "`authenticator_code_required`: the email code is right; two-step sign-in is on, so send `authenticator_code` too",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "429": {
            "description": "Too many failed attempts",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        }
      }
    },
    "/v1/app/shell": {
      "get": {
        "tags": [
          "auth"
        ],
        "summary": "The app frame",
        "description": "The signed-in user (in the company they act in), the super admin company\nswitcher, the acting company's name and logo, the portal a position locks\nthe user into, and the features and permissions the frame switches on.",
        "operationId": "get_app_shell",
        "responses": {
          "200": {
            "description": "The frame",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AppShell"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/me/onboarding": {
      "get": {
        "tags": [
          "me"
        ],
        "summary": "My onboarding progress",
        "description": "The first-run journey, feature tours and points saved for the signed-in\nuser (their home company's journey). `has_row` is false before any.\n`usage` lists the features the user already uses (check id -> first use):\nthe app never starts those tours by itself and offers them only as\n0-point replays. Data checks run here (positives are cached); it is empty\nwhile the company's guided tours are off. `account_created_at` dates the\naccount (new-user pacing of tours). `state.sightings` holds, per task id,\nwhen the user first met a tour's opening control on its page before the\ntour ever ran; the app starts that tour by itself only on a later local\nday. Sightings at or before the user's feature-tour reset are left out.",
        "operationId": "get_my_onboarding",
        "responses": {
          "200": {
            "description": "Progress",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OnboardingRecord"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Not an employee or shop user",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/me/onboarding/events": {
      "post": {
        "tags": [
          "me"
        ],
        "summary": "Save onboarding progress",
        "description": "Applies the events in one write. Replays are harmless; events dated\nbefore the user's last reset are dropped; task events are dropped while\nthe home company's guided tours are off, for retired tours, and for setup\ntasks only the server may complete. Points come from the tour registry,\nnever from the request.",
        "operationId": "save_my_onboarding_events",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/EventsInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Saved",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AppliedProgress"
                }
              }
            }
          },
          "400": {
            "description": "Malformed events",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Not an employee or shop user",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/me/onboarding/usage": {
      "post": {
        "tags": [
          "me"
        ],
        "summary": "Report a feature use",
        "description": "Records that the signed-in user used a feature only the app can see (a\npanel opened in the browser), so its guided tour is treated as already\nused: the first report stamps the time, later ones change nothing. Ignored\n(still 204) while the home company's guided tours are off. Read the result\nin `usage` of `GET /v1/me/onboarding`.",
        "operationId": "report_my_onboarding_usage",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UsageInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Recorded, or ignored while guided tours are off"
          },
          "400": {
            "description": "Not a check the app reports itself",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Not an employee or shop user",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/me/onboarding/reset": {
      "post": {
        "tags": [
          "me"
        ],
        "summary": "Restart the first-run journey",
        "description": "Clears the old tours' modules and position; feature tours and points\nstay. Events the device still holds from before are dropped.",
        "operationId": "reset_my_onboarding",
        "responses": {
          "204": {
            "description": "Restarted"
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Not an employee or shop user",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/me/onboarding/setup": {
      "get": {
        "tags": [
          "me"
        ],
        "summary": "The onboarding widget",
        "description": "The user's onboarding profile and progress, the setup checklist, and\ncredit for setup work already done (the email name, signature and\nTelegram tasks complete with their points, once). `credit` is null unless\nsomething was credited just now.",
        "operationId": "get_my_onboarding_setup",
        "responses": {
          "200": {
            "description": "The widget's data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SetupPage"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or of the shop",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/me/onboarding/claim": {
      "post": {
        "tags": [
          "me"
        ],
        "summary": "Claim a setup task",
        "description": "Completes a setup task, with its points, when the user's own setup shows\nits work is done; a second claim pays nothing more.",
        "operationId": "claim_my_onboarding_task",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ClaimInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "The outcome",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ClaimResult"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or of the shop",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/onboarding/team": {
      "get": {
        "tags": [
          "onboarding"
        ],
        "summary": "The onboarding team",
        "description": "The employees of the company the request acts in, with the facts the\ntour registry reads (admin, manager and shop positions, a texting line),\nthe company's capabilities and everyone's saved tours progress, the\nfeatures they already use, their sections and phone and message access.\nWhile the company's guided tours are off, `enabled` is false and the list\nempty.",
        "operationId": "get_onboarding_team",
        "responses": {
          "200": {
            "description": "The team",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Team"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/ai/improve": {
      "post": {
        "tags": [
          "ai"
        ],
        "summary": "Improve a draft",
        "description": "Rewrites a customer-facing email or text: grammar, spelling and slightly\nbetter wording, same meaning, facts and links. The reply is the raw text.\nWith `partial`, only a selected part of a draft is sent and the reply is\nshaped to be put back in its place.",
        "operationId": "improve_message",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ImproveInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Improved draft",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Improved"
                }
              }
            }
          },
          "400": {
            "description": "Empty draft",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "502": {
            "description": "OpenAI failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/ai/call-note": {
      "post": {
        "tags": [
          "ai"
        ],
        "summary": "Summarize a call",
        "description": "A CRM note of the job facts in a sales call (or a short voicemail note).",
        "operationId": "summarize_call_note",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CallNoteInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Note",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CallNote"
                }
              }
            }
          },
          "400": {
            "description": "Empty transcript",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "422": {
            "description": "Nothing work-related in the transcript",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "502": {
            "description": "OpenAI failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/ai/call-activities": {
      "post": {
        "tags": [
          "ai"
        ],
        "summary": "Extract activities from a call",
        "description": "The follow-up tasks of a call (call backs, links and quotes to send,\nphotos to wait for, on-site estimates) with their deadlines, read by AI\nand checked against the transcript.",
        "operationId": "extract_call_activities",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CallActivitiesInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Activities",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CallActivities"
                }
              }
            }
          },
          "400": {
            "description": "Empty transcript",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "502": {
            "description": "OpenAI failed or answered with something else",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/ai/email-template": {
      "post": {
        "tags": [
          "ai"
        ],
        "summary": "Draft an email template",
        "description": "Writes a template name, subject and HTML body from a description, using\nthe built-in `{{variables}}` where it can.",
        "operationId": "draft_email_template",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/EmailTemplateInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Template",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EmailTemplateDraft"
                }
              }
            }
          },
          "400": {
            "description": "Empty description",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "502": {
            "description": "OpenAI failed or answered without a template",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/ai/port-details-check": {
      "post": {
        "tags": [
          "ai"
        ],
        "summary": "Check a port's business details with AI",
        "description": "Reads the Business details step as typed and lists what looks wrong\nbefore it is saved. Nothing is saved or sent to Telnyx.",
        "operationId": "check_port_details",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PortCheckInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "What looks wrong",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PortCheckResult"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "502": {
            "description": "OpenAI failed or answered without a list",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/ai/port-ask": {
      "post": {
        "tags": [
          "ai"
        ],
        "summary": "Ask AI about a port's steps",
        "description": "Answers a question such as what goes in a field or what to upload, from\nthe step the user is on and the details as typed. Nothing is saved.",
        "operationId": "ask_port",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PortAskInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "The answer",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PortAskResult"
                }
              }
            }
          },
          "400": {
            "description": "No question, or a question too long",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "502": {
            "description": "OpenAI failed or answered nothing",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/ai/port-bill-read": {
      "post": {
        "tags": [
          "ai"
        ],
        "summary": "Read a port's business details from the carrier's bill with AI",
        "description": "Reads a PDF, JPEG or PNG of the current carrier's bill (at most 4 MB,\nsent base64) and returns the Business details it shows, copied as\nprinted. Nothing is saved, kept or sent to Telnyx. Company admins (and\nsuper admins, superusers) only.",
        "operationId": "read_port_bill",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PortBillInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "What the bill shows",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PortBillDetails"
                }
              }
            }
          },
          "400": {
            "description": "Not base64, empty, too big, or not a PDF, JPEG or PNG",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "502": {
            "description": "OpenAI failed or answered without the details",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/ai/stone-colors": {
      "post": {
        "tags": [
          "ai"
        ],
        "summary": "Pick a stone's colors from its photo with AI",
        "description": "Reads a JPEG, PNG or WebP photo of a stone (at most 4 MB, sent base64)\nand returns the colors from `GET /v1/colors` that it shows: the main\ncolor first, then up to 3 more, surest first. Nothing is saved. Company\nadmins (and super admins, superusers) only.",
        "operationId": "pick_stone_colors",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/StoneColorsInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "The colors the photo shows",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StoneColors"
                }
              }
            }
          },
          "400": {
            "description": "Not base64, empty, too big, or not a JPEG, PNG or WebP",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "502": {
            "description": "OpenAI failed or answered without colors",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/ai/transcribe": {
      "post": {
        "tags": [
          "ai"
        ],
        "summary": "Turn speech into text",
        "description": "Transcribes a short recording of the caller asking something (the Agent\npage's microphone) with OpenAI's speech-to-text. Nothing is stored.",
        "operationId": "transcribe_speech",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TranscribeInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "What was said",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Transcript"
                }
              }
            }
          },
          "400": {
            "description": "Not base64, empty, too long, or not a recording type OpenAI takes",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "502": {
            "description": "OpenAI failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/ai/invoice-edit": {
      "post": {
        "tags": [
          "ai"
        ],
        "summary": "Propose an invoice edit",
        "description": "Applies a plain-language instruction to the invoice with AI and returns\nthe result for the editor to preview. Nothing is saved.",
        "operationId": "propose_invoice_edit",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/InvoiceEditInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Proposed invoice",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InvoiceEdit"
                }
              }
            }
          },
          "400": {
            "description": "Empty or too long instruction",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "502": {
            "description": "OpenAI failed or answered with something else",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/ai/signature-fields": {
      "post": {
        "tags": [
          "ai"
        ],
        "summary": "Label the blanks of a contract",
        "description": "The e-signature editor's Auto-detect: for each blank (with the words\naround it) the AI says whether it is a signature, a date, a text field\n(with a label) or decoration to skip.",
        "operationId": "detect_signature_fields",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DetectInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "The labeled blanks",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DetectedFields"
                }
              }
            }
          },
          "400": {
            "description": "Too many blanks or a malformed one",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "503": {
            "description": "The AI is unavailable; use the rules instead",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/ai/agentic-questions": {
      "post": {
        "tags": [
          "ai"
        ],
        "summary": "Ask the agent",
        "description": "Queues a question for the claude-job-runner agent, in the caller's latest\nchat or a new one. Poll `GET /v1/ai/agentic-questions/{id}` for the answer.",
        "operationId": "ask_agent",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/NewAgenticQuestion"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Queued",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/QueuedQuestion"
                }
              }
            }
          },
          "400": {
            "description": "Empty or too long question",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/ai/agentic-questions/{id}": {
      "get": {
        "tags": [
          "ai"
        ],
        "summary": "Follow a question",
        "description": "Where the caller's question is, and the agent's answer once it is done.\nOther people's questions read as not found.",
        "operationId": "get_agentic_question",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "The question's id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The question's state",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AgenticJob"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such question of the caller",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/ai/agentic-questions/{id}/agent-token": {
      "post": {
        "tags": [
          "ai"
        ],
        "summary": "Issue an agent token",
        "description": "For the claude-job-runner, with `AGENT_RUNNER_KEY`: a token that lets its\nagent read the API as the person who asked question `id`, in the company\nthey asked in. It reads only (plus `POST /v1/call-transcripts` and\n`POST /v1/ai/agent-actions`, proposing a write), never as\na superuser, and works for 30 minutes or until the question is answered.\nAsk for a new one when it runs out mid-answer.",
        "operationId": "issue_agent_token",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "The question's id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "responses": {
          "201": {
            "description": "The token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AgentToken"
                }
              }
            }
          },
          "401": {
            "description": "Missing or wrong runner key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No open question asked in the last 7 days by someone who can still act in its company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "agent_runner_key": []
          }
        ]
      }
    },
    "/v1/ai/agentic-questions/{id}/stop": {
      "post": {
        "tags": [
          "ai"
        ],
        "summary": "Stop a question",
        "description": "The caller stops their own question that is still queued or being worked\non: it reads as `failed` (\"You stopped it.\"), the runner no longer picks\nit up, and its agent token stops working. A finished question is left as\nit is.",
        "operationId": "stop_agentic_question",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "The question's id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Stopped, or already finished"
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such question of the caller",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/ai/agent/wake": {
      "post": {
        "tags": [
          "ai"
        ],
        "summary": "Wake the agent",
        "description": "Starts the agent's machine if it is asleep, so the question the caller is\ntyping is picked up at once. Cheap to call again; answers how ready it is.",
        "operationId": "wake_agent",
        "responses": {
          "200": {
            "description": "How ready the agent is",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AgentWake"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/ai/agent/chats": {
      "get": {
        "tags": [
          "ai"
        ],
        "summary": "List agent conversations",
        "description": "The caller's conversations with the agent in this company, newest first.",
        "operationId": "list_agent_chats",
        "responses": {
          "200": {
            "description": "The conversations",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/AgentChat"
                  }
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/ai/agent/chats/{id}": {
      "get": {
        "tags": [
          "ai"
        ],
        "summary": "Open an agent conversation",
        "description": "One of the caller's conversations with the agent: every question with\nits state and progress, and every answer with its HTML pages.",
        "operationId": "get_agent_chat",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "The chat's id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The conversation",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AgentConversation"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such chat of the caller",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "delete": {
        "tags": [
          "ai"
        ],
        "summary": "Delete an agent conversation",
        "description": "Forgets one of the caller's conversations with the agent, with its\nquestions and answers. A question still being answered is dropped.",
        "operationId": "delete_agent_chat",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "The chat's id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Deleted"
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such chat of the caller",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/ai/agent/skills": {
      "get": {
        "tags": [
          "ai"
        ],
        "summary": "List my agent skills",
        "description": "The caller's own skills in this company, by name.",
        "operationId": "list_agent_skills",
        "responses": {
          "200": {
            "description": "The skills",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/AgentSkill"
                  }
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "post": {
        "tags": [
          "ai"
        ],
        "summary": "Save an agent skill",
        "description": "A new skill of the caller's.",
        "operationId": "create_agent_skill",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AgentSkillInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Saved",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AgentSkill"
                }
              }
            }
          },
          "400": {
            "description": "No name or instructions, or too long",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "409": {
            "description": "The caller already has the most skills",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/ai/agent/skills/{id}": {
      "put": {
        "tags": [
          "ai"
        ],
        "summary": "Change an agent skill",
        "description": "Replaces the name, description and instructions of one of the caller's\nskills.",
        "operationId": "update_agent_skill",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "The skill's id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AgentSkillInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Saved",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AgentSkill"
                }
              }
            }
          },
          "400": {
            "description": "No name or instructions, or too long",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such skill of the caller",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "delete": {
        "tags": [
          "ai"
        ],
        "summary": "Delete an agent skill",
        "description": "Forgets one of the caller's skills.",
        "operationId": "delete_agent_skill",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "The skill's id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Deleted"
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such skill of the caller",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/ai/agent/company-skills": {
      "get": {
        "tags": [
          "ai"
        ],
        "summary": "List the company's skill changes",
        "description": "The company's changes to the General skills: edited and deleted ones.",
        "operationId": "list_agent_company_skills",
        "responses": {
          "200": {
            "description": "The changes",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/CompanySkill"
                  }
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/ai/agent/company-skills/{key}": {
      "put": {
        "tags": [
          "ai"
        ],
        "summary": "Change a General skill for the company",
        "description": "Replaces the name, description, question and fields of one General skill\nfor everyone in the caller's company (and brings it back if deleted).",
        "operationId": "update_agent_company_skill",
        "parameters": [
          {
            "name": "key",
            "in": "path",
            "description": "The General skill's key",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AgentSkillInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Saved",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CompanySkill"
                }
              }
            }
          },
          "400": {
            "description": "No name or instructions, too long, or a bad key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "delete": {
        "tags": [
          "ai"
        ],
        "summary": "Delete a General skill for the company",
        "description": "Takes one General skill off the list of everyone in the caller's company.",
        "operationId": "delete_agent_company_skill",
        "parameters": [
          {
            "name": "key",
            "in": "path",
            "description": "The General skill's key",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Deleted"
          },
          "400": {
            "description": "A bad key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/ai/agent/company-skills/{key}/change": {
      "delete": {
        "tags": [
          "ai"
        ],
        "summary": "Restore a General skill for the company",
        "description": "Forgets the company's change to one General skill: the original is back,\nfor everyone in the caller's company.",
        "operationId": "restore_agent_company_skill",
        "parameters": [
          {
            "name": "key",
            "in": "path",
            "description": "The General skill's key",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Restored"
          },
          "400": {
            "description": "A bad key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/ai/design/pictures": {
      "get": {
        "tags": [
          "ai"
        ],
        "summary": "List pictures customers emailed",
        "description": "Image attachments of emails the caller received, newest first, with the\ncustomer who sent each when known.",
        "operationId": "list_ai_design_pictures",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "description": "Page size, 1 to 60 (default 9).",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          },
          {
            "name": "offset",
            "in": "query",
            "description": "Pictures to skip, at most 500.",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          },
          {
            "name": "search",
            "in": "query",
            "description": "Matches the customer's name, the sender or the file name.",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "A page of pictures",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EmailedPictures"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/ai/design/deals": {
      "get": {
        "tags": [
          "ai"
        ],
        "summary": "List the caller's deals for a design",
        "description": "The caller's own live deals, newest first (at most 200).",
        "operationId": "list_ai_design_deals",
        "responses": {
          "200": {
            "description": "The caller's deals",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/DesignDeal"
                  }
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/ai/design/stones": {
      "get": {
        "tags": [
          "ai"
        ],
        "summary": "List stones for AI Design",
        "description": "The company's displayed stones that have a picture and are in stock\n(a free slab, their own or a linked stone's, or regular stock).",
        "operationId": "list_ai_design_stones",
        "parameters": [
          {
            "name": "q",
            "in": "query",
            "description": "Part of the stone's name.",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Stones",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DesignStones"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/ai/design": {
      "post": {
        "tags": [
          "ai"
        ],
        "summary": "Design a kitchen",
        "description": "The kitchen photo with each stone installed on the surfaces asked for,\nas newline-delimited JSON: `{\"type\":\"status\",\"status\":\"generating\"}`,\nthen per stone `{\"type\":\"design\",\"stoneId\",\"stoneName\",\"image\"}` (a\n`data:` URL) or `{\"type\":\"stoneError\",\"stoneName\",\"error\"}`, `{\"type\":\n\"ping\"}` every 10 s, and finally `{\"type\":\"done\",\"count\"}` or\n`{\"type\":\"error\",\"error\"}` when no stone worked.",
        "operationId": "design_kitchen",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DesignInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "The designs, as newline-delimited JSON",
            "content": {
              "application/x-ndjson": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "400": {
            "description": "No usable photo or stone",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/ai/compose/inventory-url": {
      "get": {
        "tags": [
          "ai"
        ],
        "summary": "The stones page link",
        "description": "The company's customer stones page, which the composer offers to insert.",
        "operationId": "compose_inventory_url",
        "responses": {
          "200": {
            "description": "The link",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InventoryUrl"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/ai/compose/autocomplete": {
      "post": {
        "tags": [
          "ai"
        ],
        "summary": "Continue the draft",
        "description": "The next few words of the rep's draft (or, with an empty draft, how the\nnext message starts), from the conversation and the rep's notes. Send\n`conversation` (a mark that changes with every message the composer\nshows) so a message that just came in or went out is read at once: the\nthread is otherwise kept for a minute. With a typed draft the suggestion\nends where the sentence being typed ends, and a draft that already ends a\nfinished sentence gets none (only a typed greeting gets the message's\nfirst sentence). With an empty draft the opener is one sentence (after\nits greeting), except the whole first message to a customer who has not\nwritten yet. An answer the checks refuse (it repeats the rep, restarts\nthe sentence, or states a time or price it was not given), or an empty one\nto a half-typed sentence or a waiting customer, is asked for once more;\n`completion` is empty when nothing fits.",
        "operationId": "compose_autocomplete",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AutocompleteRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "The suggestion",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Completion"
                }
              }
            }
          },
          "400": {
            "description": "No customer, not a customer of the company, or an invalid phone",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "502": {
            "description": "The model failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/ai/compose/learn": {
      "post": {
        "tags": [
          "ai"
        ],
        "summary": "Learn from a sent message",
        "description": "The rep sent something other than the AI's suggestion: keeps the pair and\nrewrites the rep's writing notes from it and the few before it.",
        "operationId": "compose_learn",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/LearnRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Whether anything was learned",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Learned"
                }
              }
            }
          },
          "400": {
            "description": "No customer",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "502": {
            "description": "The model failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/ai/compose/outcomes": {
      "post": {
        "tags": [
          "ai"
        ],
        "summary": "What became of the suggestions",
        "description": "The composer reports every suggestion it showed while one message was\nwritten, once the message is sent or left: taken, typed along, dismissed\nor ignored, how long the gray words took, and whether taken words were\nstill in the sent message. One row each in `ai_compose_suggestions`: how\noften suggestions are used, by rep, channel and kind of draft. No model\nis called.",
        "operationId": "compose_outcomes",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/OutcomesRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "How many were written down",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OutcomesSaved"
                }
              }
            }
          },
          "400": {
            "description": "No customer, or an invalid phone",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/ai/first-contact-email": {
      "post": {
        "tags": [
          "ai"
        ],
        "summary": "Draft a first email",
        "description": "The first email to a new lead, from what they told us (their request,\nproject and source), introducing the rep and ending with a question.",
        "operationId": "draft_first_contact_email",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/FirstContactRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "The draft",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DraftedEmail"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "502": {
            "description": "The model failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "503": {
            "description": "AI is not configured",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/ai/conversation-reply": {
      "post": {
        "tags": [
          "ai"
        ],
        "summary": "Draft the next message",
        "description": "Drafts the next SMS or email to a customer from the whole conversation\n(SMS and email together), the customer's profile, deals and quotes\n(colors, totals, sent / opened / signed), the company's AI instructions\nand the rep's own recent messages: a fast reply, a follow-up on the open\ntopic, or a custom draft (and revisions of it). The draft greets the\ncustomer by name only in a new conversation or when the last SMS or email\nwith them is from an earlier day; otherwise it has no greeting and no\nname. An email Follow up with `email_thread_id` is drafted from that\nthread alone, without the texts and the customer's other email threads.\nTakes several seconds (a larger model).",
        "operationId": "draft_conversation_reply",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ConversationReplyInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "The draft",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ConversationReply"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request, phone, or no customer, phone or email",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such customer in the caller's company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "The model wrote nothing",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "502": {
            "description": "The model failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "503": {
            "description": "AI is not configured",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/ai/conversation-reply/chat": {
      "post": {
        "tags": [
          "ai"
        ],
        "summary": "Chat with AI about a customer conversation",
        "description": "The AI Reply dialog's chat: the rep asks anything about one customer's\nconversation (what they want, what a problem most likely is, how to\nhandle it) and gets an expert answer, with a ready-to-send message when\none is asked for or is the next step. Reads the whole SMS and email\nthread, the profile and schedule, quotes and price list, the company's\ninstructions and the rep's own writing; pictures the rep adds are read\ntoo. The client keeps the chat and sends it whole each time. Takes\nseveral seconds (a larger model).",
        "operationId": "chat_about_conversation",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ConversationChatInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "The answer",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ConversationChatAnswer"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request, phone, pictures, or no customer, phone or email",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such customer in the caller's company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "The model wrote nothing",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "502": {
            "description": "The model failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "503": {
            "description": "AI is not configured",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/ai/chat": {
      "post": {
        "tags": [
          "ai"
        ],
        "summary": "Ask the AI chat",
        "description": "Answers a question in instructions mode (company instructions and the\nCRM manual), price lists mode (supplier price files, special orders) or\nassistant mode (the company's records, employees only), streamed as\nserver-sent events. The conversation is kept per user; `isNew` starts it\nover. Each user may ask at most 100 questions in any hour; past that the\nanswer is 429 with when to try again (a refused question does not count).",
        "operationId": "ask_chat",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ChatInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "The answer as server-sent events",
            "content": {
              "text/event-stream": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "400": {
            "description": "No question",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Assistant mode asked for by a user who is not an employee",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "429": {
            "description": "100 questions asked in the last hour; the message says in how many minutes to try again",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/ai/crm-manual-feedback": {
      "post": {
        "tags": [
          "ai"
        ],
        "summary": "Give feedback on a CRM manual answer",
        "description": "`dislike`: a corrected answer from the manual and the user's access\n(attempt 1 or 2). `approve` / `escalate`: the conversation is saved for\nthe super admins' instruction corrections page.",
        "operationId": "give_crm_manual_feedback",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/FeedbackInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "The correction, or the saved feedback",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FeedbackOut"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Saving failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/ai/promises": {
      "get": {
        "tags": [
          "ai"
        ],
        "summary": "List the caller's open promises",
        "description": "What the caller promised customers on calls, texts and emails and has not\ndone yet, the quotes customers asked them to make or update (one task per\ncustomer, with what they asked for), and what waits for a customer's\napproval, newest first: each promise with the message that keeps it when\na text or email can, each appointment with its event on the schedule and\nwhat it clashes with. With a customer, phone or email: only that\ncustomer's; without, also the customers whose text waits for the\ncaller's reply.",
        "operationId": "list_ai_promises",
        "parameters": [
          {
            "name": "customer_id",
            "in": "query",
            "description": "Only this customer's promises.",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "phone_digits",
            "in": "query",
            "description": "Only promises to this phone (its last 10 digits count).",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "customer_email",
            "in": "query",
            "description": "Only promises to this email.",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Open promises",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AiPromises"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee, or AI promises are not on for them",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/ai/promises/{id}": {
      "patch": {
        "tags": [
          "ai"
        ],
        "summary": "Close or reopen a promise",
        "description": "`done` once the rep kept it (sending its message does this), `dismissed`\nwhen it was not a promise or is not wanted, `open` to bring it back.",
        "operationId": "update_ai_promise",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Promise id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64",
              "minimum": 0
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PromiseUpdate"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Saved"
          },
          "400": {
            "description": "Status is not done, dismissed or open",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee, or AI promises are not on for them",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "Not one of the caller's promises",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/notifications": {
      "get": {
        "tags": [
          "notifications"
        ],
        "summary": "List notifications",
        "description": "Unread incoming mail of the last 14 days (one per conversation), due\nnotifications on live deals (signature status is emailed to the sender\ninstead, so it is left out), 911 alerts (`e911_alert`, for the\ncompany's admins; they open `/admin/phone`), the texting registration's\nnotices (`tendlc_ready` for superusers, opening their list of\nregistrations; `tendlc_status` for the company's admins and Managers,\nopening `/admin/phone`), number port news (`phone_port`, for the\ncompany's admins, opening `/admin/phone`), open billing notices,\nmissed `CloudTalk` and `RingCentral` calls, and Granite Manager calls of\nthe last 3 days that nobody answered and the caller has not seen (missed\ncalls, voicemails and AI messages of their direct lines and of the lines\nthat ring them; `telnyx-call-<id>`, `type_title` names the line), newest\nfirst. The onboarding tour's sample notifications are left out unless\n`samples` is set.",
        "operationId": "list_notifications",
        "parameters": [
          {
            "name": "samples",
            "in": "query",
            "description": "The onboarding tour is open: keep its sample notifications.",
            "required": false,
            "schema": {
              "type": "boolean"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Notifications",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Notifications"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/notifications/done": {
      "post": {
        "tags": [
          "notifications"
        ],
        "summary": "Dismiss notifications",
        "description": "Marks activity and billing notifications done, the listed email threads\nread and the listed Granite Manager calls seen (for the caller only, as in\nthe phone app). With `clear_all`, dismisses every activity notification\nthat is due (later reminders stay) and every billing notification, marks\nall unread incoming mail read and the bell's Granite Manager calls seen.",
        "operationId": "dismiss_notifications",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DoneInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Dismissed"
          },
          "400": {
            "description": "Nothing to dismiss, or more than 200 items",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/notifications/{id}": {
      "get": {
        "tags": [
          "notifications"
        ],
        "summary": "Get one activity notification",
        "description": "The caller's own due activity notification `notif-<id>`, as\n`GET /v1/notifications` lists it, with the deal it opens (`deal_id`),\nelse its customer (`customer_id`).\nThe phone app reads it for a `notification` push, which names only the\nid. 404 for another user's, a dismissed one, or one `GET\n/v1/notifications` would not list.",
        "operationId": "get_notification",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "The notification (`notif-<id>` without the prefix)",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The notification",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/NotificationItem"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such notification of the caller",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/customers/{id}/qbo-invoices": {
      "get": {
        "tags": [
          "quickbooks"
        ],
        "summary": "List a customer's QuickBooks invoices",
        "description": "The invoices of the customer's `QuickBooks` customer, newest first. A\ncustomer not linked yet is matched by email, then by name, and linked.\n`status` says why there are none when `QuickBooks` is not connected or\nhas no matching customer.",
        "operationId": "list_customer_qbo_invoices",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Customer id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Invoices",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CustomerInvoices"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such customer in the caller's company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "post": {
        "tags": [
          "quickbooks"
        ],
        "summary": "Create a QuickBooks invoice for a customer",
        "description": "Creates the editor's invoice in `QuickBooks` for the customer, matching\nor creating the customer's `QuickBooks` customer first. With `quote_id`\nthe quote keeps the invoice's id, and a quote that has one already is\nrefused.",
        "operationId": "create_customer_qbo_invoice",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Customer id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/InvoiceCreate"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "The created invoice",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EditableInvoice"
                }
              }
            }
          },
          "400": {
            "description": "No sales line, a sales line without an item, or QuickBooks refused it",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such customer, or no such quote of the customer",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "409": {
            "description": "QuickBooks is not connected",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "502": {
            "description": "QuickBooks failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/webhooks/quickbooks": {
      "post": {
        "tags": [
          "quickbooks"
        ],
        "summary": "Receive a QuickBooks webhook",
        "description": "`QuickBooks` says invoices or payments changed: the named companies'\ninvoice copies read the changes before they are shown next.",
        "operationId": "receive_quickbooks_webhook",
        "parameters": [
          {
            "name": "intuit-signature",
            "in": "header",
            "description": "Intuit's signature of the body",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "description": "The notification, as Intuit sent it",
          "content": {
            "application/json": {
              "schema": {
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Marked",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/QboWebhookReceived"
                }
              }
            }
          },
          "400": {
            "description": "Missing or invalid signature, or not configured",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        }
      }
    },
    "/v1/customers/{id}/qbo-invoices/split": {
      "post": {
        "tags": [
          "quickbooks"
        ],
        "summary": "Split a quote's invoice into several in QuickBooks",
        "description": "Creates one `QuickBooks` invoice per split invoice, in order, each with\nevery line of the editor's invoice and its share of each priced line\n(the shares of a line add up to it). The message of an invoice is its\nlabel. When `QuickBooks` refuses one, those already made are deleted.\nThe quote keeps the first invoice's id.",
        "operationId": "create_customer_qbo_invoice_split",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Customer id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SplitCreate"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "The created invoices",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SplitCreated"
                }
              }
            }
          },
          "400": {
            "description": "The shares do not add up, or QuickBooks refused an invoice",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin, or the quote is another customer's",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such customer",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "409": {
            "description": "QuickBooks is not connected",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "An invoice was made and could not be deleted after a later one failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "502": {
            "description": "QuickBooks failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/qbo/invoice-split": {
      "get": {
        "tags": [
          "quickbooks"
        ],
        "summary": "The company's usual invoice split",
        "description": "How the company last split the invoice of a quote with these parts\n(else one with more parts, else any), as the percent each invoice\ncharged of each part, and the class the rep last gave each part's\nlines. A starting point: the editor changes anything.",
        "operationId": "get_qbo_invoice_split",
        "parameters": [
          {
            "name": "parts",
            "in": "query",
            "description": "The quote's parts, comma-separated (e.g. `stone,area`).",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The usual split",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SplitTemplate"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/customers/{id}/qbo-invoices/{invoice_id}": {
      "get": {
        "tags": [
          "quickbooks"
        ],
        "summary": "Get a customer's QuickBooks invoice",
        "description": "One invoice of the customer, for the invoice editor.",
        "operationId": "get_customer_qbo_invoice",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Customer id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "invoice_id",
            "in": "path",
            "description": "QuickBooks invoice id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Invoice",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EditableInvoice"
                }
              }
            }
          },
          "400": {
            "description": "Invalid invoice id",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Not an invoice of this customer",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such customer, or it is not linked to QuickBooks",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "409": {
            "description": "QuickBooks is not connected",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "502": {
            "description": "QuickBooks failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "put": {
        "tags": [
          "quickbooks"
        ],
        "summary": "Save a customer's QuickBooks invoice",
        "description": "Writes the editor's lines, dates, notes and addresses to the invoice.\nLines the editor removed are deleted; discounts and tax stay. When\n`QuickBooks` refuses a stale version the update is retried once on the\ncurrent one.",
        "operationId": "update_customer_qbo_invoice",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Customer id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "invoice_id",
            "in": "path",
            "description": "QuickBooks invoice id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/InvoiceUpdate"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "The saved invoice",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EditableInvoice"
                }
              }
            }
          },
          "400": {
            "description": "Invalid invoice, or a sales line without an item",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Not an invoice of this customer",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such customer, or it is not linked to QuickBooks",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "409": {
            "description": "QuickBooks is not connected",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "502": {
            "description": "QuickBooks failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/customers/{id}/qbo-invoices/{invoice_id}/pdf": {
      "get": {
        "tags": [
          "quickbooks"
        ],
        "summary": "Get a customer's QuickBooks invoice as a PDF",
        "description": "The invoice's PDF, once it is known to be this customer's.",
        "operationId": "get_customer_qbo_invoice_pdf",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Customer id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "invoice_id",
            "in": "path",
            "description": "QuickBooks invoice id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The PDF",
            "content": {
              "application/pdf": {
                "schema": {
                  "type": "array",
                  "items": {
                    "type": "integer",
                    "format": "int32",
                    "minimum": 0
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid invoice id",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Not an invoice of this customer",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such customer, or it is not linked to QuickBooks",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "409": {
            "description": "QuickBooks is not connected",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "502": {
            "description": "QuickBooks failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/qbo/invoices/{invoice_id}/pdf": {
      "get": {
        "tags": [
          "quickbooks"
        ],
        "summary": "Get a QuickBooks invoice as a PDF",
        "description": "Any invoice of the company's `QuickBooks`, for the rep's sales panel and\nschedule events.",
        "operationId": "get_qbo_invoice_pdf",
        "parameters": [
          {
            "name": "invoice_id",
            "in": "path",
            "description": "QuickBooks invoice id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The PDF",
            "content": {
              "application/pdf": {
                "schema": {
                  "type": "array",
                  "items": {
                    "type": "integer",
                    "format": "int32",
                    "minimum": 0
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid invoice id",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "409": {
            "description": "QuickBooks is not connected",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "502": {
            "description": "QuickBooks failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/qbo/invoices/{invoice_id}/balance": {
      "get": {
        "tags": [
          "quickbooks"
        ],
        "summary": "What the customer still owes on a QuickBooks invoice",
        "description": "For the crew's job page: after Complete job it shows the amount to\ncollect. Installers only for an invoice linked to one of their jobs.",
        "operationId": "get_qbo_invoice_balance",
        "parameters": [
          {
            "name": "invoice_id",
            "in": "path",
            "description": "QuickBooks invoice id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The balance",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InvoiceBalance"
                }
              }
            }
          },
          "400": {
            "description": "Invalid invoice id",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Not linked to one of the installer's jobs",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "409": {
            "description": "QuickBooks is not connected",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "502": {
            "description": "QuickBooks failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/qbo/customers": {
      "get": {
        "tags": [
          "quickbooks"
        ],
        "summary": "Find QuickBooks customers",
        "description": "`QuickBooks` customers whose display name contains `name` (up to 25), or\nwhose primary email is `email`.",
        "operationId": "search_qbo_customers",
        "parameters": [
          {
            "name": "email",
            "in": "query",
            "description": "Exact primary email.",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "name",
            "in": "query",
            "description": "Part of the display name (wins over `email`).",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Matches",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/QboCustomers"
                }
              }
            }
          },
          "400": {
            "description": "Neither email nor name",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "502": {
            "description": "QuickBooks failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/qbo/items": {
      "get": {
        "tags": [
          "quickbooks"
        ],
        "summary": "List QuickBooks products and services",
        "description": "The company's active services and products (up to 1000), by name, for\nthe lines of a new invoice.",
        "operationId": "list_qbo_items",
        "responses": {
          "200": {
            "description": "Items",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/QboItems"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "409": {
            "description": "QuickBooks is not connected",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "502": {
            "description": "QuickBooks failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/qbo/invoices/recent": {
      "get": {
        "tags": [
          "quickbooks"
        ],
        "summary": "List recent QuickBooks invoices as QuickBooks has them",
        "description": "The company's newest invoices with every field `QuickBooks` keeps (class,\nCC, terms, custom fields, lines), to learn how the company writes its\ninvoices. Admins only; read-only.",
        "operationId": "list_recent_qbo_invoices",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "description": "How many, newest first (1–500, default 200).",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int32",
              "minimum": 0
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Invoices, newest first",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RecentInvoices"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "409": {
            "description": "QuickBooks is not connected",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "502": {
            "description": "QuickBooks failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/quotes/{id}/invoice-draft": {
      "post": {
        "tags": [
          "quickbooks"
        ],
        "summary": "Make a quote's invoice draft the company's way",
        "description": "Applies the changes the company's recent invoices keep making to such a\ndraft: lines reworded or left out (text lines only; amounts never change),\nand the class, CC and product they usually get, from invoices made here\n(as they are in `QuickBooks` now, so what the office changes there counts)\nand the company's newest `QuickBooks` invoices. The class is the one named\nafter the quote's sales rep unless the company's invoices carry a fixed\none. Also says where the addresses go and when the invoice is due, as the\ncompany's invoices usually have it. Nothing is saved.",
        "operationId": "apply_invoice_draft_rules",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Quote id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DraftInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "The draft the company's way",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DraftRules"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such quote in the caller's company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/qbo/invoice-instructions": {
      "get": {
        "tags": [
          "quickbooks"
        ],
        "summary": "Read the invoice instructions",
        "description": "What the admin told the AI about the company's invoices and the rules it\nmade of them.",
        "operationId": "get_qbo_invoice_instructions",
        "responses": {
          "200": {
            "description": "The instructions and their rules",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InvoiceInstructions"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "put": {
        "tags": [
          "quickbooks"
        ],
        "summary": "Save the invoice instructions",
        "description": "The AI turns them into exact rules (checked against the company's\n`QuickBooks` products and classes) that every new invoice draft follows.\nEmpty instructions remove them.",
        "operationId": "save_qbo_invoice_instructions",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/InstructionsInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Saved, with the rules made of them",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InvoiceInstructions"
                }
              }
            }
          },
          "400": {
            "description": "Too long",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "409": {
            "description": "QuickBooks is not connected",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "502": {
            "description": "QuickBooks or the AI failed; nothing was saved",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/qbo/invoice-style": {
      "get": {
        "tags": [
          "quickbooks"
        ],
        "summary": "Read what the AI learned from the company's invoices",
        "description": "The rules every new invoice draft follows because the company's own\n`QuickBooks` invoices are written that way (lines left out, lines\nreworded), when they were learned and from how many invoices. Empty\nbefore the first time. The invoice instructions win over these.",
        "operationId": "get_qbo_invoice_style",
        "responses": {
          "200": {
            "description": "What was learned",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InvoiceStyle"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "post": {
        "tags": [
          "quickbooks"
        ],
        "summary": "Learn how the company writes its invoices",
        "description": "The AI reads the company's newest `QuickBooks` invoices and what became\nof earlier invoice drafts (also what the office changed in `QuickBooks`\nafterwards), and proposes which lines to leave out and how to reword\nothers. Each rule is checked against those invoices before it is kept,\nand new drafts then follow the kept ones. Learned at most once in 20\nhours: sooner, what was learned is returned as it is, unless an admin\nsends `force`. Meant to be called in the background when Create invoice\nopens (`style_due` of `POST /v1/quotes/{id}/invoice-draft`); it can take\nup to 25 seconds.",
        "operationId": "learn_qbo_invoice_style",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/LearnInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "What was learned",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InvoiceStyle"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin, or is an installer",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "409": {
            "description": "QuickBooks is not connected",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "502": {
            "description": "The AI failed; what was learned before stays",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/quotes/{id}/invoice-fields": {
      "post": {
        "tags": [
          "quickbooks"
        ],
        "summary": "Fill in a new invoice's custom fields from its quote",
        "description": "The custom fields the company's `QuickBooks` invoices usually fill (e.g.\n\"Room & Color\", \"Sink & Stove\", \"Edge & BS\"), each with the value for\nthis quote written the way the company's own invoices write it. The AI\nwrites the values from the quote's lines, the field's recent values and\nthe values the office gave earlier invoices made from quotes. They are a\nsuggestion for the editor: send the ones to keep as `custom_fields` of\nthe invoice when creating it. Without the AI, or when it does not answer\nin 12 seconds, the fields come with null values. Nothing is saved.",
        "operationId": "fill_invoice_custom_fields",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Quote id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/FieldsInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "The fields with this quote's values",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DraftFields"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin, or is an installer",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such quote in the caller's company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/me/qbo-sales": {
      "get": {
        "tags": [
          "quickbooks"
        ],
        "summary": "Get my QuickBooks sales this month",
        "description": "The sum of the caller's classes in this month's Sales by Class report,\nwith the periods the sales goal panel shows.",
        "operationId": "get_my_qbo_sales",
        "responses": {
          "200": {
            "description": "Sales",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RepSales"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/me/qbo-sales/customers": {
      "get": {
        "tags": [
          "quickbooks"
        ],
        "summary": "List my QuickBooks customers this month",
        "description": "The customers in this month's Sales by Customer report for the caller's\nclasses, each with this month's invoices.",
        "operationId": "list_my_qbo_sales_customers",
        "responses": {
          "200": {
            "description": "Customers",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RepCustomers"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/company/sales-goal": {
      "put": {
        "tags": [
          "quickbooks"
        ],
        "summary": "Set the company's monthly sales goal",
        "description": "A Manager or Sales Manager sets the goal every employee sees on the\n`QuickBooks` sales widget's Company view. Null clears it.",
        "operationId": "set_company_sales_goal",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateCompanyGoal"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "The goal as saved",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CompanyGoal"
                }
              }
            }
          },
          "400": {
            "description": "Goal out of range",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not a Manager or Sales Manager",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/qbo/class-sales": {
      "get": {
        "tags": [
          "quickbooks"
        ],
        "summary": "Sales by class",
        "description": "The company's `QuickBooks` \"Sales by Class\" report (accrual basis) for the\ndays, and its classes so the page can nest them. `not_connected` when\n`QuickBooks` is off or disconnected, `error` when the report failed.",
        "operationId": "get_qbo_class_sales",
        "parameters": [
          {
            "name": "start_date",
            "in": "query",
            "description": "First day (`YYYY-MM-DD`); `QuickBooks`' default when empty.",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "end_date",
            "in": "query",
            "description": "Last day (`YYYY-MM-DD`); `QuickBooks`' default when empty.",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The report, or why there is none",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ClassSales"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/jobs/appointment-reminders": {
      "post": {
        "tags": [
          "jobs"
        ],
        "summary": "Send due appointment reminders",
        "description": "Texts (else emails) customers their 24-hour and 1-hour reminders, and\nnotifies reps the day before and an hour before. Reminders for\nappointments that already started are marked failed.",
        "operationId": "run_appointment_reminders",
        "responses": {
          "200": {
            "description": "What was sent",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ReminderRun"
                }
              }
            }
          },
          "401": {
            "description": "Missing or wrong job key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "job_key": []
          }
        ]
      }
    },
    "/v1/jobs/batch": {
      "post": {
        "tags": [
          "jobs"
        ],
        "summary": "Run several jobs",
        "description": "Runs the named jobs one after another, each exactly as its own\n`POST /v1/jobs/<job>` would, and answers what each of them answered. A\njob that fails does not stop the ones after it.",
        "operationId": "run_job_batch",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/BatchInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "What each job answered",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BatchRun"
                }
              }
            }
          },
          "401": {
            "description": "Missing or wrong job key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "The app was not set up to run jobs",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "job_key": []
          }
        ]
      }
    },
    "/v1/jobs/maintenance-reminders": {
      "post": {
        "tags": [
          "jobs"
        ],
        "summary": "Send today's maintenance digests",
        "description": "At 9 AM store time, sends each shop worker and shop manager with Telegram\nnotifications a list of their company's equipment checks due today, once a\nday, and pushes how many there are to the signed-in phones of each shop\nworker and shop manager (Telegram linked or not).",
        "operationId": "run_maintenance_reminders",
        "responses": {
          "200": {
            "description": "What was sent",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DigestRun"
                }
              }
            }
          },
          "401": {
            "description": "Missing or wrong job key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "job_key": []
          }
        ]
      }
    },
    "/v1/jobs/survey-notifications": {
      "post": {
        "tags": [
          "jobs"
        ],
        "summary": "Send due post-installation surveys",
        "description": "Inside the send window, sends the survey invitations and reminders that\nare due.",
        "operationId": "run_survey_notifications",
        "responses": {
          "200": {
            "description": "What was sent",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SurveyRun"
                }
              }
            }
          },
          "401": {
            "description": "Missing or wrong job key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "job_key": []
          }
        ]
      }
    },
    "/v1/jobs/call-points": {
      "post": {
        "tags": [
          "jobs"
        ],
        "summary": "Sync and classify call points",
        "description": "Pulls reps' outbound calls into the call points table, then transcribes\nand classifies a few of the calls long enough to need it.",
        "operationId": "run_call_points",
        "responses": {
          "200": {
            "description": "What was done",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CallPointsRun"
                }
              }
            }
          },
          "401": {
            "description": "Missing or wrong job key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "job_key": []
          }
        ]
      }
    },
    "/v1/jobs/call-history": {
      "post": {
        "tags": [
          "jobs"
        ],
        "summary": "Save call history",
        "description": "Saves the `RingCentral` calls of every connected company,\nso they stay in its history after it changes provider. Also renews reps'\nown `RingCentral` sign-ins before they lapse unused.",
        "operationId": "run_call_history",
        "responses": {
          "200": {
            "description": "What was done",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CallHistoryRun"
                }
              }
            }
          },
          "401": {
            "description": "Missing or wrong job key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "job_key": []
          }
        ]
      }
    },
    "/v1/jobs/signature-reminders": {
      "post": {
        "tags": [
          "jobs"
        ],
        "summary": "Run the native signature lifecycle",
        "description": "Expires open requests past their expiry, then sends due reminders and\nthe senders' notifications. Called by the `time-triggered` Lambda with\n`Authorization: <LAMBDA_KEY>`. While native signatures are not enabled\nit does nothing.",
        "operationId": "run_signature_reminders",
        "responses": {
          "200": {
            "description": "What the run did",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SignatureRun"
                }
              }
            }
          },
          "401": {
            "description": "Missing or wrong job key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "job_key": []
          }
        ]
      }
    },
    "/v1/jobs/sms-followups": {
      "post": {
        "tags": [
          "jobs"
        ],
        "summary": "Send due follow-ups",
        "description": "Sends the due steps of SMS / email flows, the drip texts of lead lists\nand everyone's scheduled emails and texts.",
        "operationId": "run_sms_followups",
        "responses": {
          "200": {
            "description": "What was done",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SmsFollowupsRun"
                }
              }
            }
          },
          "401": {
            "description": "Missing or wrong job key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "job_key": []
          }
        ]
      }
    },
    "/v1/jobs/supplier-files": {
      "post": {
        "tags": [
          "jobs"
        ],
        "summary": "Process waiting supplier price files",
        "description": "Returns files stuck in processing to the queue, then processes waiting\nfiles (newest first) until none is left or ten minutes have passed.",
        "operationId": "run_supplier_files",
        "responses": {
          "200": {
            "description": "How many files were processed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupplierFilesRun"
                }
              }
            }
          },
          "401": {
            "description": "Missing or wrong job key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "job_key": []
          }
        ]
      }
    },
    "/v1/jobs/contact-sync": {
      "post": {
        "tags": [
          "jobs"
        ],
        "summary": "Sync missing contacts",
        "description": "Pushes a few customers without a `RingCentral` contact to their company's\n`RingCentral`, and renews up to 2 `RingCentral` SMS\nsubscriptions whose token is not the current webhooks token (a failed\nrenewal waits 2 hours; none is ever created here).",
        "operationId": "run_contact_sync",
        "responses": {
          "200": {
            "description": "What was done",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ContactSyncRun"
                }
              }
            }
          },
          "401": {
            "description": "Missing or wrong job key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "job_key": []
          }
        ]
      }
    },
    "/v1/jobs/phone": {
      "post": {
        "tags": [
          "jobs"
        ],
        "summary": "Run Granite Manager's upkeep",
        "description": "Signs out the phones of users who may no longer use Granite Manager (or\nwhose company was deleted) and browser phones whose CRM sign-in ended, deletes\nleftover Telnyx credentials of signed-out phones (backing off on\nfailures), deletes Telnyx callbacks older than 30 days and the AI chat's\nquestion counts older than an hour, closes calls\nTelnyx never reported the end of (after 6 hours), keeps the customer\nphone index that matches calls to customers in step (customers changed\nor added since the last run; each company's first fill, at most 5,000\ncustomers a run), writes up to 3 AI notes (transcript, note tidied like\nthe CRM's, on the call and its deal, the customer's sales rep notified), gives\nanswered outbound calls their call points (provider `telnyx`), deletes\nTelnyx's copies of copied recordings whose delete failed, retries failed\nrecording copies (5 attempts), brings port-in orders up to date from\nTelnyx (adding ported numbers to the company), asks Telnyx again about\nsent texts with no final status yet (so one that did not go out shows as\nfailed), and last reads sent 10DLC\ntexting registrations and pending number assignments again. Bounded work per run, and\nno new work after 20 seconds; the next run takes the rest. Returns what\nwas done.",
        "operationId": "run_phone_job",
        "responses": {
          "200": {
            "description": "What was done",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PhoneJobRun"
                }
              }
            }
          },
          "401": {
            "description": "Missing or wrong job key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "job_key": []
          }
        ]
      }
    },
    "/v1/jobs/posthog-autofix": {
      "post": {
        "tags": [
          "jobs"
        ],
        "summary": "Run one tick of the PostHog auto-fix intake",
        "description": "Gives up on fix runs that never reported back, then (at most once per\npoll window, `POSTHOG_AUTOFIX_POLL_MINUTES`) reads the PostHog\n`$exception` events since the last read (never before the cutover) and\nrecords them as bugs, one per signature whatever issue they are in;\njudges bugs that have settled (skipped as noise, a browser 5xx folded into\nthe API error of the same route, a toast folded into the web error it\nrepeats, or queued); emails when a fixed issue is reopened; and (with\n`POSTHOG_AUTOFIX_WRITE_KEY` and `_ASSIGNEE` set) assigns the issues of\nopened fixes in PostHog. Last, in live mode, it starts queued fix runs\n(bugs seen in the last day first, then the most widespread) within the\nconcurrency and daily caps; in dry-run mode it emails the runs it would\nhave started instead. With `POSTHOG_AUTOFIX_MODE` off it does nothing.\nWhen another tick is running it returns at once with `busy`. PostHog or\nGitHub failures do not fail the call: they are listed in `errors` and\nretried on the next tick.",
        "operationId": "run_posthog_autofix",
        "responses": {
          "200": {
            "description": "What the tick did",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TickReport"
                }
              }
            }
          },
          "401": {
            "description": "Missing or wrong job key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "job_key": []
          }
        ]
      }
    },
    "/v1/jobs/tendlc-checks": {
      "post": {
        "tags": [
          "jobs"
        ],
        "summary": "Run the AI check of a texting registration (10DLC)",
        "description": "Takes the registration that has waited longest for its AI check (or one\nwhose check stopped midway, after 15 minutes), reads its quote form,\nprivacy policy, terms and website, and has the AI check them and the\nform the way the carriers do. The Manager who marked it ready is\nemailed what to change, or that it passed; one that passed is ready and\nthe superusers are told (bell and email). After 3 runs where the AI\ncould not answer it goes to the superusers unchecked.",
        "operationId": "run_tendlc_checks",
        "responses": {
          "200": {
            "description": "How many registrations were checked",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TenDlcChecksRun"
                }
              }
            }
          },
          "401": {
            "description": "Missing or wrong job key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "job_key": []
          }
        ]
      }
    },
    "/v1/jobs/promises": {
      "post": {
        "tags": [
          "jobs"
        ],
        "summary": "Read reps' calls and messages for promises",
        "description": "For the reps AI promises is on for: reminds them of promises that came\ndue, closes the tasks they finished in the CRM (a quote saved or emailed,\na document sent to sign, an event on the schedule, a call), queues their calls, texts\nand emails of the last 3 days not read yet, then reads up to 4 (a call is\ntranscribed first): saves what the rep promised the customer and by when,\ncloses the open promises it keeps, adds the quote work the customer gave\nthem to that customer's one quote task, and writes the text or email that\nkeeps each promise a message can keep, in the rep's own style.",
        "operationId": "run_promises",
        "responses": {
          "200": {
            "description": "What the run did",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PromisesRun"
                }
              }
            }
          },
          "401": {
            "description": "Missing or wrong job key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "job_key": []
          }
        ]
      }
    },
    "/v1/jobs/raptor-jobs": {
      "post": {
        "tags": [
          "jobs"
        ],
        "summary": "Make the Raptor jobs of new projects",
        "description": "For each company with a Raptor login, the projects created since the login\nwas saved that have no Raptor job yet: their jobs are added to Raptor with\nthe job info, material, sink cutouts and the \"Notes\" note.",
        "operationId": "run_raptor_jobs",
        "responses": {
          "200": {
            "description": "How many projects were sent",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RaptorJobsRun"
                }
              }
            }
          },
          "401": {
            "description": "Missing or wrong job key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "job_key": []
          }
        ]
      }
    },
    "/v1/jobs/ringcentral-delivery": {
      "post": {
        "tags": [
          "jobs"
        ],
        "summary": "Mark texts RingCentral did not deliver",
        "description": "Reads one page of the texts a rep sent through `RingCentral` and marks\nthe CRM's copy of each one `RingCentral` did not deliver as failed, with\nthe reason (marked as spam, number flagged as spam, or undelivered).",
        "operationId": "run_ringcentral_delivery",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RingcentralDeliveryInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "What was done",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RingcentralDeliveryRun"
                }
              }
            }
          },
          "401": {
            "description": "Missing or wrong job key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "502": {
            "description": "RingCentral refused the request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "job_key": []
          }
        ]
      }
    },
    "/v1/jobs/company-exports": {
      "post": {
        "tags": [
          "jobs"
        ],
        "summary": "Send today's company data exports",
        "description": "Called by the scheduler every minute. For each company with an export set\nup, once its local time reaches the export hour, builds that day's zip\n(every table's rows as CSV, new pictures and documents, all of them on\nMondays), stores it privately and emails the recipients a download link\nthat works 7 days; once per company and day. Failed exports are retried\nthree times, then an alert is emailed. Zips older than 7 days are deleted.",
        "operationId": "run_company_exports",
        "responses": {
          "200": {
            "description": "What was sent, retried, alerted and deleted",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ExportsRun"
                }
              }
            }
          },
          "401": {
            "description": "Missing or wrong job key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "job_key": []
          }
        ]
      }
    },
    "/v1/jobs/company-taxes": {
      "post": {
        "tags": [
          "jobs"
        ],
        "summary": "Refresh company sales taxes",
        "description": "Looks up the sales tax of the company checked longest ago (never, or\nover 30 days ago) from its address and saves it.",
        "operationId": "run_company_taxes",
        "responses": {
          "200": {
            "description": "How many companies were looked up",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CompanyTaxesRun"
                }
              }
            }
          },
          "401": {
            "description": "Missing or wrong job key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "job_key": []
          }
        ]
      }
    },
    "/v1/jobs/invoice-copies": {
      "post": {
        "tags": [
          "jobs"
        ],
        "summary": "Check the QuickBooks copies of Order invoices",
        "description": "Reads the `QuickBooks` copy of the Order invoices checked longest ago and\nbrings their payments onto ours.",
        "operationId": "run_invoice_copies",
        "responses": {
          "200": {
            "description": "How many invoices were checked",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InvoiceCopiesRun"
                }
              }
            }
          },
          "401": {
            "description": "Missing or wrong job key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "job_key": []
          }
        ]
      }
    },
    "/v1/jobs/support-escalations": {
      "post": {
        "tags": [
          "jobs"
        ],
        "summary": "Escalate unassigned support requests",
        "description": "Tells the escalation users (`SUPPORT_ESCALATION_USER_IDS`) once about\neach support request that nobody on the team has taken\n`SUPPORT_ESCALATION_MINUTES` after it was opened, and that is not\nresolved: a bell notification pushed to the Granite Manager app (no\nTelegram). Does nothing while either setting is empty or 0; nobody is\non the list by default, so it is off (owner, 2026-12-01).",
        "operationId": "run_support_escalations",
        "responses": {
          "200": {
            "description": "How many requests were escalated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupportEscalationsRun"
                }
              }
            }
          },
          "401": {
            "description": "Missing or wrong job key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "job_key": []
          }
        ]
      }
    },
    "/v1/jobs/file-confirmations": {
      "post": {
        "tags": [
          "jobs"
        ],
        "summary": "Email the file confirmation reports",
        "description": "Called by the scheduler every minute. At 5:30 PM Indianapolis time, emails\neach company set up for it the files not confirmed 48 hours after they were\nsent and the customers emailed a file without a text about it; once a day,\nand only when there is something to list.",
        "operationId": "run_file_confirmations",
        "responses": {
          "200": {
            "description": "What was sent",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FileConfirmationsRun"
                }
              }
            }
          },
          "401": {
            "description": "Missing or wrong job key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "job_key": []
          }
        ]
      }
    },
    "/v1/jobs/horus-sync": {
      "post": {
        "tags": [
          "jobs"
        ],
        "summary": "Copy Horus slabs",
        "description": "For each company with a FusionDrive key whose turn it is (15 minutes\nafter its last sync, or asked for with Sync now): reads its whole Horus\nslab list and copies it into its slabs.",
        "operationId": "run_horus_sync",
        "responses": {
          "200": {
            "description": "How many companies were synced",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HorusSyncRun"
                }
              }
            }
          },
          "401": {
            "description": "Missing or wrong job key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "job_key": []
          }
        ]
      }
    },
    "/v1/jobs/qbo-invoice-copies": {
      "post": {
        "tags": [
          "jobs"
        ],
        "summary": "Keep the copies of QuickBooks invoices",
        "description": "Fills the copies not filled yet and reads the changes of the others.",
        "operationId": "run_qbo_invoice_copies",
        "responses": {
          "200": {
            "description": "What the run did",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/QboInvoiceCopiesRun"
                }
              }
            }
          },
          "401": {
            "description": "Missing or wrong job key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "job_key": []
          }
        ]
      }
    },
    "/v1/me/call-coaching": {
      "get": {
        "tags": [
          "me"
        ],
        "summary": "Get my call coaching",
        "description": "The caller's last three real calls with their scores: `CloudTalk` and\n`RingCentral` calls when they have either line, and Granite Manager calls\nthey placed or answered (`tx_<id>`) when they have a Granite Manager number.",
        "operationId": "get_my_call_coaching",
        "responses": {
          "200": {
            "description": "Calls",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Coaching"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "post": {
        "tags": [
          "me"
        ],
        "summary": "Ask the coach about a call",
        "description": "Transcribes and scores one of the calls `GET` lists (once; a failed one\nis tried again), then returns the list. Scoring takes a while; a page\nthat stops waiting sees the result on its next `GET`.",
        "operationId": "evaluate_my_call",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/EvaluateInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Calls, the asked one scored",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Coaching"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/followups/instruction": {
      "get": {
        "tags": [
          "followups"
        ],
        "summary": "Get the AI follow-up instruction",
        "description": "The company's rule for AI-written follow-ups (cadence, tone, what to\nmention), as plain text. Empty when none is saved.",
        "operationId": "get_followup_instruction",
        "responses": {
          "200": {
            "description": "The instruction",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FollowupInstruction"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "put": {
        "tags": [
          "followups"
        ],
        "summary": "Save the AI follow-up instruction",
        "description": "Replaces the company's rule with `instruction`, trimmed. An empty (or\nblank) instruction deletes it. Answers the saved text.",
        "operationId": "save_followup_instruction",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/FollowupInstruction"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "The saved instruction",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FollowupInstruction"
                }
              }
            }
          },
          "400": {
            "description": "Longer than 2000 characters",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/followups/timeline": {
      "get": {
        "tags": [
          "sms"
        ],
        "summary": "Show the follow-up conversation",
        "description": "The texts and emails with the customer (by id or phone) the AI\nfollow-up writer reads, oldest first.",
        "operationId": "get_followup_timeline",
        "parameters": [
          {
            "name": "customer_id",
            "in": "query",
            "description": "The customer.",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "phone_digits",
            "in": "query",
            "description": "Or the phone (5 to 15 digits) of the SMS thread.",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The conversation",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FollowupTimeline"
                }
              }
            }
          },
          "400": {
            "description": "`invalid_phone` or `customer_or_phone_required`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such customer in the caller's company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/customers/{customer_id}/flow": {
      "get": {
        "tags": [
          "followups"
        ],
        "summary": "A customer's flow",
        "description": "The flow running for the customer (or the last one that failed).",
        "operationId": "get_customer_flow",
        "parameters": [
          {
            "name": "customer_id",
            "in": "path",
            "description": "Customer id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The flow",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FlowState"
                }
              }
            }
          },
          "400": {
            "description": "Not a customer id",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "post": {
        "tags": [
          "followups"
        ],
        "summary": "Act on a customer's flow",
        "description": "Starts, switches, pauses, resumes or stops the customer's flow, or sends\nits next step now. Refusals come back as a token in `error`\n(`flow_not_found`, `agent_not_linked`, `missing_email`, `invalid_status`,\n`not_due`, ...).",
        "operationId": "act_on_customer_flow",
        "parameters": [
          {
            "name": "customer_id",
            "in": "path",
            "description": "Customer id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/FlowAction"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "The flow afterwards",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FlowState"
                }
              }
            }
          },
          "400": {
            "description": "Refused",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Not the caller's flow to change",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "409": {
            "description": "A flow is already running",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "429": {
            "description": "Over ten starts a minute",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/sms/{provider}/threads/{phone}/flow": {
      "get": {
        "tags": [
          "sms"
        ],
        "summary": "A thread's flow",
        "description": "The flow running on the phone, for someone who may see it.",
        "operationId": "get_sms_thread_flow",
        "parameters": [
          {
            "name": "provider",
            "in": "path",
            "description": "SMS provider",
            "required": true,
            "schema": {
              "$ref": "#/components/schemas/SmsProvider"
            }
          },
          {
            "name": "phone",
            "in": "path",
            "description": "The other party's phone digits",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The flow",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FlowState"
                }
              }
            }
          },
          "400": {
            "description": "Not a phone number",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "post": {
        "tags": [
          "sms"
        ],
        "summary": "Act on a thread's flow",
        "description": "Like the customer's, for the phone of an SMS conversation.",
        "operationId": "act_on_sms_thread_flow",
        "parameters": [
          {
            "name": "provider",
            "in": "path",
            "description": "SMS provider",
            "required": true,
            "schema": {
              "$ref": "#/components/schemas/SmsProvider"
            }
          },
          {
            "name": "phone",
            "in": "path",
            "description": "The other party's phone digits",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/FlowAction"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "The flow afterwards",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FlowState"
                }
              }
            }
          },
          "400": {
            "description": "Refused",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Not the caller's flow to change",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "409": {
            "description": "A flow is already running",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "429": {
            "description": "Over ten starts a minute",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/followups/call-check": {
      "post": {
        "tags": [
          "followups"
        ],
        "summary": "Check an outbound call",
        "description": "Whether the customer talked back on a rep's call. A conversation stops\nthe customer's running SMS / email flows. `call_id` may be a Granite\nPhone call `tx_<id>` (the transcript kept on it is checked); the API runs\nthose checks itself.",
        "operationId": "check_followup_call",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CallCheck"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "What the check found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CallCheckResult"
                }
              }
            }
          },
          "400": {
            "description": "Invalid body",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "Missing or wrong key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "job_key": []
          }
        ]
      }
    },
    "/v1/followups/ai-cadence/preview": {
      "post": {
        "tags": [
          "followups"
        ],
        "summary": "Preview an AI follow-up",
        "description": "Plans the follow-up for the customer and has the model write it. A\ncustomer who should not be followed up now comes back as 400\n`nothing_to_send` with the reason (`force_generate` overrides most).",
        "operationId": "preview_ai_cadence",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PreviewRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "The written follow-up",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PreviewResult"
                }
              }
            }
          },
          "400": {
            "description": "Nothing to send, or no way to reach the customer",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CadenceError"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "502": {
            "description": "The model failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CadenceError"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/followups/ai-cadence/regenerate": {
      "post": {
        "tags": [
          "followups"
        ],
        "summary": "Rewrite one message",
        "description": "Writes the message again, different from the drafts the rep turned down\n(400 `regenerate_too_similar` when the model keeps repeating itself).",
        "operationId": "regenerate_ai_cadence_message",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RegenerateRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "The new draft",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Regenerated"
                }
              }
            }
          },
          "400": {
            "description": "Invalid, or nothing to send",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CadenceError"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "502": {
            "description": "The model failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CadenceError"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/followups/ai-cadence": {
      "post": {
        "tags": [
          "followups"
        ],
        "summary": "Start an AI follow-up",
        "description": "Saves the approved messages as the rep's \"Generated with AI\" flow and\nstarts it for the customer (`switch`: replacing the running one). A\nfirst message due now is sent before the response.",
        "operationId": "start_ai_cadence",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/StartRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "The flow now running",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FlowState"
                }
              }
            }
          },
          "400": {
            "description": "Refused (e.g. `nothing_to_send`)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CadenceError"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Not the caller's flow to replace",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CadenceError"
                }
              }
            }
          },
          "409": {
            "description": "A flow is already running",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CadenceError"
                }
              }
            }
          },
          "429": {
            "description": "Over ten starts a minute",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CadenceError"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/suppliers/file-readiness": {
      "get": {
        "tags": [
          "catalog"
        ],
        "summary": "Get a supplier's price-file readiness",
        "description": "How many of the named supplier's price files are processed, still being\nprocessed or failed, so a price answer can say it may be incomplete.",
        "operationId": "get_supplier_file_readiness",
        "parameters": [
          {
            "name": "name",
            "in": "query",
            "description": "Supplier name as the company wrote it (compared trimmed); blank answers null.",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Readiness, or null for an unknown supplier",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ReadinessReply"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/supplier-files/{id}/retry": {
      "post": {
        "tags": [
          "catalog"
        ],
        "summary": "Retry a failed price file",
        "description": "Puts a failed price file of the company back in the processing queue\n(attempts reset). The processor picks it up within a minute.",
        "operationId": "retry_supplier_file",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Supplier file id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Queued again"
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No failed file with that id in the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/suppliers/price-offers": {
      "get": {
        "tags": [
          "catalog"
        ],
        "summary": "Find supplier prices for a color",
        "description": "Searches the company's processed supplier price files and has the AI\nlist the matching prices (never estimated: only prices written in the\nfiles). With `supplier` and `color`, only that supplier's files are read\nand picked by the color's words; else the material in `q` is searched\nover the suppliers it names. Each offer says which file it was read from\n(`file_id`, `url`) when the AI cited one of the searched files. Also\nanswers the company's sales tax, which the quote builder adds to a\nsupplier price.",
        "operationId": "find_supplier_price_offers",
        "parameters": [
          {
            "name": "supplier",
            "in": "query",
            "description": "The supplier to price from, as the company names it (compared\ntrimmed, any case; else the closest supplier names). With `color`,\nonly that supplier's price files are read.",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "color",
            "in": "query",
            "description": "The color to price, e.g. `Calacatta Laza`, used with `supplier`:\nexcerpts are picked by its words only. Under 2 characters finds\nnothing.",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "q",
            "in": "query",
            "description": "What to price in words, naming the material and ideally the\nsupplier, e.g. `Price for Calacatta Laza from MSI`, searched over\nevery supplier the text names. Used when `supplier` or `color` is\nblank. Under 2 characters finds nothing.",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Prices found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PriceOffers"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "502": {
            "description": "The AI failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/suppliers/{id}": {
      "get": {
        "tags": [
          "catalog"
        ],
        "summary": "Get a supplier",
        "description": "One supplier of the company with its contact details.",
        "operationId": "get_supplier",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Supplier id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The supplier",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Supplier"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such supplier in the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "put": {
        "tags": [
          "catalog"
        ],
        "summary": "Edit a supplier",
        "description": "Replaces the supplier's details and updates its `CloudTalk` contact\n(removed when the phone number is gone).",
        "operationId": "update_supplier",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Supplier id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SupplierInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Saved"
          },
          "400": {
            "description": "Missing name, a malformed website, phone or email, or a value longer than its limit",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such supplier in the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "delete": {
        "tags": [
          "catalog"
        ],
        "summary": "Delete a supplier",
        "description": "Deletes the supplier and its price files and removes it from the\ncompany's `CloudTalk` contacts. It leaves the supplier lists, and its\nroutes answer 404. Its stones, sinks and faucets stay in inventory and\nkeep showing its name.",
        "operationId": "delete_supplier",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Supplier id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Deleted"
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such supplier in the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/suppliers/{id}/files": {
      "get": {
        "tags": [
          "catalog"
        ],
        "summary": "List a supplier's price files",
        "description": "The supplier's price files, newest first, with their processing state.\nFiles in `pending`/`processing` are picked up by the processor within a\nminute; poll while any is.",
        "operationId": "list_supplier_files",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Supplier id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The files",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/SupplierPriceFile"
                  }
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such supplier in the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "post": {
        "tags": [
          "catalog"
        ],
        "summary": "Add a supplier price file",
        "description": "Records an uploaded price file as `pending`; the processor turns it into\nsearchable prices within a minute (`GET /v1/suppliers/{id}/files` shows\nits state). A file the supplier already has is refused (409).",
        "operationId": "add_supplier_file",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Supplier id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/NewSupplierFile"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Added",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CreatedId"
                }
              }
            }
          },
          "400": {
            "description": "Missing or too long name, or not an uploaded file of an accepted type",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such supplier in the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "409": {
            "description": "The supplier already has this file",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database or storage error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/supplier-files/{id}": {
      "delete": {
        "tags": [
          "catalog"
        ],
        "summary": "Delete a supplier price file",
        "description": "Deletes a price file of one of the company's suppliers, its prices and\nthe stored file.",
        "operationId": "delete_supplier_file",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Supplier file id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64",
              "minimum": 0
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Deleted"
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such file in the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/billing/reactivation": {
      "get": {
        "tags": [
          "billing"
        ],
        "summary": "Get what restoring access costs",
        "description": "For a suspended company: the plan and price to pay, the saved cards and\nthe Stripe.js key; then pay with `POST /v1/billing/reactivation`.",
        "operationId": "get_billing_reactivation",
        "responses": {
          "200": {
            "description": "The quote",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ReactivationQuote"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not a manager of the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "post": {
        "tags": [
          "billing"
        ],
        "summary": "Start paying to restore access",
        "description": "For a company whose subscription ended unpaid: creates a new subscription\ncharged to the card (managers only). Answers `paid` when there is nothing\nto pay (the company is not restricted, or Stripe already has it paid),\notherwise the payment for the browser to confirm. Stripe's refusals\n(\"Your card was declined.\") are 400s with Stripe's message.",
        "operationId": "start_billing_reactivation",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/StartReactivation"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Paid, or a payment to confirm",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ReactivationStarted"
                }
              }
            }
          },
          "400": {
            "description": "No card, or Stripe refused",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not a manager of the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/billing/reactivation/finish": {
      "post": {
        "tags": [
          "billing"
        ],
        "summary": "Finish restoring access",
        "description": "After the browser confirmed the payment: waits a few seconds for Stripe\nto mark the subscription paid and applies it.",
        "operationId": "finish_billing_reactivation",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/FinishReactivation"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Active or pending",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ReactivationFinished"
                }
              }
            }
          },
          "400": {
            "description": "Not the company's subscription, or Stripe failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not a manager of the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/webhooks/stripe": {
      "post": {
        "tags": [
          "billing"
        ],
        "summary": "Receive a Stripe event",
        "description": "Stripe's webhook endpoint: checkout, subscription, invoice and payment\nmethod events update the company's billing (each event once). Needs a\nvalid `Stripe-Signature` for `STRIPE_WEBHOOK_SECRET`; no session.",
        "operationId": "receive_stripe_webhook",
        "parameters": [
          {
            "name": "Stripe-Signature",
            "in": "header",
            "description": "Stripe's signature of the body",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "description": "The Stripe event, as Stripe sent it",
          "content": {
            "application/json": {
              "schema": {
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Processed (or ignored)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookReceived"
                }
              }
            }
          },
          "400": {
            "description": "Missing or invalid signature, or not configured",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Processing failed; Stripe retries",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        }
      }
    },
    "/v1/billing/gate": {
      "get": {
        "tags": [
          "billing"
        ],
        "summary": "Get the billing gate",
        "description": "Whether the company's access is paused for an unpaid subscription\n(`restricted`: only the billing pages work) and whether managers see the\npast-due warning with the grace days left. Checks Stripe now and then\n(throttled); errors keep access.",
        "operationId": "get_billing_gate",
        "responses": {
          "200": {
            "description": "The gate",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BillingGate"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/billing": {
      "get": {
        "tags": [
          "billing"
        ],
        "summary": "Get the company's billing",
        "description": "The subscription (refreshed from Stripe first), the card on file, the\nplans and the invoices. Managers only; other users read\n`GET /v1/billing/gate`.",
        "operationId": "get_billing",
        "responses": {
          "200": {
            "description": "The company's billing",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BillingOverview"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not a manager of the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/billing/checkout": {
      "post": {
        "tags": [
          "billing"
        ],
        "summary": "Subscribe through Stripe Checkout",
        "description": "A Stripe Checkout link that subscribes the company to the plan; Stripe\nreturns to `/admin/billing?checkout=success` (or `cancel`). Only while the\ncompany has no running subscription (400 otherwise: change the plan).\nOnly one such page is open at a time: asked again for the same plan, the\nopen page is answered again; for another plan it is closed first, so the\ncompany cannot pay for two subscriptions from two pages.",
        "operationId": "create_billing_checkout",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PlanChoice"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "The Checkout link",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Redirect"
                }
              }
            }
          },
          "400": {
            "description": "Unknown plan, already subscribed, or Stripe refused",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not a manager of the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/billing/portal": {
      "post": {
        "tags": [
          "billing"
        ],
        "summary": "Open the Stripe billing portal",
        "description": "A Stripe billing portal link for the company's customer, returning to\n`/admin/billing`.",
        "operationId": "create_billing_portal",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PortalChoice"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "The portal link",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Redirect"
                }
              }
            }
          },
          "400": {
            "description": "No Stripe customer, or Stripe refused",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not a manager of the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/billing/subscription": {
      "put": {
        "tags": [
          "billing"
        ],
        "summary": "Change the plan",
        "description": "Moves the running subscription to another plan (prorated).",
        "operationId": "change_billing_plan",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PlanChoice"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Changed"
          },
          "400": {
            "description": "Unknown plan, no running subscription, or Stripe refused",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not a manager of the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/billing/first-payment": {
      "get": {
        "tags": [
          "billing"
        ],
        "summary": "Get what the company pays",
        "description": "Its monthly price, the free time Granite Manager gave it (if any) and\nwho to write to for a free month and a demo. Pay with\n`POST /v1/billing/first-payment/checkout`. Managers only.",
        "operationId": "get_billing_first_payment",
        "responses": {
          "200": {
            "description": "The price",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FirstPayment"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not a manager of the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/billing/first-payment/checkout": {
      "post": {
        "tags": [
          "billing"
        ],
        "summary": "Pay the monthly subscription",
        "description": "A Stripe Checkout link for a monthly subscription at the company's price\n(`GET /v1/billing/first-payment`), charged now, or when the free time\nGranite Manager gave ends. Stripe returns to\n`/admin/billing?checkout=success` (or `cancel`); access opens once Stripe\nconfirms the payment. 400 when Stripe is not set up or refused, 409\nwhile a subscription is running. Only one such page is open at a time\n(asked again, the open page is answered again; after a change of price\nit is closed and a new one made), so the company cannot pay twice from\ntwo pages. Managers only.",
        "operationId": "create_billing_first_payment_checkout",
        "responses": {
          "200": {
            "description": "The Checkout link",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Redirect"
                }
              }
            }
          },
          "400": {
            "description": "Stripe is not set up, or refused",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not a manager of the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "409": {
            "description": "The company already has a subscription",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/public/signup": {
      "get": {
        "tags": [
          "public"
        ],
        "summary": "What signing up costs",
        "description": "The flat monthly price (USD cents), the address to write to for a free\nmonth and a demo instead, and the domain web addresses go under. Then\ncheck a web address with `GET /v1/public/signup/subdomain/{subdomain}`\nand sign up with `POST /v1/public/signup`. No session.",
        "operationId": "get_signup_options",
        "responses": {
          "200": {
            "description": "The price and the contact",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SignupOptions"
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "public"
        ],
        "summary": "Sign up a new company",
        "description": "Creates the company (seeded like one a superuser creates: calendars,\nstarter pipeline, email templates, a walk-in kiosk login), makes the\nperson signing up its Manager and an admin, sets its price ($800 a\nmonth) and signs them in: the answer and the session cookie are those\nof `POST /v1/auth/login`. Everything they typed is saved here, before\nany payment. Next they pay (`POST /v1/billing/first-payment/checkout`,\nto Stripe) or write to Granite Manager for a free month and a demo.\nUntil Stripe shows the payment, or a superuser gives free time, the API\nrefuses everything but sign-in and billing (`company.source =\n'signup_page'`, `auth::paywall`). The web address is kept as asked for;\nGranite Manager turns it on later, so the company starts on the main\nhost. No session.\n\n400 for a missing or bad field, 409 when the email already signs in\nsomewhere (sign in instead) or the web address is taken, 429 after\n`MAX_SIGNUPS_PER_ADDRESS` sign-ups from one address in a day. The robot\ncheck (`turnstile_token`) is only logged.",
        "operationId": "sign_up_company",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SignupInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Created and signed in; the session cookie is set",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AuthSession"
                }
              }
            }
          },
          "400": {
            "description": "A field is missing or bad",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "409": {
            "description": "The email already has an account, or the web address is taken",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "429": {
            "description": "Too many sign-ups from this address today",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        }
      }
    },
    "/v1/public/signup/subdomain/{subdomain}": {
      "get": {
        "tags": [
          "public"
        ],
        "summary": "Check a web address",
        "description": "Whether `subdomain` (`acme` of `acme.granite-manager.com`) is well formed\n(3 to 40 lowercase letters, numbers and single hyphens), not reserved and\nnot taken or asked for by another company. No session.",
        "operationId": "check_signup_subdomain",
        "parameters": [
          {
            "name": "subdomain",
            "in": "path",
            "description": "The web address to check, e.g. `acme`",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Whether it is available",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SubdomainCheck"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        }
      }
    },
    "/v1/public/payments/{token}": {
      "get": {
        "tags": [
          "payments"
        ],
        "summary": "Show a company's payment page",
        "description": "The company named by the payment link, the monthly price a new\nsubscription would charge, and its live Stripe subscription if it has one.\nNo session: the signed link is the credential. Next: `POST\n/v1/public/payments/{token}/checkout` to subscribe, or `POST\n/v1/public/payments/{token}/portal` to manage a subscription.",
        "operationId": "get_payment_page",
        "parameters": [
          {
            "name": "token",
            "in": "path",
            "description": "The `c` value of the company's payment link: `<company id>.<signature>`",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The company and its subscription",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PaymentPage"
                }
              }
            }
          },
          "404": {
            "description": "The link is not valid, or the company was deleted",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "502": {
            "description": "Stripe failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "503": {
            "description": "Payments are not set up",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        }
      }
    },
    "/v1/public/payments/{token}/checkout": {
      "post": {
        "tags": [
          "payments"
        ],
        "summary": "Start a company's monthly subscription",
        "description": "A Stripe Checkout link for a monthly subscription at the company's price\n(`subscription_price_cents`, read now; later price changes do not touch a\nrunning subscription). The first time, a Stripe customer is created and\nsaved on the company. Stripe sends the payer back to the payments page\nwith `&checkout=success` or `&checkout=cancel`. 409 while the company has\na live subscription: open the portal instead. Only one such page is open\nat a time, so a company cannot pay for two subscriptions from two pages:\nasked again, the page that is open is answered again, and when the price\nor the first payment day changed since, that page is closed and a new one\nmade.",
        "operationId": "create_payment_checkout",
        "parameters": [
          {
            "name": "token",
            "in": "path",
            "description": "The `c` value of the company's payment link",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The Checkout link",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StripeLink"
                }
              }
            }
          },
          "404": {
            "description": "The link is not valid, or the company was deleted",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "409": {
            "description": "The company already has a subscription",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "502": {
            "description": "Stripe failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "503": {
            "description": "Payments are not set up",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        }
      }
    },
    "/v1/public/payments/{token}/portal": {
      "post": {
        "tags": [
          "payments"
        ],
        "summary": "Manage a company's subscription in Stripe",
        "description": "A Stripe billing portal link where the company cancels its subscription\n(at the end of the paid month), changes its card and downloads invoices.\nStripe sends it back to the payments page. 409 when the company never\nsubscribed.",
        "operationId": "create_payment_portal",
        "parameters": [
          {
            "name": "token",
            "in": "path",
            "description": "The `c` value of the company's payment link",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The billing portal link",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StripeLink"
                }
              }
            }
          },
          "404": {
            "description": "The link is not valid, or the company was deleted",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "409": {
            "description": "The company has no Stripe customer yet",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "502": {
            "description": "Stripe failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "503": {
            "description": "Payments are not set up",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        }
      }
    },
    "/v1/superuser/payments": {
      "get": {
        "tags": [
          "superuser"
        ],
        "summary": "List every company's payments",
        "description": "Every company (deleted ones hidden), by name: its monthly price, the\npayments page link to send it, and from Stripe its subscription (live,\nelse the latest ended one), whether it renews and when, and its last\nsuccessful payment. A company whose Stripe data could not be read has\n`stripe_error` set. Also, from the database, how many of the jobs it sold\nin the last 90 days its customers paid through our payment links\n(`paid_through_us`). Superusers only. Change a price with `PUT\n/v1/superuser/companies/{id}/subscription-price`.",
        "operationId": "list_company_payments",
        "responses": {
          "200": {
            "description": "Every company's payments",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/CompanyPayments"
                  }
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not a superuser",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "503": {
            "description": "Payments are not set up",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/superuser/companies/{id}/subscription-price": {
      "put": {
        "tags": [
          "superuser"
        ],
        "summary": "Set a company's monthly price",
        "description": "The company's monthly price: its next new subscription starts at it, and\na running subscription is charged it from its next payment (no proration,\ndates unchanged). Superusers only.",
        "operationId": "set_company_subscription_price",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Company id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SubscriptionPrice"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Saved"
          },
          "400": {
            "description": "Price out of range",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not a superuser",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "502": {
            "description": "Stripe refused the change",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/superuser/companies/{id}/first-payment-date": {
      "put": {
        "tags": [
          "superuser"
        ],
        "summary": "Set a company's first payment date",
        "description": "The day its next new subscription is first charged: it saves its card at\ncheckout, is charged on that day and then every month from it. Null\ncharges at checkout. A running subscription keeps its dates. Superusers\nonly.",
        "operationId": "set_company_first_payment_date",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Company id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/FirstPaymentDate"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Saved"
          },
          "400": {
            "description": "Date out of range",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not a superuser",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/superuser/companies/{id}/billing-day": {
      "put": {
        "tags": [
          "superuser"
        ],
        "summary": "Set a running subscription's billing day",
        "description": "Moves the company's live subscription to be charged on `day` of every\nmonth, from the next such day on. The days until then are free (no\nproration). Superusers only.",
        "operationId": "set_company_billing_day",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Company id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/BillingDay"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Moved",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/NextCharge"
                }
              }
            }
          },
          "400": {
            "description": "Day out of range",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not a superuser",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "409": {
            "description": "The company has no running subscription",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "502": {
            "description": "Stripe refused the change",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "503": {
            "description": "Payments are not set up",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/superuser/stripe-balance": {
      "get": {
        "tags": [
          "superuser"
        ],
        "summary": "The Stripe balance and payouts",
        "description": "What the Stripe account holds (available and pending, in USD) and its\nlatest payouts to the bank. Superusers only.",
        "operationId": "get_stripe_balance",
        "responses": {
          "200": {
            "description": "Balance and payouts",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StripeBalance"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not a superuser",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "502": {
            "description": "Stripe could not be read",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "503": {
            "description": "Payments are not set up",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/superuser/paid-features": {
      "get": {
        "tags": [
          "superuser"
        ],
        "summary": "Features, who paid for them, and usage",
        "description": "Every feature with its monthly price, the companies marked as having\npaid for each, the features self-signed-up companies picked, and every\ncompany's usage counts over the last `usage_days` days. Superusers only.",
        "operationId": "list_paid_features",
        "responses": {
          "200": {
            "description": "Features, paid marks and usage",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PaidFeatures"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not a superuser",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "post": {
        "tags": [
          "superuser"
        ],
        "summary": "Add a feature",
        "description": "Superusers only.",
        "operationId": "create_paid_feature",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/FeatureInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Added",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Feature"
                }
              }
            }
          },
          "400": {
            "description": "Bad name, usage count or price",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not a superuser",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "409": {
            "description": "The name is taken",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/superuser/paid-features/{id}": {
      "put": {
        "tags": [
          "superuser"
        ],
        "summary": "Rename a feature, or change its usage count or price",
        "description": "A price left out of the body stays as it is. Superusers only.",
        "operationId": "update_paid_feature",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Feature id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/FeatureInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Saved"
          },
          "400": {
            "description": "Bad name, usage count or price",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not a superuser",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such feature",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "409": {
            "description": "The name is taken",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "delete": {
        "tags": [
          "superuser"
        ],
        "summary": "Remove a feature",
        "description": "Removes the companies' paid marks for it too. Superusers only.",
        "operationId": "delete_paid_feature",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Feature id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Removed"
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not a superuser",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such feature",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/superuser/companies/{id}/paid-features/{feature_id}": {
      "put": {
        "tags": [
          "superuser"
        ],
        "summary": "Mark a company as having paid for a feature",
        "description": "Marking it again changes nothing. Superusers only.",
        "operationId": "mark_company_feature_paid",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Company id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "feature_id",
            "in": "path",
            "description": "Feature id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Marked"
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not a superuser",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such company or feature",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "delete": {
        "tags": [
          "superuser"
        ],
        "summary": "Unmark a company's paid feature",
        "description": "Unmarking one that is not marked changes nothing. Superusers only.",
        "operationId": "unmark_company_feature_paid",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Company id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "feature_id",
            "in": "path",
            "description": "Feature id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Unmarked"
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not a superuser",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/company/settings": {
      "get": {
        "tags": [
          "company"
        ],
        "summary": "Get the company settings",
        "description": "The company's name, address, logo, sales tax and the state of its\n`QuickBooks` and `RingCentral` connections (the latter checked with\n`RingCentral`). Superusers and company managers (admins with the Manager\nposition); superusers may pass `company_id`.",
        "operationId": "get_company_settings",
        "parameters": [
          {
            "name": "company_id",
            "in": "query",
            "description": "Superusers only: the company to act on (default: the caller's).",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The settings",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CompanySettings"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller does not manage the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "put": {
        "tags": [
          "company"
        ],
        "summary": "Save the company settings",
        "description": "Replaces the name, address and logo height, and the logo when a new one\nis given. A new address also sets the sales tax, looked up from it; an\naddress that can't be placed on the map is refused.",
        "operationId": "save_company_settings",
        "parameters": [
          {
            "name": "company_id",
            "in": "query",
            "description": "Superusers only: the company to act on (default: the caller's).",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CompanySettingsInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Saved"
          },
          "400": {
            "description": "Missing name, a value out of range, or an address the sales tax can't be found for",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller does not manage the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/company/email-deliverability": {
      "get": {
        "tags": [
          "company"
        ],
        "summary": "Get the company's email deliverability",
        "description": "How likely the company's email is to reach inboxes: a 0-100 spam risk\n(lower is better) of the domain its mail goes out from, with the DNS\nchanges that would lower it. The same check superusers see on the\ncompanies list; a check from the last day is reused unless `recheck`\nasks for a new one. Null when the company has neither sent mail nor a\ndomain. Superusers and company managers; superusers may pass\n`company_id`.",
        "operationId": "get_company_email_deliverability",
        "parameters": [
          {
            "name": "company_id",
            "in": "query",
            "description": "Superusers only: the company to act on (default: the caller's).",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "recheck",
            "in": "query",
            "description": "Check again now instead of reusing the last day's check (a check\nfrom the last minute is still reused).",
            "required": false,
            "schema": {
              "type": "boolean"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The deliverability, or null",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/DomainTrust"
                    },
                    {
                      "type": "null"
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller does not manage the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/company/auto-sale": {
      "put": {
        "tags": [
          "company"
        ],
        "summary": "Switch the sale form on a win",
        "description": "Admin › Quotes › Automation. When on, marking a deal won or a quote sold opens\nthe sale form, filled from the quote (`auto_sale` in\n`GET /v1/company/features`).",
        "operationId": "save_company_auto_sale",
        "parameters": [
          {
            "name": "company_id",
            "in": "query",
            "description": "Superusers only: the company to act on (default: the caller's).",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AutoSaleInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Saved"
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller does not manage the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/company/auto-unscheduled-jobs": {
      "put": {
        "tags": [
          "company"
        ],
        "summary": "Switch a sold quote's jobs in Unscheduled",
        "description": "Admin › Quotes › Automation. When on, marking a quote sold adds a template and an\ninstallation event to the schedule's Unscheduled list\n(`auto_unscheduled_jobs` in `GET /v1/company/features`).",
        "operationId": "save_company_auto_unscheduled_jobs",
        "parameters": [
          {
            "name": "company_id",
            "in": "query",
            "description": "Superusers only: the company to act on (default: the caller's).",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AutoUnscheduledJobsInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Saved"
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller does not manage the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/company/sale-built-in-jobs": {
      "put": {
        "tags": [
          "company"
        ],
        "summary": "Keep or remove a sold quote's template and installation events",
        "description": "Admin › Quotes › Automation › Event templates. With Jobs to Unscheduled\non, marking a quote sold adds a template and an installation event; each\ncan be removed here (`sale_template_job` and `sale_installation_job` in\n`GET /v1/company/features`).",
        "operationId": "save_company_sale_built_in_jobs",
        "parameters": [
          {
            "name": "company_id",
            "in": "query",
            "description": "Superusers only: the company to act on (default: the caller's).",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SaleBuiltInJobsInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Saved"
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller does not manage the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/company/auto-invoice": {
      "put": {
        "tags": [
          "company"
        ],
        "summary": "Switch the invoice on a sold quote",
        "description": "Admin › Quotes › Automation \"Create invoice from quote\". When on, marking\na quote sold opens its QuickBooks invoice, filled from the sold option;\nconfirming it creates the invoice in QuickBooks (`auto_invoice` in\n`GET /v1/company/features`).",
        "operationId": "save_company_auto_invoice",
        "parameters": [
          {
            "name": "company_id",
            "in": "query",
            "description": "Superusers only: the company to act on (default: the caller's).",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AutoInvoiceInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Saved"
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller does not manage the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/company/quote-invoice-sync": {
      "put": {
        "tags": [
          "company"
        ],
        "summary": "Switch keeping invoices in sync with their quote",
        "description": "Admin › Quotes › Automation \"Automatically synchronize quote with\ninvoices\". When on, an invoice created from a quote starts with \"Keep in\nsync with the quote\" ticked: when the quote changes, the invoice is\nrebuilt from it (`quote_invoice_sync` in `GET /v1/company/features`,\n`PUT /v1/quotes/{id}/invoice-sync`).",
        "operationId": "save_company_quote_invoice_sync",
        "parameters": [
          {
            "name": "company_id",
            "in": "query",
            "description": "Superusers only: the company to act on (default: the caller's).",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/QuoteInvoiceSyncInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Saved"
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller does not manage the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/company/qbo-invoice-copy": {
      "put": {
        "tags": [
          "company"
        ],
        "summary": "Switch copying every Order's invoice to `QuickBooks`",
        "description": "Admin › Quotes › Invoices \"Sync invoices with `QuickBooks`\nautomatically\". When on, the invoice made for each Order is created in\n`QuickBooks` too, and its changes and payments follow it there\n(`qbo_invoice_copy` in `GET /v1/company/features`).",
        "operationId": "save_company_qbo_invoice_copy",
        "parameters": [
          {
            "name": "company_id",
            "in": "query",
            "description": "Superusers only: the company to act on (default: the caller's).",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/QuoteInvoiceSyncInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Saved"
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller does not manage the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/company/auto-project": {
      "put": {
        "tags": [
          "company"
        ],
        "summary": "Switch starting a project on a sale",
        "description": "Admin › Quotes › Automation \"Project on a sale\". When on, marking a deal\nwon or a quote sold starts its project in Projects (`auto_project` in\n`GET /v1/company/features`). Off, projects are added by hand.",
        "operationId": "save_company_auto_project",
        "parameters": [
          {
            "name": "company_id",
            "in": "query",
            "description": "Superusers only: the company to act on (default: the caller's).",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AutoProjectInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Saved"
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller does not manage the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/company/auto-sales-order": {
      "put": {
        "tags": [
          "company"
        ],
        "summary": "Switch making a sales order on a sale",
        "description": "Admin › Quotes › Automation \"Sales order on a sale\". When on, marking a\nquote sold makes its sales order for the Inventory Manager\n(`auto_sales_order` in `GET /v1/company/features`). Off, none is made.",
        "operationId": "save_company_auto_sales_order",
        "parameters": [
          {
            "name": "company_id",
            "in": "query",
            "description": "Superusers only: the company to act on (default: the caller's).",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AutoSalesOrderInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Saved"
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller does not manage the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/company/quote-link-signing": {
      "put": {
        "tags": [
          "company"
        ],
        "summary": "Switch signing on the customer's quote link",
        "description": "Admin › Quotes › Automation \"Sign on the quote link\". When on, the\ncustomer's quote link lets them pick an option and sign\n(`POST /v1/public/quote-portal/{token}/acceptance`); off, the link only\nshows the quote (`quote_link_signing` in `GET /v1/company/features`).",
        "operationId": "save_company_quote_link_signing",
        "parameters": [
          {
            "name": "company_id",
            "in": "query",
            "description": "Superusers only: the company to act on (default: the caller's).",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/QuoteLinkSigningInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Saved"
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller does not manage the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/company/sale-opens-invoice": {
      "put": {
        "tags": [
          "company"
        ],
        "summary": "Switch opening the invoice after a sale",
        "description": "Admin › Quotes › Automation \"On sale, open the invoice\": the invoice\nopens automatically\n(`sale_opens_invoice` in `GET /v1/company/features`).",
        "operationId": "save_company_sale_opens_invoice",
        "parameters": [
          {
            "name": "company_id",
            "in": "query",
            "description": "Superusers only: the company to act on (default: the caller's).",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AfterSaleStepInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Saved"
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller does not manage the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/company/invoice-opens-payment": {
      "put": {
        "tags": [
          "company"
        ],
        "summary": "Switch opening the first payment after the order's invoice",
        "description": "Admin › Quotes › Automation \"On sale, open the first payment\": once the\ninvoice is saved, the payment opens automatically for the first payment (`invoice_opens_payment` in `GET /v1/company/features`).",
        "operationId": "save_company_invoice_opens_payment",
        "parameters": [
          {
            "name": "company_id",
            "in": "query",
            "description": "Superusers only: the company to act on (default: the caller's).",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AfterSaleStepInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Saved"
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller does not manage the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/company/sales-playbook": {
      "put": {
        "tags": [
          "company"
        ],
        "summary": "Switch the sales playbook",
        "description": "Admin › Deals › Task Settings \"Sales playbook\" (`sales_playbook` in\n`GET /v1/company/features`). Off by default: until it is on, nobody in\nthe company sees sub-stages, touch plans, stage limits or sales KPIs.\nTurning it off hides them and keeps their set-up.",
        "operationId": "save_company_sales_playbook",
        "parameters": [
          {
            "name": "company_id",
            "in": "query",
            "description": "Superusers only: the company to act on (default: the caller's).",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SalesPlaybookInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Saved"
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller does not manage the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/company/api-token-email": {
      "post": {
        "tags": [
          "company"
        ],
        "summary": "Email the API bearer token",
        "description": "Sends Granite Manager's documentation API bearer token\n(`GRANITE_MANAGER_DOCS_BEARER_TOKEN`) to the address given. Only for\nholders of the Manager position.",
        "operationId": "email_api_token",
        "parameters": [
          {
            "name": "company_id",
            "in": "query",
            "description": "Superusers only: the company to act on (default: the caller's).",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ApiTokenEmail"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Sent"
          },
          "400": {
            "description": "Not an email address",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not a Manager of the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "502": {
            "description": "Sending failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "503": {
            "description": "No token is configured",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/quickbooks/connection": {
      "get": {
        "tags": [
          "company"
        ],
        "summary": "Get the QuickBooks connection",
        "description": "Whether the caller's company can connect `QuickBooks` and whether it is\nconnected (for the connect page).",
        "operationId": "get_quickbooks_connection",
        "responses": {
          "200": {
            "description": "The connection",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/QuickbooksConnection"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "post": {
        "tags": [
          "company"
        ],
        "summary": "Finish connecting QuickBooks",
        "description": "Trades the code Intuit returned for tokens and saves the connection. The\n`state` must be one `POST /v1/quickbooks/connection/start` gave this user\nfor this company in the last 15 minutes (400 \"connection expired\"\notherwise).",
        "operationId": "finish_quickbooks_connection",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/QuickbooksCallback"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Connected",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Connected"
                }
              }
            }
          },
          "400": {
            "description": "Expired or foreign state, a bad realm id, or Intuit refused the code",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "delete": {
        "tags": [
          "company"
        ],
        "summary": "Disconnect QuickBooks",
        "description": "Forgets the company's `QuickBooks` connection.",
        "operationId": "disconnect_quickbooks",
        "parameters": [
          {
            "name": "company_id",
            "in": "query",
            "description": "Superusers only: the company to act on (default: the caller's).",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Disconnected"
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller does not manage the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/quickbooks/connection/start": {
      "post": {
        "tags": [
          "company"
        ],
        "summary": "Start connecting QuickBooks",
        "description": "Intuit's consent page for the caller's company. Intuit returns to\n`/redirects/quickbooks/user-auth` on the app's apex domain with `code`,\n`state` and `realmId`; post them to `POST /v1/quickbooks/connection`\nwithin 15 minutes.",
        "operationId": "start_quickbooks_connection",
        "responses": {
          "200": {
            "description": "Intuit's consent page",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AuthorizeLink"
                }
              }
            }
          },
          "400": {
            "description": "QuickBooks connect is not set up for the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/quickbooks/disconnected": {
      "post": {
        "tags": [
          "company"
        ],
        "summary": "QuickBooks was disconnected at Intuit",
        "description": "Intuit sends users who disconnect the app to `/quickbooks/disconnect`\nwith the `realmId`; the page posts it here and the caller's company loses\nits connection when it holds that `QuickBooks` company. A session is\nrequired: anyone could otherwise disconnect a company knowing its realm id\n(a signed-out visitor loses nothing: the app asks to reconnect once Intuit\nrefuses the tokens). Always 204 (it never tells whether it matched).",
        "operationId": "quickbooks_disconnected",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RealmDisconnect"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Done (whether or not the company matched)"
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/superuser/companies/{id}/quickbooks-app": {
      "put": {
        "tags": [
          "superuser"
        ],
        "summary": "Save a company's own QuickBooks app",
        "description": "Superusers: stores (encrypted) the client id and secret of an Intuit app\nthe company connects through instead of the shared one.",
        "operationId": "save_company_quickbooks_app",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Company id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/QuickbooksApp"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Saved"
          },
          "400": {
            "description": "Keys shorter than 10 characters",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not a superuser",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "503": {
            "description": "AES_KEY is not set",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/ringcentral/connection": {
      "post": {
        "tags": [
          "company"
        ],
        "summary": "Finish connecting RingCentral",
        "description": "Trades the code for tokens, saves the connection and subscribes to the\ncompany's texts (a failed subscription does not undo the connect).",
        "operationId": "finish_ringcentral_connection",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RingcentralCallback"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Connected",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Connected"
                }
              }
            }
          },
          "400": {
            "description": "Cancelled, expired or foreign state, or RingCentral refused the code",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "delete": {
        "tags": [
          "company"
        ],
        "summary": "Disconnect RingCentral",
        "description": "Stops `RingCentral` pushing the company's texts and forgets the\nconnection.",
        "operationId": "disconnect_ringcentral",
        "parameters": [
          {
            "name": "company_id",
            "in": "query",
            "description": "Superusers only: the company to act on (default: the caller's).",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Disconnected"
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller does not manage the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/ringcentral/connection/start": {
      "post": {
        "tags": [
          "company"
        ],
        "summary": "Start connecting RingCentral",
        "description": "`RingCentral`'s sign-in page for the caller's company. `RingCentral`\nreturns to `/redirects/ringcentral/user-auth` on the app's apex domain\nwith `code` and `state` (or `error`); post them to\n`POST /v1/ringcentral/connection` within 15 minutes.",
        "operationId": "start_ringcentral_connection",
        "responses": {
          "200": {
            "description": "RingCentral's sign-in page",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AuthorizeLink"
                }
              }
            }
          },
          "400": {
            "description": "RingCentral connect is not set up",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/company/position-sections": {
      "get": {
        "tags": [
          "company"
        ],
        "summary": "List position access",
        "description": "Every tab of the app, and for each position the company may change (all\nbut Super Admin and the portal ones: Installer, Marketing, Walk-in,\nTemplate Guy) the tabs it opens, its defaults and whether the company\nchanged them. Shop Worker stays in the Shop app: its tabs are that app's\nTransactions, Samples and Schedule. Someone with several positions gets\nall their tabs together. By default every position opens the whole main\napp, except Shop Manager and Shop Worker (Schedule, Transactions,\nSamples), Inventory Manager and Scheduling Manager. The Admin switch still opens\nevery admin page; an admin tab opens that page to someone without it.\nEvery skill too, and each position's: by default every position sells\nslabs and works with transactions and quotes, and only Scheduling Manager\nplans the schedule; the Admin switch keeps every skill. Superusers and\ncompany managers (admins with the Manager position);\nsuperusers may pass `company_id`. Change one with `PUT\n/v1/company/position-sections/{position_id}`.",
        "operationId": "list_position_sections",
        "parameters": [
          {
            "name": "company_id",
            "in": "query",
            "description": "Superusers only: the company to act on (default: the caller's).",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The tabs and each position's",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PositionAccess"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller does not manage the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/company/position-sections/{position_id}": {
      "put": {
        "tags": [
          "company"
        ],
        "summary": "Save a position's tabs",
        "description": "Replaces the tabs the position opens in the company, and its skills\n(null: the defaults), from then on for every user holding it (their next\nrequest). Unknown keys are refused, and for Shop Worker any tab the Shop\napp doesn't have.\n`DELETE` the same path to go back to the defaults.",
        "operationId": "save_position_sections",
        "parameters": [
          {
            "name": "position_id",
            "in": "path",
            "description": "1 Sales Rep, 2 Sales Manager, 5 Manager, 3 Shop Manager, 4 Shop Worker, 12 Inventory Manager, 13 Scheduling Manager",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "company_id",
            "in": "query",
            "description": "Superusers only: the company to act on (default: the caller's).",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PositionSectionsInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Saved"
          },
          "400": {
            "description": "A position whose tabs can't be changed, or an unknown tab or skill",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller does not manage the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such company (a superuser's `company_id`)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "delete": {
        "tags": [
          "company"
        ],
        "summary": "Reset a position's tabs",
        "description": "The position opens its default tabs, with its default skills, again in\nthe company.",
        "operationId": "reset_position_sections",
        "parameters": [
          {
            "name": "position_id",
            "in": "path",
            "description": "1 Sales Rep, 2 Sales Manager, 5 Manager, 3 Shop Manager, 4 Shop Worker, 12 Inventory Manager, 13 Scheduling Manager",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "company_id",
            "in": "query",
            "description": "Superusers only: the company to act on (default: the caller's).",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Back to the defaults"
          },
          "400": {
            "description": "A position whose tabs can't be changed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller does not manage the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/company/position-sections/reviewed": {
      "post": {
        "tags": [
          "company"
        ],
        "summary": "Mark position access reviewed",
        "description": "A Manager opened Position access: the setup checklist's \"Adjust\npermissions\" is done for the company (`company.permissions_reviewed_at`,\nkept from the first time).",
        "operationId": "mark_position_access_reviewed",
        "parameters": [
          {
            "name": "company_id",
            "in": "query",
            "description": "Superusers only: the company to act on (default: the caller's).",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Marked"
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller does not manage the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/superuser/companies": {
      "get": {
        "tags": [
          "superuser"
        ],
        "summary": "List the companies",
        "description": "Every live company, most users first: users counting toward the limit,\ntours progress, connected integrations, feature switches and whether\nStripe payment is required. The slower checks come from\n`GET /v1/superuser/companies/statuses` for all companies at once, or per\ncompany from `/{id}/domain-trust`, `/{id}/ses-inbound`, `/{id}/setup-checklist`.",
        "operationId": "list_platform_companies",
        "responses": {
          "200": {
            "description": "The companies",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/CompanySummary"
                  }
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not a superuser",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "post": {
        "tags": [
          "superuser"
        ],
        "summary": "Create a company",
        "description": "Creates the company with its system calendars, the default company email\ntemplates and customer sources, the statistics widgets hidden, a\n`walk-in@<subdomain>.com` employee for the check-in kiosk, and checks\nits domain's deliverability.",
        "operationId": "create_platform_company",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CompanyInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CreatedId"
                }
              }
            }
          },
          "400": {
            "description": "Missing name, bad subdomain or tax",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not a superuser",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "409": {
            "description": "Subdomain already in use",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/superuser/companies/{id}": {
      "get": {
        "tags": [
          "superuser"
        ],
        "summary": "Get a company",
        "description": "A company's settings, keys and switches, as the edit form shows them.",
        "operationId": "get_platform_company",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Company id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CompanyDetails"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not a superuser",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "put": {
        "tags": [
          "superuser"
        ],
        "summary": "Save a company",
        "description": "Replaces the company's settings, keys and switches (and its logo when a\nnew one is given), then re-checks its domain's deliverability.",
        "operationId": "update_platform_company",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Company id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CompanyInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Saved"
          },
          "400": {
            "description": "Missing name, bad subdomain, tax, limit or logo",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not a superuser",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "409": {
            "description": "Subdomain already in use",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "delete": {
        "tags": [
          "superuser"
        ],
        "summary": "Delete a company",
        "description": "Marks the company deleted. `confirm_name` must be its exact name (400\notherwise). Its Granite Manager calling is switched off and its phones are\nsigned out (Telnyx credentials and push tokens dropped).",
        "operationId": "delete_platform_company",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Company id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "confirm_name",
            "in": "query",
            "description": "The company's exact name, typed by the super admin.",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Deleted"
          },
          "400": {
            "description": "The name does not match",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not a superuser",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/superuser/companies/{id}/users": {
      "get": {
        "tags": [
          "superuser"
        ],
        "summary": "List a company's users",
        "description": "The company's active users with their roles, `CloudTalk` fields and\nguided tours progress, and how many users were deleted.",
        "operationId": "list_platform_company_users",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Company id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The users",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CompanyUsers"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not a superuser",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/superuser/companies/statuses": {
      "get": {
        "tags": [
          "superuser"
        ],
        "summary": "List the companies' email and setup statuses",
        "description": "For every live company at once (ordered by id): its domain's\ndeliverability, its SES inbound status and its setup checklist, the same\nvalues `GET /v1/superuser/companies/{id}/domain-trust`, `.../ses-inbound`\nand `.../setup-checklist` answer one company at a time. A domain check\nfrom the last day is reused, so the answer can take a few seconds only\nwhen some domain needs a fresh check. Join it to\n`GET /v1/superuser/companies` by `id`.",
        "operationId": "list_platform_company_statuses",
        "responses": {
          "200": {
            "description": "One status per live company",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/CompanyStatus"
                  }
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not a superuser",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/superuser/companies/{id}/domain-trust": {
      "get": {
        "tags": [
          "superuser"
        ],
        "summary": "Get a company's email deliverability",
        "description": "Checks the email deliverability of the domain the company's mail really\ngoes out from (the one most of its mail sent through the CRM in the last\n90 days came from, else its company domain): DNS (MX, SPF, DMARC, DKIM\nunder common selectors and those its real mail is signed with) and the\nblocklists. A check of the same domain from the last day is reused\nunless `recheck` asks for a new one. Null when the company has neither\nsent mail nor a usable domain.",
        "operationId": "get_platform_company_domain_trust",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Company id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "recheck",
            "in": "query",
            "description": "Check again now instead of reusing the last day's check (a check\nfrom the last minute is still reused).",
            "required": false,
            "schema": {
              "type": "boolean"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The deliverability, or null",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/DomainTrust"
                    },
                    {
                      "type": "null"
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not a superuser",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/superuser/companies/{id}/ses-inbound": {
      "get": {
        "tags": [
          "superuser"
        ],
        "summary": "Get a company's SES inbound status",
        "description": "Whether SES verified the company's domain and its MX points at SES email\nreceiving, i.e. whether customers' replies reach the CRM.",
        "operationId": "get_platform_company_ses_inbound",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Company id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The status",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SesInbound"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not a superuser",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/superuser/companies/{id}/setup-checklist": {
      "get": {
        "tags": [
          "superuser"
        ],
        "summary": "Get a company's setup checklist",
        "description": "What is done of the company's setup: subdomain DNS, domain, key people,\ninbound email (SES), stones on its website, tours, integrations; each\nautomatically or ticked by hand.",
        "operationId": "get_platform_company_setup_checklist",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Company id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The checklist",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Checklist"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not a superuser",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/superuser/companies/{id}/setup-checklist/items/{key}": {
      "put": {
        "tags": [
          "superuser"
        ],
        "summary": "Tick a setup item by hand",
        "description": "Marks a checklist item done (or not) by hand; automatic checks still\ncount either way.",
        "operationId": "tick_platform_company_setup_item",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Company id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "key",
            "in": "path",
            "description": "Item key, e.g. `users.manager`",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Tick"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Saved"
          },
          "400": {
            "description": "Unknown item",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not a superuser",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/superuser/companies/{id}/features/{feature}": {
      "put": {
        "tags": [
          "superuser"
        ],
        "summary": "Switch a company feature",
        "description": "Turns `quickbooks`, `signature`, `onboarding`, `leaderboard` or\n`customer_payments` on or off for the company (an explicit setting, over\nthe platform default; `customer_payments` has no platform default and is\noff until turned on here).",
        "operationId": "switch_platform_company_feature",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Company id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "feature",
            "in": "path",
            "description": "`quickbooks`, `signature`, `onboarding`, `leaderboard` or `customer_payments`",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Switch"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Saved"
          },
          "400": {
            "description": "Unknown feature",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not a superuser",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/superuser/companies/{id}/billing-required": {
      "put": {
        "tags": [
          "superuser"
        ],
        "summary": "Require Stripe payment",
        "description": "Whether the company's access depends on its Stripe subscription (off:\nit pays some other way).",
        "operationId": "set_platform_company_billing_required",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Company id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Switch"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Saved"
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not a superuser",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/superuser/companies/{id}/free-access": {
      "put": {
        "tags": [
          "superuser"
        ],
        "summary": "Give a sign-up company free time",
        "description": "A company from the sign-up page has no access until it pays; this lets\nit in free until the end of `until` (a free month with a demo), or ends\nthe free time (null). When it subscribes during the free time, its first\ncharge waits for the end. Answers the end (ISO 8601) or null. Superusers\nonly; 404 for a deleted or unknown company.",
        "operationId": "set_platform_company_free_access",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Company id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/FreeAccess"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Saved; the end of the free time, or null",
            "content": {
              "application/json": {
                "schema": {
                  "type": [
                    "string",
                    "null"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "A day in the past or too far ahead",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not a superuser",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/superuser/companies/{id}/ringcentral/catch-up": {
      "post": {
        "tags": [
          "superuser"
        ],
        "summary": "Store missed `RingCentral` texts",
        "description": "Reads the message store of `extensions` for the window and hands every\ntext the CRM does not have to the webhook that stores pushes. Without\n`extensions` it only lists them in `remaining`; send one at a time.",
        "operationId": "catch_up_ringcentral_texts",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Company id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CatchUpRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "What was read and handed over",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CatchUpReport"
                }
              }
            }
          },
          "400": {
            "description": "Bad window, or pushes are off on this server",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not a superuser",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/superuser/manual-feedback": {
      "get": {
        "tags": [
          "superuser"
        ],
        "summary": "List manual feedback to review",
        "description": "Unresolved threads users approved or escalated, newest first.",
        "operationId": "list_manual_feedback_reviews",
        "responses": {
          "200": {
            "description": "Threads to review",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/FeedbackReview"
                  }
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not a superuser",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/superuser/manual-feedback/{id}/resolve": {
      "post": {
        "tags": [
          "superuser"
        ],
        "summary": "Resolve a manual feedback thread",
        "description": "Marks the thread reviewed; with `apply_manual_change` its proposed\nsection text replaces that section of the CRM manual for the chat.\nResolving a thread resolved already changes nothing and answers 204, so\na second click never puts an old text back over a newer correction.",
        "operationId": "resolve_manual_feedback_review",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Feedback id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Resolve"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Resolved"
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not a superuser",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such feedback",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/signature-requests": {
      "get": {
        "tags": [
          "customers"
        ],
        "summary": "List documents sent for signature",
        "description": "Newest first, with the customer and sender names. `mine` (default):\nwhat the caller sent; `company` (admins): the whole company. Open\n`SignWell` requests are checked with `SignWell` first.",
        "operationId": "list_signature_requests",
        "parameters": [
          {
            "name": "scope",
            "in": "query",
            "description": "`mine` (default): what the caller sent; `company`: everyone's (admins).",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The requests",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/SentRequest"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Unknown scope",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee, or not an admin for `company`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/signature-requests/{id}/cancel": {
      "post": {
        "tags": [
          "customers"
        ],
        "summary": "Cancel a signature request",
        "description": "Stops a request the caller sent that is not finished: a `SignWell`\ndocument is deleted at `SignWell` (its link stops working); a native one\nis revoked here and gets no more reminders. The request becomes `expired`.\n`SignWell` is asked first how the document stands: one the customer has\nalready signed there is never deleted; the answer is 400, nothing changes\nhere and nobody is emailed (the signature is recorded when `SignWell`\nreports it).\nWith `notify_customer`, the signer is emailed that it was cancelled (from\nthe sender, in the invitation's thread when there is one) and the answer\nsays whether that email went out.",
        "operationId": "cancel_signature_request",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Signature request id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "requestBody": {
          "description": "Optional; no body: the customer is not told",
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CancelInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Cancelled; whether the customer was emailed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Cancelled"
                }
              }
            }
          },
          "204": {
            "description": "Cancelled"
          },
          "400": {
            "description": "Already finished, already signed at SignWell (not deleted), or SignWell refused (its message)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an employee",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such request sent by the caller",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/public/signing/{document_id}/session": {
      "post": {
        "tags": [
          "signing"
        ],
        "summary": "Open a signing session",
        "description": "Trades the invitation link's token for a 30-minute signing session\n(`__Host-native_signing_<document>` cookie of this host). Opening the link\ncounts as the signer viewing the document (the sender is told once).",
        "operationId": "open_signing_session",
        "parameters": [
          {
            "name": "document_id",
            "in": "path",
            "description": "The document's id (a UUID)",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/InvitationToken"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Session open (cookie set)"
          },
          "404": {
            "description": "Not a valid link",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SignerErrorBody"
                }
              }
            }
          },
          "409": {
            "description": "Not ready for signing",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SignerErrorBody"
                }
              }
            }
          },
          "410": {
            "description": "The link has expired",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SignerErrorBody"
                }
              }
            }
          },
          "503": {
            "description": "Signing is unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SignerErrorBody"
                }
              }
            }
          }
        }
      }
    },
    "/v1/public/signing/{document_id}": {
      "get": {
        "tags": [
          "signing"
        ],
        "summary": "Open a signing link",
        "description": "For a native document: the document and the signer's state (needs the\nsession cookie from `.../session`). For a `SignWell` document: its\nembedded signing page.",
        "operationId": "get_signing_page",
        "parameters": [
          {
            "name": "document_id",
            "in": "path",
            "description": "The document's id (a UUID)",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "What to show",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SigningPage"
                }
              }
            }
          },
          "404": {
            "description": "Not a valid link (or no session)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SignerErrorBody"
                }
              }
            }
          },
          "503": {
            "description": "Signing is unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SignerErrorBody"
                }
              }
            }
          }
        }
      }
    },
    "/v1/public/signing/{document_id}/actions": {
      "post": {
        "tags": [
          "signing"
        ],
        "summary": "Act on a document",
        "description": "Starts (the signer reviewed it), finishes (signs; answers in\n`submission`: `documentVersion`, `consent: true`, `consentVersion`,\n`idempotencyKey`, `answers` by field id), resumes an interrupted finish,\nor declines. Must come from the signing page's origin with the session\ncookie and its `csrf`. Answers the updated view.",
        "operationId": "act_on_signing",
        "parameters": [
          {
            "name": "document_id",
            "in": "path",
            "description": "The document's id (a UUID)",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SigningAction"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "The updated view",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SigningPage"
                }
              }
            }
          },
          "400": {
            "description": "Invalid answers",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SignerErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Wrong origin or CSRF token, or declining is off",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SignerErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "Not a valid link (or no session)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SignerErrorBody"
                }
              }
            }
          },
          "409": {
            "description": "Already signed or declined, a finish is in progress, or the document changed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SignerErrorBody"
                }
              }
            }
          },
          "410": {
            "description": "The link has expired",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SignerErrorBody"
                }
              }
            }
          },
          "413": {
            "description": "Too large",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SignerErrorBody"
                }
              }
            }
          },
          "415": {
            "description": "Not JSON",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SignerErrorBody"
                }
              }
            }
          },
          "503": {
            "description": "Unavailable, or the signed PDF could not be saved (resume)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SignerErrorBody"
                }
              }
            }
          }
        }
      }
    },
    "/v1/public/signing/{document_id}/download": {
      "get": {
        "tags": [
          "signing"
        ],
        "summary": "Download the document",
        "description": "`prepared`: the document to review (while it can be signed), shown\ninline. `completed`: the signed copy, as an attachment. Needs the\nsession cookie. Big files redirect to a short-lived link.",
        "operationId": "download_signing_document",
        "parameters": [
          {
            "name": "document_id",
            "in": "path",
            "description": "The document's id (a UUID)",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "kind",
            "in": "query",
            "description": "`prepared` (the document to read) or `completed` (the signed copy).",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The PDF",
            "content": {
              "application/pdf": {}
            }
          },
          "302": {
            "description": "A short-lived link to a big PDF"
          },
          "404": {
            "description": "Not a valid link, kind or session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SignerErrorBody"
                }
              }
            }
          },
          "409": {
            "description": "Not signable any more",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SignerErrorBody"
                }
              }
            }
          },
          "410": {
            "description": "Expired",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SignerErrorBody"
                }
              }
            }
          },
          "503": {
            "description": "Unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SignerErrorBody"
                }
              }
            }
          }
        }
      }
    },
    "/v1/signatures/{id}/document": {
      "get": {
        "tags": [
          "customers"
        ],
        "summary": "Open a natively signed document",
        "description": "The document as sent, or signed once the customer signed it, from the\nprivate signature bucket; one over 4 MB redirects to a presigned link.\nFor a browser tab: errors are plain text.",
        "operationId": "open_native_signature_document",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Signature request id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          },
          {
            "name": "customer_id",
            "in": "query",
            "description": "Opened from this customer's documents: anyone in the company may\nopen the customer's documents. Otherwise only the sender or an admin.",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The PDF",
            "content": {
              "application/pdf": {}
            }
          },
          "302": {
            "description": "Over 4 MB: redirect to a presigned link"
          },
          "401": {
            "description": "No valid session, or not an employee",
            "content": {
              "text/plain": {}
            }
          },
          "404": {
            "description": "No such document the caller may open",
            "content": {
              "text/plain": {}
            }
          },
          "503": {
            "description": "The file cannot be read right now",
            "content": {
              "text/plain": {}
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/signature-requests/{id}/signed-pdf": {
      "get": {
        "tags": [
          "customers"
        ],
        "summary": "Open a signed `SignWell` document",
        "description": "The signed PDF, titled and named \"<document> signed.pdf\"; the original\nfile while it is not signed. One over 4 MB is stored in the bucket and\nredirects to a presigned link. For a browser tab: errors are plain text.",
        "operationId": "open_signed_pdf",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Signature request id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The PDF",
            "content": {
              "application/pdf": {}
            }
          },
          "302": {
            "description": "Over 4 MB: redirect to a presigned link"
          },
          "401": {
            "description": "No valid session, or not an employee",
            "content": {
              "text/plain": {}
            }
          },
          "404": {
            "description": "No such request in the caller's company",
            "content": {
              "text/plain": {}
            }
          },
          "502": {
            "description": "The document could not be downloaded",
            "content": {
              "text/plain": {}
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/webhooks/signwell": {
      "get": {
        "tags": [
          "signatures"
        ],
        "summary": "Check the webhook URL",
        "description": "Answers `SignWell` checking that the webhook URL is there.",
        "operationId": "check_signwell_webhook",
        "responses": {
          "200": {
            "description": "The URL is there",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookOk"
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "signatures"
        ],
        "summary": "Receive a `SignWell` event",
        "description": "A document's event (`document_viewed`, `document_completed`,\n`document_declined`, `document_canceled`…): its signature request moves\nforward, the sender is notified, and a signed contract sells its quote.\nNeeds `?token=` / `x-webhook-token` (`SIGNWELL_WEBHOOK_SECRET`) or the\nevent's hash (`SIGNWELL_WEBHOOK_ID`); no session.",
        "operationId": "receive_signwell_webhook",
        "parameters": [
          {
            "name": "token",
            "in": "query",
            "description": "`SIGNWELL_WEBHOOK_SECRET`, when the webhook URL carries it.",
            "required": false,
            "schema": {
              "type": [
                "string",
                "null"
              ]
            }
          },
          {
            "name": "x-webhook-token",
            "in": "header",
            "description": "`SIGNWELL_WEBHOOK_SECRET`",
            "required": false,
            "schema": {
              "type": [
                "string",
                "null"
              ]
            }
          }
        ],
        "requestBody": {
          "description": "The event, as SignWell sends it: `event` (`type`, `time`, `hash`) and `data.object.id`",
          "content": {
            "application/json": {
              "schema": {
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Taken (an unknown document or event changes nothing)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookOk"
                }
              }
            }
          },
          "400": {
            "description": "Not an event, or no document id",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "Neither the token nor the hash checks out",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        }
      }
    },
    "/v1/posthog-autofix/runs/{id}/started": {
      "post": {
        "tags": [
          "posthog-autofix"
        ],
        "summary": "Record that a fix run started",
        "description": "Called once by the `posthog-autofix` GitHub workflow when it begins,\nbefore the agent runs. Moves the run from `dispatched` to `running` and\nstores the GitHub run link. `issue_id` must be the run's PostHog issue id.\nRepeating the same call (same `github_run_url`) answers 200 with\n`changed: false`. Any other status (for example a run the intake never\ndispatched) answers 409, and the workflow must stop. Uses the callback\nsecret, not a session.",
        "operationId": "start_posthog_autofix_run",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Ledger run id, passed to the workflow as an input",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64",
              "minimum": 0
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/StartedReport"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Recorded, or already recorded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CallbackApplied"
                }
              }
            }
          },
          "400": {
            "description": "Malformed body, issue id or GitHub link",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "Missing or wrong callback secret",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such run, or its issue id differs",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "409": {
            "description": "The run is not dispatched; the workflow must stop",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "autofix_callback": []
          }
        ]
      }
    },
    "/v1/posthog-autofix/runs/{id}/result": {
      "post": {
        "tags": [
          "posthog-autofix"
        ],
        "summary": "Record a fix run's result",
        "description": "Called once by the `posthog-autofix` GitHub workflow when it ends. Closes\nthe run as `succeeded` (`conclusion` completed, with the agent's answer in\n`agent`) or `failed`, stores the outcome, pull request, verification and\ncost, and emails the developers. A `usage_limited` conclusion puts the run\nback in the queue to be retried in an hour, with no email, until its\nattempts run out; then it fails. A late result for a run the watchdog\ntimed out is still recorded. Repeating a result answers 200 with\n`changed: false` and sends no second email. A result for a run that never\nstarted answers 409. Uses the callback secret, not a session.",
        "operationId": "finish_posthog_autofix_run",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Ledger run id, passed to the workflow as an input",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64",
              "minimum": 0
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RunReport"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Recorded, or already recorded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CallbackApplied"
                }
              }
            }
          },
          "400": {
            "description": "Malformed body, issue id or link, or a completed run without `agent`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "Missing or wrong callback secret",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such run, or its issue id differs",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "409": {
            "description": "The run is in a status that cannot take a result",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "autofix_callback": []
          }
        ]
      }
    },
    "/v1/auth/device-sessions": {
      "post": {
        "tags": [
          "phone"
        ],
        "summary": "Sign a phone in",
        "description": "Signs the Granite Manager app in with the CRM email and password and\nreturns its device token (send it as the `X-Granite-Device` header) and\nits call key (signs the calls it places), both shown only here. Only\nemployees, admins, superusers and holders of a position with set pages\n(a Shop Worker, say) of a company that is not deleted may:\nothers get 403 `no_phone_access`.\nFailed attempts count together with `POST /v1/auth/login`'s (10 per\nemail and address, 50 per email in 15 minutes, then 429\n`rate_limited`), and a wrong email and a wrong password both answer 401\n`invalid_credentials`. The sign-in lasts until the phone signs out or is\nrevoked, never ending by time. Next:\n`POST /v1/phone/devices` registers the phone for calling.\n\nWhen the account needs another step first (two-step sign-in is on, the\npassword is 1111, or a superuser has not set up two-step sign-in), the\nanswer is 202 with a `LoginChallenge` when `steps` is true (see `POST\n/v1/auth/login/code`, `/password`, `/authenticator`: the last step\nanswers this route's 201), else 403 asking to update the app.",
        "operationId": "create_device_session",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DeviceSignIn"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Signed in; the device token and call key are in the body",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DeviceSession"
                }
              }
            }
          },
          "202": {
            "description": "Right password; another step is needed first (`steps` true)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LoginChallenge"
                }
              }
            }
          },
          "400": {
            "description": "A field is missing or empty, or the platform is unknown",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "`invalid_credentials`: wrong email or password",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "`no_phone_access`: not an employee, admin, superuser or position holder, or the company is deleted; or the account needs a sign-in step this app cannot do (`steps` false)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "429": {
            "description": "`rate_limited`: too many failed attempts; try later",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        }
      }
    },
    "/v1/auth/device-sessions/current": {
      "delete": {
        "tags": [
          "phone"
        ],
        "summary": "Sign this phone out",
        "description": "Ends the device session of the request's `X-Granite-Device` token: the\ntoken stops working, the phone's Telnyx credential is deleted and its\npush token cleared. The app then wipes its local data. Device token only.",
        "operationId": "delete_current_device_session",
        "responses": {
          "204": {
            "description": "Signed out"
          },
          "401": {
            "description": "No valid device token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "device_token": []
          }
        ]
      }
    },
    "/v1/me/devices": {
      "get": {
        "tags": [
          "phone"
        ],
        "summary": "List my signed-in phones",
        "description": "The caller's Granite Manager sign-ins that are not signed out, newest\nfirst; `current` marks the phone making the request (always false with\nthe CRM's cookie). Revoke one with `DELETE /v1/me/devices/{id}`. Takes\nthe device token or the session cookie (employees, admins, superusers).",
        "operationId": "list_my_devices",
        "responses": {
          "200": {
            "description": "The caller's phones",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SignedInDevices"
                }
              }
            }
          },
          "401": {
            "description": "No valid device token or session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Cookie of a user who is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "device_token": []
          },
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/me/devices/{id}": {
      "delete": {
        "tags": [
          "phone"
        ],
        "summary": "Sign one of my phones out",
        "description": "Revokes one of the caller's device sessions (an id from\n`GET /v1/me/devices`; it may be the calling phone itself): its token stops\nworking, its Telnyx credential is deleted and the phone is told to wipe\nitself. 404 when the session is not the caller's or is signed out already.\nTakes the device token or the session cookie.",
        "operationId": "revoke_my_device",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Device session id (`SignedInDevice.id`)",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Signed out"
          },
          "401": {
            "description": "No valid device token or session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Cookie of a user who is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "Not one of the caller's signed-in phones",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "device_token": []
          },
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/phone/active-company": {
      "put": {
        "tags": [
          "phone"
        ],
        "summary": "Switch the app to another company",
        "description": "An installer or template guy picks which of their companies (`PhoneUser.companies`) the\nphone acts in: its jobs, schedule and projects. Kept on this device session. Notifications\nof every one of those companies still come to the phone. Answers the user as they now are.",
        "operationId": "set_phone_active_company",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PhoneActiveCompany"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Switched",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PhoneUser"
                }
              }
            }
          },
          "401": {
            "description": "No valid device token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Not one of the user's companies",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "device_token": []
          }
        ]
      }
    },
    "/v1/auth/web-link": {
      "post": {
        "tags": [
          "phone"
        ],
        "summary": "Get a link that opens a CRM page signed in",
        "description": "For the Granite Manager app: returns a link to `path` on the caller's CRM\nhost that signs the phone's browser in as the caller on the way. Open it\nat once (the API's base URL + `link_path`): it works for `expires_in`\nseconds, and only while this phone stays signed in. Device token only.",
        "operationId": "create_web_link",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WebLinkInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "The link",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebLink"
                }
              }
            }
          },
          "400": {
            "description": "The path is not a page of the CRM's host",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid device token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "device_token": []
          }
        ]
      }
    },
    "/v1/auth/web-link/{token}": {
      "get": {
        "tags": [
          "phone"
        ],
        "summary": "Open a CRM page signed in",
        "description": "Follows a link from `POST /v1/auth/web-link`: redirects (303) to its page\non the company's CRM host, with a session cookie for the link's user. A\nbrowser already signed in as that user keeps its session; otherwise a new\none starts, as signing in with the password does. An expired or changed\nlink, or one whose phone was signed out since, redirects to the CRM's\nsign-in page instead. Takes no other credentials.",
        "operationId": "open_web_link",
        "parameters": [
          {
            "name": "token",
            "in": "path",
            "description": "The token of the link",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "303": {
            "description": "To the page signed in, or to the sign-in page when the link no longer works"
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        }
      }
    },
    "/v1/phone/bootstrap": {
      "get": {
        "tags": [
          "phone"
        ],
        "summary": "Start the phone app",
        "description": "One call at app start, on resume after 5 minutes and after a push wake:\nthe user, this phone's registration, caller IDs, settings, availability,\nthe company's switches (calling, recording mode, minimum app version),\nthe notices to show, the contact index's version and the unread counts.\nDevice token only. Next: `POST /v1/phone/devices` when `device` is null,\n`GET /v1/phone/contacts/index` when `contacts.etag` changed.",
        "operationId": "get_phone_bootstrap",
        "responses": {
          "200": {
            "description": "Everything the app needs",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Bootstrap"
                }
              }
            }
          },
          "401": {
            "description": "No valid device token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "device_token": []
          }
        ]
      }
    },
    "/v1/phone/devices": {
      "post": {
        "tags": [
          "phone"
        ],
        "summary": "Register this phone",
        "description": "Registers the phone of this device session for calling, or updates it\n(idempotent: 201 the first time, 200 after). While calling is on for the\ncompany it also gets its Telnyx telephony credential (working 30 days,\nextended with every login JWT); `sipUsername` stays null while calling is\noff. A `pushToken` here or later (`PUT .../push-token`) lets us push\nmissed calls; no other phone keeps that token. Device token only. Next:\n`POST /v1/phone/devices/{id}/token`.",
        "operationId": "register_phone_device",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DeviceRegistration"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Already registered; updated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PhoneDevice"
                }
              }
            }
          },
          "201": {
            "description": "Registered",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PhoneDevice"
                }
              }
            }
          },
          "400": {
            "description": "Missing device name, unknown platform or too long a push token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid device token, or `device_revoked`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "502": {
            "description": "Telnyx did not create the credential; try again",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "device_token": []
          }
        ]
      }
    },
    "/v1/phone/devices/{id}/token": {
      "post": {
        "tags": [
          "phone"
        ],
        "summary": "Get a Telnyx login JWT",
        "description": "Mints a Telnyx login JWT (about 24 hours) for this phone's SIP credential\nand extends the credential to 30 days; makes the credential first when\nthe phone has none yet. At most one a minute and six an hour per phone\n(429 with `retryAfterSecs`); a failed mint does not count. 403\n`calling_disabled` while the company's calling is off, 403\n`update_required` when the app is older than the minimum version (the\nversion in `X-Granite-App-Version` when sent, which is also saved; else\nthe registered one), 404 when `id` is not this session's phone. The\nnative calling module calls it too, with the same headers.",
        "operationId": "mint_phone_device_token",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "This session's phone device (`PhoneDevice.id`)",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The JWT",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DeviceToken"
                }
              }
            }
          },
          "401": {
            "description": "No valid device token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "`calling_disabled` or `update_required`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "Not this session's phone",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "429": {
            "description": "`rate_limited`: one a minute, six an hour",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RateLimited"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "502": {
            "description": "Telnyx failed; try again",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "503": {
            "description": "Telnyx is not set up on the server",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "device_token": []
          }
        ]
      }
    },
    "/v1/phone/devices/{id}/push-token": {
      "put": {
        "tags": [
          "phone"
        ],
        "summary": "Set this phone's push token",
        "description": "Saves the phone's FCM registration token (after it changes), for our\npushes: missed calls, voicemails, AI messages, new emails, sign-outs. No\nother phone keeps the token. 404 when `id` is not this session's phone. The native\ncalling module calls it too.",
        "operationId": "set_phone_push_token",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "This session's phone device (`PhoneDevice.id`)",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PushTokenInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Saved"
          },
          "400": {
            "description": "Empty or too long",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid device token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "Not this session's phone",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "device_token": []
          }
        ]
      }
    },
    "/v1/phone/caller-ids": {
      "get": {
        "tags": [
          "phone"
        ],
        "summary": "List my caller IDs",
        "description": "The company numbers the user may call from (direct lines first, then\nshared lines, then the main line) and the one to preselect. Device token\nonly.",
        "operationId": "list_phone_caller_ids",
        "responses": {
          "200": {
            "description": "My caller IDs",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CallerIds"
                }
              }
            }
          },
          "401": {
            "description": "No valid device token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "device_token": []
          }
        ]
      }
    },
    "/v1/phone/settings": {
      "put": {
        "tags": [
          "phone"
        ],
        "summary": "Change my phone settings",
        "description": "Changes only the fields sent: default caller ID, AI notes, working\nhours, cell fallback, ring timeout, \"Forward all calls\", incoming call\ninformation (display number, announcements, answer PIN) and hold music;\nreturns all the settings. The cell number changes only through\n`POST /v1/phone/cell/verify` and `/confirm`; Do not disturb through\n`PUT /v1/phone/availability`; custom rules through\n`/v1/phone/call-rules`. 400 `not_a_caller_id`, `cell_not_verified`,\n`invalid_phone`, `invalid_pin`, `pin_required`, `invalid_hold_music`, or\na message for bad hours or timeouts. Device token only.",
        "operationId": "update_phone_settings",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SettingsPatch"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "The settings now",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PhoneSettings"
                }
              }
            }
          },
          "400": {
            "description": "`not_a_caller_id`, `cell_not_verified`, `invalid_phone`, `invalid_pin`, `pin_required`, `invalid_hold_music`, or what is wrong",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid device token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "device_token": []
          }
        ]
      }
    },
    "/v1/phone/availability": {
      "put": {
        "tags": [
          "phone"
        ],
        "summary": "Set my availability",
        "description": "`available` ends Do not disturb; `dnd` turns it on until `dndUntil`, or\nuntil turned off when that is null. Returns the availability now, which\nis `outside_hours` when the user is available but outside their working\nhours. While not available, calls go to the number's fallback (and still\nshow in Recents). Device token only.",
        "operationId": "set_phone_availability",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AvailabilityInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "My availability now",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Availability"
                }
              }
            }
          },
          "400": {
            "description": "Unknown status, or `dndUntil` not in the next year",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid device token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "device_token": []
          }
        ]
      }
    },
    "/v1/phone/notices/accept": {
      "post": {
        "tags": [
          "phone"
        ],
        "summary": "Accept a notice",
        "description": "Records that the user accepted this version of the recording notice or\nthe 911 notice (on this phone); accepting again is fine. 400 for a\nversion that does not exist (below 1 or above the current one). Device\ntoken only.",
        "operationId": "accept_phone_notice",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/NoticeAcceptance"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Accepted"
          },
          "400": {
            "description": "Unknown notice or version",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid device token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "device_token": []
          }
        ]
      }
    },
    "/v1/phone/cell/verify": {
      "post": {
        "tags": [
          "phone"
        ],
        "summary": "Verify my cell",
        "description": "Our server calls `cellNumber` (US or Canada) from a company number and\nreads out a 6-digit code, valid 10 minutes; send it to\n`POST /v1/phone/cell/confirm`. The verified cell stays as it is until the\nnew one is confirmed. At most one code call a minute and five a day\n(429, also when the code was confirmed or voided since), and each takes\none of the user's 6 calls a minute (429 while those are used up); a\ncall Telnyx did not place does not count. 400 `invalid_phone`; 403\n`calling_disabled` while the company's calling is off or it has no\nnumber to call from. Takes the device token or the session cookie (the\nCRM's phone dock verifies the cell for Call via my cell).",
        "operationId": "verify_phone_cell",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CellVerify"
              }
            }
          },
          "required": true
        },
        "responses": {
          "202": {
            "description": "Calling the cell now"
          },
          "400": {
            "description": "`invalid_phone`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid device token or session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "`calling_disabled`, or a cookie of a user who is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "429": {
            "description": "`rate_limited`: a code call went out less than a minute ago, five today, or 6 calls this minute",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RateLimited"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "502": {
            "description": "Telnyx did not place the call; try again",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "503": {
            "description": "Telnyx is not set up on the server",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "device_token": []
          },
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/phone/cell/confirm": {
      "post": {
        "tags": [
          "phone"
        ],
        "summary": "Confirm my cell",
        "description": "Checks the code our call read out; when right, the pending number\nbecomes the verified cell (`cellNumber` in the settings returned). 400\n`wrong_code` for a wrong, expired or used-up code (5 tries, then ask for\na new call). Takes the device token or the session cookie.",
        "operationId": "confirm_phone_cell",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CellConfirm"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Verified; my settings now",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PhoneSettings"
                }
              }
            }
          },
          "400": {
            "description": "`wrong_code`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid device token or session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "A cookie of a user who is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "device_token": []
          },
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/phone/contacts/index": {
      "get": {
        "tags": [
          "phone"
        ],
        "summary": "Download the contact index",
        "description": "The compact index of the company's customers (all live ones but the\nonboarding sample) and coworkers, for search on the phone. Without\nparameters: the first page of a full download (5,000 contacts by id;\nfollow `nextAfter` with `?after=`). With `?since=<cursor>`: the customers\nchanged, added or called since, and the ids deleted since (a full\ndownload when the cursor is too old or there are more than 5,000\nchanges). Deal changes (open deal, stage) reach the phone with a full\ndownload, which the app does daily, so a full download always answers\nthe index. `If-None-Match` with the ETag of the last answer (or\n`GET /v1/phone/bootstrap` `contacts.etag`) answers 304 when nothing\nchanged, on a since-sync only. Later pages (`after`) carry no `ETag`.\nDevice token only.",
        "operationId": "get_phone_contact_index",
        "parameters": [
          {
            "name": "since",
            "in": "query",
            "description": "The `cursor` of the last sync: only what changed since (a too old or\nunreadable cursor gets a full download instead).",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "after",
            "in": "query",
            "description": "Pages a full download: the `nextAfter` of the previous page.",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          },
          {
            "name": "If-None-Match",
            "in": "header",
            "description": "The ETag of the phone's copy: 304 when the index is unchanged (since-syncs only)",
            "required": false,
            "schema": {
              "type": [
                "string",
                "null"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Contacts (the `ETag` header is the index version; none on `after` pages)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ContactIndex"
                }
              }
            }
          },
          "304": {
            "description": "Unchanged since the `If-None-Match` ETag (a since-sync)"
          },
          "400": {
            "description": "Malformed query",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid device token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "device_token": []
          }
        ]
      }
    },
    "/v1/phone/contacts/lookup": {
      "post": {
        "tags": [
          "phone"
        ],
        "summary": "Look numbers up",
        "description": "Who each number is: the newest customer of the company with that phone\nor phone 2, and the coworker with that number, any of theirs (matched\nby the last 10 digits; numbers with fewer digits match nothing). Up to 20\nnumbers. Device token only.",
        "operationId": "lookup_phone_contacts",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/LookupInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "One match per number",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ContactLookup"
                }
              }
            }
          },
          "400": {
            "description": "More than 20 numbers",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid device token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "device_token": []
          }
        ]
      }
    },
    "/v1/phone/contacts": {
      "post": {
        "tags": [
          "phone"
        ],
        "summary": "Create a contact",
        "description": "Creates a customer with this name, phone, company, emails, address and,\noptionally, a second phone, source, sales rep and notes (the CRM's\ncustomer form). The sales rep defaults to the caller and the source to\n`call-in`; the rep gets an open deal. Returns them as an index contact;\ncalls from either number match them at once. 400 `invalid_phone` (or\n`invalid_phone2`) unless a US or Canada number; 400 for an empty or too\nlong name, an invalid email, an unknown source or sales rep; 409 when\nanother customer of the company has a phone or email. Device token only.",
        "operationId": "create_phone_contact",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/NewContact"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/IndexContact"
                }
              }
            }
          },
          "400": {
            "description": "`invalid_phone`, `invalid_phone2`, the name is empty or too long, an email is invalid, or the source or sales rep is unknown",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid device token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "409": {
            "description": "Another customer of the company has a phone or email",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "device_token": []
          }
        ]
      }
    },
    "/v1/phone/contacts/{id}": {
      "get": {
        "tags": [
          "phone"
        ],
        "summary": "Get a contact card",
        "description": "A customer of the company with their email, rep and address, their live\ndeals (stage, outcome, amount, newest note) and the last 20 calls with\nthem, and the link to their CRM page. 404 for other companies' customers,\ndeleted ones and the onboarding sample. Device token only.",
        "operationId": "get_phone_contact_card",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Customer id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The contact card",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ContactCard"
                }
              }
            }
          },
          "401": {
            "description": "No valid device token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such customer in the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "device_token": []
          }
        ]
      }
    },
    "/v1/phone/contacts/{id}/phones": {
      "post": {
        "tags": [
          "phone"
        ],
        "summary": "Add a number to a contact",
        "description": "Saves the number as the customer's phone when it is empty, else as phone\n2; when both are used, 409 `phone_2_taken` (with the current phone 2)\nunless `replacePhone2`. A number the customer has already changes\nnothing. A number another customer of the company has is refused (409,\n`error` names that customer). Calls from the customer's numbers match\nthem at once (a replaced phone 2 no longer does). Returns the contact.\n400 `invalid_phone`; 404 for other companies' customers. Device token only.",
        "operationId": "add_phone_contact_number",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Customer id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AddPhone"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "The contact now",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/IndexContact"
                }
              }
            }
          },
          "400": {
            "description": "`invalid_phone`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid device token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such customer in the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "409": {
            "description": "`phone_2_taken`: ask before replacing phone 2. Any other `error`: another customer has the number (the text names them)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Phone2Taken"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "device_token": []
          }
        ]
      }
    },
    "/v1/phone/contact-groups": {
      "get": {
        "tags": [
          "phone"
        ],
        "summary": "List contact groups",
        "description": "The company's contact groups (made by any of its users) with their\nmembers, by name, and which of them I hid from the top of my Contacts;\nalso whether I hid the built-in Coworkers. Members are ids to show from\nthe contact index (`GET /v1/phone/contacts/index`: customers by `id`,\ncoworkers by `userId`); deleted customers and users are left out. Change\na group with `PATCH /v1/phone/contact-groups/{id}` and\n`PUT /v1/phone/contact-groups/{id}/members`. Device token only.",
        "operationId": "list_phone_contact_groups",
        "responses": {
          "200": {
            "description": "The company's groups and what I hid",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ContactGroups"
                }
              }
            }
          },
          "401": {
            "description": "No valid device token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "device_token": []
          }
        ]
      },
      "post": {
        "tags": [
          "phone"
        ],
        "summary": "Create a contact group",
        "description": "A new group with me as its maker, and optionally its first members. Made\nby a Manager, a Sales Manager, an admin or a superuser it is the\ncompany's (`shared` true): every user of the company sees it at the top\nof their Contacts (until they hide it). Made by anyone else it is their\nown (`shared` false): only they see it. `GET /v1/phone/contact-groups`\n`canShare` says which mine will be. At most 100 groups that I see (400\n`too_many_groups`) and 500 members per group (400 `too_many_members`).\n400 `name_taken`, `unknown_contact`, `unknown_coworker`, or what is\nwrong with the name. Device token only.",
        "operationId": "create_phone_contact_group",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/NewGroup"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "The new group",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ContactGroup"
                }
              }
            }
          },
          "400": {
            "description": "`name_taken`, `too_many_groups`, `too_many_members`, `unknown_contact`, `unknown_coworker`, or what is wrong",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid device token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "device_token": []
          }
        ]
      }
    },
    "/v1/phone/contact-groups/{id}": {
      "delete": {
        "tags": [
          "phone"
        ],
        "summary": "Delete a contact group",
        "description": "Deletes the group for everyone who sees it (its customers and coworkers\nthemselves stay). To only take it off the top of my Contacts, hide it\ninstead (`PATCH /v1/phone/contact-groups/{id}` `hidden`). 403 for the\ncompany's group unless I am a Manager, a Sales Manager, an admin or a\nsuperuser (`canEdit`); 404 when the group is not one I see. Device token\nonly.",
        "operationId": "delete_phone_contact_group",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "The group's id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Deleted"
          },
          "401": {
            "description": "No valid device token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "The company's group, and I am not a Manager, a Sales Manager, an admin or a superuser",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "Not a group I see",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "device_token": []
          }
        ]
      },
      "patch": {
        "tags": [
          "phone"
        ],
        "summary": "Rename, hide or show a contact group",
        "description": "`name` renames the group for everyone who sees it (400 as for\n`POST /v1/phone/contact-groups`; 403 for the company's group unless I am\na Manager, a Sales Manager, an admin or a superuser: `canEdit`);\n`hidden` hides it from the top of my own Contacts or shows it there\nagain (other users' tops are left alone; the group and its members\nstay), which anyone may do. Send either or both. 404 when the group is\nnot one I see. Device token only.",
        "operationId": "update_phone_contact_group",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "The group's id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/GroupChange"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "The group now",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ContactGroup"
                }
              }
            }
          },
          "400": {
            "description": "`name_taken`, or what is wrong",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid device token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Renaming the company's group without being a Manager, a Sales Manager, an admin or a superuser",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "Not a group I see",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "device_token": []
          }
        ]
      }
    },
    "/v1/phone/contact-groups/coworkers": {
      "patch": {
        "tags": [
          "phone"
        ],
        "summary": "Hide or show Coworkers",
        "description": "Hides the built-in Coworkers group (everyone at the company with a phone\nnumber) from the top of my Contacts, or shows it there again. Only for\nme; Coworkers itself is unchanged. `GET /v1/phone/contact-groups`\n`coworkersHidden` says which. Device token only.",
        "operationId": "update_phone_coworkers_group",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CoworkersChange"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Saved"
          },
          "400": {
            "description": "No `hidden`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid device token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "device_token": []
          }
        ]
      }
    },
    "/v1/phone/contact-groups/{id}/members": {
      "put": {
        "tags": [
          "phone"
        ],
        "summary": "Set a contact group's members",
        "description": "Makes the group's members exactly the customers and coworkers sent\n(send the whole list: who is left out is taken out; empty lists empty\nthe group). For everyone who sees the group. At most 500 members (400\n`too_many_members`); 400 `unknown_contact` / `unknown_coworker` for ids\nthat are not my company's live customers / users. 403 for the company's\ngroup unless I am a Manager, a Sales Manager, an admin or a superuser\n(`canEdit`); 404 when the group is not one I see. Device token only.",
        "operationId": "set_phone_contact_group_members",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "The group's id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/GroupMembers"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "The group now",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ContactGroup"
                }
              }
            }
          },
          "400": {
            "description": "`too_many_members`, `unknown_contact` or `unknown_coworker`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid device token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "The company's group, and I am not a Manager, a Sales Manager, an admin or a superuser",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "Not a group I see",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "device_token": []
          }
        ]
      }
    },
    "/v1/phone/calls": {
      "get": {
        "tags": [
          "phone"
        ],
        "summary": "List my Recents",
        "description": "The caller's calls, newest first: calls they placed or answered, every\ncall of a direct line assigned to them, and unanswered incoming calls of\nshared and main lines that ring them; calls they hid are left out.\n`filter`: `missed` = incoming calls nobody answered (voicemails and AI\nmessages included), `incoming`, `outgoing`, `recorded`, `voicemail`\n(voicemails and AI messages); `number` = one number's calls. Pages by id\n(`before`, `limit` 1 to 100, default 50). Takes the device token or the\nsession cookie (the CRM's phone dock).",
        "operationId": "list_phone_calls",
        "parameters": [
          {
            "name": "before",
            "in": "query",
            "description": "Paging: only calls with ids below this (the previous page's\n`nextBefore`).",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Calls per page, 1 to 100 (default 50).",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          },
          {
            "name": "filter",
            "in": "query",
            "description": "`all` (default), `missed`, `incoming`, `outgoing`, `recorded` or\n`voicemail`.",
            "required": false,
            "schema": {
              "type": "string",
              "description": "Which calls Recents lists: `all`, `missed` (incoming calls nobody\nanswered, voicemails and AI messages included), `incoming`,\n`outgoing`, `recorded` (with a recording) or `voicemail` (voicemails\nand AI messages).",
              "enum": [
                "All",
                "Missed",
                "Incoming",
                "Outgoing",
                "Recorded",
                "Voicemail"
              ]
            }
          },
          {
            "name": "number",
            "in": "query",
            "description": "Only calls with this number (E.164 or 10 digits; matched by the last\n10 digits).",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "A page of Recents",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CallList"
                }
              }
            }
          },
          "400": {
            "description": "Bad `limit`, `filter` or `number` (`invalid_phone`)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid device token or session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "A cookie of a user who is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "device_token": []
          },
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/phone/calls/ringcentral": {
      "get": {
        "tags": [
          "phone"
        ],
        "summary": "List my `RingCentral` calls",
        "description": "The caller's `RingCentral` calls of the last 30 days, newest first: those\nof an extension of theirs, now or ever, and those to or from a number of\ntheirs, now or ever (the rule texts follow). Each is named after our\ncustomer with that number. Empty when the company has no `RingCentral`\nor it can't be read. Device token only.",
        "operationId": "list_ringcentral_calls",
        "responses": {
          "200": {
            "description": "The caller's RingCentral calls",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RingCentralCalls"
                }
              }
            }
          },
          "401": {
            "description": "No valid device token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "device_token": []
          }
        ]
      }
    },
    "/v1/phone/calls/{id}": {
      "get": {
        "tags": [
          "phone"
        ],
        "summary": "Get a call",
        "description": "One call of the company as the caller sees it (`seen` is theirs), in\ntheir Recents or not; its recording and AI note only when the caller may\nhear it (`hasRecording`). The native calling module reads it (device\nheader) to word missed-call notifications. 404 for other companies'\ncalls. Device token only.",
        "operationId": "get_phone_call",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Our call id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The call",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CallRow"
                }
              }
            }
          },
          "401": {
            "description": "No valid device token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such call in the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "device_token": []
          }
        ]
      },
      "delete": {
        "tags": [
          "phone"
        ],
        "summary": "Hide a call from my Recents",
        "description": "Hides the call from the caller's Recents only (others still see it; it\nstays in contact cards and stats). 404 for other companies' calls.\nDevice token only.",
        "operationId": "hide_phone_call",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Our call id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Hidden"
          },
          "401": {
            "description": "No valid device token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such call in the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "device_token": []
          }
        ]
      }
    },
    "/v1/phone/calls/seen": {
      "post": {
        "tags": [
          "phone"
        ],
        "summary": "Mark calls seen",
        "description": "Marks calls seen for the caller (clears them from the unread counts and\nshows them as seen): the `ids` sent, or every call in their Recents that\nstarted at or before `upTo`. Send one of the two. Takes the device token\nor the session cookie (the CRM's phone dock).",
        "operationId": "mark_phone_calls_seen",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SeenInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Marked"
          },
          "400": {
            "description": "Neither or both of `ids` and `upTo`, or over 500 ids",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid device token or session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "A cookie of a user who is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "device_token": []
          },
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/phone/calls/stats": {
      "get": {
        "tags": [
          "phone"
        ],
        "summary": "Get my call totals",
        "description": "The caller's answered calls (placed or taken) and their talk time today,\nthis week (from Monday) and this month, in the company's time zone (its\nbusiness hours' zone, else America/Indiana/Indianapolis). Device token\nonly.",
        "operationId": "get_phone_call_stats",
        "responses": {
          "200": {
            "description": "My totals",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CallStats"
                }
              }
            }
          },
          "401": {
            "description": "No valid device token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "device_token": []
          }
        ]
      }
    },
    "/v1/phone/calls/{id}/recording": {
      "get": {
        "tags": [
          "phone"
        ],
        "summary": "Get a call's recording",
        "description": "A link to the call's recording that works 5 minutes. Only for those who\nmay hear the call (403 for others): its user, the users of the direct\nline it came in on or went out from, for an incoming call nobody\nanswered the users its line rings, the owner of its deal, company admins\nand sales managers. 404 when the call has no recording (or is another\ncompany's). Device token only.",
        "operationId": "get_phone_call_recording",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Our call id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The link",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RecordingLink"
                }
              }
            }
          },
          "401": {
            "description": "No valid device token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "The caller may not hear this call",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such call, or no recording",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database or storage error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "503": {
            "description": "Recordings are not set up on the server",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "device_token": []
          }
        ]
      }
    },
    "/v1/phone/calls/{id}/note": {
      "post": {
        "tags": [
          "phone"
        ],
        "summary": "Add a note about a call",
        "description": "Adds a deal note (by the caller) on the call's deal, or else on the\noldest open deal of the call's customer, and tells the customer's sales rep\nlike a note written in the CRM. 400 `no_deal` when the call has neither;\n404 for other companies' calls. Device token only.",
        "operationId": "add_phone_call_note",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Our call id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CallNoteInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Added",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CallNoteCreated"
                }
              }
            }
          },
          "400": {
            "description": "Empty or too long, or `no_deal`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid device token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such call in the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "device_token": []
          }
        ]
      }
    },
    "/v1/phone/calls/via-cell": {
      "post": {
        "tags": [
          "phone"
        ],
        "summary": "Call via my cell",
        "description": "\"Call via my cell\" (no data on the phone, or from the CRM): our server\nrings the caller's verified cell from the caller ID; they press 1 and\nthe customer is dialed, recorded and logged (`viaCell` in Recents). The\ncustomer is the one sent when it is the company's, else the number's.\n400 `invalid_phone` (callable US and Canada numbers only), `no_cell`\n(no verified cell), `not_a_caller_id`; 403 `calling_disabled`; 429\n`rate_limited` (6 calls a minute, and the company's daily limit; counted\nfor all the user's phones and the CRM together). Takes the device token\nor the session cookie.",
        "operationId": "call_phone_via_cell",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ViaCellInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "202": {
            "description": "Ringing my cell now",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CallStarted"
                }
              }
            }
          },
          "400": {
            "description": "`invalid_phone`, `no_cell` or `not_a_caller_id`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid device token or session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "`calling_disabled`, or a cookie of a user who is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "429": {
            "description": "`rate_limited`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RateLimited"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "502": {
            "description": "Telnyx did not place the call; try again",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "503": {
            "description": "Telnyx is not set up on the server",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "device_token": []
          },
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/phone/calls/test": {
      "post": {
        "tags": [
          "phone"
        ],
        "summary": "Test this phone",
        "description": "The call health check: our server calls this phone (its SIP user) from\nthe caller's default caller ID (else a company number) and plays a short\nmessage. Test calls are not in Recents or stats; follow it with\n`GET /v1/phone/calls/{id}`. 400 when the phone is not registered; 403\n`calling_disabled`; 429 `rate_limited` (6 calls a minute). Device token\nonly.",
        "operationId": "test_phone_call",
        "responses": {
          "202": {
            "description": "Calling this phone now",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CallStarted"
                }
              }
            }
          },
          "400": {
            "description": "This phone is not registered for calls",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid device token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "`calling_disabled`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "429": {
            "description": "`rate_limited`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RateLimited"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "502": {
            "description": "Telnyx did not place the call; try again",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "503": {
            "description": "Telnyx is not set up on the server",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "device_token": []
          }
        ]
      }
    },
    "/v1/phone/calls/decline": {
      "post": {
        "tags": [
          "phone"
        ],
        "summary": "Decline an incoming call",
        "description": "Best effort, after the user declined on this phone: the call's leg to\nthis phone is marked declined, and when the call still rings, nobody\nanswered and no other person's phone rings, the caller goes on to the\nnumber's no-answer action (AI Assistant, voicemail or forward), which\nstops the user's other phones. On a shared line that also rings others,\nonly this phone stops. Unknown ids are ignored. Device token only.",
        "operationId": "decline_phone_call",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DeclineInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Done (or nothing to do)"
          },
          "400": {
            "description": "Empty id",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid device token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "device_token": []
          }
        ]
      }
    },
    "/v1/phone/calls/reply": {
      "post": {
        "tags": [
          "phone"
        ],
        "summary": "Text the caller of an incoming call",
        "description": "The call screen's quick replies: after the user declined a ringing call\non this phone with a message, the message goes to the caller as a text\nfrom the line they called (the call's number), as `POST /v1/phone/texts`\nsends it, and shows in the Texts tab's thread. Returns 201 with the stored\ntext. 404 when the call did not ring this phone or has\nno caller number or line; 403 `texting_disabled` or `not_my_line` (the\ncalled line is not one the user texts from), 409 `opted_out`, 429\n`rate_limited`, 502 when Telnyx failed. Device token only.",
        "operationId": "reply_to_phone_call",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CallReplyInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Sent",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TextMessage"
                }
              }
            }
          },
          "400": {
            "description": "Empty id, `empty_message` or `text_too_long`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid device token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "`texting_disabled` or `not_my_line`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "Not a call that rang this phone, or no caller number or line",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "409": {
            "description": "`opted_out`: the person texted STOP",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "429": {
            "description": "`rate_limited`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RateLimited"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "502": {
            "description": "Telnyx failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "device_token": []
          }
        ]
      }
    },
    "/v1/phone/directions": {
      "get": {
        "tags": [
          "phone"
        ],
        "summary": "Find where an address is, for driving directions",
        "description": "Returns the address's latitude and longitude (Google geocoding), which\nthe app hands to the phone's maps app so turn-by-turn navigation starts\nat once: a map app given only the words may show the place, or a list\nof matches, first. 404 when Google can't find the address (the app then\npasses the words as before); 400 for an empty or too long address.\nDevice token only.",
        "operationId": "find_phone_directions_point",
        "parameters": [
          {
            "name": "address",
            "in": "query",
            "description": "The address to drive to, as the app shows it (an event's or a\ncustomer's), e.g. `6309 Looking Glass Lane, Indianapolis, IN 46235`.\nAt most 300 characters.",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Where the address is",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Point"
                }
              }
            }
          },
          "400": {
            "description": "Empty or too long address",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid device token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "Google can't find the address",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "device_token": []
          }
        ]
      }
    },
    "/v1/phone/e911": {
      "post": {
        "tags": [
          "phone"
        ],
        "summary": "Alert the admins: 911 dialed",
        "description": "The app opened the phone's own dialer for an emergency or N11 code (the\ncall never goes through Telnyx); this tells the company's admins at once:\nan in-app notification for each, and an `e911_alert` push to their\nphones signed in to the company. The caller is not alerted. Alerts are\ndeduplicated for 10 minutes per phone: a repeat of the same code, or\nany code after an emergency code (911, 112, 933, 988), alerts nobody\nagain (still 204); an emergency code after another N11 code does. 400\n`invalid_phone` for anything but an N11 or emergency code. Device token\nonly.",
        "operationId": "report_phone_e911",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/E911Input"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Admins alerted (or alerted in the last 10 minutes already)"
          },
          "400": {
            "description": "`invalid_phone`: not an emergency or N11 code",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid device token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "device_token": []
          }
        ]
      }
    },
    "/v1/phone/texts/threads": {
      "get": {
        "tags": [
          "phone"
        ],
        "summary": "List my text threads",
        "description": "The conversations of the numbers I may call from, one per line and other\nnumber, newest activity first (page back with `before` = `nextBefore`),\noptionally only those with one other `number`, only those with texts I\nhaven't read (`unread=true`, paged the same way), or only those a\n`search` finds (by number, customer or supplier name, or text). Each has our line, the\nother number, the customer with it, the newest text and my unread count;\n`unread` totals every thread. 403 `texting_disabled` unless the company\ntexts through Telnyx. Next: `GET /v1/phone/texts/threads/{key}/messages`.",
        "operationId": "list_phone_text_threads",
        "parameters": [
          {
            "name": "before",
            "in": "query",
            "description": "`nextBefore` of the previous page.",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Threads per page, 1 to 100 (default 30).",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          },
          {
            "name": "number",
            "in": "query",
            "description": "Only the threads with this other number (E.164 or 10 digits).",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "unread",
            "in": "query",
            "description": "`true`: only the threads with texts I haven't read (the Unread tab).\nDefault `false`, every thread.",
            "required": false,
            "schema": {
              "type": "boolean"
            }
          },
          {
            "name": "search",
            "in": "query",
            "description": "Only the threads this finds, over every thread of my lines (not only\na loaded page): digits anywhere in the other number, the name or\ncompany of the customer or supplier with that number (typos allowed,\n2 or more characters), or words in any of the thread's texts. Up to\n100 characters; empty means no search.",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "A page of threads",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TextThreadList"
                }
              }
            }
          },
          "400": {
            "description": "Bad `limit` or `before`, or `number` is not a phone (`invalid_phone`)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid device token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "`texting_disabled`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "device_token": []
          }
        ]
      }
    },
    "/v1/phone/texts/threads/{key}/messages": {
      "get": {
        "tags": [
          "phone"
        ],
        "summary": "Get a text thread's texts",
        "description": "The newest texts of one of my threads (newest first; page back with\n`before` = `nextBefore`), each with its pictures and files (each with its\nlasting `url`; one without it gets a link from\n`GET /v1/phone/texts/media/{id}`), status, error and sender, and the\nthread itself. 404 for a thread that is not one of my lines' (or has no\ntexts). Opening it does not mark it read: `POST .../read` does.",
        "operationId": "list_phone_text_messages",
        "parameters": [
          {
            "name": "key",
            "in": "path",
            "description": "The thread's key",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "before",
            "in": "query",
            "description": "`nextBefore` of the previous page (a text id).",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Texts per page, 1 to 100 (default 50).",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "A page of texts and the thread",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TextMessageList"
                }
              }
            }
          },
          "400": {
            "description": "Bad `limit` or `before`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid device token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "`texting_disabled`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "Not one of my threads",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "device_token": []
          }
        ]
      }
    },
    "/v1/phone/texts/messages/{id}/thread": {
      "get": {
        "tags": [
          "phone"
        ],
        "summary": "Get the thread of a text",
        "description": "The thread a text is in (one of my lines and one other number), as\n`GET /v1/phone/texts/threads` lists it: its `key`, the other number, the\ncustomer, the newest text and my unread count. The app's new-text\nnotification starts here: the `text` push names only the text\n(`textId`), never the number or the thread. 404 for a text that is not\non one of my lines (or another company's). Device token only.",
        "operationId": "get_phone_text_thread",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "The text's id (`textId` of a `text` push, or a text's `id`)",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The thread",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TextThread"
                }
              }
            }
          },
          "401": {
            "description": "No valid device token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "`texting_disabled`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "Not a text of my lines",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "device_token": []
          }
        ]
      }
    },
    "/v1/phone/texts/messages/{id}": {
      "delete": {
        "tags": [
          "phone"
        ],
        "summary": "Delete a text that failed",
        "description": "Removes one of my lines' outbound texts that was not delivered (status\n`failed`), with its files: it never reached the other person, so the\nconversation no longer shows it. The app deletes the failed text it sends\nagain, so it is never sent twice. 409 for a text that went out (or is\nstill going), 404 for one not on my lines. Device token only.",
        "operationId": "delete_failed_phone_text",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "The text's id (a text's `id`)",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Deleted"
          },
          "401": {
            "description": "No valid device token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "`texting_disabled`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "Not a text of my lines",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "409": {
            "description": "The text did not fail: only a failed text can be deleted",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "device_token": []
          }
        ]
      }
    },
    "/v1/phone/texts/media/{id}": {
      "get": {
        "tags": [
          "phone"
        ],
        "summary": "Link to a text's picture or file",
        "description": "A 5-minute link to a picture or file of a text on one of my lines. 404\nfor one that is not.",
        "operationId": "get_phone_text_media",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "The file's id (`media[].id` of a text)",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "A link",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MediaLink"
                }
              }
            }
          },
          "401": {
            "description": "No valid device token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "`texting_disabled`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "Not a file of my texts",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database or storage error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "device_token": []
          }
        ]
      }
    },
    "/v1/phone/texts": {
      "post": {
        "tags": [
          "phone"
        ],
        "summary": "Text from one of my lines",
        "description": "Sends an SMS from `ourNumberId` (a number I may call from) to `to`\n(US and Canada only) and returns it (`queued`; Telnyx's delivery events\nupdate it), with the thread marked read for me. Files from\n`POST /v1/sms/attachments` go with it (pictures as MMS, other files as\nlinks). 400 `invalid_phone`, a bad text (up to 1600 characters, a text or\na file), or a bad file (`invalid_attachment`, `too_many_images`,\n`images_disabled`), 403 `texting_disabled` /\n`not_my_line`, 409 `opted_out` (the person texted STOP), 429\n`rate_limited` (ten texts a minute, shared with the CRM) with\n`retryAfterSecs`, 502 when Telnyx failed.",
        "operationId": "send_phone_text",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SendText"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Sent",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TextMessage"
                }
              }
            }
          },
          "400": {
            "description": "`invalid_phone`, `empty_message`, `text_too_long`, `invalid_attachment`, `too_many_images` or `images_disabled`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid device token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "`texting_disabled` or `not_my_line`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "409": {
            "description": "`opted_out`: the person texted STOP",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "429": {
            "description": "`rate_limited`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RateLimited"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "502": {
            "description": "Telnyx failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "device_token": []
          }
        ]
      }
    },
    "/v1/phone/texts/threads/{key}/read": {
      "post": {
        "tags": [
          "phone"
        ],
        "summary": "Mark a text thread read",
        "description": "Marks the other number's texts read for me (the CRM's unread counts\nfollow). 404 for a thread that is not one of my lines'.",
        "operationId": "mark_phone_text_thread_read",
        "parameters": [
          {
            "name": "key",
            "in": "path",
            "description": "The thread's key",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Marked read"
          },
          "401": {
            "description": "No valid device token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "`texting_disabled`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "Not one of my threads",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "device_token": []
          }
        ]
      }
    },
    "/v1/phone/admin/numbers": {
      "get": {
        "tags": [
          "phone"
        ],
        "summary": "List the company's phone numbers",
        "description": "The company's Granite Manager numbers (main line first, then shared and\ndirect lines), who each one rings and who may call from it; the users\nnumbers can be given to (employees and admins, by name); and the\ncompany's calling status (`enabled`, `recordingMode`, `configured` =\nTelnyx is set up). Change a number with `PUT\n/v1/phone/admin/numbers/{id}`; add the TeXML app's numbers with `POST\n/v1/phone/admin/numbers/import`. Company admins (and super admins,\nsuperusers) only.",
        "operationId": "list_phone_admin_numbers",
        "responses": {
          "200": {
            "description": "The numbers, users and calling status",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AdminNumbers"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/phone/admin/numbers/{id}": {
      "put": {
        "tags": [
          "phone"
        ],
        "summary": "Change a phone number",
        "description": "Saves the whole number: label, kind (`direct`, `shared`, `main`), what a\ncall nobody answers does (`ai`, `voicemail`, `forward` with `forwardTo`,\na US or Canada number), the voicemail greeting, whether it is active,\nforward only (`forwardOnly`: it rings nobody and every call goes to\n`forwardTo`), where its texts are sent on (`forwardTextsTo`), and\nwho it rings and who may call from it (the list replaces the current\none; every user must be a live user of the company, else 400). A number\nmay not forward to itself (400). Returns\nthe number as saved. The change is written to the phone audit log.\nCompany admins (and super admins, superusers) only.",
        "operationId": "update_phone_admin_number",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "The number (`AdminNumber.id`)",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/NumberInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "The number as saved",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AdminNumber"
                }
              }
            }
          },
          "400": {
            "description": "What is wrong: a label or greeting too long, no or a bad forward number, a user who is not in the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such number in the caller's company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "delete": {
        "tags": [
          "phone"
        ],
        "summary": "Delete a phone number",
        "description": "Releases the number at Telnyx, so the company stops paying for it (it\ncan't be taken back), and takes it off the company's numbers: it rings\nnobody and nobody can call from it. Its calls and texts stay. A number\nTelnyx no longer has is just taken off. 404 when the company has no such\nnumber, 503 when Telnyx is not set up on the server, 502 when Telnyx\nfails (nothing changes). Written to the phone audit log. Company admins\n(and super admins, superusers) only.",
        "operationId": "delete_phone_admin_number",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "The number (`AdminNumber.id`)",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Released and taken off"
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such number in the caller's company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "502": {
            "description": "Telnyx failed; try again",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "503": {
            "description": "Telnyx is not set up on the server",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/phone/admin/numbers/import": {
      "post": {
        "tags": [
          "phone"
        ],
        "summary": "Import the company's numbers from Telnyx",
        "description": "Reads the numbers assigned to the company's TeXML app in Telnyx and adds\nthe ones that are missing here as unassigned direct lines (no label,\nvoicemail when nobody answers); numbers already here are left as\nthey are. Returns how many were added and the company's numbers. 400\nwhen Telnyx is not set up for the company (no TeXML app saved), 503\nwhen Telnyx is not set up on the server, 502 when Telnyx fails. Company\nadmins (and super admins, superusers) only.",
        "operationId": "import_phone_admin_numbers",
        "responses": {
          "200": {
            "description": "How many were added, and the numbers now",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ImportedNumbers"
                }
              }
            }
          },
          "400": {
            "description": "Telnyx is not set up for the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "502": {
            "description": "Telnyx failed; try again",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "503": {
            "description": "Telnyx is not set up on the server",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/phone/admin/devices": {
      "get": {
        "tags": [
          "phone"
        ],
        "summary": "List the company's signed-in phones",
        "description": "Every Granite Manager sign-in of the company's users that is not signed\nout (expired and idle ones stay listed until revoked), newest first,\nwith whose phone it is and its Telnyx SIP user. Sign one out with\n`DELETE /v1/phone/admin/devices/{id}`. Company admins (and super admins,\nsuperusers) only.",
        "operationId": "list_phone_admin_devices",
        "responses": {
          "200": {
            "description": "The company's phones",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AdminDevices"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/phone/admin/devices/{id}": {
      "delete": {
        "tags": [
          "phone"
        ],
        "summary": "Sign a company phone out",
        "description": "Revokes a device session of the company (an id from\n`GET /v1/phone/admin/devices`): its token stops working at once, the\nphone is told to wipe itself (a `revoked` push), its Telnyx credential\nis deleted (retried by the phone job when Telnyx fails) and its push\ntoken cleared. 404 when it is not the company's or is signed out\nalready. Written to the phone audit log. Company admins (and super\nadmins, superusers) only.",
        "operationId": "revoke_phone_admin_device",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Device session id (`AdminDevice.id`)",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Signed out"
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "Not a signed-in phone of the caller's company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/phone/admin/hours": {
      "get": {
        "tags": [
          "phone"
        ],
        "summary": "Get the company's business hours",
        "description": "The main line's business hours and holidays. 404 until Telnyx is\nconnected for the company. Company admins (and super admins,\nsuperusers) only.",
        "operationId": "get_phone_admin_hours",
        "responses": {
          "200": {
            "description": "The hours and holidays",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CompanyHours"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "Telnyx is not set up for the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "put": {
        "tags": [
          "phone"
        ],
        "summary": "Save the company's business hours",
        "description": "Saves the main line's business hours and holidays and returns them.\nChecks: a valid IANA time zone, at least one range, `HH:MM` with start\nbefore end, `YYYY-MM-DD` holidays (at most 366); 400 with a message\notherwise. 404 until Telnyx is connected for the company.\nWritten to the phone audit log. Company admins (and super admins,\nsuperusers) only.",
        "operationId": "save_phone_admin_hours",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CompanyHours"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "The hours as saved",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CompanyHours"
                }
              }
            }
          },
          "400": {
            "description": "What is wrong",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "Telnyx is not set up for the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/phone/admin/recording": {
      "get": {
        "tags": [
          "phone"
        ],
        "summary": "Get the company's call recording",
        "description": "Which calls are recorded and the notice played on recorded outgoing\ncalls. 404 until Telnyx is connected for the company. Company\nadmins (and super admins, superusers) only.",
        "operationId": "get_phone_admin_recording",
        "responses": {
          "200": {
            "description": "The recording setting",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CompanyRecording"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "Telnyx is not set up for the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "put": {
        "tags": [
          "phone"
        ],
        "summary": "Save the company's call recording",
        "description": "Saves which calls are recorded and the notice audio, and returns them.\nThe notice is an `http(s)://` URL (at most 512 characters; blank =\nspoken); 400 otherwise. 404 until Telnyx is connected for the\ncompany. Written to the phone audit log. Company admins (and super\nadmins, superusers) only.",
        "operationId": "save_phone_admin_recording",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CompanyRecording"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "The recording setting as saved",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CompanyRecording"
                }
              }
            }
          },
          "400": {
            "description": "What is wrong",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "Telnyx is not set up for the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/phone/admin/users/{id}/recording-voice": {
      "put": {
        "tags": [
          "phone"
        ],
        "summary": "Turn a user's recording notice on or off",
        "description": "The Phone page's switch per user. Off: their outgoing calls record\nwithout the notice, and callers\nof a number skip it once every user the number rings has it off. Which\ncalls are recorded is `PUT /v1/phone/admin/recording`. 404 when the user\nis not one of the company's phone users. Written to the phone audit log.\nCompany admins (and super admins, superusers) only.",
        "operationId": "set_phone_admin_user_recording_voice",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "The user",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UserRecordingVoice"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Saved"
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "Not one of the company's phone users",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/phone/admin/connect": {
      "post": {
        "tags": [
          "phone"
        ],
        "summary": "Connect Telnyx",
        "description": "Sets the caller's company up for Granite Manager calls and texts in one\ngo (see the module): billing group, outbound voice profile, TeXML\napplication, credential connection and messaging profile, each made\nwhen missing and pointed at the company's webhooks; the company's\nnumbers are put on them and the TeXML app's numbers imported. Safe to\nrun again: it repairs what changed in Telnyx. A company connecting for\nthe first time gets calling switched on. 409 while another connect of\nthe company runs, 502 when Telnyx fails (what was made is kept; try\nagain), 503 when Telnyx is not set up on the server. Written to the\nphone audit log. Company admins (and super admins, superusers) only.",
        "operationId": "connect_phone_admin_telnyx",
        "responses": {
          "200": {
            "description": "Connected",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TelnyxConnection"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "409": {
            "description": "Another connect is running",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "502": {
            "description": "Telnyx failed; try again",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "503": {
            "description": "Telnyx is not set up on the server",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/phone/admin/numbers/available": {
      "get": {
        "tags": [
          "phone"
        ],
        "summary": "Find numbers to buy",
        "description": "Local US numbers with calls and texts for sale in an area code (at most\n12), with their monthly and up-front price. 400 unless `areaCode` is\nthree digits, 502 when Telnyx fails, 503 when Telnyx is not set up on\nthe server. Company admins (and super admins, superusers) only.",
        "operationId": "search_phone_admin_numbers",
        "parameters": [
          {
            "name": "areaCode",
            "in": "query",
            "description": "A US area code, like `317`.",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Numbers for sale",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BuyableNumbers"
                }
              }
            }
          },
          "400": {
            "description": "Not an area code",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "502": {
            "description": "Telnyx failed; try again",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "503": {
            "description": "Telnyx is not set up on the server",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/phone/admin/numbers/buy": {
      "post": {
        "tags": [
          "phone"
        ],
        "summary": "Buy a number",
        "description": "Buys a number for the caller's company in Telnyx (on its TeXML app,\nmessaging profile and billing group) and adds it as an unassigned direct\nline; answers it (assign it with `PUT /v1/phone/admin/numbers/{id}`).\nThe company is charged by Telnyx's price for it. 400 when Telnyx is not\nconnected for the company or the number is not a US or Canadian one,\n403 while its calling is switched off or once it has 25 numbers (a\nsuperuser can buy either way), 409 when\nthe company has it already, 502 when Telnyx fails (the number may be\ntaken: search again). Written to the phone audit log. Company admins\n(and super admins, superusers) only.",
        "operationId": "buy_phone_admin_number",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/BuyNumber"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "The number, bought",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AdminNumber"
                }
              }
            }
          },
          "400": {
            "description": "Not connected, or not a number",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Not an admin, or the company has its most numbers",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "409": {
            "description": "The company has the number already",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "502": {
            "description": "Telnyx did not sell it; try another",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "503": {
            "description": "Telnyx is not set up on the server",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/superuser/companies/{id}/telnyx/connect": {
      "post": {
        "tags": [
          "phone"
        ],
        "summary": "Connect a company's Telnyx",
        "description": "As `POST /v1/phone/admin/connect`, for any company; answers the\ncompany's whole setup. 404 for an unknown or deleted company.\nSuperusers only.",
        "operationId": "connect_company_telnyx",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Company id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The setup after connecting",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TelnyxCompanyConfig"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not a superuser",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "409": {
            "description": "Another connect is running",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "502": {
            "description": "Telnyx failed; try again",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "503": {
            "description": "Telnyx is not set up on the server",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/superuser/companies/{id}/telnyx": {
      "get": {
        "tags": [
          "phone"
        ],
        "summary": "Get a company's Telnyx setup",
        "description": "The company's Granite Manager calling setup: the kill switch, Telnyx\nresource ids, recording mode and notice, the main line's business hours\nand holidays, the minimum app version, the daily call limit, and\n`webhookBase`, the root of the company's Telnyx webhooks to paste into\nthe Telnyx portal. 404 when the company has no setup yet (save one with\n`PUT`) or does not exist. Superusers only.",
        "operationId": "get_company_telnyx_config",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Company id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The setup",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TelnyxCompanyConfig"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not a superuser",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such company, or no Telnyx setup saved yet",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "put": {
        "tags": [
          "phone"
        ],
        "summary": "Save a company's Telnyx setup",
        "description": "Saves the whole setup and returns it: every field of\n`TelnyxCompanyConfig` but the read-only `webhookBase` and what the\ncompany's admins decide (`businessHours` and `holidays` with `PUT\n/v1/phone/admin/hours`, `recordingMode` and `recordingNoticeUrl` with\n`PUT /v1/phone/admin/recording`); blank text is null. The first save makes\nthe company's webhook token (32 random characters, kept from then on),\nso `webhookBase` is known from then on. A `telnyxAccountId` makes every\nTeXML request to the company's webhooks carry that `AccountSid` (403\notherwise). Checks: Telnyx ids without spaces (64 characters, the AI\nAssistant's 128), `http(s)://` URLs,\na version like `1.4.0`,\na daily limit of 0 to 1,000,000; 400 with a message otherwise. Written\nto the phone audit log. Superusers only.",
        "operationId": "save_company_telnyx_config",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Company id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TelnyxConfigInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "The setup as saved",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TelnyxCompanyConfig"
                }
              }
            }
          },
          "400": {
            "description": "What is wrong",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not a superuser",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/phone/admin/ports/portability": {
      "post": {
        "tags": [
          "phone"
        ],
        "summary": "Check whether numbers can move to Telnyx",
        "description": "Asks Telnyx whether each number can be ported in (and with FastPort,\nwithin the day), and says which are company numbers on Telnyx already or\nin an open port. Nothing is saved. 400 unless 1 to 50 US or Canada\nnumbers; 503 when Telnyx is not set up on the server; 502 when Telnyx\nfails. Next: `POST /v1/phone/admin/ports` with the portable ones.\nCompany admins (and super admins, superusers) only.",
        "operationId": "check_phone_port_portability",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PortabilityInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Each number's portability",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PortabilityResults"
                }
              }
            }
          },
          "400": {
            "description": "No numbers, too many, or one that is not a US or Canada number; or Telnyx refused",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "502": {
            "description": "Telnyx failed; try again",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "503": {
            "description": "Telnyx is not set up on the server",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/phone/admin/ports": {
      "get": {
        "tags": [
          "phone"
        ],
        "summary": "List the company's number ports",
        "description": "Every port order of the company, newest first, from our copy (no Telnyx\ncall): numbers, status, port dates, who started it and what the admin\nmay do. Open one with `GET /v1/phone/admin/ports/{id}` to read it again\nfrom Telnyx. Company admins (and super admins, superusers) only.",
        "operationId": "list_phone_port_orders",
        "responses": {
          "200": {
            "description": "The company's port orders",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PortOrders"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "post": {
        "tags": [
          "phone"
        ],
        "summary": "Start porting numbers to Telnyx",
        "description": "Creates a draft port order in Telnyx for the numbers (Telnyx splits it\ninto several when they are with different carriers, of different types,\nor FastPort and not: each order is completed and submitted on its own),\nsets each one up (our webhook; once ported the numbers land on the\ncompany's TeXML app, and its messaging profile when texting is set up)\nand saves our copy. Returns the new orders (201). Next: `PATCH` each\nwith the business details, upload the bill and the signed LOA, pick a\ndate, then `POST .../submit`. 400 when a number is not a US or Canada\nnumber, is a company number already or is in an open port, or Telnyx\nrefuses (its reason in the message); 400 too when Telnyx is not set up\nfor the company. Audited. Company admins (and super admins, superusers)\nonly.",
        "operationId": "create_phone_port_order",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PortCreateInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "The new draft orders",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PortOrders"
                }
              }
            }
          },
          "400": {
            "description": "Bad numbers or label, numbers on Telnyx or in a port already, Telnyx not set up for the company, or Telnyx refused",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "502": {
            "description": "Telnyx failed; try again",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "503": {
            "description": "Telnyx is not set up on the server",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/phone/admin/ports/{id}": {
      "get": {
        "tags": [
          "phone"
        ],
        "summary": "Open a number port",
        "description": "Reads the order from Telnyx and brings our copy up to date (a status\nchange is written to the timeline and told to the admins once; a port\nthat just completed has its numbers added to the company). Returns our\ncopy with Telnyx's details (business details, address, port type,\nattached documents, the numbers' statuses). When Telnyx cannot be read,\nthe saved copy comes back with `details` null and `refreshError` saying\nwhy. 404 when it is not the company's. Company admins (and super admins,\nsuperusers) only.",
        "operationId": "get_phone_port_order",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "The port order (`PortOrder.id`)",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The order, read again from Telnyx",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PortOrderDetail"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such port in the caller's company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "delete": {
        "tags": [
          "phone"
        ],
        "summary": "Delete a draft port",
        "description": "Deletes a draft order in Telnyx (one Telnyx deleted already is fine)\nand marks ours `deleted`; the numbers stay with the current carrier.\nOnly drafts (409 otherwise: cancel a submitted port with `POST\n.../cancel`). Returns the order. Audited. Company admins (and super\nadmins, superusers) only.",
        "operationId": "delete_phone_port_order",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "The port order (`PortOrder.id`)",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The order, deleted",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PortOrderDetail"
                }
              }
            }
          },
          "400": {
            "description": "Telnyx refused",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such port in the caller's company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "409": {
            "description": "Not a draft",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "502": {
            "description": "Telnyx failed; try again",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "503": {
            "description": "Telnyx is not set up on the server",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "patch": {
        "tags": [
          "phone"
        ],
        "summary": "Change a number port",
        "description": "Saves the sections sent (each whole; the ones left out stay): the label\n(ours only), the account holder as on the current carrier's bill\n(business name, authorized person, billing number, account number, PIN;\nan empty PIN keeps the saved one), the service address (US or Canada),\nfull or partial port, the port date to ask for (inside a window of `GET\n.../foc-windows`) and text values for requirements. Telnyx takes changes\nwhile the order is a draft, in process or in exception (else 409).\nReturns the order with Telnyx's details. 400 with what is wrong, or\nTelnyx's reason when it refuses. Audited (section names only). Company\nadmins (and super admins, superusers) only.",
        "operationId": "update_phone_port_order",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "The port order (`PortOrder.id`)",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PortUpdateInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "The order as saved",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PortOrderDetail"
                }
              }
            }
          },
          "400": {
            "description": "What is wrong (a missing or bad field, a date Telnyx does not offer), or Telnyx refused",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such port in the caller's company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "409": {
            "description": "The order can no longer be changed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "502": {
            "description": "Telnyx failed; try again",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "503": {
            "description": "Telnyx is not set up on the server",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/phone/admin/ports/{id}/submit": {
      "post": {
        "tags": [
          "phone"
        ],
        "summary": "Submit a number port",
        "description": "Submits the order to the current carrier through Telnyx (a draft, or\nagain after an exception once it is fixed). Telnyx checks that the\nbusiness details, the signed LOA, the bill and the date are there and\nrefuses otherwise (400, its reason in the message). Returns the order.\nAudited. Company admins (and super admins, superusers) only.",
        "operationId": "submit_phone_port_order",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "The port order (`PortOrder.id`)",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The order, submitted",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PortOrderDetail"
                }
              }
            }
          },
          "400": {
            "description": "Telnyx refused (something is missing)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such port in the caller's company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "409": {
            "description": "Not a draft or an order in exception",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "502": {
            "description": "Telnyx failed; try again",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "503": {
            "description": "Telnyx is not set up on the server",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/phone/admin/ports/{id}/cancel": {
      "post": {
        "tags": [
          "phone"
        ],
        "summary": "Cancel a number port",
        "description": "Asks Telnyx to cancel a submitted order: it goes `cancel-pending` while\nTelnyx's porting team handles it, then `cancelled` (the admins are told).\nNot within 48 hours of the confirmed port date (400: Telnyx support must\ncancel then); a draft is deleted instead (409). Returns the order.\nAudited. Company admins (and super admins, superusers) only.",
        "operationId": "cancel_phone_port_order",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "The port order (`PortOrder.id`)",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The order, cancel asked",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PortOrderDetail"
                }
              }
            }
          },
          "400": {
            "description": "Within 48 hours of the port date, or Telnyx refused",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such port in the caller's company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "409": {
            "description": "A draft, or a port that is done or cancelling",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "502": {
            "description": "Telnyx failed; try again",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "503": {
            "description": "Telnyx is not set up on the server",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/phone/admin/ports/{id}/requirements": {
      "get": {
        "tags": [
          "phone"
        ],
        "summary": "List what a number port still needs",
        "description": "The order's requirements as Telnyx lists them now (by country and\nnumber type): what each asks for, whether it was given and its review\nstatus. Fulfil a textual one with `PATCH` (`requirements`), a document\nwith `POST .../documents` (kind `requirement`). 404 when it is not the\ncompany's. Company admins (and super admins, superusers) only.",
        "operationId": "list_phone_port_requirements",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "The port order (`PortOrder.id`)",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The order's requirements",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PortRequirements"
                }
              }
            }
          },
          "400": {
            "description": "Telnyx refused",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such port in the caller's company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "502": {
            "description": "Telnyx failed; try again",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "503": {
            "description": "Telnyx is not set up on the server",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/phone/admin/ports/{id}/foc-windows": {
      "get": {
        "tags": [
          "phone"
        ],
        "summary": "List the port dates Telnyx offers",
        "description": "The windows a port date may be asked for in (Telnyx's, by the current\ncarrier and the numbers; FastPort orders get earlier ones), earliest\nfirst. Ask for one with `PATCH` (`focDatetimeRequested`); the current\ncarrier confirms the actual date later (`focAt`). 404 when it is not the\ncompany's. Company admins (and super admins, superusers) only.",
        "operationId": "list_phone_port_foc_windows",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "The port order (`PortOrder.id`)",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The windows",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PortFocWindows"
                }
              }
            }
          },
          "400": {
            "description": "Telnyx refused (the order is not ready for a date)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such port in the caller's company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "502": {
            "description": "Telnyx failed; try again",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "503": {
            "description": "Telnyx is not set up on the server",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/phone/admin/ports/{id}/loa-template": {
      "get": {
        "tags": [
          "phone"
        ],
        "summary": "Download a port's Letter of Authorization",
        "description": "The order's LOA from Telnyx, a PDF filled in from the order (save the\nbusiness details first): print or e-sign it, then upload it with `POST\n.../documents` (kind `loa`). 404 when it is not the company's. Company\nadmins (and super admins, superusers) only.",
        "operationId": "download_phone_port_loa_template",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "The port order (`PortOrder.id`)",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The LOA to sign",
            "content": {
              "application/pdf": {
                "schema": {
                  "type": "array",
                  "items": {
                    "type": "integer",
                    "format": "int32",
                    "minimum": 0
                  }
                }
              }
            }
          },
          "400": {
            "description": "Telnyx refused",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such port in the caller's company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "502": {
            "description": "Telnyx failed; try again",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "503": {
            "description": "Telnyx is not set up on the server",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/phone/admin/ports/{id}/timeline": {
      "get": {
        "tags": [
          "phone"
        ],
        "summary": "List a port's timeline",
        "description": "What happened to the order, oldest first: who started, changed and\nsubmitted it, every status change (with Telnyx's exception codes), port\ndate moves, comments from Telnyx, splits, cancellation, and the ported\nnumbers added. From our copy (no Telnyx call). 404 when it is not the\ncompany's. Company admins (and super admins, superusers) only.",
        "operationId": "list_phone_port_timeline",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "The port order (`PortOrder.id`)",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The timeline",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PortTimeline"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such port in the caller's company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/phone/admin/ports/{id}/comments": {
      "get": {
        "tags": [
          "phone"
        ],
        "summary": "List a port's comments",
        "description": "The order's comments with Telnyx's porting team, oldest first, as\nTelnyx has them now (they ask for documents or fixes here; the admins\nare told when one comes). Reply with `POST .../comments`. 404 when it is\nnot the company's. Company admins (and super admins, superusers) only.",
        "operationId": "list_phone_port_comments",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "The port order (`PortOrder.id`)",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The comments",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PortComments"
                }
              }
            }
          },
          "400": {
            "description": "Telnyx refused",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such port in the caller's company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "502": {
            "description": "Telnyx failed; try again",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "503": {
            "description": "Telnyx is not set up on the server",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "post": {
        "tags": [
          "phone"
        ],
        "summary": "Write to Telnyx's porting team on a port",
        "description": "Adds a comment to the order (answer their questions, say a fix is\ndone). Returns it. Not on a deleted draft (409). Audited (not the text).\nCompany admins (and super admins, superusers) only.",
        "operationId": "add_phone_port_comment",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "The port order (`PortOrder.id`)",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PortCommentInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "The comment",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PortComment"
                }
              }
            }
          },
          "400": {
            "description": "Empty or too long, or Telnyx refused",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such port in the caller's company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "409": {
            "description": "The draft was deleted",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "502": {
            "description": "Telnyx failed; try again",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "503": {
            "description": "Telnyx is not set up on the server",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/phone/admin/ports/{id}/documents": {
      "post": {
        "tags": [
          "phone"
        ],
        "summary": "Attach a document to a number port",
        "description": "Uploads the file to Telnyx (a PDF, JPEG or PNG of at most 4 MB, sent\nbase64) and attaches it to the order: the signed LOA (`loa`), a recent\nbill of the current carrier (`invoice`), or what a requirement asks for\n(`requirement` with `requirementTypeId`). A new one replaces the one\nattached. We keep no copy. Only while the order takes changes (409\notherwise). Returns the order with Telnyx's details. Audited (the kind\nonly). Company admins (and super admins, superusers) only.",
        "operationId": "upload_phone_port_document",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "The port order (`PortOrder.id`)",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PortDocumentInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "The order with the document attached",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PortOrderDetail"
                }
              }
            }
          },
          "400": {
            "description": "Not base64, too big, not a PDF, JPEG or PNG, no requirement named, or Telnyx refused",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such port in the caller's company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "409": {
            "description": "The order can no longer be changed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "502": {
            "description": "Telnyx failed; try again",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "503": {
            "description": "Telnyx is not set up on the server",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/phone/admin/ports/{id}/loa/sign": {
      "post": {
        "tags": [
          "phone"
        ],
        "summary": "Sign a port's LOA now",
        "description": "For the authorized person signing on this screen: prints the drawn\nsignature and today's date in the boxes on Telnyx's LOA and attaches it\nas the signed LOA (it replaces one attached). Only while the order takes\nchanges (409 otherwise). Audited with the confirmed name. Company admins\n(and super admins, superusers) only.",
        "operationId": "sign_phone_port_loa",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "The port order (`PortOrder.id`)",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/LoaSignInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "The order with the signed LOA attached",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PortOrderDetail"
                }
              }
            }
          },
          "400": {
            "description": "No name, no signature box, no drawn signature, or Telnyx refused",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such port in the caller's company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "409": {
            "description": "The order can no longer be changed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "502": {
            "description": "Telnyx failed; try again",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "503": {
            "description": "Telnyx is not set up on the server",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/phone/admin/ports/{id}/loa/invite": {
      "post": {
        "tags": [
          "phone"
        ],
        "summary": "Send the LOA to be signed",
        "description": "Emails the authorized person a link to sign the port's LOA on a page of\nits own (no account; good for 7 days and one signature). A new link\nreplaces the port's open one. The order must take changes (409\notherwise). Audited. Company admins (and super admins, superusers) only.",
        "operationId": "invite_phone_port_loa_signer",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "The port order (`PortOrder.id`)",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/LoaInviteInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "The link was emailed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LoaInviteSent"
                }
              }
            }
          },
          "400": {
            "description": "No name or not an email address",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not an admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such port in the caller's company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "409": {
            "description": "The order can no longer be changed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "502": {
            "description": "The email could not be sent; try again",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/public/port-loa/{token}": {
      "get": {
        "tags": [
          "phone"
        ],
        "summary": "A signing link's page",
        "description": "Who is asked to sign which port, and whether the link still works. No\nsession: the link's token is the proof. 404 for an unknown link.",
        "operationId": "view_port_loa_invite",
        "parameters": [
          {
            "name": "token",
            "in": "path",
            "description": "The link's token",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The page",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LoaInviteView"
                }
              }
            }
          },
          "404": {
            "description": "No such link",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        }
      }
    },
    "/v1/public/port-loa/{token}/template": {
      "get": {
        "tags": [
          "phone"
        ],
        "summary": "A signing link's LOA",
        "description": "The port's LOA from Telnyx (a PDF), while the link works (409 once it\nwas signed or expired). No session: the link's token is the proof.",
        "operationId": "port_loa_invite_template",
        "parameters": [
          {
            "name": "token",
            "in": "path",
            "description": "The link's token",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The LOA to sign",
            "content": {
              "application/pdf": {
                "schema": {
                  "type": "array",
                  "items": {
                    "type": "integer",
                    "format": "int32",
                    "minimum": 0
                  }
                }
              }
            }
          },
          "400": {
            "description": "Telnyx refused",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such link",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "409": {
            "description": "The link was signed or expired",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "502": {
            "description": "Telnyx failed; try again",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        }
      }
    },
    "/v1/public/port-loa/{token}/sign": {
      "post": {
        "tags": [
          "phone"
        ],
        "summary": "Sign through a link",
        "description": "Prints the drawn signature and today's date in the boxes on the port's\nLOA and attaches it as the signed LOA, as the admin who sent the link;\nthe link then stops working and that admin is emailed. 409 once the link\nwas signed or expired. No session: the link's token is the proof.",
        "operationId": "sign_port_loa_invite",
        "parameters": [
          {
            "name": "token",
            "in": "path",
            "description": "The link's token",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/LoaLinkSignInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Signed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LoaInviteView"
                }
              }
            }
          },
          "400": {
            "description": "No signature box, no drawn signature, or Telnyx refused",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such link",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "409": {
            "description": "The link was signed or expired",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "502": {
            "description": "Telnyx failed; try again",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "503": {
            "description": "Telnyx is not set up on the server",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        }
      }
    },
    "/v1/phone/push-settings": {
      "get": {
        "tags": [
          "phone"
        ],
        "summary": "List my push switches",
        "description": "Every kind of push I can turn off, and whether it is on; all are on\nuntil turned off. Device token only.",
        "operationId": "get_phone_push_settings",
        "responses": {
          "200": {
            "description": "My push switches",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PushSettings"
                }
              }
            }
          },
          "401": {
            "description": "No valid device token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "device_token": []
          }
        ]
      },
      "put": {
        "tags": [
          "phone"
        ],
        "summary": "Turn a push on or off",
        "description": "Saved for me, so it holds on every phone I sign in on; the bell still\nlists what a muted push would have said. Returns all my switches.\nDevice token only.",
        "operationId": "set_phone_push_setting",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PushSettingInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "My push switches",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PushSettings"
                }
              }
            }
          },
          "400": {
            "description": "Not one of my switches",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid device token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "device_token": []
          }
        ]
      }
    },
    "/v1/phone/pushes/notification": {
      "post": {
        "tags": [
          "phone"
        ],
        "summary": "Push a CRM notification to its user's phones",
        "description": "Called by the `time-triggered` Lambda (job key) when an activity\ndeadline reminder is due, as it sends the Telegram message. The\nnotification is pushed to its user's signed-in phones as data\n`{granite: \"1\", type: \"notification\", notificationId, heading}`: its id\nand heading (\"Activity Reminder\"). The app reads the rest with\n`GET /v1/notifications/{id}`. Nothing is pushed\n(`pushed: 0`) for an unknown notification or a deleted user. Calling it\nagain pushes again.",
        "operationId": "push_notification",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/NotificationPush"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Phones told",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PushSent"
                }
              }
            }
          },
          "400": {
            "description": "Invalid body",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "Missing or wrong key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "job_key": []
          }
        ]
      }
    },
    "/v1/phone/pushes/lead": {
      "post": {
        "tags": [
          "phone"
        ],
        "summary": "Push a lead alert to phones",
        "description": "Called by the `webhooks` Lambda (job key) as it sends a lead alert to\nTelegram: to the sales rep `user_id`, else to every sales manager of the\ncompany (linked to Telegram or not). Pushed as data `{granite: \"1\",\ntype: \"lead\", kind, customerId, dealId}` (`dealId` left out when the lead\nhas no deal yet): ids only. The managers' new and repeated leads also\ncarry `assign: \"1\"` (tapping opens the Assign a sales rep sheet). A\n`taken` push tells the managers (but `except_user_ids`) that the lead\nwas assigned, as its Telegram message is edited. Nothing is pushed (`pushed: 0`) for another\ncompany's or a deleted customer. Calling it again pushes again.\n\nA managers' push (no `user_id`) but `quote` also sends every other phone\nof the company, the rep and the manager who assigned it included, a quiet\n`{granite: \"1\", type: \"leads\"}` push (not counted in `pushed`): it shows\nnothing and makes the app refetch its lead inbox, so a lead assigned in\nTelegram leaves \"Waiting for a sales rep\" on every phone at once.",
        "operationId": "push_lead",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/LeadPush"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Phones told",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PushSent"
                }
              }
            }
          },
          "400": {
            "description": "Invalid body",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "Missing or wrong key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "job_key": []
          }
        ]
      }
    },
    "/v1/phone/pushes/test": {
      "post": {
        "tags": [
          "phone"
        ],
        "summary": "Send me a test push (temporary)",
        "description": "Sends one push of `kind` to the caller's signed-in phones, as the real\nevent would, so the app's Settings can show each notification. The CRM\nkinds save a real notification first (on the caller's newest deal; it\nshows in the bell too); the activity reminder uses the caller's latest\nopen activity that has a time; lead kinds name a real customer. 409 when\nthere is nothing to test with.",
        "operationId": "send_test_push",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TestPush"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Phones told",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PushSent"
                }
              }
            }
          },
          "400": {
            "description": "Invalid body",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid device token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "409": {
            "description": "Nothing to test with",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "device_token": []
          }
        ]
      }
    },
    "/v1/phone/web/bootstrap": {
      "get": {
        "tags": [
          "phone"
        ],
        "summary": "Get what the phone dock needs",
        "description": "The CRM's phone dock reads this when it starts: whether the browser can\ncall (the company's calling is on), the recording mode (show the notice;\nthe Record button), the caller IDs and the default one, the user's\nphone settings (a verified cell enables Call via my cell) and\navailability, and our clock (calls are signed with it). Session cookie\n(employees, admins, superusers). Next: `POST /v1/phone/web/devices`.",
        "operationId": "get_web_phone_bootstrap",
        "responses": {
          "200": {
            "description": "The dock's start",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebPhoneBootstrap"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/phone/web/devices": {
      "post": {
        "tags": [
          "phone"
        ],
        "summary": "Register this browser as a phone",
        "description": "The CRM's phone dock registers the browser for calls with the session\ncookie: the web session's browser phone (one per web session, so every\ntab gets the same; idempotent: 201 the first time, 200 after) with its\nTelnyx credential (working 30 days, extended with every login JWT), and\nits call key, which signs the browser's calls (`X-Granite-Call-Auth`, as\nthe app does). It rings with the user's app phones while the dock says it\nis connected (`PUT .../presence`). Signing out of the CRM signs it out.\n403 `calling_disabled` while the company's calling is off; 502 when\nTelnyx did not make the credential (try again); 503 when Telnyx is not\nset up on the server. Next: `POST /v1/phone/web/devices/{id}/token`.",
        "operationId": "register_web_phone",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WebDeviceRegistration"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "This web session's browser phone, registered before",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebPhone"
                }
              }
            }
          },
          "201": {
            "description": "Registered",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebPhone"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "`calling_disabled`, or not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "502": {
            "description": "Telnyx did not make the credential; try again",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "503": {
            "description": "Telnyx is not set up on the server",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/phone/web/devices/{id}/token": {
      "post": {
        "tags": [
          "phone"
        ],
        "summary": "Get a Telnyx login JWT for this browser",
        "description": "Mints a Telnyx login JWT (about 24 hours) for this browser phone's SIP\ncredential and extends the credential to 30 days, like the app's\n`POST /v1/phone/devices/{id}/token`, with the same limits: one a minute\nand six an hour per phone (429 with `retryAfterSecs`; a failed mint does\nnot count), so the dock keeps the JWT until it expires instead of\nminting one per page. 404 when `id` is not this web session's browser\nphone, 401 `device_revoked` once it was signed out, 403\n`calling_disabled` while the company's calling is off.",
        "operationId": "mint_web_phone_token",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "This browser's phone (`WebPhone.id`)",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The JWT",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DeviceToken"
                }
              }
            }
          },
          "401": {
            "description": "No valid session, or `device_revoked`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "`calling_disabled`, or not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "Not this web session's browser phone",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "429": {
            "description": "`rate_limited`: one a minute, six an hour",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RateLimited"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "502": {
            "description": "Telnyx failed; try again",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "503": {
            "description": "Telnyx is not set up on the server",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/phone/web/devices/{id}/presence": {
      "put": {
        "tags": [
          "phone"
        ],
        "summary": "Say whether this browser rings",
        "description": "The dock says `online: true` once its Telnyx client is connected and\nevery minute after: incoming calls ring the browser for the next 150\nseconds (with the user's app phones). `online: false` (the dock closed,\nthe phone turned off on this computer) stops it ringing at once. 404 when\n`id` is not this web session's browser phone, 401 `device_revoked` once\nit was signed out.",
        "operationId": "set_web_phone_presence",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "This browser's phone (`WebPhone.id`)",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WebPresence"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Saved"
          },
          "401": {
            "description": "No valid session, or `device_revoked`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "Not this web session's browser phone",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/phone/web/devices/{id}/decline": {
      "post": {
        "tags": [
          "phone"
        ],
        "summary": "Decline the call ringing this browser",
        "description": "Best effort, after the user declined in the dock: the newest call still\nringing this browser has its leg marked declined, and when nobody\nanswered and no other person's phone rings, the caller goes on to the\nnumber's no-answer action (AI Assistant, voicemail or forward), which\nstops the user's other phones too (as the app's\n`POST /v1/phone/calls/decline`). On a shared line that also rings\nothers, only this browser stops. Nothing ringing: nothing to do (204).\n404 when `id` is not this web session's browser phone.",
        "operationId": "decline_web_phone_call",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "This browser's phone (`WebPhone.id`)",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Done (or nothing to do)"
          },
          "401": {
            "description": "No valid session, or `device_revoked`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "Not this web session's browser phone",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/phone/calls/recording": {
      "put": {
        "tags": [
          "phone"
        ],
        "summary": "Record (or pause) my live call",
        "description": "The Record button of a call in progress: `recording: true` starts the\ncall's recording (an outgoing call when the company records incoming\ncalls only: both sides first hear \"This call is being recorded.\", or the\ncompany's notice) or resumes it after a pause (the notice again on the\napp's and the browser's calls); `recording: false` pauses it (the paused\npart is left out). A call has one recording, copied to the private\nbucket when the call ends like any other. The call is the caller's\nanswered call that has not ended, the one the given Telnyx ids name\n(else the newest). 403 `recording_off` when the company records no\ncalls, `calling_disabled` while its calling is off; 404 when the caller\nis on no call; 409 `recording_unavailable` when this call cannot be\nrecorded here (an emergency or test call, a Call via my cell call the\ncompany does not record, a TeXML call without the company's Telnyx\naccount id saved, or no recording to resume); 502 when Telnyx failed.\nTakes the device token or the session cookie.",
        "operationId": "set_live_call_recording",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RecordingInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Recording (or paused) now",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LiveRecording"
                }
              }
            }
          },
          "401": {
            "description": "No valid device token or session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "`recording_off`, `calling_disabled`, or a cookie of a user who is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "The caller is on no call",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "409": {
            "description": "`recording_unavailable`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "502": {
            "description": "Telnyx did not take the command; try again",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "503": {
            "description": "Telnyx is not set up on the server",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "device_token": []
          },
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/phone/calls/hold": {
      "put": {
        "tags": [
          "phone"
        ],
        "summary": "Put my live call on hold (or resume it)",
        "description": "The app calls this right after it holds or resumes a call (its own\nhold, a swap between two calls, answering a waiting call), so the other\nparty hears my hold music (`holdMusic` in my settings) instead of\nsilence: Telnyx plays it in a loop until the call is resumed or ends. An\nend clears the hold by itself. Saying the same thing twice changes\nnothing. The call is my answered call that has not ended, the one the\ngiven Telnyx ids name (else the newest). The hold itself is the app's:\nwhen Telnyx does not take the music the call is still on hold, with\n`music: false`. 404 when I am on no call; 409 `hold_unavailable` for a\nCall via my cell call or a test call. Takes the device token or the\nsession cookie.",
        "operationId": "set_live_call_hold",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/HoldInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "On hold (or not) now",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HoldState"
                }
              }
            }
          },
          "401": {
            "description": "No valid device token or session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "A cookie of a user who is not an employee or admin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "I am on no call",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "409": {
            "description": "`hold_unavailable`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "device_token": []
          },
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/phone/hold-music": {
      "get": {
        "tags": [
          "phone"
        ],
        "summary": "List the hold music tracks",
        "description": "The built-in tracks (original music the company may use freely), with a\npublic MP3 link each for the preview, and the upload size limit. My\nchoice is `holdMusic` in `GET /v1/phone/bootstrap` `settings`; change it\nwith `PUT /v1/phone/settings`. Device token only.",
        "operationId": "list_phone_hold_music",
        "responses": {
          "200": {
            "description": "The tracks",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HoldMusicOptions"
                }
              }
            }
          },
          "401": {
            "description": "No valid device token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "device_token": []
          }
        ]
      }
    },
    "/v1/phone/hold-music/upload": {
      "post": {
        "tags": [
          "phone"
        ],
        "summary": "Start uploading my hold music",
        "description": "Returns a presigned URL to `PUT` an MP3 or WAV file to (at most 5 MB;\nchecked when it is chosen), and the URL to choose it with\n(`PUT /v1/phone/settings` `holdMusic: custom`, `holdMusicUrl`). 400\n`invalid_hold_music` for another kind of file; 503 when uploads are not\nset up on the server. Device token only.",
        "operationId": "start_phone_hold_music_upload",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/HoldMusicUploadInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Where to put the file",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HoldMusicUpload"
                }
              }
            }
          },
          "400": {
            "description": "`invalid_hold_music`: not an MP3 or WAV",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid device token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Storage error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "503": {
            "description": "Uploads are not set up on the server",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "device_token": []
          }
        ]
      }
    },
    "/v1/phone/lines": {
      "get": {
        "tags": [
          "phone"
        ],
        "summary": "List my lines",
        "description": "The company's active numbers that ring me or that I may call from, with\nwhat their calls do when nobody answers (the AI Assistant, voicemail or\na forward, as it works now: the AI Assistant falls back to voicemail\nwhen the company has none) and whether the line rings only me (where my\nrules decide whole calls). For the \"Incoming calls\" summary and a rule's\n\"number called\" condition. Device token only.",
        "operationId": "list_phone_lines",
        "responses": {
          "200": {
            "description": "My lines",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MyLines"
                }
              }
            }
          },
          "401": {
            "description": "No valid device token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "device_token": []
          }
        ]
      }
    },
    "/v1/phone/call-rules": {
      "get": {
        "tags": [
          "phone"
        ],
        "summary": "List my incoming call rules",
        "description": "My custom incoming call rules, in the order they are tried. \"Forward all\ncalls\", Do not disturb and working hours are in `GET /v1/phone/bootstrap`\n`settings` / `availability`. Device token only.",
        "operationId": "list_phone_call_rules",
        "responses": {
          "200": {
            "description": "My rules",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CallRules"
                }
              }
            }
          },
          "401": {
            "description": "No valid device token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "device_token": []
          }
        ]
      },
      "post": {
        "tags": [
          "phone"
        ],
        "summary": "Add an incoming call rule",
        "description": "A new rule, tried after my others: when a call matches every condition\nit sets (callers, schedule, number called), it decides what the call\ndoes for me (ring my phones even outside working hours, forward, send\nto voicemail, or play a message and hang up). On my own direct line it\ndecides the whole call; on shared and main lines only whether my phones\nring. Do not disturb and \"Forward all calls\" win over rules. At most 20\nrules (400 `too_many_rules`). 400 `invalid_phone`, `unknown_contact`,\n`not_my_number`, or what is wrong. Device token only.",
        "operationId": "create_phone_call_rule",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RuleInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "The new rule",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CallRule"
                }
              }
            }
          },
          "400": {
            "description": "`too_many_rules`, `invalid_phone`, `unknown_contact`, `not_my_number`, or what is wrong",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid device token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "device_token": []
          }
        ]
      }
    },
    "/v1/phone/call-rules/{id}": {
      "put": {
        "tags": [
          "phone"
        ],
        "summary": "Change an incoming call rule",
        "description": "Replaces my rule with the one sent (send it whole, e.g. with `enabled`\nflipped for its switch); it keeps its place in the order. 404 when the\nrule is not mine; 400 as for `POST /v1/phone/call-rules`. Device token\nonly.",
        "operationId": "update_phone_call_rule",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "The rule's id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RuleInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "The rule now",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CallRule"
                }
              }
            }
          },
          "400": {
            "description": "`invalid_phone`, `unknown_contact`, `not_my_number`, or what is wrong",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid device token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "Not one of my rules",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "device_token": []
          }
        ]
      },
      "delete": {
        "tags": [
          "phone"
        ],
        "summary": "Delete an incoming call rule",
        "description": "Deletes my rule; 404 when it is not mine. Device token only.",
        "operationId": "delete_phone_call_rule",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "The rule's id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Deleted"
          },
          "401": {
            "description": "No valid device token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "Not one of my rules",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "device_token": []
          }
        ]
      }
    },
    "/v1/phone/call-blocking": {
      "get": {
        "tags": [
          "phone"
        ],
        "summary": "Read the company's spam and blocked numbers",
        "description": "Spam call handling, the blocked numbers and area codes, the action for\nblocked calls and its announcement, the trusted numbers, and whether\ncalls with no caller ID are blocked (the defaults until an admin saves:\nspam rings, blocked callers hear the default announcement, nothing is\nblocked). Company admins only (403 `admin_only`). Device token only.",
        "operationId": "get_phone_call_blocking",
        "responses": {
          "200": {
            "description": "The company's call blocking",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CallBlocking"
                }
              }
            }
          },
          "401": {
            "description": "No valid device token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "`admin_only`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "device_token": []
          }
        ]
      },
      "put": {
        "tags": [
          "phone"
        ],
        "summary": "Save the company's spam and blocked numbers",
        "description": "Replaces the company's whole call blocking with the one sent, for every\nincoming call from now on: it applies before anything rings, and blocked\ncalls get no missed-call push. A trusted number is never blocked, not\neven as spam. Returns it as saved (entries normalized to E.164 and\nsorted). Audited. Company admins only (403 `admin_only`). 400\n`invalid_entry` for an entry that is not a number (or, for blocked, a\n3-digit area code), or what is wrong. Device token only.",
        "operationId": "save_phone_call_blocking",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CallBlockingInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "The company's call blocking now",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CallBlocking"
                }
              }
            }
          },
          "400": {
            "description": "`invalid_entry`, or what is wrong",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid device token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "`admin_only`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "device_token": []
          }
        ]
      }
    },
    "/v1/phone/admin/tendlc": {
      "get": {
        "tags": [
          "phone"
        ],
        "summary": "Get the company's texting registration (10DLC)",
        "description": "The registration of the company the request acts in: the form (the\nbusiness and how it texts), where it is, what still blocks marking it\nready (`problems`), Telnyx's reasons when it refused it, and what the\nManager may do. Before the first save, `saved` is false and `draft` is a\nsuggested first draft: the company's name in every text, sample texts\nthat end \"Reply STOP to opt out\", the caller's email and the company's\nmain line. Save it with `PUT`, then `POST .../ready`. The company's\nManagers only (the Manager position in the company; admins without it\nget 403).",
        "operationId": "get_tendlc_registration",
        "responses": {
          "200": {
            "description": "The registration, or a suggested first draft",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TenDlcRegistration"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not a Manager of the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "put": {
        "tags": [
          "phone"
        ],
        "summary": "Save the company's texting registration (10DLC)",
        "description": "Saves the whole form as a draft of the company the request acts in (the\nfirst save makes the registration) and returns it with `problems`, what\nstill blocks marking it ready. Text is trimmed, the phone saved as E.164\nwhen it is a US or Canada number, keyword lists as `A,B`, empty sample\ntexts dropped. Only while it is a draft, ready or rejected (409 once it\nis with Telnyx); a ready registration that is no longer complete goes\nback to draft. Once Telnyx has the campaign only its sample texts,\nmessage flow and help message may change. 400 for a field longer than\nTelnyx takes or a change it no longer takes. Audited. The company's\nManagers only.",
        "operationId": "save_tendlc_registration",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TenDlcDraft"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "The registration as saved",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TenDlcRegistration"
                }
              }
            }
          },
          "400": {
            "description": "A field is too long, or a change Telnyx no longer takes",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not a Manager of the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "409": {
            "description": "It is with Telnyx: it can't change now",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/phone/admin/tendlc/ready": {
      "post": {
        "tags": [
          "phone"
        ],
        "summary": "Mark the texting registration (10DLC) ready",
        "description": "Says the company's registration is complete. An AI checks it first\n(`aiCheck`, within minutes: the form and the quote form, privacy policy\nand terms pages, as the carriers check them) and emails the Manager the\nresult: what to change (it stays a draft), or that it passed, and then\nit is ready: the superusers are told (bell and email) and one of them\nsends it to Telnyx; the company never sends it. Without an AI on the\nserver it is ready at once. Also after a rejection, once it is fixed.\n400 when nothing is saved yet or it is not complete (the first of\n`problems`); 409 once it is with Telnyx. Marking a ready one, or one\nbeing checked, again changes nothing. Audited. The company's Managers\nonly.",
        "operationId": "mark_tendlc_registration_ready",
        "responses": {
          "200": {
            "description": "The registration, being checked or ready",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TenDlcRegistration"
                }
              }
            }
          },
          "400": {
            "description": "Nothing saved yet, or not complete",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not a Manager of the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "409": {
            "description": "It is with Telnyx already",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/phone/admin/tendlc/send-anyway": {
      "post": {
        "tags": [
          "phone"
        ],
        "summary": "Send the texting registration (10DLC) on despite the AI check",
        "description": "When the AI check asked for changes (`aiCheck.status` `changes`) and the\nManager is sure the AI is wrong: the registration becomes ready as it\nis, the AI check's status `overridden`, and the superusers are told\n(bell and email) with the changes the AI asked for; one of them decides\nand sends it to Telnyx. 400 when nothing is saved, it is not complete,\nor the AI check did not ask for changes; 409 once it is with Telnyx.\nAudited. The company's Managers only.",
        "operationId": "send_tendlc_registration_anyway",
        "responses": {
          "200": {
            "description": "The registration, ready",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TenDlcRegistration"
                }
              }
            }
          },
          "400": {
            "description": "Nothing saved, not complete, or no changes asked for",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not a Manager of the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "409": {
            "description": "It is with Telnyx already",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/superuser/tendlc": {
      "get": {
        "tags": [
          "phone"
        ],
        "summary": "List the companies' texting registrations (10DLC)",
        "description": "Every company's registration (deleted companies left out), those\nwaiting for a superuser first (ready, then rejected), then the newest;\n`status` narrows it. Each row: the company, where it is, the business\nname, how many problems block sending it, Telnyx's statuses and when it\nwas marked ready and sent. Open one with\n`GET /v1/superuser/companies/{id}/tendlc`. Superusers only.",
        "operationId": "list_tendlc_registrations",
        "parameters": [
          {
            "name": "status",
            "in": "query",
            "description": "Only registrations in these statuses (repeat the key for several,\n`?status=ready&status=rejected`); every one when left out.",
            "required": false,
            "schema": {
              "type": "array",
              "items": {
                "$ref": "#/components/schemas/TenDlcStatus"
              }
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The registrations",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TenDlcList"
                }
              }
            }
          },
          "400": {
            "description": "An unknown status",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not a superuser",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/superuser/companies/{id}/tendlc": {
      "get": {
        "tags": [
          "phone"
        ],
        "summary": "Review a company's texting registration (10DLC)",
        "description": "Everything about the company's registration: the form, its problems,\nTelnyx's statuses, ids and reasons, the company's active numbers and\ntheir campaign assignments, whether its Telnyx setup (needed to send)\nand messaging profile exist, and what may be done now. Before the\ncompany saved one, `registration.saved` is false and the form is a\nsuggested first draft (a superuser may fill it in with `PUT`). 404 when\nthe company does not exist. Superusers only.",
        "operationId": "get_company_tendlc",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Company id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The registration",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TenDlcReview"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not a superuser",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      },
      "put": {
        "tags": [
          "phone"
        ],
        "summary": "Edit a company's texting registration (10DLC)",
        "description": "Saves the whole form for the company, as `PUT /v1/phone/admin/tendlc`\ndoes for its Managers (same checks: 409 once it is with Telnyx, 400 for\na field too long or a change Telnyx no longer takes); the first save\nmakes the registration. Returns the review. Audited. Superusers only.",
        "operationId": "save_company_tendlc",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Company id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TenDlcDraft"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "The registration as saved",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TenDlcReview"
                }
              }
            }
          },
          "400": {
            "description": "A field is too long, or a change Telnyx no longer takes",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not a superuser",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "409": {
            "description": "It is with Telnyx: it can't change now",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/superuser/companies/{id}/tendlc/link": {
      "put": {
        "tags": [
          "phone"
        ],
        "summary": "Link a company to another company's texting registration (10DLC)",
        "description": "One business with several locations (one EIN) registers one Brand and\none Campaign: the company then uses `formCompanyId`'s form. Its Managers\nsee and edit that form, its numbers are assigned to that campaign (the\nsuperuser's Assign button, and the phone job once approved), and its\nadmins and Managers are told when it is approved, rejected or suspended.\nNull unlinks it: it uses its own form again (numbers already assigned\nstay on the campaign at Telnyx). 400 when the form's company is the\ncompany itself, does not exist or uses another company's form itself;\n409 when other companies use this company's form, or this company's own\nform was sent to Telnyx. Returns the company's review. Audited.\nSuperusers only.",
        "operationId": "link_company_tendlc",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Company id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TenDlcLinkInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "The company's review, with the form it uses now",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TenDlcReview"
                }
              }
            }
          },
          "400": {
            "description": "The form's company is this company, does not exist, or uses another's form",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not a superuser",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "409": {
            "description": "Other companies use this company's form, or its own form is with Telnyx",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/superuser/companies/{id}/tendlc/cost": {
      "get": {
        "tags": [
          "phone"
        ],
        "summary": "Get what Telnyx charges for a company's campaign",
        "description": "Telnyx's price of a campaign of the form's use case (up front, then\nmonthly), to show before sending. The brand and each number assignment\ncost extra (Telnyx's 10DLC price list). 400 when the form has no use\ncase yet or Telnyx refused; 502 when Telnyx did not answer; 503 when\nTelnyx is not set up on the server. Superusers only.",
        "operationId": "get_company_tendlc_cost",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Company id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Telnyx's price of the campaign",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TenDlcCost"
                }
              }
            }
          },
          "400": {
            "description": "No use case chosen yet, or Telnyx refused",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not a superuser",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "502": {
            "description": "Telnyx did not answer",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "503": {
            "description": "Telnyx is not set up on the server",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/superuser/companies/{id}/tendlc/send": {
      "post": {
        "tags": [
          "phone"
        ],
        "summary": "Send a company's texting registration to Telnyx",
        "description": "The first send (Telnyx charges for the brand, and for the campaign\nthree months up front): registers the business as a brand, then, once\nTCR registered it, the campaign (Telnyx's notifications, a refresh or\nthe phone job create it when the brand takes longer). Never a second\nbrand: a send whose answer never came looks the brand up on Telnyx\nfirst. The form must be complete (the company's Managers usually mark it\nready first) and the company needs its Telnyx setup (Telnyx reports to\nits webhooks). With an AI on the server, its check must have passed this\nform within the last 24 hours (pages change): an older check, or none,\nis asked for again and the send answers 409 until it passes (the\nsuperusers are told, in minutes). Returns the review: `sent` while the\nbrand registers, `campaign_pending`, or `rejected` with Telnyx's reasons.\n400 when not complete, without a Telnyx setup, or when Telnyx refused\nthe brand (nothing was made); 409 when sent already (use `.../resend`),\nanother send runs, or the AI check has not passed this form within a\nday; 502 when Telnyx did not answer about the brand; 503 when Telnyx is\nnot set up on the server. Audited. Superusers only.",
        "operationId": "send_company_tendlc",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Company id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The registration, sent",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TenDlcReview"
                }
              }
            }
          },
          "400": {
            "description": "Not complete, no Telnyx setup, or Telnyx refused the brand",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not a superuser",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "409": {
            "description": "Sent already, another send runs, or the AI check has not passed this form within a day (it runs again)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "502": {
            "description": "Telnyx did not answer",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "503": {
            "description": "Telnyx is not set up on the server",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/superuser/companies/{id}/tendlc/resend": {
      "post": {
        "tags": [
          "phone"
        ],
        "summary": "Send a company's texting registration again after a rejection",
        "description": "After Telnyx or a carrier refused it, and the form was fixed: the brand\nwhen it changed (or was refused); for a refused campaign its sample\ntexts, message flow and help message when they changed (the only parts\nTelnyx takes on a registered campaign; it reviews it again), and the\nappeal when `appealReason` is written (for a fix outside the form); a\nnew campaign when TCR refused the first one or Telnyx refused to create\nit. As for the first send, the AI check must have passed this form\nwithin a day (else it runs again first). Returns the review. 400 when\nnot complete, nothing changed and no appeal is written, or Telnyx\nrefused the first change; 409 when it was never sent, Telnyx is\nreviewing it, or the AI check has not passed this form within a day;\n502 when Telnyx did not answer; 503 when Telnyx is not set up on the\nserver. Audited. Superusers only.",
        "operationId": "resend_company_tendlc",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Company id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TenDlcResendInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "The registration, sent again",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TenDlcReview"
                }
              }
            }
          },
          "400": {
            "description": "Not complete, nothing changed, an appeal too long, or Telnyx refused",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not a superuser",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "409": {
            "description": "Never sent, Telnyx is reviewing it, another send runs, or the AI check has not passed this form within a day (it runs again)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "502": {
            "description": "Telnyx did not answer",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "503": {
            "description": "Telnyx is not set up on the server",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/superuser/companies/{id}/tendlc/refresh": {
      "post": {
        "tags": [
          "phone"
        ],
        "summary": "Read a company's texting registration again from Telnyx",
        "description": "Reads the brand and campaign from Telnyx (and why they failed), and\nmoves the registration on (the company is told when it is approved,\nrejected or suspended); a sent registration whose brand is now\nregistered gets its campaign. Returns the review. 409 before it was\nsent; 400 or 502 when Telnyx refused or did not answer; 503 when Telnyx\nis not set up on the server. Superusers only.",
        "operationId": "refresh_company_tendlc",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Company id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The registration, read again",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TenDlcReview"
                }
              }
            }
          },
          "400": {
            "description": "Telnyx refused",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not a superuser",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "409": {
            "description": "Not sent yet",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "502": {
            "description": "Telnyx did not answer",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "503": {
            "description": "Telnyx is not set up on the server",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/superuser/companies/{id}/tendlc/numbers": {
      "post": {
        "tags": [
          "phone"
        ],
        "summary": "Assign a company's numbers to its approved campaign",
        "description": "Assigns every active number of the company that is not assigned to the\ncampaign yet (Telnyx charges for each); numbers that failed before are\ntried again. Telnyx confirms each (its notifications, and the phone job\nreads pending ones again). The numbers must be on the company's\nmessaging profile. 409 until the carriers approved the campaign, or\nwhile another send runs; 400 when the company has no active numbers;\n503 when Telnyx is not set up on the server. Audited (counts only).\nSuperusers only.",
        "operationId": "assign_company_tendlc_numbers",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Company id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "What was assigned",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TenDlcNumbersAssigned"
                }
              }
            }
          },
          "400": {
            "description": "No active numbers",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not a superuser",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "409": {
            "description": "The campaign is not approved yet, or another send runs",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "503": {
            "description": "Telnyx is not set up on the server",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/phone/admin/tendlc/chat": {
      "post": {
        "tags": [
          "phone"
        ],
        "summary": "Ask the texting registration (10DLC) helper",
        "description": "The AI helper beside the form answers a question about filling it in,\nstreamed as server-sent events (unnamed `message` pieces, then `done`,\nor `failure` with what to tell the user). It reads the form as sent\n(what is on screen, unsaved edits included) and its step, what blocks\nmarking it ready, the company (name, address, website, numbers), where\nthe registration is (the carriers' reasons, the AI check's changes) and\nthe carriers' rules. The conversation is the browser's; nothing is\nsaved. 400 when the last message is not a question. The company's\nManagers only.",
        "operationId": "ask_tendlc_helper",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TenDlcChatInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "The answer as server-sent events",
            "content": {
              "text/event-stream": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "400": {
            "description": "No question",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not a Manager of the company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/superuser/companies/{id}/tendlc/chat": {
      "post": {
        "tags": [
          "phone"
        ],
        "summary": "Ask the texting registration (10DLC) helper about a company's form",
        "description": "As `POST /v1/phone/admin/tendlc/chat`, for a superuser reviewing the\ncompany's registration. Superusers only.",
        "operationId": "ask_company_tendlc_helper",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "Company id",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TenDlcChatInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "The answer as server-sent events",
            "content": {
              "text/event-stream": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "400": {
            "description": "No question",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "Caller is not a superuser",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No such company",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        },
        "security": [
          {
            "session_cookie": []
          }
        ]
      }
    },
    "/v1/webhooks/telnyx/{token}/inbound": {
      "post": {
        "tags": [
          "telnyx-webhooks"
        ],
        "summary": "Answer an incoming call",
        "description": "Telnyx's TeXML app voice URL, fetched when someone calls one of the\ncompany's numbers (`To`). First the company's spam and blocked numbers\n(`GET /v1/phone/admin/call-blocking`): a trusted number is never\nblocked; a hidden number (when the company blocks those), a blocked\nnumber or area code, or likely spam (STIR/SHAKEN validation failed, or\nTelnyx's call screening says `SPAM LIKELY`; when the company blocks spam\nor sends it to voicemail) is logged as blocked and hears the\nannouncement then a hang-up, is rejected, or goes to voicemail without\nringing anyone; blocked calls get no missed-call push. Otherwise the\ncall is logged (`ringing`; the customer is the company's newest live\ncustomer with the caller's number; `spamLikely` when the caller-ID check\nsays so) and answered with TeXML: \"This call may be recorded.\" when the\ncompany records incoming calls (unless every user the number rings\nturned the recording voice off), then a `<Dial>` ringing every signed-in\nphone of the users whose part of the call is to ring (not Do not\ndisturb, no forward of all calls, their first matching incoming call\nrule, else their working hours; the main line only while the company is\nopen), with `dial-result` as its action, a `leg-status` callback per\nphone, the `whisper` announcement for users who turned it on, and the\nnumber called as the caller ID when every one of them chose to see it.\nOn a user's own direct line their forward, voicemail or message rule\ntakes the whole call (no missed-call push). A forward-only number rings\nnobody: the call goes straight to its forward number (no recording\nnotice, no missed-call push; voicemail when the number has none). When no phone can ring it\ngoes straight on: the cells of users with cell fallback on, else the\nnumber's no-answer action (AI Assistant, voicemail or forward) and a\n`missed_call` push. A repeated request answers the same call again. An\ninternal error answers the fallback TeXML (`<Redirect>`). 403 when the\nnumber, account or connection is not the token's company's.",
        "operationId": "answer_telnyx_inbound_call",
        "parameters": [
          {
            "name": "token",
            "in": "path",
            "description": "The company's webhook token (the end of `webhookBase`)",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "description": "Telnyx's TeXML request: `AccountSid`, `CallSid`, `ConnectionId`, `From`, `To`, and when sent `CallerId`, `ShakenStirAttestation`, `ShakenStirValidated`",
          "content": {
            "application/x-www-form-urlencoded": {
              "schema": {
                "$ref": "#/components/schemas/TexmlRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "TeXML: ring the phones, a user's rule, the no-answer action, or the blocked-call action",
            "content": {
              "application/xml": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "400": {
            "description": "Not a form-encoded request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "Telnyx's signature does not check out",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "The number, account or connection is not the company's",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No company has this webhook token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error before the company was known",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        }
      }
    },
    "/v1/webhooks/telnyx/{token}/dial-result": {
      "post": {
        "tags": [
          "telnyx-webhooks"
        ],
        "summary": "Continue a call after its phones rang",
        "description": "The `<Dial>` action of an incoming call (and where a decline sends it,\n`declined=1`). Answered (`DialCallStatus=completed`): the call is logged\nas answered and the TeXML hangs up. The caller hung up: logged as\ncanceled, hang up. Else the next step: the verified cells of the users it\nrings with cell fallback on (not after a decline, and once), each behind\n\"press 1\"; then the number's no-answer action: the AI Assistant\n(`after-ai` next), voicemail (no assistant id: voicemail too) or a\nforward. Entering the no-answer action logs the call as `missed` (or\n`declined`) and pushes `missed_call` to the users it rang. Any internal\nerror answers the company's fallback TeXML (`<Redirect>`).",
        "operationId": "continue_telnyx_dial_result",
        "parameters": [
          {
            "name": "token",
            "in": "path",
            "description": "The company's webhook token",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "call",
            "in": "query",
            "description": "Our call id.",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          },
          {
            "name": "declined",
            "in": "query",
            "description": "`1` when a user declined the call on a phone\n(`POST /v1/phone/calls/decline` sent it here).",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "cell",
            "in": "query",
            "description": "`1` after the cells of users with cell fallback on were rung.",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "description": "Telnyx's `<Dial>` action request: `CallSid`, `CallStatus`, `DialCallStatus`, `DialCallSid`, `DialCallDuration`",
          "content": {
            "application/x-www-form-urlencoded": {
              "schema": {
                "$ref": "#/components/schemas/TexmlRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "TeXML: hang up, ring the cells, or the no-answer action (or the fallback `<Redirect>`)",
            "content": {
              "application/xml": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "400": {
            "description": "Not a form-encoded request, or no `call`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "Telnyx's signature does not check out",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "The account or connection is not the company's",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No company has this webhook token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error before the company was known",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        }
      }
    },
    "/v1/webhooks/telnyx/{token}/cell-screen": {
      "post": {
        "tags": [
          "telnyx-webhooks"
        ],
        "summary": "Screen a fallback cell",
        "description": "The `<Number url>` of a cell rung after the phones: the user hears who is\ncalling and \"Press 1 to answer\"; anything else (or nothing) hangs the\ncell up, so its voicemail cannot take the call. The answer goes to\n`cell-screen-result`. A call answered meanwhile hangs the cell up.",
        "operationId": "screen_telnyx_fallback_cell",
        "parameters": [
          {
            "name": "token",
            "in": "path",
            "description": "The company's webhook token",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "call",
            "in": "query",
            "description": "Our call id.",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          },
          {
            "name": "user",
            "in": "query",
            "description": "The user whose cell is ringing.",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "description": "Telnyx's `<Number url>` request for the cell's leg: `CallSid`, `To`",
          "content": {
            "application/x-www-form-urlencoded": {
              "schema": {
                "$ref": "#/components/schemas/TexmlRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "TeXML: \"Press 1 to answer\", or hang up",
            "content": {
              "application/xml": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "400": {
            "description": "Not a form-encoded request, or no `call` / `user`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "Telnyx's signature does not check out",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "The account or connection is not the company's",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No company has this webhook token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error before the company was known",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        }
      }
    },
    "/v1/webhooks/telnyx/{token}/cell-screen-result": {
      "post": {
        "tags": [
          "telnyx-webhooks"
        ],
        "summary": "Answer on a fallback cell",
        "description": "The cell screen's `<Gather>` action: `Digits=1` connects the caller to\nthis cell (the call is logged as answered by the cell's user, when no one\nanswered first); anything else hangs the cell up, as does a leg whose\n`To` is not that user's verified cell.",
        "operationId": "answer_telnyx_fallback_cell",
        "parameters": [
          {
            "name": "token",
            "in": "path",
            "description": "The company's webhook token",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "call",
            "in": "query",
            "description": "Our call id.",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          },
          {
            "name": "user",
            "in": "query",
            "description": "The user whose cell is ringing.",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "description": "Telnyx's `<Gather>` action request: `CallSid`, `To` (the cell), `Digits`",
          "content": {
            "application/x-www-form-urlencoded": {
              "schema": {
                "$ref": "#/components/schemas/TexmlRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "TeXML: an empty answer (connect) or hang up",
            "content": {
              "application/xml": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "400": {
            "description": "Not a form-encoded request, or no `call` / `user`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "Telnyx's signature does not check out",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "The account or connection is not the company's",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No company has this webhook token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error before the company was known",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        }
      }
    },
    "/v1/webhooks/telnyx/{token}/after-ai": {
      "post": {
        "tags": [
          "telnyx-webhooks"
        ],
        "summary": "Continue after the AI Assistant",
        "description": "The `<Connect>` action of the AI Assistant. When it could not start\n(`CallStatus=conversation_start_failed`) the caller leaves a voicemail\ninstead (the number's greeting, then `<Record>`). Otherwise the call is\nlogged as `ai_message`, the users it rang get an `ai_message` push, and\nthe TeXML hangs up. Any internal error answers the fallback TeXML.",
        "operationId": "continue_telnyx_after_ai",
        "parameters": [
          {
            "name": "token",
            "in": "path",
            "description": "The company's webhook token",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "call",
            "in": "query",
            "description": "Our call id.",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "requestBody": {
          "description": "Telnyx's `<Connect>` action request: `CallSid`, `CallStatus`, `Reason`",
          "content": {
            "application/x-www-form-urlencoded": {
              "schema": {
                "$ref": "#/components/schemas/TexmlRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "TeXML: voicemail, or hang up (or the fallback `<Redirect>`)",
            "content": {
              "application/xml": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "400": {
            "description": "Not a form-encoded request, or no `call`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "Telnyx's signature does not check out",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "The account or connection is not the company's",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No company has this webhook token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error before the company was known",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        }
      }
    },
    "/v1/webhooks/telnyx/{token}/voicemail-done": {
      "post": {
        "tags": [
          "telnyx-webhooks"
        ],
        "summary": "End a voicemail",
        "description": "The `<Record>` action of a voicemail: the call is logged as `voicemail`\n(unless nothing was recorded) and ends, the users it rang get a\n`voicemail` push, and the TeXML hangs up. The recording itself arrives\nat `recording?kind=voicemail`.",
        "operationId": "finish_telnyx_voicemail",
        "parameters": [
          {
            "name": "token",
            "in": "path",
            "description": "The company's webhook token",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "call",
            "in": "query",
            "description": "Our call id.",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "requestBody": {
          "description": "Telnyx's `<Record>` action request: `CallSid`, `RecordingSid`, `RecordingDuration`",
          "content": {
            "application/x-www-form-urlencoded": {
              "schema": {
                "$ref": "#/components/schemas/TexmlRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "TeXML: hang up",
            "content": {
              "application/xml": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "400": {
            "description": "Not a form-encoded request, or no `call`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "Telnyx's signature does not check out",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "The account or connection is not the company's",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No company has this webhook token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error before the company was known",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        }
      }
    },
    "/v1/webhooks/telnyx/{token}/whisper": {
      "post": {
        "tags": [
          "telnyx-webhooks"
        ],
        "summary": "Announce a call before it connects",
        "description": "The `<Sip url>` of a phone of a user who turned on the announcement\n(`PUT /v1/phone/settings/call-information`): once they answer they hear\n\"Call for <line name> from <caller>\" (the line's name only when they\nchose it; the caller is the CRM customer's name, else the number read\nout), then the call connects; a key press connects at once. A call that\nended, or that someone else answered meanwhile, hangs this phone up.",
        "operationId": "announce_telnyx_incoming_call",
        "parameters": [
          {
            "name": "token",
            "in": "path",
            "description": "The company's webhook token",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "call",
            "in": "query",
            "description": "Our call id.",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          },
          {
            "name": "user",
            "in": "query",
            "description": "The user whose phone answered.",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "done",
            "in": "query",
            "description": "`1` when the user pressed a key during the announcement: connect.",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "description": "Telnyx's `<Sip url>` request for the phone's leg: `CallSid`",
          "content": {
            "application/x-www-form-urlencoded": {
              "schema": {
                "$ref": "#/components/schemas/TexmlRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "TeXML: the announcement (then the call connects), or hang up",
            "content": {
              "application/xml": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "400": {
            "description": "Not a form-encoded request, or no `call` / `user`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "Telnyx's signature does not check out",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "The account or connection is not the company's",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No company has this webhook token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error before the company was known",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        }
      }
    },
    "/v1/webhooks/telnyx/{token}/leg-status": {
      "post": {
        "tags": [
          "telnyx-webhooks"
        ],
        "summary": "Record a leg's progress",
        "description": "The `statusCallback` of each `<Sip>` (a phone an incoming call rings)\nand of the customer's `<Number>` of Call via my cell: the leg is saved\n(`initiated`, `ringing`, `in-progress`, ...; a leg never moves back, and\na declined one stays declined until it ends). An answered leg makes the\ncall `in_progress`, answered by that phone's user (the first answer\nwins; `device` counts only when the call rang that phone). When the\nanswering leg ends, so does the call (final status, talk time from the\nleg's `CallDuration`, else Telnyx's times). The Call via my cell\ncustomer's leg `completed` means answered, then ended; one who does not\nanswer logs the call as `busy`, `no_answer`, `canceled` or `failed`.\nUnknown calls are ignored.",
        "operationId": "record_telnyx_leg_status",
        "parameters": [
          {
            "name": "token",
            "in": "path",
            "description": "The company's webhook token",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "call",
            "in": "query",
            "description": "Our call id.",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          },
          {
            "name": "device",
            "in": "query",
            "description": "The phone (`phone_devices.id`) this leg rings; none for the\ncustomer's leg of Call via my cell.",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "requestBody": {
          "description": "Telnyx's status callback for the leg: `CallSid` (the leg), `CallStatus`, `CallDuration`",
          "content": {
            "application/x-www-form-urlencoded": {
              "schema": {
                "$ref": "#/components/schemas/TexmlRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Taken"
          },
          "400": {
            "description": "Not a form-encoded request, or no `call`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "Telnyx's signature does not check out",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "The account or connection is not the company's",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No company has this webhook token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error (Telnyx sends it again)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        }
      }
    },
    "/v1/webhooks/telnyx/{token}/call-status": {
      "post": {
        "tags": [
          "telnyx-webhooks"
        ],
        "summary": "Record a call's end",
        "description": "The status callback of the TeXML app (by `CallSid`) and of the calls our\nserver places (Call via my cell, test calls: `?call=` names ours; its\n`CallSid` must be the call's, and is saved when Telnyx's answer to our\nrequest had none). A final status (`completed`, `busy`, `no-answer`,\n`canceled`, `failed`) ends the call once, at Telnyx's time: `answered`\nwith its talk time when someone answered; else an incoming call becomes\n`canceled` (the caller hung up while it rang), `busy` or `failed`, and an\nunfinished Call via my cell `canceled` or `failed`; a missed call keeps\nits status (voicemail, AI message ...). Then the follow-through: a\nmissed-call push when the caller hung up while it rang, and for a\ncustomer, the deal leaves its first stage after a talk of 90 seconds or\nmore and the customer's SMS flows stop. Other statuses and unknown calls\nare only stored.",
        "operationId": "record_telnyx_call_status",
        "parameters": [
          {
            "name": "token",
            "in": "path",
            "description": "The company's webhook token",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "call",
            "in": "query",
            "description": "Our call id, on the status callbacks of the calls our server places\n(Call via my cell, test calls); the TeXML app's own callbacks name\nnone (the call is found by `CallSid`).",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "requestBody": {
          "description": "Telnyx's status callback: `CallSid`, `CallStatus`, `CallDuration`, `HangupCause`, `Timestamp`",
          "content": {
            "application/x-www-form-urlencoded": {
              "schema": {
                "$ref": "#/components/schemas/TexmlRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Taken"
          },
          "400": {
            "description": "Not a form-encoded request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "Telnyx's signature does not check out",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "The account or connection is not the company's",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No company has this webhook token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error (Telnyx sends it again)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        }
      }
    },
    "/v1/webhooks/telnyx/{token}/recording": {
      "post": {
        "tags": [
          "telnyx-webhooks"
        ],
        "summary": "Copy a call's recording",
        "description": "The `recordingStatusCallback` of a recorded `<Dial>` (`kind=call`) or a\nvoicemail's `<Record>` (`kind=voicemail`). When Telnyx says the recording\nis `completed`, it is looked up by `RecordingSid` with our key (never\nthe callback's link) and must be of this call (Telnyx's call ids for it\ninclude one of the call's, its connection is the company's; else\nnothing is stored or deleted), downloaded, stored once in the private\nrecordings bucket at `phone/{company}/{yyyy}/{mm}/{call id}-{kind}.mp3`\nand checked (our copy's size must match); then Telnyx's copy is deleted\n(retried by the phone job when that fails). The call gets\n`hasRecording`, and is queued for transcription (`transcriptStatus`\n`pending`) when the call's user has AI notes on, for any voicemail, and\nfor an answered outgoing call (its transcript scores it; its AI note\nstill needs AI notes on). Each copy\ncounts as an attempt; one that fails leaves the recording pending for\nthe phone job to retry. Repeats and other statuses change nothing.",
        "operationId": "copy_telnyx_recording",
        "parameters": [
          {
            "name": "token",
            "in": "path",
            "description": "The company's webhook token",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "call",
            "in": "query",
            "description": "Our call id.",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          },
          {
            "name": "kind",
            "in": "query",
            "description": "`call` (the conversation; default) or `voicemail`.",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "description": "Telnyx's recording status callback: `CallSid`, `RecordingSid`, `RecordingStatus`, `RecordingDuration`",
          "content": {
            "application/x-www-form-urlencoded": {
              "schema": {
                "$ref": "#/components/schemas/TexmlRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Taken (copied, or left for the phone job)"
          },
          "400": {
            "description": "Not a form-encoded request, no `call`, or an unknown `kind`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "Telnyx's signature does not check out",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "The account or connection is not the company's",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No company has this webhook token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error (Telnyx sends it again)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        }
      }
    },
    "/v1/webhooks/telnyx/{token}/outbound": {
      "post": {
        "tags": [
          "telnyx-webhooks"
        ],
        "summary": "Take a Call Control event",
        "description": "The webhook of the company's credential connection (Call Control v2,\nJSON). Telnyx's Ed25519 signature is required: without\n`TELNYX_PUBLIC_KEY` on the server every event is refused (503), unless\n`PHONE_ALLOW_UNSIGNED_WEBHOOKS=1` (local testing only). `call.initiated`\nof a parked app call: approved (transferred to the number with the\nuser's caller ID, `command_id` `approve-{call id}`; recorded only after\na notice, see the module docs) or hung up and logged `failed`; see the\nchecks in the module docs. Emergency codes (911, 112, 933, 988) are\nnever refused (the admins get an `e911_alert`, at most one per phone in\n10 minutes). Later events of the call update it: `call.answered` of the\ncustomer's leg (answered, at Telnyx's time; a call recorded after the\nspoken notice gets it, then its recording; `call.bridged` changes\nnothing, the customer's phone may still ring),\n`call.hangup` (final status, talk time, the CRM follow-through),\n`call.recording.saved` (the recording is copied to the private bucket).\nEvery event is stored and handled once.",
        "operationId": "take_telnyx_call_control_event",
        "parameters": [
          {
            "name": "token",
            "in": "path",
            "description": "The company's webhook token",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "telnyx-signature-ed25519",
            "in": "header",
            "description": "Telnyx's Ed25519 signature of `{telnyx-timestamp}|{body}` (base64); required",
            "required": false,
            "schema": {
              "type": [
                "string",
                "null"
              ]
            }
          },
          {
            "name": "telnyx-timestamp",
            "in": "header",
            "description": "When Telnyx signed it (Unix seconds; at most 5 minutes off)",
            "required": false,
            "schema": {
              "type": [
                "string",
                "null"
              ]
            }
          }
        ],
        "requestBody": {
          "description": "A Call Control v2 event, as Telnyx sends it: `data.id`, `data.event_type`, `data.occurred_at`, `data.payload` (`call_control_id`, `call_session_id`, `connection_id`, `from`, `to`, `state`, `custom_headers` ...)",
          "content": {
            "application/json": {
              "schema": {
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Taken"
          },
          "400": {
            "description": "Not a Call Control event",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid Telnyx signature",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "The connection is not the company's",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No company has this webhook token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error (Telnyx sends it again)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "503": {
            "description": "Telnyx signatures are not set up on the server (`TELNYX_PUBLIC_KEY`)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        }
      }
    },
    "/v1/webhooks/telnyx/{token}/via-cell": {
      "post": {
        "tags": [
          "telnyx-webhooks"
        ],
        "summary": "Ask the user's cell to place the call",
        "description": "The TeXML our Call via my cell call fetches when the user's cell\nanswers: \"Press 1 to call {customer's name, or the number digit by\ndigit}.\" (`<Gather>` one key, 8 seconds, to `via-cell-gather`), else\nhang up. A call that is over (or not a Call via my cell) hangs up.",
        "operationId": "prompt_telnyx_via_cell",
        "parameters": [
          {
            "name": "token",
            "in": "path",
            "description": "The company's webhook token",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "call",
            "in": "query",
            "description": "Our call id.",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "requestBody": {
          "description": "Telnyx's request when the user's cell answered: `CallSid`, `CallStatus`",
          "content": {
            "application/x-www-form-urlencoded": {
              "schema": {
                "$ref": "#/components/schemas/TexmlRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "TeXML: \"Press 1 to call ...\", or hang up",
            "content": {
              "application/xml": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "400": {
            "description": "Not a form-encoded request, or no `call`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "Telnyx's signature does not check out",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "The account or connection is not the company's",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No company has this webhook token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error before the company was known",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        }
      }
    },
    "/v1/webhooks/telnyx/{token}/via-cell-gather": {
      "post": {
        "tags": [
          "telnyx-webhooks"
        ],
        "summary": "Dial the customer from the user's cell",
        "description": "The `<Gather>` action of `via-cell`: `Digits=1` dials the customer from\nthe call's caller ID (`<Dial callerId>`), with a `leg-status` callback\non the customer's leg; when the company records outgoing calls the call\nis recorded and the customer hears \"This call may be recorded.\"\n(`notice`) first. Any other key ends the call (logged as canceled).",
        "operationId": "dial_telnyx_via_cell",
        "parameters": [
          {
            "name": "token",
            "in": "path",
            "description": "The company's webhook token",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "call",
            "in": "query",
            "description": "Our call id.",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "requestBody": {
          "description": "Telnyx's `<Gather>` action request: `CallSid`, `Digits`",
          "content": {
            "application/x-www-form-urlencoded": {
              "schema": {
                "$ref": "#/components/schemas/TexmlRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "TeXML: `<Dial>` the customer, or hang up",
            "content": {
              "application/xml": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "400": {
            "description": "Not a form-encoded request, or no `call`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "Telnyx's signature does not check out",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "The account or connection is not the company's",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No company has this webhook token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error before the company was known",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        }
      }
    },
    "/v1/webhooks/telnyx/{token}/notice": {
      "post": {
        "tags": [
          "telnyx-webhooks"
        ],
        "summary": "Play the recording notice",
        "description": "The `<Number url>` the customer's leg of Call via my cell fetches when\nthe company records outgoing calls: \"This call may be recorded.\", then\nthe call connects.",
        "operationId": "play_telnyx_recording_notice",
        "parameters": [
          {
            "name": "token",
            "in": "path",
            "description": "The company's webhook token",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "description": "Telnyx's `<Number url>` request: `CallSid`",
          "content": {
            "application/x-www-form-urlencoded": {
              "schema": {
                "$ref": "#/components/schemas/TexmlRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "TeXML: the notice",
            "content": {
              "application/xml": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "400": {
            "description": "Not a form-encoded request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "Telnyx's signature does not check out",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "The account or connection is not the company's",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No company has this webhook token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error before the company was known",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        }
      }
    },
    "/v1/webhooks/telnyx/{token}/test-call": {
      "post": {
        "tags": [
          "telnyx-webhooks"
        ],
        "summary": "Speak a test call",
        "description": "The TeXML our test call fetches when the phone answers: a short message,\nthen hang up. The test call is logged as answered (it never shows in\nRecents or stats). Any other call hangs up.",
        "operationId": "speak_telnyx_test_call",
        "parameters": [
          {
            "name": "token",
            "in": "path",
            "description": "The company's webhook token",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "call",
            "in": "query",
            "description": "Our call id (the test call).",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "requestBody": {
          "description": "Telnyx's request when the phone answered: `CallSid`, `CallStatus`",
          "content": {
            "application/x-www-form-urlencoded": {
              "schema": {
                "$ref": "#/components/schemas/TexmlRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "TeXML: the test message, then hang up",
            "content": {
              "application/xml": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "400": {
            "description": "Not a form-encoded request, or no `call`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "Telnyx's signature does not check out",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "The account or connection is not the company's",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No company has this webhook token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error before the company was known",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        }
      }
    },
    "/v1/webhooks/telnyx/{token}/cell-code": {
      "post": {
        "tags": [
          "telnyx-webhooks"
        ],
        "summary": "Read a cell verification code",
        "description": "The TeXML our code call to the user's new cell fetches when it answers:\nthe user's pending 6-digit code, read twice, then hang up. Nothing is\nread when the code expired or was used, when the user is not the\ntoken's company's, or when the request's `To` is missing or not the cell\nbeing verified.",
        "operationId": "read_telnyx_cell_code",
        "parameters": [
          {
            "name": "token",
            "in": "path",
            "description": "The company's webhook token",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "user",
            "in": "query",
            "description": "The user whose cell is being verified.",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "requestBody": {
          "description": "Telnyx's request when the cell answered: `CallSid`, `To`",
          "content": {
            "application/x-www-form-urlencoded": {
              "schema": {
                "$ref": "#/components/schemas/TexmlRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "TeXML: the code, or that there is none",
            "content": {
              "application/xml": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "400": {
            "description": "Not a form-encoded request, or no `user`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "Telnyx's signature does not check out",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "The account or connection is not the company's",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No company has this webhook token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error before the company was known",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        }
      }
    },
    "/v1/webhooks/telnyx/{token}/schedule-call": {
      "post": {
        "tags": [
          "telnyx-webhooks"
        ],
        "summary": "Speak a scheduling call",
        "description": "The TeXML our scheduling call fetches when the customer picks up: a\n`<Gather>` (a spoken word or one key) in which the voice reads the\nscheduling text and asks for yes (1), no (2) or \"repeat\"; whatever comes\ngoes to `schedule-call-answer`. Hangs up when the call is over, is not\nthe company's, or an answering machine picked up (`AnsweredBy`).",
        "operationId": "speak_telnyx_schedule_call",
        "parameters": [
          {
            "name": "token",
            "in": "path",
            "description": "The company's webhook token",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "call",
            "in": "query",
            "description": "The scheduling call (`schedule_calls.id`).",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "requestBody": {
          "description": "Telnyx's request when the customer's phone answered: `CallSid`, `AnsweredBy`",
          "content": {
            "application/x-www-form-urlencoded": {
              "schema": {
                "$ref": "#/components/schemas/TexmlRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "TeXML: the message and the question, or hang up",
            "content": {
              "application/xml": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "400": {
            "description": "Not a form-encoded request, or no `call`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "Telnyx's signature does not check out",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "The account or connection is not the company's",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No company has this webhook token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error before the company was known",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        }
      }
    },
    "/v1/webhooks/telnyx/{token}/schedule-call-answer": {
      "post": {
        "tags": [
          "telnyx-webhooks"
        ],
        "summary": "Take a scheduling call's answer",
        "description": "The `<Gather>` action of `schedule-call`: `Digits` (1 yes, 2 no, 3 repeat) or\n`SpeechResult` (the words said). A yes turns the job Confirmed and tells\nthe Scheduling Managers; a no tells them; \"repeat\" reads the message\nagain; anything else (nothing too) is asked again, and after the last\ntry the customer is told a text is coming and gets the scheduling text.",
        "operationId": "answer_telnyx_schedule_call",
        "parameters": [
          {
            "name": "token",
            "in": "path",
            "description": "The company's webhook token",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "call",
            "in": "query",
            "description": "The scheduling call (`schedule_calls.id`).",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "requestBody": {
          "description": "Telnyx's `<Gather>` action request: `CallSid`, `Digits`, `SpeechResult`",
          "content": {
            "application/x-www-form-urlencoded": {
              "schema": {
                "$ref": "#/components/schemas/TexmlRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "TeXML: the closing words, the question again, or hang up",
            "content": {
              "application/xml": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "400": {
            "description": "Not a form-encoded request, or no `call`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "Telnyx's signature does not check out",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "The account or connection is not the company's",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No company has this webhook token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error before the company was known",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        }
      }
    },
    "/v1/webhooks/telnyx/{token}/schedule-call-machine": {
      "post": {
        "tags": [
          "telnyx-webhooks"
        ],
        "summary": "Hear what picked up a scheduling call",
        "description": "Telnyx's answering-machine detection for the call (`AnsweredBy`): for a\nmachine or a fax the call ends as unanswered, is hung up, and the\ncustomer gets the scheduling text. A person changes nothing.",
        "operationId": "detect_telnyx_schedule_call_machine",
        "parameters": [
          {
            "name": "token",
            "in": "path",
            "description": "The company's webhook token",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "call",
            "in": "query",
            "description": "The scheduling call (`schedule_calls.id`).",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "requestBody": {
          "description": "Telnyx's detection result: `CallSid`, `AnsweredBy` (`human`, `machine_start`, `fax`, `unknown`)",
          "content": {
            "application/x-www-form-urlencoded": {
              "schema": {
                "$ref": "#/components/schemas/TexmlRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Taken"
          },
          "400": {
            "description": "Not a form-encoded request, or no `call`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "Telnyx's signature does not check out",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "The account or connection is not the company's",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No company has this webhook token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error before the company was known",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        }
      }
    },
    "/v1/webhooks/telnyx/{token}/schedule-call-status": {
      "post": {
        "tags": [
          "telnyx-webhooks"
        ],
        "summary": "End a scheduling call",
        "description": "The call's status callback. An end without a yes or a no (`busy`,\n`no-answer`, `canceled`, `failed`, or `completed` before an answer) is\nnoted on the event and the customer gets the scheduling text. Other\nstatuses change nothing.",
        "operationId": "end_telnyx_schedule_call",
        "parameters": [
          {
            "name": "token",
            "in": "path",
            "description": "The company's webhook token",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "call",
            "in": "query",
            "description": "The scheduling call (`schedule_calls.id`).",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "requestBody": {
          "description": "Telnyx's status callback: `CallSid`, `CallStatus`",
          "content": {
            "application/x-www-form-urlencoded": {
              "schema": {
                "$ref": "#/components/schemas/TexmlRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Taken"
          },
          "400": {
            "description": "Not a form-encoded request, or no `call`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "Telnyx's signature does not check out",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "403": {
            "description": "The account or connection is not the company's",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No company has this webhook token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error before the company was known",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        }
      }
    },
    "/v1/webhooks/telnyx/{token}/porting": {
      "post": {
        "tags": [
          "telnyx-webhooks"
        ],
        "summary": "Take a Telnyx porting notification",
        "description": "Telnyx's notification about one of the company's port orders. The\norder is read again from Telnyx and our copy brought up to date (a\nstatus change is written to its timeline and told to the admins once; a\nport that completed gets its numbers added to the company). A comment\nfrom Telnyx's porting team is noted on the timeline and told to the\nadmins; an order split off ours is saved as the company's too; a deleted\ndraft is marked deleted. Notifications about orders that are not the\ncompany's, or seen before, are answered 200 and change nothing.",
        "operationId": "receive_telnyx_porting_event",
        "parameters": [
          {
            "name": "token",
            "in": "path",
            "description": "The company's webhook token",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "description": "Telnyx's porting notification",
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PortingNotification"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Taken (or not the company's, or seen before: nothing to do)"
          },
          "400": {
            "description": "Not JSON",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "Telnyx's signature is missing or does not check out",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No company has this webhook token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "It could not be handled (database, or Telnyx unreachable): Telnyx sends it again",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "503": {
            "description": "Telnyx signatures are not set up on the server",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        }
      }
    },
    "/v1/webhooks/telnyx/{token}/messaging": {
      "post": {
        "tags": [
          "telnyx-webhooks"
        ],
        "summary": "Take a Telnyx messaging event",
        "description": "The webhook of the company's Telnyx messaging profile (its webhook URL is\n`{webhookBase}/messaging`), also named on every text we send.\n`message.received`: an inbound text or MMS to one of the company's\nnumbers is stored once (Telnyx's message id), its files are copied to\nour bucket at once (Telnyx's links expire), and the first time: STOP /\nSTART mark the phone opted out / in, the customer's SMS flows stop and\ntheir deal leaves the first stage of its pipeline, as with the other\nproviders. A text to a number that is not the company's is ignored.\n`message.sent` / `message.finalized`: the delivery status of a text we\nsent (`delivered`, or failed with Telnyx's code; `40300` marks the phone\nopted out). Other events are taken and ignored. Ed25519-signed,\nalways required. Answers 200; Telnyx sends it again on any other status.",
        "operationId": "take_telnyx_messaging_event",
        "parameters": [
          {
            "name": "token",
            "in": "path",
            "description": "The company's webhook token",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "telnyx-signature-ed25519",
            "in": "header",
            "description": "Telnyx's Ed25519 signature of `{telnyx-timestamp}|{body}` (base64); required",
            "required": false,
            "schema": {
              "type": [
                "string",
                "null"
              ]
            }
          },
          {
            "name": "telnyx-timestamp",
            "in": "header",
            "description": "When Telnyx signed it (Unix seconds; at most 5 minutes off)",
            "required": false,
            "schema": {
              "type": [
                "string",
                "null"
              ]
            }
          }
        ],
        "requestBody": {
          "description": "A messaging event, as Telnyx sends it: `data.event_type` (`message.received`, `message.sent`, `message.finalized`), `data.id`, `data.occurred_at`, `data.payload` (`id`, `direction`, `from.phone_number`, `to[].phone_number` and `.status`, `text`, `media[]` with `url` and `content_type`, `errors[].code`, `messaging_profile_id`)",
          "content": {
            "application/json": {
              "schema": {
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Taken"
          },
          "400": {
            "description": "Not a messaging event",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "No valid Telnyx signature",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No company has this webhook token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "409": {
            "description": "A status about a text whose send is still being recorded (Telnyx sends it again)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "Database error (Telnyx sends it again)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "503": {
            "description": "Telnyx signatures are not set up on the server (`TELNYX_PUBLIC_KEY`)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        }
      }
    },
    "/v1/webhooks/telnyx/{token}/10dlc": {
      "post": {
        "tags": [
          "telnyx-webhooks"
        ],
        "summary": "Take a Telnyx 10DLC notification",
        "description": "Telnyx's notification about the company's texting registration: a\nbrand update (registered, refused, vetted), a campaign update (Telnyx's\nor a carrier's review, suspension, provisioning) or a number's\nassignment. Brand and campaign notifications read the registration\nagain from Telnyx and move it on (the company is told when it is\napproved, rejected or suspended; a registered brand gets its campaign);\na refused campaign's reasons are kept for the superuser and the company.\nA number notification updates that number's assignment. Notifications\nabout another brand or campaign, or seen before, are answered 200 and\nchange nothing.",
        "operationId": "take_telnyx_10dlc_event",
        "parameters": [
          {
            "name": "token",
            "in": "path",
            "description": "The company's webhook token",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "telnyx-signature-ed25519",
            "in": "header",
            "description": "Telnyx's Ed25519 signature of `{telnyx-timestamp}|{body}` (base64); required",
            "required": false,
            "schema": {
              "type": [
                "string",
                "null"
              ]
            }
          },
          {
            "name": "telnyx-timestamp",
            "in": "header",
            "description": "When Telnyx signed it (Unix seconds; at most 5 minutes off)",
            "required": false,
            "schema": {
              "type": [
                "string",
                "null"
              ]
            }
          }
        ],
        "requestBody": {
          "description": "A 10DLC event, as Telnyx sends it: `data.event_type` (`10dlc.brand.update`, `10dlc.campaign.update`, `10dlc.phone_number.update`), `data.id`, `data.occurred_at`, `data.payload` (`brandId` or `campaignId`, `type` such as `REGISTRATION`, `TELNYX_REVIEW`, `MNO_REVIEW`, `VERIFIED`, `ASSIGNMENT`, `STATUS_UPDATE`; `status`, `description`, `reasons[]` with `description` and `fields`, `phoneNumber`)",
          "content": {
            "application/json": {
              "schema": {
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Taken (or not the company's, or seen before: nothing to do)"
          },
          "400": {
            "description": "Not JSON",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "401": {
            "description": "Telnyx's signature is missing or does not check out",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "404": {
            "description": "No company has this webhook token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "500": {
            "description": "It could not be handled (database, or Telnyx unreachable): Telnyx sends it again",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          },
          "503": {
            "description": "Telnyx signatures are not set up on the server (`TELNYX_PUBLIC_KEY`)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorBody"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Acceptance": {
        "type": "object",
        "description": "The customer's acceptance.",
        "required": [
          "option",
          "signature"
        ],
        "properties": {
          "option": {
            "type": "integer",
            "format": "int32",
            "description": "Index of the option accepted."
          },
          "signature": {
            "type": "string",
            "description": "The signature (a PNG data URL)."
          },
          "e": {
            "type": [
              "string",
              "null"
            ],
            "description": "The email the link came from."
          }
        },
        "additionalProperties": false
      },
      "Account": {
        "type": "object",
        "description": "`GET /v1/me/account`.",
        "required": [
          "user_id",
          "ringcentral_signed_in",
          "has_cloudtalk_api",
          "has_ringcentral_api",
          "shows_email_signature",
          "has_onboarding_feedback",
          "feedback_dismissed",
          "has_granite_phone",
          "granite_phone_numbers",
          "mfa"
        ],
        "properties": {
          "user_id": {
            "type": "integer",
            "format": "int32",
            "description": "The user."
          },
          "name": {
            "type": [
              "string",
              "null"
            ],
            "description": "Name."
          },
          "email": {
            "type": [
              "string",
              "null"
            ],
            "description": "Sign-in email."
          },
          "phone_number": {
            "type": [
              "string",
              "null"
            ],
            "description": "Phone."
          },
          "email_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "The name recipients see in the From field."
          },
          "email_signature": {
            "type": [
              "string",
              "null"
            ],
            "description": "The email signature (sanitized HTML)."
          },
          "cloudtalk_agent_id": {
            "type": [
              "string",
              "null"
            ],
            "description": "`CloudTalk` agent id."
          },
          "cloudtalk_phone_number": {
            "type": [
              "string",
              "null"
            ],
            "description": "`CloudTalk` line (10 digits)."
          },
          "ringcentral_extension_id": {
            "type": [
              "string",
              "null"
            ],
            "description": "`RingCentral` extension of the line."
          },
          "ringcentral_phone_number": {
            "type": [
              "string",
              "null"
            ],
            "description": "`RingCentral` line (10 digits)."
          },
          "ringcentral_signed_in": {
            "type": "boolean",
            "description": "Texts from the CRM go out as the user through `RingCentral`: they\nconnected their own `RingCentral` (`/v1/me/ringcentral`), or theirs is\nthe login the company connected with."
          },
          "has_cloudtalk_api": {
            "type": "boolean",
            "description": "The home company has `CloudTalk`."
          },
          "has_ringcentral_api": {
            "type": "boolean",
            "description": "The home company has `RingCentral`."
          },
          "shows_email_signature": {
            "type": "boolean",
            "description": "The signature applies (not for shop managers and workers)."
          },
          "has_onboarding_feedback": {
            "type": "boolean",
            "description": "The user already rated the guided tours."
          },
          "feedback_dismissed": {
            "type": "boolean",
            "description": "The user dismissed the tours rating."
          },
          "has_granite_phone": {
            "type": "boolean",
            "description": "The home company calls through Granite Manager (Telnyx calling is on)."
          },
          "granite_phone_numbers": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "The Granite Manager numbers the user can call from (E.164); an admin\nassigns them on the Phone page."
          },
          "photo_url": {
            "type": [
              "string",
              "null"
            ],
            "description": "My picture (`PUT /v1/me/photo`); null when I have none."
          },
          "mfa": {
            "$ref": "#/components/schemas/MfaStatus",
            "description": "My two-step sign-in, as `GET /v1/me/mfa` answers it."
          },
          "undo_send": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/UndoSend",
                "description": "My Undo send, as `GET /v1/me/undo-send` answers it; null for a shop\nmanager or worker who is not an employee."
              },
              {
                "type": "null"
              }
            ]
          },
          "lead_automation": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/LeadAutomationMode",
                "description": "Whose automations my deals get (`company` or `own`), as `GET\n/v1/me/lead-automation` answers it; null for a shop manager or worker\nwho is not an employee."
              },
              {
                "type": "null"
              }
            ]
          }
        }
      },
      "AccountInput": {
        "type": "object",
        "description": "Body of `PUT /v1/me/account`. A field left out keeps its value; an empty\none clears it.",
        "required": [
          "name",
          "email"
        ],
        "properties": {
          "name": {
            "type": "string",
            "description": "Name (required)."
          },
          "email": {
            "type": "string",
            "description": "Sign-in email (required)."
          },
          "phone_number": {
            "type": [
              "string",
              "null"
            ],
            "description": "Phone (at least 10 digits)."
          },
          "password": {
            "type": [
              "string",
              "null"
            ],
            "description": "A new password (at least 8 characters); empty keeps the current one."
          },
          "email_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "The email sender name."
          },
          "email_signature": {
            "type": [
              "string",
              "null"
            ],
            "description": "The email signature (HTML, sanitized on save)."
          },
          "cloudtalk_agent_id": {
            "type": [
              "string",
              "null"
            ],
            "description": "`CloudTalk` agent id (digits)."
          },
          "cloudtalk_phone_number": {
            "type": [
              "string",
              "null"
            ],
            "description": "`CloudTalk` line (10+ digits)."
          },
          "ringcentral_phone_number": {
            "type": [
              "string",
              "null"
            ],
            "description": "`RingCentral` line (10+ digits); the extension is looked up from it."
          }
        },
        "additionalProperties": false
      },
      "AccountSaved": {
        "type": "object",
        "description": "What a save did.",
        "required": [
          "texting_line_status"
        ],
        "properties": {
          "texting_line_status": {
            "type": "string",
            "description": "The texting line: `saved`, `unchanged`, `unmatched` (the provider did\nnot confirm it), `incomplete` (a `CloudTalk` line without its agent id)\nor `none` (no line submitted)."
          },
          "texting_line_provider": {
            "type": [
              "string",
              "null"
            ],
            "description": "The provider of that line (`CloudTalk`, `RingCentral`); null for `none`."
          },
          "credit": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/Credit",
                "description": "Setup tasks this save finished, with their points; null when none."
              },
              {
                "type": "null"
              }
            ]
          }
        }
      },
      "Action": {
        "oneOf": [
          {
            "type": "object",
            "description": "The priced lines get this product.",
            "required": [
              "item_id",
              "item_name",
              "type"
            ],
            "properties": {
              "item_id": {
                "type": "string",
                "description": "QuickBooks item id."
              },
              "item_name": {
                "type": "string",
                "description": "Its name."
              },
              "type": {
                "type": "string",
                "enum": [
                  "product"
                ]
              }
            }
          },
          {
            "type": "object",
            "description": "The priced lines never get this product (another one is learned).",
            "required": [
              "item_id",
              "item_name",
              "type"
            ],
            "properties": {
              "item_id": {
                "type": "string",
                "description": "QuickBooks item id."
              },
              "item_name": {
                "type": "string",
                "description": "Its name."
              },
              "type": {
                "type": "string",
                "enum": [
                  "avoid_product"
                ]
              }
            }
          },
          {
            "type": "object",
            "description": "Text lines with the phrase are left out (the editor offers them back).",
            "required": [
              "line",
              "type"
            ],
            "properties": {
              "line": {
                "type": "string",
                "description": "The phrase."
              },
              "type": {
                "type": "string",
                "enum": [
                  "hide"
                ]
              }
            }
          },
          {
            "type": "object",
            "description": "The phrase in a line becomes `to`.",
            "required": [
              "line",
              "to",
              "type"
            ],
            "properties": {
              "line": {
                "type": "string",
                "description": "The phrase."
              },
              "to": {
                "type": "string",
                "description": "What it becomes."
              },
              "type": {
                "type": "string",
                "enum": [
                  "rename"
                ]
              }
            }
          },
          {
            "type": "object",
            "description": "A text line added at the end.",
            "required": [
              "text",
              "type"
            ],
            "properties": {
              "text": {
                "type": "string",
                "description": "The line."
              },
              "type": {
                "type": "string",
                "enum": [
                  "add_line"
                ]
              }
            }
          },
          {
            "type": "object",
            "description": "The invoice's class.",
            "required": [
              "name",
              "type"
            ],
            "properties": {
              "name": {
                "type": "string",
                "description": "The QuickBooks class name."
              },
              "type": {
                "type": "string",
                "enum": [
                  "class"
                ]
              }
            }
          },
          {
            "type": "object",
            "description": "The invoice's CC.",
            "required": [
              "email",
              "type"
            ],
            "properties": {
              "email": {
                "type": "string",
                "description": "The email address."
              },
              "type": {
                "type": "string",
                "enum": [
                  "cc"
                ]
              }
            }
          },
          {
            "type": "object",
            "description": "Lines with the phrase stay as drafted: nothing learned from past\ninvoices leaves them out or rewords them.",
            "required": [
              "line",
              "type"
            ],
            "properties": {
              "line": {
                "type": "string",
                "description": "The phrase."
              },
              "type": {
                "type": "string",
                "enum": [
                  "keep"
                ]
              }
            }
          }
        ],
        "description": "What a rule does."
      },
      "ActionArgs": {
        "type": "object",
        "description": "What the call is made with, as the agent proposed it or the asker edited it.",
        "properties": {
          "path_params": {
            "type": "object",
            "description": "Values for the `{placeholders}` of the route, by name."
          },
          "query": {
            "type": "object",
            "description": "Query parameters by name."
          },
          "body": {
            "type": "object",
            "description": "The JSON request body."
          }
        }
      },
      "ActiveCompany": {
        "type": "object",
        "description": "Body of `PUT /v1/auth/active-company`.",
        "required": [
          "company_id"
        ],
        "properties": {
          "company_id": {
            "type": "integer",
            "format": "int32",
            "description": "A company the caller holds the Super Admin position in."
          }
        }
      },
      "ActiveFlow": {
        "type": "object",
        "description": "An SMS flow running (or failed) on the phone.",
        "required": [
          "enrollment_id",
          "flow_id",
          "flow_name",
          "status",
          "next_step_position",
          "total_steps"
        ],
        "properties": {
          "enrollment_id": {
            "type": "integer",
            "format": "int32",
            "description": "The phone's enrollment in the flow."
          },
          "flow_id": {
            "type": "integer",
            "format": "int32",
            "description": "The flow."
          },
          "flow_name": {
            "type": "string",
            "description": "The flow's name."
          },
          "status": {
            "type": "string",
            "description": "`active`, `paused` or `failed`."
          },
          "next_step_position": {
            "type": "integer",
            "format": "int32",
            "description": "Position of the next step (1 = first)."
          },
          "next_step_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "The next step's template."
          },
          "next_step_preview": {
            "type": [
              "string",
              "null"
            ],
            "description": "What the next step sends."
          },
          "next_send_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When the next step goes out."
          },
          "total_steps": {
            "type": "integer",
            "format": "int64",
            "description": "Steps in the flow."
          },
          "error_message": {
            "type": [
              "string",
              "null"
            ],
            "description": "Why the flow failed."
          }
        }
      },
      "ActiveFlows": {
        "type": "object",
        "description": "`GET /v1/schedule/notifications/active`.",
        "required": [
          "flows",
          "templates",
          "skipped_flow_ids",
          "picked_flow_ids"
        ],
        "properties": {
          "flows": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/NotificationFlow"
            },
            "description": "The flows turned on, of every calendar, oldest first."
          },
          "templates": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/NotificationTemplate"
            },
            "description": "The templates their steps send."
          },
          "skipped_flow_ids": {
            "type": "array",
            "items": {
              "type": "integer",
              "format": "int32"
            },
            "description": "Default flows turned off for `event_id`."
          },
          "picked_flow_ids": {
            "type": "array",
            "items": {
              "type": "integer",
              "format": "int32"
            },
            "description": "Other flows picked for `event_id`."
          }
        }
      },
      "Activity": {
        "type": "object",
        "description": "A to-do on a deal.",
        "required": [
          "id",
          "deal_id",
          "name",
          "priority",
          "is_completed",
          "is_automatic"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "Activity id."
          },
          "deal_id": {
            "type": "integer",
            "format": "int64",
            "description": "Deal it belongs to."
          },
          "name": {
            "type": "string",
            "description": "What to do."
          },
          "deadline": {
            "type": [
              "string",
              "null"
            ],
            "description": "Store wall time `YYYY-MM-DDTHH:MM:SS` (midnight means a whole day), or null."
          },
          "priority": {
            "type": "string",
            "description": "`low`, `medium` or `high`."
          },
          "is_completed": {
            "type": "boolean",
            "description": "Done."
          },
          "completed_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When it was marked done."
          },
          "created_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When it was created."
          },
          "created_by": {
            "type": [
              "string",
              "null"
            ],
            "description": "Name of the user who created it."
          },
          "is_automatic": {
            "type": "boolean",
            "description": "Added by a rule of Admin › Deals › Automatic Activities."
          }
        }
      },
      "ActivityAnswer": {
        "type": "object",
        "description": "`POST /v1/customers/{id}/activity-search`.",
        "required": [
          "answer",
          "sources"
        ],
        "properties": {
          "answer": {
            "type": "string",
            "description": "The answer."
          },
          "sources": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ActivitySource"
            },
            "description": "The sources it rests on."
          }
        }
      },
      "ActivityEvent": {
        "type": "object",
        "description": "An event with its latest activity.",
        "required": [
          "event",
          "unscheduled",
          "last_activity_at",
          "lines"
        ],
        "properties": {
          "event": {
            "$ref": "#/components/schemas/ScheduleEvent",
            "description": "The event."
          },
          "unscheduled": {
            "type": "boolean",
            "description": "Waiting for its day (not on the calendar)."
          },
          "assignee_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "The installer or template maker on it."
          },
          "creator_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "Who made it."
          },
          "last_activity_at": {
            "type": "string",
            "format": "date-time",
            "description": "When it last changed."
          },
          "lines": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ActivityLine"
            },
            "description": "Its last three lines, oldest first."
          }
        }
      },
      "ActivityInput": {
        "type": "object",
        "description": "Body of `POST /v1/deals/{id}/activities`.",
        "required": [
          "name"
        ],
        "properties": {
          "name": {
            "type": "string",
            "description": "What to do, at most 255 characters."
          },
          "deadline": {
            "type": [
              "string",
              "null"
            ],
            "description": "`YYYY-MM-DD` (whole day), or a store wall time\n`YYYY-MM-DDTHH:MM:SS` / `YYYY-MM-DD HH:MM:SS`. A time sends the deal\nowner a reminder then."
          },
          "priority": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/Priority",
                "description": "Default `medium`."
              },
              {
                "type": "null"
              }
            ]
          }
        }
      },
      "ActivityLine": {
        "type": "object",
        "description": "A change to an event or a comment on it.",
        "required": [
          "action",
          "message",
          "created_at"
        ],
        "properties": {
          "action": {
            "type": "string",
            "description": "e.g. `created`, `date_updated`; `commented` for a comment."
          },
          "message": {
            "type": "string",
            "description": "Shown text."
          },
          "created_by": {
            "type": [
              "string",
              "null"
            ],
            "description": "Who."
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "description": "When."
          }
        }
      },
      "ActivityPage": {
        "type": "object",
        "description": "`GET /v1/users/activity`.",
        "required": [
          "sales_reps",
          "activities",
          "calls_from",
          "calls_to"
        ],
        "properties": {
          "sales_reps": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ActivityRep"
            },
            "description": "The company's sales reps, by name."
          },
          "activities": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/UserActivity"
            },
            "description": "The last 90 days, newest first."
          },
          "call_sms_points": {
            "type": [
              "array",
              "null"
            ],
            "items": {
              "$ref": "#/components/schemas/CallSmsPointsRow"
            },
            "description": "Calls, texts and points per user in the table's days; null while the\ncompany's leaderboard is off."
          },
          "calls_from": {
            "type": "string",
            "format": "date",
            "description": "The table's days."
          },
          "calls_to": {
            "type": "string",
            "format": "date",
            "description": "Inclusive."
          }
        }
      },
      "ActivityPatch": {
        "type": "object",
        "description": "Body of `PATCH /v1/deals/{id}/activities/{activity_id}`.",
        "properties": {
          "name": {
            "type": [
              "string",
              "null"
            ],
            "description": "New name."
          },
          "deadline": {
            "type": [
              "string",
              "null"
            ],
            "description": "New deadline (same formats as when creating); null clears it."
          },
          "priority": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/Priority",
                "description": "New priority."
              },
              {
                "type": "null"
              }
            ]
          },
          "is_completed": {
            "type": [
              "boolean",
              "null"
            ],
            "description": "Mark done or not done."
          }
        }
      },
      "ActivityPreview": {
        "type": "object",
        "description": "An activity preview on a customer's deal.",
        "required": [
          "id",
          "name",
          "priority",
          "is_completed"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "Activity id."
          },
          "name": {
            "type": "string",
            "description": "What to do."
          },
          "deadline": {
            "type": [
              "string",
              "null"
            ],
            "description": "Store wall time, or null."
          },
          "priority": {
            "type": "string",
            "description": "`low`, `medium` or `high`."
          },
          "is_completed": {
            "type": "boolean",
            "description": "Done."
          }
        }
      },
      "ActivityRep": {
        "type": "object",
        "description": "A sales rep of the company.",
        "required": [
          "id",
          "email"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "User id."
          },
          "name": {
            "type": [
              "string",
              "null"
            ],
            "description": "Name."
          },
          "email": {
            "type": "string",
            "description": "Email."
          },
          "cloudtalk_agent_id": {
            "type": [
              "string",
              "null"
            ],
            "description": "`CloudTalk` agent id."
          }
        }
      },
      "ActivityRule": {
        "type": "object",
        "description": "A rule, as the admin page shows it.",
        "required": [
          "id",
          "to_list_id",
          "activity_name",
          "due_amount",
          "due_unit",
          "is_enabled"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "Rule id."
          },
          "from_list_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "The list the deal leaves; null: any list."
          },
          "to_list_id": {
            "type": "integer",
            "format": "int32",
            "description": "The list the deal lands on."
          },
          "activity_name": {
            "type": "string",
            "description": "Name of the activity it adds."
          },
          "due_amount": {
            "type": "integer",
            "format": "int32",
            "description": "Due this many `due_unit` after the move."
          },
          "due_unit": {
            "type": "string",
            "description": "`hours` or `days`."
          },
          "is_enabled": {
            "type": "boolean",
            "description": "Off: adds nothing."
          }
        }
      },
      "ActivityRuleInput": {
        "type": "object",
        "description": "Body of `POST /v1/deal-stage-activity-rules` and `PUT /v1/deal-stage-activity-rules/{id}`.",
        "required": [
          "to_list_id",
          "activity_name",
          "due_amount",
          "due_unit"
        ],
        "properties": {
          "from_list_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "The list the deal leaves; null: any list."
          },
          "to_list_id": {
            "type": "integer",
            "format": "int32",
            "description": "The list the deal lands on (same pipeline as `from_list_id`)."
          },
          "activity_name": {
            "type": "string",
            "description": "Name of the activity, 1–255 characters."
          },
          "due_amount": {
            "type": "integer",
            "format": "int32",
            "description": "0–999."
          },
          "due_unit": {
            "type": "string",
            "description": "`hours` or `days`."
          },
          "is_enabled": {
            "type": [
              "boolean",
              "null"
            ],
            "description": "Default on."
          }
        },
        "additionalProperties": false
      },
      "ActivitySearchInput": {
        "type": "object",
        "description": "Body of `POST /v1/customers/{id}/activity-search`.",
        "required": [
          "question"
        ],
        "properties": {
          "question": {
            "type": "string",
            "description": "The question, 3 to 500 characters."
          },
          "include_calls": {
            "type": "boolean",
            "description": "Also transcribe the last two recorded calls (slower, costs more)."
          }
        }
      },
      "ActivitySource": {
        "type": "object",
        "description": "A source the answer cites.",
        "required": [
          "key",
          "label"
        ],
        "properties": {
          "key": {
            "type": "string",
            "description": "`email:42`, `note:5`, `activity:7`, a text (`sms:10` of `CloudTalk`,\n`sms:rc10` of `RingCentral`, `sms:tx10` of our own numbers) or a call\n(`call:999`; `call:tx_12` on our own numbers)."
          },
          "label": {
            "type": "string",
            "description": "What it is and when."
          },
          "href": {
            "type": [
              "string",
              "null"
            ],
            "description": "Where to open it in the CRM (emails and texts)."
          }
        }
      },
      "ActivitySuggestion": {
        "type": "object",
        "description": "An activity name the caller used before.",
        "required": [
          "name",
          "uses"
        ],
        "properties": {
          "name": {
            "type": "string",
            "description": "The name, trimmed."
          },
          "uses": {
            "type": "integer",
            "format": "int64",
            "description": "How many live activities the caller created with it."
          }
        }
      },
      "AddImages": {
        "type": "object",
        "description": "Body of `POST /v1/stones/{id}/images`.",
        "required": [
          "urls"
        ],
        "properties": {
          "urls": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "URLs of uploads to the `stones` folder (`POST /v1/uploads`), 1 to 50."
          }
        },
        "additionalProperties": false
      },
      "AddPhone": {
        "type": "object",
        "description": "Body of `POST /v1/phone/contacts/{id}/phones`.",
        "required": [
          "phone"
        ],
        "properties": {
          "phone": {
            "type": "string",
            "description": "The number to add: E.164 or 10 digits (US or Canada)."
          },
          "replacePhone2": {
            "type": "boolean",
            "description": "When phone and phone 2 are both used: replace phone 2 (else 409\n`phone_2_taken`)."
          }
        }
      },
      "AddPhotos": {
        "type": "object",
        "description": "Body of the add photos routes.",
        "required": [
          "urls"
        ],
        "properties": {
          "urls": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "URLs of uploads to the model's folder, 1 to 50."
          }
        },
        "additionalProperties": false
      },
      "AddToDeal": {
        "type": "object",
        "description": "Body of `POST /v1/email-attachments/{id}/deal`.",
        "required": [
          "deal_id"
        ],
        "properties": {
          "deal_id": {
            "type": "integer",
            "format": "int64",
            "description": "Deal to save the attachment on."
          }
        },
        "additionalProperties": false
      },
      "AddedExtra": {
        "type": "object",
        "description": "The extra added.",
        "required": [
          "id"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "Its commission row id."
          }
        }
      },
      "AddedSlab": {
        "type": "object",
        "description": "Body of `POST /v1/transactions/{id}/slabs`.",
        "required": [
          "slab_id",
          "room"
        ],
        "properties": {
          "slab_id": {
            "type": "integer",
            "format": "int32",
            "description": "A free slab of the company."
          },
          "room": {
            "type": "string",
            "description": "The room it goes to; at most 255 characters."
          },
          "room_uuid": {
            "type": [
              "string",
              "null"
            ],
            "description": "That room's id (hex), when it has one."
          }
        },
        "additionalProperties": false
      },
      "AddedToPayroll": {
        "type": "object",
        "description": "Where a job went in the salary.",
        "required": [
          "payrollDate"
        ],
        "properties": {
          "payrollDate": {
            "type": "string",
            "description": "The payroll it is paid with (YYYY-MM-DD)."
          }
        }
      },
      "Address": {
        "type": "object",
        "description": "An address of an invoice.",
        "properties": {
          "line1": {
            "type": [
              "string",
              "null"
            ],
            "description": "First street line."
          },
          "line2": {
            "type": [
              "string",
              "null"
            ],
            "description": "Second line."
          },
          "line3": {
            "type": [
              "string",
              "null"
            ],
            "description": "Third line."
          },
          "city": {
            "type": [
              "string",
              "null"
            ],
            "description": "City."
          },
          "country_sub_division_code": {
            "type": [
              "string",
              "null"
            ],
            "description": "State code."
          },
          "postal_code": {
            "type": [
              "string",
              "null"
            ],
            "description": "ZIP code."
          }
        }
      },
      "AddressCheck": {
        "type": "object",
        "description": "`GET /v1/places/check`.",
        "required": [
          "status"
        ],
        "properties": {
          "status": {
            "type": "string",
            "description": "`found`, `not_found`, or `unknown` (Google could not be asked)."
          },
          "formatted_address": {
            "type": [
              "string",
              "null"
            ],
            "description": "Google's full address when found."
          }
        }
      },
      "AdminDevice": {
        "type": "object",
        "description": "A phone signed in to the company.",
        "required": [
          "id",
          "deviceName",
          "platform",
          "createdAt",
          "current",
          "userId",
          "userName"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int64",
            "description": "The device session: pass it to `DELETE /v1/phone/admin/devices/{id}`."
          },
          "deviceName": {
            "type": "string",
            "description": "The name the phone gave at sign-in."
          },
          "platform": {
            "$ref": "#/components/schemas/DevicePlatform",
            "description": "`android` or `ios` (the app), or `web` (a browser phone of the CRM)."
          },
          "appVersion": {
            "type": [
              "string",
              "null"
            ],
            "description": "The app version at sign-in; null when it sent none (always for a\nbrowser phone)."
          },
          "createdAt": {
            "type": "string",
            "format": "date-time",
            "description": "When it signed in."
          },
          "lastSeenAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When it was last used (updated at most every 5 minutes); null when\nnever since sign-in."
          },
          "current": {
            "type": "boolean",
            "description": "The caller's own phone: always false here (the admin page signs in\nwith the session cookie)."
          },
          "userId": {
            "type": "integer",
            "format": "int32",
            "description": "Whose phone it is."
          },
          "userName": {
            "type": "string",
            "description": "Their name, else their email."
          },
          "sipUsername": {
            "type": [
              "string",
              "null"
            ],
            "description": "The phone's SIP user on Telnyx (`gencred...`); null until it\nregistered for calling with calling on."
          }
        }
      },
      "AdminDevices": {
        "type": "object",
        "description": "`GET /v1/phone/admin/devices`.",
        "required": [
          "devices"
        ],
        "properties": {
          "devices": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/AdminDevice"
            },
            "description": "The company's phones that are not signed out, newest first."
          }
        }
      },
      "AdminNumber": {
        "type": "object",
        "description": "A company number, as the admin page edits it.",
        "required": [
          "id",
          "e164",
          "label",
          "kind",
          "noAnswerAction",
          "active",
          "forwardOnly",
          "assignments",
          "schedulingManagers",
          "notifications"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "The number (`PUT /v1/phone/admin/numbers/{id}`)."
          },
          "e164": {
            "type": "string",
            "description": "The number, E.164 (`+13175550101`)."
          },
          "label": {
            "type": "string",
            "description": "Its label, e.g. \"Main line\"; may be empty."
          },
          "kind": {
            "$ref": "#/components/schemas/NumberKind",
            "description": "`direct` (one person's line), `shared` (a team line) or `main` (the\ncompany's main line, which rings only in business hours)."
          },
          "noAnswerAction": {
            "$ref": "#/components/schemas/NoAnswerAction",
            "description": "What a call nobody answers does: `ai` (the AI Assistant), `voicemail`\nor `forward` (to `forwardTo`)."
          },
          "forwardTo": {
            "type": [
              "string",
              "null"
            ],
            "description": "Where `forward` sends calls, E.164; null when none."
          },
          "greeting": {
            "type": [
              "string",
              "null"
            ],
            "description": "What callers hear before leaving a voicemail; null = the standard\ngreeting."
          },
          "active": {
            "type": "boolean",
            "description": "In use: an inactive number rings nobody and is nobody's caller ID."
          },
          "forwardOnly": {
            "type": "boolean",
            "description": "Forward only: it rings nobody, every call goes to `forwardTo`."
          },
          "forwardTextsTo": {
            "type": [
              "string",
              "null"
            ],
            "description": "Where texts to the number are sent on (from the number, with the\nsender's number in front), E.164; null = they stay in the CRM."
          },
          "assignments": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/NumberAssignment"
            },
            "description": "Who it rings and who may call from it, by user id (users of the\ncompany only); users who have it through a position are not listed."
          },
          "schedulingManagers": {
            "type": "boolean",
            "description": "The company's Scheduling Manager number: everyone with that position\nhas it."
          },
          "notifications": {
            "type": "boolean",
            "description": "The company's Notification number: every automated text goes out\nfrom it. It is one way: a reply lands on the Scheduling Manager's line."
          }
        }
      },
      "AdminNumbers": {
        "type": "object",
        "description": "`GET /v1/phone/admin/numbers`.",
        "required": [
          "numbers",
          "users",
          "config"
        ],
        "properties": {
          "numbers": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/AdminNumber"
            },
            "description": "The company's numbers: the main line first, then shared lines, then\ndirect lines (each by label)."
          },
          "users": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PhoneAdminUser"
            },
            "description": "The company's users who may use Granite Manager (employees, admins),\nby name: who numbers can be given to."
          },
          "config": {
            "$ref": "#/components/schemas/PhoneAdminStatus",
            "description": "The company's calling status."
          }
        }
      },
      "AdminQuestion": {
        "type": "object",
        "description": "A question, for the admin page.",
        "required": [
          "id",
          "text",
          "question_type",
          "is_visible_to_employees"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "The question."
          },
          "text": {
            "type": "string",
            "description": "Its text."
          },
          "instruction_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "The instruction it tests."
          },
          "question_type": {
            "type": "string",
            "description": "`MC` or `TF`."
          },
          "is_visible_to_employees": {
            "type": "boolean",
            "description": "Published to employees (else a draft)."
          },
          "created_date": {
            "type": [
              "string",
              "null"
            ],
            "description": "When it was added (UTC, ISO 8601)."
          }
        }
      },
      "AdminQuestions": {
        "type": "object",
        "description": "`GET /v1/teach-mode/questions`.",
        "required": [
          "questions",
          "answer_choices"
        ],
        "properties": {
          "questions": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/AdminQuestion"
            },
            "description": "Not deleted questions, newest first."
          },
          "answer_choices": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/AnswerChoice"
            },
            "description": "Their answers, by question."
          }
        }
      },
      "AfterSaleStepInput": {
        "type": "object",
        "description": "Body of `PUT /v1/company/sale-opens-invoice` and\n`PUT /v1/company/invoice-opens-payment`.",
        "required": [
          "enabled"
        ],
        "properties": {
          "enabled": {
            "type": "boolean",
            "description": "On: the step opens by itself."
          }
        },
        "additionalProperties": false
      },
      "Agent": {
        "type": "object",
        "description": "A member of the support team.",
        "required": [
          "id",
          "email"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "User id."
          },
          "name": {
            "type": [
              "string",
              "null"
            ],
            "description": "Name; null when the user has none."
          },
          "email": {
            "type": "string",
            "description": "Login email."
          }
        }
      },
      "AgentAction": {
        "type": "object",
        "description": "A write the agent proposed.",
        "required": [
          "id",
          "question_id",
          "operation_id",
          "summary",
          "args",
          "status",
          "created_at"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int64",
            "description": "Action id."
          },
          "question_id": {
            "type": "integer",
            "format": "int64",
            "description": "The question it was proposed for."
          },
          "operation_id": {
            "type": "string",
            "description": "The endpoint, one of the confirmable ones (`send_email`)."
          },
          "summary": {
            "type": "string",
            "description": "What it does, in the agent's words (\"Email Dima a thank-you\")."
          },
          "args": {
            "$ref": "#/components/schemas/ActionArgs",
            "description": "The arguments: as proposed while `pending`, as sent once run."
          },
          "status": {
            "type": "string",
            "description": "`pending` (waiting for the asker), `running`, `done`, `failed` or\n`dismissed`."
          },
          "error": {
            "type": [
              "string",
              "null"
            ],
            "description": "Why it failed, once `failed`."
          },
          "http_status": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "The HTTP status the call answered, once run.",
            "minimum": 0
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "description": "When the agent proposed it."
          },
          "decided_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When the asker confirmed or dismissed it."
          }
        }
      },
      "AgentChat": {
        "type": "object",
        "description": "One of the caller's agent conversations.",
        "required": [
          "id",
          "title",
          "updated_at"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int64",
            "description": "The chat's id."
          },
          "title": {
            "type": "string",
            "description": "Its first question, on one line."
          },
          "updated_at": {
            "type": "string",
            "format": "date-time",
            "description": "When something was last asked in it."
          }
        }
      },
      "AgentConversation": {
        "type": "object",
        "description": "One agent conversation.",
        "required": [
          "id",
          "title",
          "messages"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int64",
            "description": "The chat's id."
          },
          "title": {
            "type": "string",
            "description": "Its title."
          },
          "messages": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/AgentMessage"
            },
            "description": "Its questions and answers, oldest first."
          }
        }
      },
      "AgentMessage": {
        "type": "object",
        "description": "A question or an answer in an agent conversation.",
        "required": [
          "id",
          "sender",
          "content",
          "created_at",
          "steps",
          "pages",
          "actions"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int64",
            "description": "The message's id (a question's id is the one to poll)."
          },
          "sender": {
            "type": "string",
            "description": "`user` (a question) or `ai` (an answer)."
          },
          "content": {
            "type": "string",
            "description": "The text."
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "description": "When it was written."
          },
          "status": {
            "type": [
              "string",
              "null"
            ],
            "description": "A question's state: `queued`, `pending`, `done` or `failed`."
          },
          "error": {
            "type": [
              "string",
              "null"
            ],
            "description": "Why the agent failed a question."
          },
          "partial": {
            "type": [
              "string",
              "null"
            ],
            "description": "What the agent answered before failing a question."
          },
          "steps": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/AgentStep"
            },
            "description": "What the agent did for a question."
          },
          "pages": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/AgentPage"
            },
            "description": "An answer's HTML pages."
          },
          "actions": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/AgentAction"
            },
            "description": "The writes the agent proposed while answering a question, for the\ncaller to confirm (oldest first; always empty on an answer)."
          }
        }
      },
      "AgentPage": {
        "type": "object",
        "description": "An HTML page the agent made as part of its answer.",
        "required": [
          "name",
          "html"
        ],
        "properties": {
          "name": {
            "type": "string",
            "description": "Its file name in the agent's workspace (`report.html`)."
          },
          "title": {
            "type": "string",
            "description": "Its `<title>`, or the file name."
          },
          "html": {
            "type": "string",
            "description": "The whole document. Shown only in a sandboxed frame with no network."
          }
        }
      },
      "AgentReply": {
        "type": "object",
        "description": "Body of `POST /v1/support/agent/conversations/{id}/messages`.",
        "required": [
          "body"
        ],
        "properties": {
          "body": {
            "type": "string",
            "description": "The text (at most 5000 characters)."
          },
          "internal": {
            "type": "boolean",
            "description": "An internal note for the team: the client never sees it, and the\nrequest's status stays."
          },
          "images": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Pictures uploaded to the `chats` folder (`POST /v1/uploads`; the\n`url` it returns), at most 4. The client sees them in their support\nchat."
          },
          "reply_to": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int64",
            "description": "The message this one answers (like a Telegram reply), of this\nrequest. An answer to the client may not quote an internal note."
          }
        },
        "additionalProperties": false
      },
      "AgentResult": {
        "type": "object",
        "description": "The agent's structured result (`.github/posthog-autofix/result.schema.json`).\nIt is the agent's claim; [`RunReport::verification`] is what the workflow\nproved.",
        "required": [
          "outcome",
          "summary",
          "root_cause",
          "fix_summary",
          "risk",
          "test"
        ],
        "properties": {
          "outcome": {
            "$ref": "#/components/schemas/Outcome",
            "description": "What the agent concluded."
          },
          "target_repo": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/TargetRepo",
                "description": "The repository it changed, if any."
              },
              {
                "type": "null"
              }
            ]
          },
          "summary": {
            "type": "string",
            "description": "One short sentence: what goes wrong and on which route (the title when\nthere is no `pr_title`, and the Issue line of an older report)."
          },
          "given": {
            "type": "string",
            "description": "The bug report's Given: the state the bug needs, e.g. `a company with\ncalling turned off`. Empty from a workflow older than these fields."
          },
          "when": {
            "type": "string",
            "description": "When: the user's action, with the page and the API route."
          },
          "then": {
            "type": "string",
            "description": "Then: what the system does at that point, e.g. `the API answers 403\ncalling_disabled`."
          },
          "actual": {
            "type": "string",
            "description": "What goes wrong now."
          },
          "expected": {
            "type": "string",
            "description": "What should happen instead."
          },
          "impact": {
            "type": "string",
            "description": "What users notice, in one sentence; the email adds the counts."
          },
          "check": {
            "type": "string",
            "description": "How a developer sees the fix by hand, in one line; empty without a fix."
          },
          "root_cause": {
            "type": "string",
            "description": "Why it happened, in a few sentences."
          },
          "fix_summary": {
            "type": "string",
            "description": "One or two short sentences: what the fix changes, naming the function\nand file (the Fix line); empty without a fix."
          },
          "risk": {
            "type": "string",
            "description": "What the fix could break, and how likely."
          },
          "test": {
            "$ref": "#/components/schemas/TestReport",
            "description": "The test, or why there is none."
          },
          "recommendation": {
            "type": [
              "string",
              "null"
            ],
            "description": "The next step for a person (a suppression rule, a migration to apply)."
          },
          "duplicate_of": {
            "type": [
              "string",
              "null"
            ],
            "description": "The pull request or commit that already covers the issue."
          },
          "pr_title": {
            "type": [
              "string",
              "null"
            ],
            "description": "The pull request title."
          }
        }
      },
      "AgentSkill": {
        "type": "object",
        "description": "One of the caller's skills.",
        "required": [
          "id",
          "name",
          "description",
          "prompt",
          "updated_at"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int64",
            "description": "The skill's id."
          },
          "name": {
            "type": "string",
            "description": "Its name, e.g. \"Analyze a sales rep\"."
          },
          "description": {
            "type": "string",
            "description": "What it does, in a line (may be empty)."
          },
          "prompt": {
            "type": "string",
            "description": "The question it asks; `{Name}` parts are filled in when it runs."
          },
          "fields": {
            "type": [
              "array",
              "null"
            ],
            "items": {
              "type": "object"
            },
            "description": "The template's choices for the `{Name}` parts, or null."
          },
          "updated_at": {
            "type": "string",
            "format": "date-time",
            "description": "When it was last changed."
          }
        }
      },
      "AgentSkillInput": {
        "type": "object",
        "description": "A skill to save.",
        "required": [
          "name",
          "prompt"
        ],
        "properties": {
          "name": {
            "type": "string",
            "description": "1 to 80 characters."
          },
          "description": {
            "type": "string",
            "description": "Up to 255 characters."
          },
          "prompt": {
            "type": "string",
            "description": "1 to 4000 characters."
          },
          "fields": {
            "type": [
              "array",
              "null"
            ],
            "items": {
              "type": "object"
            },
            "description": "The template's choices for the `{Name}` parts (up to 20), or null."
          }
        }
      },
      "AgentStep": {
        "type": "object",
        "description": "One thing the agent did while answering.",
        "required": [
          "text"
        ],
        "properties": {
          "at": {
            "type": "integer",
            "format": "int64",
            "description": "When (unix seconds)."
          },
          "text": {
            "type": "string",
            "description": "What, in a few words (\"Looked up deals\")."
          }
        }
      },
      "AgentToken": {
        "type": "object",
        "description": "A token the agent reads the API with.",
        "required": [
          "token",
          "expires_at",
          "user_id",
          "company_id"
        ],
        "properties": {
          "token": {
            "type": "string",
            "description": "Send as `Authorization: Bearer <token>`."
          },
          "expires_at": {
            "type": "integer",
            "format": "int64",
            "description": "When it stops working (unix seconds); it also stops once the question\nis `done` or `failed`."
          },
          "user_id": {
            "type": "integer",
            "format": "int32",
            "description": "The asker, whom the token acts as."
          },
          "company_id": {
            "type": "integer",
            "format": "int32",
            "description": "The only company the token sees."
          }
        }
      },
      "AgentWake": {
        "type": "object",
        "description": "How ready the agent is.",
        "required": [
          "runner"
        ],
        "properties": {
          "runner": {
            "$ref": "#/components/schemas/RunnerState",
            "description": "`ready`, `starting` or `unknown`."
          }
        }
      },
      "AgenticJob": {
        "type": "object",
        "description": "Where a question is.",
        "required": [
          "id",
          "status",
          "chat_id",
          "steps",
          "pages",
          "actions"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int64",
            "description": "The question's id."
          },
          "status": {
            "type": "string",
            "description": "`queued` (not picked up yet), `pending`, `done` or `failed`."
          },
          "reply": {
            "type": [
              "string",
              "null"
            ],
            "description": "The answer, once `done`."
          },
          "error": {
            "type": [
              "string",
              "null"
            ],
            "description": "Why the agent failed, once `failed`."
          },
          "partial": {
            "type": [
              "string",
              "null"
            ],
            "description": "What the agent answered before failing, if anything."
          },
          "chat_id": {
            "type": "integer",
            "format": "int64",
            "description": "The chat it was asked in."
          },
          "steps": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/AgentStep"
            },
            "description": "What the agent has done so far, oldest first."
          },
          "pages": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/AgentPage"
            },
            "description": "The HTML pages of the answer, once `done`."
          },
          "actions": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/AgentAction"
            },
            "description": "The writes the agent proposed for the caller to confirm, oldest first."
          }
        }
      },
      "AgreedTime": {
        "type": "object",
        "description": "An agreed estimate time, on the user's clock.",
        "required": [
          "start",
          "evidence"
        ],
        "properties": {
          "start": {
            "type": "string",
            "description": "`YYYY-MM-DDTHH:mm`."
          },
          "end": {
            "type": [
              "string",
              "null"
            ],
            "description": "`YYYY-MM-DDTHH:mm`, when the conversation says."
          },
          "evidence": {
            "type": "string",
            "description": "The words that set the time."
          }
        }
      },
      "AiAssistantSwitch": {
        "type": "object",
        "description": "Body of `PUT /v1/me/ai-assistant`.",
        "required": [
          "on"
        ],
        "properties": {
          "on": {
            "type": "boolean",
            "description": "The AI personal assistant (AI promises) runs for me."
          }
        }
      },
      "AiModelChange": {
        "type": "object",
        "description": "One change on the AI models page.",
        "required": [
          "feature",
          "step"
        ],
        "properties": {
          "feature": {
            "type": "string",
            "description": "The step's feature."
          },
          "step": {
            "type": "string",
            "description": "The step within the feature; `\"\"` when the feature has one."
          },
          "name": {
            "type": [
              "string",
              "null"
            ],
            "description": "The feature's name; null for a step the code no longer has."
          },
          "label": {
            "type": [
              "string",
              "null"
            ],
            "description": "What the step does; null for a step the code no longer has."
          },
          "company_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "The company of a company's own pick; null for every company."
          },
          "company_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "The company's name; null for every company or a company that is gone."
          },
          "model": {
            "type": [
              "string",
              "null"
            ],
            "description": "The model picked; null when the step went back to its default."
          },
          "reasoning_effort": {
            "type": [
              "string",
              "null"
            ],
            "description": "The reasoning effort picked; null keeps the code's."
          },
          "changed_by": {
            "type": [
              "string",
              "null"
            ],
            "description": "Who changed it; null when the user is gone."
          },
          "changed_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When (UTC)."
          }
        }
      },
      "AiModelOption": {
        "type": "object",
        "description": "A model that can be picked, with today's price in US dollars.",
        "required": [
          "model",
          "kind",
          "needs_effort"
        ],
        "properties": {
          "model": {
            "type": "string",
            "description": "The model's name, as `POST /v1/ai-models/settings` takes it."
          },
          "kind": {
            "type": "string",
            "description": "`text`, `image` or `speech`."
          },
          "needs_effort": {
            "type": "boolean",
            "description": "True for a model that refuses `reasoning_effort: none` (the sol\nmodels): see a step's `no_thinking`."
          },
          "input_per_1m_usd": {
            "type": [
              "number",
              "null"
            ],
            "format": "double",
            "description": "Per million input tokens."
          },
          "cached_input_per_1m_usd": {
            "type": [
              "number",
              "null"
            ],
            "format": "double",
            "description": "Per million cached input tokens."
          },
          "output_per_1m_usd": {
            "type": [
              "number",
              "null"
            ],
            "format": "double",
            "description": "Per million output tokens."
          },
          "per_image_usd": {
            "type": [
              "number",
              "null"
            ],
            "format": "double",
            "description": "Per picture made."
          },
          "per_minute_usd": {
            "type": [
              "number",
              "null"
            ],
            "format": "double",
            "description": "Per minute of speech."
          }
        }
      },
      "AiModelsPage": {
        "type": "object",
        "description": "`GET /v1/ai-models`: the steps and what can be picked for them.",
        "required": [
          "steps",
          "models",
          "efforts"
        ],
        "properties": {
          "steps": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/AiStep"
            },
            "description": "Every AI step whose model can be changed, in the page's order."
          },
          "models": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/AiModelOption"
            },
            "description": "The models that can be picked: `OpenAI` models with a price in force\ntoday, so their calls are costed on the analytics page."
          },
          "efforts": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "The reasoning efforts a text step may be given."
          }
        }
      },
      "AiPromise": {
        "type": "object",
        "description": "A promise the rep made a customer, the quote work a customer gave them,\nor something they sent a customer to approve.",
        "required": [
          "id",
          "kind",
          "source",
          "promised_at",
          "title",
          "said",
          "is_appointment"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int64",
            "description": "Promise id.",
            "minimum": 0
          },
          "kind": {
            "type": "string",
            "description": "`promise`: the rep's; `quote`: the customer's quote to make or update\n(one task per customer, what they asked for in `details`); `approval`:\nsomething the rep sent for the customer's approval (due a day later)."
          },
          "crm_action": {
            "type": [
              "string",
              "null"
            ],
            "description": "What the rep does in the CRM that closes the promise by itself:\n`contract` (a document sent to sign), `schedule` (an event for the\ncustomer on the schedule) or `call` (a call with them); null when only\na message that keeps it, or Done, closes it. A quote task closes once\none of the customer's quotes is saved or emailed."
          },
          "source": {
            "type": "string",
            "description": "Where it was said: `call`, `sms` or `email`."
          },
          "promised_at": {
            "type": "string",
            "format": "date-time",
            "description": "When it was said."
          },
          "customer_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "The customer; null for a caller whose number is on no customer."
          },
          "customer_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "That customer's name."
          },
          "customer_digits": {
            "type": [
              "string",
              "null"
            ],
            "description": "The customer's phone (10 digits), for a call or a text."
          },
          "customer_email": {
            "type": [
              "string",
              "null"
            ],
            "description": "The customer's email, for an email."
          },
          "customer_label": {
            "type": [
              "string",
              "null"
            ],
            "description": "The name the customer goes by in the call or message (for a caller\nwhose number is on no customer)."
          },
          "quote_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "A quote task's quote: the customer's newest."
          },
          "title": {
            "type": "string",
            "description": "What to do, e.g. \"Send the inventory link\"."
          },
          "said": {
            "type": "string",
            "description": "The words that made it (for a quote task, its latest ask's)."
          },
          "details": {
            "type": [
              "string",
              "null"
            ],
            "description": "A quote task's asks, one per line: what the quote must have or change."
          },
          "due_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When it was promised for."
          },
          "is_appointment": {
            "type": "boolean",
            "description": "An appointment at a set time (a visit, measuring, a showroom meeting)."
          },
          "channel": {
            "type": [
              "string",
              "null"
            ],
            "description": "`sms` or `email` when a message keeps it."
          },
          "draft": {
            "type": [
              "string",
              "null"
            ],
            "description": "That message, ready to send (null when the AI could not write it)."
          },
          "scheduled": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/PromiseEvent",
                "description": "An appointment's event for the customer within 12 hours of it (null:\nnot on the schedule, or not an appointment)."
              },
              {
                "type": "null"
              }
            ]
          },
          "clash": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/PromiseEvent",
                "description": "Another appointment within the hour: one the rep promised someone\nelse, or an event assigned to them."
              },
              {
                "type": "null"
              }
            ]
          }
        }
      },
      "AiPromises": {
        "type": "object",
        "description": "Open promises.",
        "required": [
          "promises",
          "waiting"
        ],
        "properties": {
          "promises": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/AiPromise"
            },
            "description": "Newest first."
          },
          "waiting": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/WaitingCustomer"
            },
            "description": "Oldest wait first; only without a customer, phone or email."
          }
        }
      },
      "AiStep": {
        "type": "object",
        "description": "One AI step: a feature's call whose model can be changed.",
        "required": [
          "feature",
          "step",
          "name",
          "label",
          "kind",
          "default_model",
          "no_thinking",
          "effort_locked",
          "companies",
          "recent"
        ],
        "properties": {
          "feature": {
            "type": "string",
            "description": "Its feature (`ai_usage_log.feature`), the key with `step`."
          },
          "step": {
            "type": "string",
            "description": "The step within the feature; `\"\"` when the feature has one."
          },
          "name": {
            "type": "string",
            "description": "The feature's name on the analytics page."
          },
          "label": {
            "type": "string",
            "description": "What the step does."
          },
          "kind": {
            "type": "string",
            "description": "`text`, `image` or `speech`: only models of this kind can be picked."
          },
          "default_model": {
            "type": "string",
            "description": "The model the code asks for when nothing is picked."
          },
          "note": {
            "type": [
              "string",
              "null"
            ],
            "description": "A warning for a step that not every model can run (short answers\nwhile typing, a step asked with no thinking); null for the others."
          },
          "no_thinking": {
            "type": "boolean",
            "description": "True when the code asks the step with no thinking\n(`reasoning_effort: none`): a model with `needs_effort` is picked\nwith an effort other than `none`, or cannot be picked at all when\n`effort_locked`."
          },
          "effort_locked": {
            "type": "boolean",
            "description": "True when no reasoning effort can be picked for the step: it answers\nsomeone typing in a few tokens, which an effort would use up."
          },
          "everyone": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/ModelPick",
                "description": "The pick for every company; null when the step runs on its default."
              },
              {
                "type": "null"
              }
            ]
          },
          "companies": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CompanyModelPick"
            },
            "description": "Companies with their own pick, which wins over `everyone`."
          },
          "recent": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ModelUse"
            },
            "description": "The feature's calls of the last 7 days by model (every step of the\nfeature together), most calls first: what really ran."
          }
        }
      },
      "AnswerAttempt": {
        "type": "object",
        "description": "One answer to a training question.",
        "required": [
          "employee_id",
          "attempt_number",
          "question_id",
          "question_text",
          "correct_answer_text"
        ],
        "properties": {
          "employee_id": {
            "type": "integer",
            "format": "int32",
            "description": "Who answered."
          },
          "attempt_number": {
            "type": "integer",
            "format": "int32",
            "description": "Their try at the question, from 1."
          },
          "question_id": {
            "type": "integer",
            "format": "int32",
            "description": "The question."
          },
          "selected_answer_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "The answer they picked; null when none."
          },
          "is_correct": {
            "type": [
              "boolean",
              "null"
            ],
            "description": "Whether it was right, as recorded."
          },
          "question_text": {
            "type": "string",
            "description": "The question."
          },
          "selected_answer_text": {
            "type": [
              "string",
              "null"
            ],
            "description": "What they picked."
          },
          "correct_answer_text": {
            "type": "string",
            "description": "The right answer."
          }
        }
      },
      "AnswerChoice": {
        "type": "object",
        "description": "An answer to pick.",
        "required": [
          "id",
          "question_id",
          "text",
          "is_correct"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "The answer."
          },
          "question_id": {
            "type": "integer",
            "format": "int32",
            "description": "Its question."
          },
          "text": {
            "type": "string",
            "description": "Its text."
          },
          "is_correct": {
            "type": "boolean",
            "description": "The right answer."
          }
        }
      },
      "AnswerInput": {
        "type": "object",
        "description": "One answer.",
        "required": [
          "question_id",
          "answer"
        ],
        "properties": {
          "question_id": {
            "type": "integer",
            "format": "int32",
            "description": "Question id (of a questionnaire the caller can use)."
          },
          "answer": {
            "type": "string",
            "description": "Answer, up to 10000 characters; empty clears it."
          }
        }
      },
      "AnsweredQuestion": {
        "type": "object",
        "description": "A question with the deal's answer.",
        "required": [
          "id",
          "question",
          "answer"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "Question id."
          },
          "question": {
            "type": "string",
            "description": "The question."
          },
          "answer": {
            "type": "string",
            "description": "The deal's answer; empty when not answered."
          }
        }
      },
      "AnswersInput": {
        "type": "object",
        "description": "Body of `PUT /v1/deals/{id}/questionnaire-answers`.",
        "required": [
          "answers"
        ],
        "properties": {
          "answers": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/AnswerInput"
            },
            "description": "Answers to save; questions the caller cannot use are ignored."
          },
          "create_note": {
            "type": "boolean",
            "description": "Also add the answered questions to the deal as a note."
          }
        }
      },
      "AnswersSaved": {
        "type": "object",
        "description": "Result of saving answers.",
        "required": [
          "note_created"
        ],
        "properties": {
          "note_created": {
            "type": "boolean",
            "description": "A note was added to the deal."
          }
        }
      },
      "ApiTokenEmail": {
        "type": "object",
        "description": "Body of `POST /v1/company/api-token-email`.",
        "required": [
          "email"
        ],
        "properties": {
          "email": {
            "type": "string",
            "description": "Where to send the token."
          }
        }
      },
      "AppPayment": {
        "type": "object",
        "description": "A payment as the app's Payments tab shows it.",
        "required": [
          "id",
          "project_key",
          "method",
          "status",
          "amount_cents",
          "customer_fee_cents",
          "refunded_cents",
          "url",
          "created_at",
          "mine"
        ],
        "properties": {
          "id": {
            "type": "string",
            "description": "The payment's id (`pay_...`), also the last part of its link."
          },
          "customer_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Whose job it is for; null for a payment taken without a customer."
          },
          "customer_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "Their name; null when the customer has none."
          },
          "project_key": {
            "type": "string",
            "description": "The job: `deal-<deal id>` or `sale-<sale id>`; empty for a payment\ntaken without a customer."
          },
          "project_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "The job's name: the deal's title, else the address of the work."
          },
          "method": {
            "$ref": "#/components/schemas/PaymentMethod",
            "description": "How the customer pays."
          },
          "status": {
            "$ref": "#/components/schemas/CustomerPaymentStatus",
            "description": "Where the payment is; withdrawn links are not listed."
          },
          "amount_cents": {
            "type": "integer",
            "format": "int32",
            "description": "What goes toward the job, in US cents."
          },
          "customer_fee_cents": {
            "type": "integer",
            "format": "int32",
            "description": "The customer's part of the fee, added on top."
          },
          "refunded_cents": {
            "type": "integer",
            "format": "int32",
            "description": "What was given back, in US cents (0 unless refunded)."
          },
          "url": {
            "type": "string",
            "description": "The page the customer pays on: the app shows it as a code to scan."
          },
          "failure_reason": {
            "type": [
              "string",
              "null"
            ],
            "description": "Why it failed, as a short plain phrase; null unless `failed`."
          },
          "created_at": {
            "type": "string",
            "description": "When it was made (ISO 8601, UTC)."
          },
          "taken_by": {
            "type": [
              "string",
              "null"
            ],
            "description": "Who took it; null when that person is gone."
          },
          "mine": {
            "type": "boolean",
            "description": "The caller took it."
          }
        }
      },
      "AppPayments": {
        "type": "object",
        "description": "What `GET /v1/payments` answers.",
        "required": [
          "enabled",
          "can_take",
          "fees",
          "payments"
        ],
        "properties": {
          "enabled": {
            "type": "boolean",
            "description": "Customer payments are turned on for the company."
          },
          "can_take": {
            "type": "boolean",
            "description": "A payment can be taken now: turned on, and the company's bank account\nis connected. While false the app offers no Take payment."
          },
          "fees": {
            "$ref": "#/components/schemas/PaymentFees",
            "description": "The fee on each payment method and who pays it."
          },
          "payments": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/AppPayment"
            },
            "description": "The payments, newest first, 100 at most."
          }
        }
      },
      "AppShell": {
        "type": "object",
        "description": "`GET /v1/app/shell`.",
        "required": [
          "user",
          "user_is_super_admin",
          "superadmin_companies",
          "company",
          "has_cloudtalk_api",
          "has_ringcentral_api",
          "has_telnyx_api",
          "has_telnyx_sms",
          "has_inbound_email",
          "sms_images_enabled",
          "can_manage_company",
          "can_manage_billing",
          "payment_required",
          "is_shop_manager",
          "is_scheduling_manager",
          "has_projects_board",
          "is_template_maker",
          "is_installer",
          "user_signature_access",
          "user_ai_promises",
          "user_ai_promises_available",
          "company_features",
          "feature_capabilities"
        ],
        "properties": {
          "user": {
            "$ref": "#/components/schemas/SessionUser",
            "description": "The signed-in user, in the company requests act in."
          },
          "user_is_super_admin": {
            "type": "boolean",
            "description": "The user holds the Super Admin position somewhere."
          },
          "superadmin_companies": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ShellCompanyRef"
            },
            "description": "Companies a super admin can switch to, by name."
          },
          "active_company_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "The company a super admin chose to act in (null when it is their own)."
          },
          "company": {
            "$ref": "#/components/schemas/ShellCompany",
            "description": "The acting company."
          },
          "portal": {
            "type": [
              "string",
              "null"
            ],
            "description": "The portal a position locks the user into (`installer`, `check-in`,\n`marketing`, `shop_worker`, `template`); null for everyone else."
          },
          "portal_home": {
            "type": [
              "string",
              "null"
            ],
            "description": "That portal's start page."
          },
          "sections": {
            "type": [
              "array",
              "null"
            ],
            "items": {
              "type": "string"
            },
            "description": "The tabs the user's positions open, when the company limits them\n(Position access): keys such as `stones`, `customers`, `schedule`,\n`admin_stones` (`GET /v1/company/position-sections` lists them all).\nThe Admin switch still opens every admin page. Null when nothing is\nlimited."
          },
          "skills": {
            "type": [
              "array",
              "null"
            ],
            "items": {
              "type": "string"
            },
            "description": "The skills the user's positions give them (Position access):\n`sell_slabs`, `edit_transactions`, `edit_quotes`, `plan_schedule`, `see_readiness`, `send_sms`, `best_days`, `events_map`.\nNull when they have every skill (admins always do)."
          },
          "has_cloudtalk_api": {
            "type": "boolean",
            "description": "The company has CloudTalk."
          },
          "has_ringcentral_api": {
            "type": "boolean",
            "description": "The company has RingCentral."
          },
          "has_telnyx_api": {
            "type": "boolean",
            "description": "The company has Granite Manager (Telnyx) switched on."
          },
          "has_telnyx_sms": {
            "type": "boolean",
            "description": "The company texts through Telnyx (its messaging profile is set):\nusers with a `telnyx_line` text from it (`/v1/sms/telnyx/...`)."
          },
          "telnyx_line": {
            "type": [
              "string",
              "null"
            ],
            "description": "The user's Telnyx line for calls and texts from the CRM (E.164): their\ndefault caller ID, else their direct number, else the first number\nthey may call from; null without one (or without Telnyx)."
          },
          "has_inbound_email": {
            "type": "boolean",
            "description": "The company receives email (it has a mail domain)."
          },
          "sms_images_enabled": {
            "type": "boolean",
            "description": "Pictures can be sent by text (`SMS_IMAGES_ENABLED` is not off)."
          },
          "can_manage_company": {
            "type": "boolean",
            "description": "May edit company settings and users (super user, or Manager)."
          },
          "can_manage_billing": {
            "type": "boolean",
            "description": "May manage billing (Manager)."
          },
          "payment_required": {
            "type": "boolean",
            "description": "The company signed itself up and has not paid (nor been given free\ntime): every other route answers 403, and the app shows only the\npage to pay or contact Granite Manager (`/activate`). Always false\nfor superusers."
          },
          "is_shop_manager": {
            "type": "boolean",
            "description": "Holds the Shop Manager position in the company."
          },
          "is_scheduling_manager": {
            "type": "boolean",
            "description": "Holds the Scheduling Manager position in the company: only they see\nan event's Scheduling text and Scheduling call."
          },
          "has_projects_board": {
            "type": "boolean",
            "description": "Projects is on and the caller's position has a Projects board (admin,\nManager, Sales Manager, Shop Manager, sales rep)."
          },
          "is_template_maker": {
            "type": "boolean",
            "description": "Holds Template in the company (their portal is their own schedule)."
          },
          "is_installer": {
            "type": "boolean",
            "description": "Holds Installer in the company. Beside Shop Worker (portal\n`shop_worker`) the Shop app adds their own jobs and checklist."
          },
          "user_signature_access": {
            "type": "boolean",
            "description": "May send documents for signature."
          },
          "user_ai_promises": {
            "type": "boolean",
            "description": "AI promises is on for the user (`users.ai_promises`): the promise list\nand the promised messages in the composers."
          },
          "user_ai_promises_available": {
            "type": "boolean",
            "description": "The user has the AI personal assistant, on or switched off by them\n(the switch on My Account)."
          },
          "company_features": {
            "$ref": "#/components/schemas/ShellFeatures",
            "description": "The acting company's switches."
          },
          "feature_capabilities": {
            "$ref": "#/components/schemas/TeamCapabilities",
            "description": "What the user's home company can do, as the guided tours gate on it."
          }
        }
      },
      "AppliedProgress": {
        "type": "object",
        "description": "The progress after events.",
        "required": [
          "state",
          "feature_tasks_enabled"
        ],
        "properties": {
          "state": {
            "$ref": "#/components/schemas/OnboardingState",
            "description": "The saved state."
          },
          "completed_at": {
            "type": [
              "string",
              "null"
            ],
            "description": "When the first-run journey was completed."
          },
          "feature_tasks_enabled": {
            "type": "boolean",
            "description": "The home company's guided tours are on (off: task events were dropped)."
          }
        }
      },
      "AppointmentPart": {
        "type": "object",
        "description": "Body of `PUT /v1/projects/{id}/appointments/{event_id}/part`.",
        "required": [
          "part_id"
        ],
        "properties": {
          "part_id": {
            "type": "integer",
            "format": "int32",
            "description": "The part the template or installation is for."
          }
        }
      },
      "AreaNameSuggestion": {
        "type": "object",
        "description": "An area name used on earlier quotes.",
        "required": [
          "name",
          "uses",
          "customers"
        ],
        "properties": {
          "name": {
            "type": "string",
            "description": "The name, spelled as on the latest quote that used it (e.g. `Kitchen`)."
          },
          "uses": {
            "type": "integer",
            "format": "int64",
            "description": "How many of the recent quotes use it."
          },
          "customers": {
            "type": "integer",
            "format": "int64",
            "description": "How many different customers those quotes are for (a quote with no\ncustomer counts by its deal, else on its own). Always 2 or more."
          },
          "last_used": {
            "type": [
              "string",
              "null"
            ],
            "description": "When the latest quote using it was last changed (UTC, ISO 8601); null if unknown."
          }
        }
      },
      "AttachableStone": {
        "type": "object",
        "description": "A stone to attach.",
        "required": [
          "id",
          "installed_count"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "The stone."
          },
          "name": {
            "type": [
              "string",
              "null"
            ],
            "description": "Its name."
          },
          "url": {
            "type": [
              "string",
              "null"
            ],
            "description": "The stone's image."
          },
          "type": {
            "type": [
              "string",
              "null"
            ],
            "description": "Material type, e.g. `granite`."
          },
          "finishing": {
            "type": [
              "string",
              "null"
            ],
            "description": "`polished`, `leathered` or `honed`."
          },
          "level": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Price level, a number of the company's levels (1 = cheapest)."
          },
          "installed_count": {
            "type": "integer",
            "format": "int64",
            "description": "Installed (project) photos, its own and those it shows from other stones."
          }
        }
      },
      "AttachedCounts": {
        "type": "object",
        "description": "How many of each kind were attached.",
        "required": [
          "images",
          "documents"
        ],
        "properties": {
          "images": {
            "type": "integer",
            "description": "Photos attached.",
            "minimum": 0
          },
          "documents": {
            "type": "integer",
            "description": "Documents attached.",
            "minimum": 0
          }
        }
      },
      "Attachment": {
        "type": "object",
        "description": "A file attached to a message.",
        "required": [
          "id",
          "email_id",
          "content_type",
          "filename",
          "url"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "Attachment id."
          },
          "email_id": {
            "type": "integer",
            "format": "int32",
            "description": "Message it belongs to."
          },
          "content_type": {
            "type": "string",
            "description": "MIME type (`application`)."
          },
          "content_subtype": {
            "type": [
              "string",
              "null"
            ],
            "description": "MIME subtype (`pdf`)."
          },
          "filename": {
            "type": "string",
            "description": "File name."
          },
          "url": {
            "type": "string",
            "description": "Stored URL."
          },
          "is_inline": {
            "type": [
              "boolean",
              "null"
            ],
            "description": "Drawn inside the body (a signature logo) rather than attached; null\nfor files saved before this was recorded."
          },
          "signed_url": {
            "type": [
              "string",
              "null"
            ],
            "description": "A link the browser can open, for private files (valid an hour)."
          },
          "signature_status": {
            "type": [
              "string",
              "null"
            ],
            "description": "Status of an e-signature request made from it: `draft`, `sent`,\n`viewed`, `signed`, `declined`, `expired`; null without one."
          }
        }
      },
      "AttachmentFile": {
        "type": "object",
        "description": "A file to attach.",
        "required": [
          "url"
        ],
        "properties": {
          "url": {
            "type": "string",
            "description": "Uploaded to the `events` folder (`POST /v1/uploads`)."
          },
          "name": {
            "type": [
              "string",
              "null"
            ],
            "description": "File name to show; defaults to the URL's last part."
          }
        }
      },
      "AttachmentsInput": {
        "type": "object",
        "description": "Body of `POST /v1/events/{id}/attachments`.",
        "required": [
          "files"
        ],
        "properties": {
          "files": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/AttachmentFile"
            },
            "description": "Documents (pdf, Word, Excel, csv, txt) or images."
          }
        }
      },
      "AttemptAnswer": {
        "type": "object",
        "description": "One answer of a finished test.",
        "required": [
          "question_id"
        ],
        "properties": {
          "question_id": {
            "type": "integer",
            "format": "int32",
            "description": "The question."
          },
          "selected_answer_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "The answer picked; null when skipped."
          }
        }
      },
      "AttemptInput": {
        "type": "object",
        "description": "Body of `POST /v1/teach-mode/attempts`.",
        "required": [
          "answers"
        ],
        "properties": {
          "answers": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/AttemptAnswer"
            },
            "description": "Every question of the test, answered or not."
          }
        }
      },
      "AttemptResult": {
        "type": "object",
        "description": "The grade of a test.",
        "required": [
          "score_percent",
          "passed"
        ],
        "properties": {
          "score_percent": {
            "type": "integer",
            "format": "int32",
            "description": "Right answers, in percent (rounded)."
          },
          "passed": {
            "type": "boolean",
            "description": "Every answer was right."
          }
        }
      },
      "AuthSession": {
        "type": "object",
        "description": "`GET /v1/auth/session` and the login result.",
        "required": [
          "user",
          "home_path",
          "switchable_companies"
        ],
        "properties": {
          "user": {
            "$ref": "#/components/schemas/SessionUser",
            "description": "The signed-in user (the company is the one requests act in)."
          },
          "home_path": {
            "type": "string",
            "description": "Where the user starts: their portal, or `/employee`."
          },
          "company_subdomain": {
            "type": [
              "string",
              "null"
            ],
            "description": "The subdomain of the acting company, for its own host\n(`{subdomain}.granite-manager.com`); null when it has none."
          },
          "switchable_companies": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SwitchableCompany"
            },
            "description": "Companies a super admin can switch to (empty for everyone else)."
          }
        }
      },
      "AuthenticatorSetup": {
        "type": "object",
        "description": "What the user adds to their authenticator app.",
        "required": [
          "secret",
          "uri",
          "qr"
        ],
        "properties": {
          "secret": {
            "type": "string",
            "description": "The secret as base32 (32 letters and digits), for typing into the\nauthenticator app when the QR code cannot be scanned (setting up on\nthe phone that shows it). Shown grouped by 4 is fine: apps ignore\nspaces."
          },
          "uri": {
            "type": "string",
            "description": "The `otpauth://totp/...` link: opening it on a phone adds the account\nto the authenticator app installed there."
          },
          "qr": {
            "type": "string",
            "description": "The QR code of `uri`, as a `data:image/png;base64,...` URL, for\nscanning with the authenticator app on another phone."
          }
        }
      },
      "AuthorizeLink": {
        "type": "object",
        "description": "Where to send the browser.",
        "required": [
          "url"
        ],
        "properties": {
          "url": {
            "type": "string",
            "description": "The provider's sign-in / consent page."
          }
        }
      },
      "AutoConfirmReplies": {
        "type": "object",
        "description": "Admin > Schedule > Auto-confirm: the text the customer gets back once AI\nreads their reply to an auto-confirm text. Sent at once (texting hours do\nnot apply), from the line they texted, only while \"Turn the job Confirmed\nwhen the customer replies YES (AI)\" is on. Variables such as\n`{{appointment.date}}` are filled in for the job.",
        "properties": {
          "yes_reply": {
            "type": [
              "string",
              "null"
            ],
            "description": "Sent after a clear YES turned the job Confirmed (up to 1600\ncharacters); null sends nothing."
          },
          "no_reply": {
            "type": [
              "string",
              "null"
            ],
            "description": "Sent after a NO or a request for another day or time (up to 1600\ncharacters); null sends nothing."
          }
        }
      },
      "AutoInvoiceInput": {
        "type": "object",
        "description": "Body of `PUT /v1/company/auto-invoice`.",
        "required": [
          "enabled"
        ],
        "properties": {
          "enabled": {
            "type": "boolean",
            "description": "On: marking a quote sold opens its QuickBooks invoice to confirm."
          }
        },
        "additionalProperties": false
      },
      "AutoPlan": {
        "type": "object",
        "description": "`POST /v1/schedule/auto-plan`.",
        "required": [
          "placements",
          "skipped"
        ],
        "properties": {
          "placements": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Placement"
            },
            "description": "The proposed times, by start."
          },
          "skipped": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Skipped"
            },
            "description": "The events left out."
          },
          "drive_note": {
            "type": [
              "string",
              "null"
            ],
            "description": "Why some drives are the job time rules' drive time rather than\nGoogle's (no company address, no Google Maps, or too many stops);\nnull when every drive between addresses is Google's."
          }
        }
      },
      "AutoPlanInput": {
        "type": "object",
        "description": "Body of `POST /v1/schedule/auto-plan`.",
        "required": [
          "calendar_id",
          "start_date",
          "days",
          "statuses"
        ],
        "properties": {
          "calendar_id": {
            "type": "integer",
            "format": "int32",
            "description": "The Templates calendar (installations are not auto-planned for now)."
          },
          "user_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "The template maker to plan for. Leave it out only when the company\nhas no one in that role."
          },
          "start_date": {
            "type": "string",
            "format": "date",
            "description": "The first day to fill (shop time)."
          },
          "days": {
            "type": "integer",
            "format": "int32",
            "description": "How many work days to fill, 1 to 30.",
            "minimum": 0
          },
          "statuses": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "The waiting statuses to plan (`ready`, `called`, `not_ready`)."
          },
          "skip_event_ids": {
            "type": "array",
            "items": {
              "type": "integer",
              "format": "int32"
            },
            "description": "Waiting events to leave out of this plan."
          },
          "best_day": {
            "type": "boolean",
            "description": "Answer with the one best day: a day that already has stops near the\nwaiting jobs, and only then an empty day."
          },
          "done_days": {
            "type": "array",
            "items": {
              "type": "string",
              "format": "date"
            },
            "description": "Days already reviewed, left out with `best_day`."
          }
        }
      },
      "AutoProjectInput": {
        "type": "object",
        "description": "Body of `PUT /v1/company/auto-project`.",
        "required": [
          "enabled"
        ],
        "properties": {
          "enabled": {
            "type": "boolean",
            "description": "On: marking a deal won or a quote sold starts its project."
          }
        },
        "additionalProperties": false
      },
      "AutoSaleInput": {
        "type": "object",
        "description": "Body of `PUT /v1/company/auto-sale`.",
        "required": [
          "enabled"
        ],
        "properties": {
          "enabled": {
            "type": "boolean",
            "description": "On: marking a deal won or a quote sold opens the sale form."
          }
        },
        "additionalProperties": false
      },
      "AutoSalesOrderInput": {
        "type": "object",
        "description": "Body of `PUT /v1/company/auto-sales-order`.",
        "required": [
          "enabled"
        ],
        "properties": {
          "enabled": {
            "type": "boolean",
            "description": "On: marking a quote sold makes its sales order."
          }
        },
        "additionalProperties": false
      },
      "AutoUnscheduledJobsInput": {
        "type": "object",
        "description": "Body of `PUT /v1/company/auto-unscheduled-jobs`.",
        "required": [
          "enabled"
        ],
        "properties": {
          "enabled": {
            "type": "boolean",
            "description": "On: marking a quote sold adds its template and installation to\nUnscheduled."
          }
        },
        "additionalProperties": false
      },
      "AutocompleteRequest": {
        "allOf": [
          {
            "$ref": "#/components/schemas/ComposeTarget"
          },
          {
            "type": "object",
            "properties": {
              "draft": {
                "type": "string",
                "description": "What the rep typed so far (empty: suggest how the message starts)."
              },
              "warm": {
                "type": "boolean",
                "description": "Only load the thread, so the first suggestion waits on the model alone."
              },
              "conversation": {
                "type": [
                  "string",
                  "null"
                ],
                "description": "The composer's mark of the newest message it shows (any text that\nchanges with a new message, like \"12:8841\"). The thread is kept for a\nminute per mark, so a message sent or received since is read at once.\nWithout it the kept thread can be up to a minute old."
              }
            }
          }
        ],
        "description": "`POST /v1/ai/compose/autocomplete`."
      },
      "Automation": {
        "type": "object",
        "description": "An automation: when `trigger` happens, the job moves to `status_key`.",
        "required": [
          "trigger",
          "enabled",
          "status_key"
        ],
        "properties": {
          "trigger": {
            "$ref": "#/components/schemas/Trigger"
          },
          "enabled": {
            "type": "boolean",
            "description": "Whether the automation runs."
          },
          "status_key": {
            "type": "string",
            "description": "The status the job moves to; empty when its status was deleted and no\nstatus of that type is left."
          }
        }
      },
      "AutomationChannel": {
        "type": "string",
        "description": "Which kind of template an automation sends.",
        "enum": [
          "email",
          "sms"
        ]
      },
      "AutomationItem": {
        "type": "object",
        "description": "One automated email or text: it goes out by itself when a deal lands on\nits list.",
        "required": [
          "channel",
          "template_id",
          "name",
          "list_id",
          "delay_minutes"
        ],
        "properties": {
          "channel": {
            "$ref": "#/components/schemas/AutomationChannel",
            "description": "Email or text."
          },
          "template_id": {
            "type": "integer",
            "format": "int32",
            "description": "The template's id: edit or delete it with `/v1/email-templates/{id}`\nor `/v1/sms-templates/{id}` by `channel`."
          },
          "name": {
            "type": "string",
            "description": "The template's name."
          },
          "list_id": {
            "type": "integer",
            "format": "int32",
            "description": "The deal list that starts it."
          },
          "list_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "That list's name; null when the list was deleted."
          },
          "group_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "The name of the list's group (pipeline); null when the list or the\ngroup was deleted."
          },
          "delay_minutes": {
            "type": "integer",
            "format": "int32",
            "description": "How long after the deal lands on the list it goes out, in minutes."
          }
        }
      },
      "AutomationsInput": {
        "type": "object",
        "description": "`PUT /v1/schedule/statuses/automations`.",
        "properties": {
          "automations": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Automation"
            },
            "description": "Every automation, as it should be now."
          },
          "texts_confirmed_only": {
            "type": [
              "boolean",
              "null"
            ],
            "description": "Whether automatic customer texts go only to Confirmed jobs; left out: unchanged."
          }
        }
      },
      "Autosave": {
        "type": "object",
        "description": "The caller's unsaved drawing.",
        "required": [
          "doc"
        ],
        "properties": {
          "doc": {
            "type": "object",
            "description": "The drawing."
          },
          "saved_at": {
            "type": [
              "string",
              "null"
            ],
            "description": "When (ISO 8601)."
          }
        }
      },
      "Availability": {
        "type": "object",
        "description": "The user's availability right now.",
        "required": [
          "status",
          "dndIndefinite"
        ],
        "properties": {
          "status": {
            "$ref": "#/components/schemas/AvailabilityStatus",
            "description": "`available`, `dnd` or `outside_hours`. Do not disturb wins over\nworking hours."
          },
          "dndUntil": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When a timed Do not disturb ends (RFC 3339, UTC); null when Do not\ndisturb is off or lasts until turned off."
          },
          "dndIndefinite": {
            "type": "boolean",
            "description": "Do not disturb is on until the user turns it off."
          }
        }
      },
      "AvailabilityChoice": {
        "type": "string",
        "description": "What the user chooses: `available` or `dnd` (Do not disturb).",
        "enum": [
          "Available",
          "Dnd"
        ]
      },
      "AvailabilityInput": {
        "type": "object",
        "description": "Body of `PUT /v1/phone/availability`.",
        "required": [
          "status"
        ],
        "properties": {
          "status": {
            "$ref": "#/components/schemas/AvailabilityChoice",
            "description": "`available` (also ends Do not disturb) or `dnd`."
          },
          "dndUntil": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "With `dnd`: when it ends (RFC 3339, in the future, within a year);\nnull or left out = until turned off. Ignored with `available`."
          }
        }
      },
      "AvailabilityStatus": {
        "type": "string",
        "description": "Whether the user's phones ring now: `available`, `dnd` (Do not\ndisturb) or `outside_hours` (outside their working hours).",
        "enum": [
          "Available",
          "Dnd",
          "OutsideHours"
        ]
      },
      "BadgeCount": {
        "type": "object",
        "description": "A badge count.",
        "required": [
          "count"
        ],
        "properties": {
          "count": {
            "type": "integer",
            "format": "int64",
            "description": "How many."
          }
        }
      },
      "BadgePart": {
        "type": "string",
        "description": "A part of `GET /v1/me/badges`.",
        "enum": [
          "emails_unread",
          "sms_unread",
          "sms_alerts",
          "sales_orders",
          "support_unread",
          "phone_app",
          "payments"
        ]
      },
      "Badges": {
        "type": "object",
        "description": "`GET /v1/me/badges`: the parts asked for; a part not asked for is absent.",
        "properties": {
          "emails_unread": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/EmailBadge",
                "description": "`emails_unread`: unread threads of the caller's inbox."
              },
              {
                "type": "null"
              }
            ]
          },
          "sms_unread": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/BadgeCount",
                "description": "`sms_unread`: the caller's conversations with unread texts over every\nprovider they text through (a phone unread through two providers\ncounts twice)."
              },
              {
                "type": "null"
              }
            ]
          },
          "sms_alerts": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/SmsAlerts",
                "description": "`sms_alerts`: the caller's unread texts to show as desktop alerts."
              },
              {
                "type": "null"
              }
            ]
          },
          "sales_orders": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/BadgeCount",
                "description": "`sales_orders`: the company's sales orders waiting to be confirmed.\nAbsent, even when asked for, for someone who does not confirm them:\nonly a superuser, or someone whose positions open the Sales orders tab\nand have the Confirm sales orders skill (Inventory Manager by\ndefault), gets it."
              },
              {
                "type": "null"
              }
            ]
          },
          "support_unread": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/BadgeCount",
                "description": "`support_unread`: the caller's support requests with an answer of\nGranite Manager's support team they have not read (the Chat button's\nbadge)."
              },
              {
                "type": "null"
              }
            ]
          },
          "phone_app": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/PhoneAppBadge",
                "description": "`phone_app`: whether the caller uses the phone app."
              },
              {
                "type": "null"
              }
            ]
          },
          "payments": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/PaymentsBadge",
                "description": "`payments`: whether the company takes customer payments now (the\nsidebar shows Payments only then)."
              },
              {
                "type": "null"
              }
            ]
          },
          "failed": {
            "type": [
              "array",
              "null"
            ],
            "items": {
              "$ref": "#/components/schemas/BadgePart"
            },
            "description": "The parts asked for that could not be read this time, left out\nabove: keep showing their last value and ask again at the next poll.\nAbsent when every part was read. When every part asked fails the\nanswer is a 500 instead."
          }
        }
      },
      "BankAccount": {
        "type": "object",
        "description": "The company's bank account, as Stripe last reported it.",
        "required": [
          "status"
        ],
        "properties": {
          "status": {
            "$ref": "#/components/schemas/BankAccountStatus",
            "description": "Whether the company can be paid."
          },
          "bank_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "The name of the bank payouts go to (the account's default bank\naccount at Stripe); null until connected, or when Stripe does not say."
          },
          "last4": {
            "type": [
              "string",
              "null"
            ],
            "description": "The account number's last 4 digits; null like `bank_name`."
          }
        }
      },
      "BankAccountStatus": {
        "type": "string",
        "description": "Whether the company can be paid.",
        "enum": [
          "not_connected",
          "setup_unfinished",
          "pending_verification",
          "connected"
        ]
      },
      "BankForm": {
        "type": "object",
        "description": "What the page needs to show Stripe's bank form.",
        "required": [
          "publishable_key",
          "stripe_account",
          "client_secret"
        ],
        "properties": {
          "publishable_key": {
            "type": "string",
            "description": "Stripe.js's publishable key (`pk_...`)."
          },
          "stripe_account": {
            "type": "string",
            "description": "The company's Stripe account (`acct_...`), which is paid."
          },
          "client_secret": {
            "type": "string",
            "description": "The payment intent's secret, for Stripe.js to confirm it with."
          },
          "name": {
            "type": [
              "string",
              "null"
            ],
            "description": "The customer's name as the company keeps it, to fill in."
          },
          "email": {
            "type": [
              "string",
              "null"
            ],
            "description": "The customer's email as the company keeps it, to fill in."
          }
        }
      },
      "BankOnboarding": {
        "type": "object",
        "description": "Where the bank account is connected.",
        "properties": {
          "url": {
            "type": [
              "string",
              "null"
            ],
            "description": "Stripe's page to open: the company fills in its business and bank\ndetails there and is sent back to Admin → Company. The link works once\nand for a few minutes. Null in demo mode, where the account is\nconnected at once."
          }
        }
      },
      "BankTransfer": {
        "type": "object",
        "description": "Where the customer sends the money from their bank app.",
        "required": [
          "routing_number",
          "account_number",
          "amount_cents"
        ],
        "properties": {
          "routing_number": {
            "type": "string",
            "description": "The routing number (ABA) to send to."
          },
          "account_number": {
            "type": "string",
            "description": "The account number to send to: the customer's own at this company,\nso the money is matched to them by itself."
          },
          "bank_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "The bank that holds that account; null when Stripe does not say."
          },
          "account_holder_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "The name on that account; null when Stripe does not say (the page\nthen shows the company's)."
          },
          "reference": {
            "type": [
              "string",
              "null"
            ],
            "description": "A code for the transfer's memo, when the customer's bank asks for\none; null when Stripe gives none."
          },
          "amount_cents": {
            "type": "integer",
            "format": "int64",
            "description": "What is still to send, in US cents: the whole payment until part of\nit arrived."
          },
          "instructions_url": {
            "type": [
              "string",
              "null"
            ],
            "description": "Stripe's own page with the same instructions; null when Stripe does\nnot give one (and in demo mode)."
          }
        }
      },
      "BasePay": {
        "type": "object",
        "description": "A rep's base pay (`commission_base_pay`): `amount` every week, two weeks\nor month from the first payday, until an optional last day. It is one\nperson's (`user_id`) or everyone's with a position (`position_id`); a\nperson's own base pay replaces their position's.",
        "required": [
          "id",
          "amount",
          "frequency",
          "startDate"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int64",
            "description": "Base pay id."
          },
          "userId": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "One person's base pay."
          },
          "rep": {
            "type": [
              "string",
              "null"
            ],
            "description": "Their name."
          },
          "positionId": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Or the base pay of everyone with this position."
          },
          "amount": {
            "type": "number",
            "format": "double",
            "description": "Paid each time."
          },
          "frequency": {
            "type": "string",
            "description": "`weekly`, `biweekly` (every two weeks) or `monthly`."
          },
          "startDate": {
            "type": "string",
            "description": "The first payday (YYYY-MM-DD); monthly pays on its day of the month."
          },
          "endDate": {
            "type": [
              "string",
              "null"
            ],
            "description": "The last day it is paid (YYYY-MM-DD); none: no end."
          }
        }
      },
      "BasePayInput": {
        "type": "object",
        "description": "A base pay as an admin sets it: for one person or for a position.",
        "required": [
          "amount",
          "frequency",
          "startDate"
        ],
        "properties": {
          "userId": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "One person (an employee of the company)…"
          },
          "positionId": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "…or everyone with this position; exactly one of the two."
          },
          "amount": {
            "type": "number",
            "format": "double",
            "description": "Paid each time; not negative."
          },
          "frequency": {
            "type": "string",
            "description": "`weekly`, `biweekly` (every two weeks) or `monthly`."
          },
          "startDate": {
            "type": "string",
            "description": "The first payday, YYYY-MM-DD; monthly pays on its day of the month."
          },
          "endDate": {
            "type": [
              "string",
              "null"
            ],
            "description": "The last day it is paid, YYYY-MM-DD; none: no end."
          }
        },
        "additionalProperties": false
      },
      "BatchInput": {
        "type": "object",
        "description": "Body of `POST /v1/jobs/batch`.",
        "required": [
          "jobs"
        ],
        "properties": {
          "jobs": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Jobs to run, in this order: names as in `/v1/jobs/<job>`."
          },
          "start_within_secs": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int64",
            "description": "No job starts once this many seconds have passed since the batch\nbegan (default 15, at most 600); those come back `skipped`.",
            "minimum": 0
          }
        }
      },
      "BatchJob": {
        "type": "object",
        "description": "What one job of the batch answered.",
        "required": [
          "job",
          "skipped"
        ],
        "properties": {
          "job": {
            "type": "string",
            "description": "The job's name, as sent in `jobs`."
          },
          "status": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "The HTTP status the job answered (404: no such job). Absent when it\nwas skipped.",
            "minimum": 0
          },
          "processed": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int64",
            "description": "The job's own `processed` count, when it answered one.",
            "minimum": 0
          },
          "skipped": {
            "type": "boolean",
            "description": "Not started: `start_within_secs` had passed. The caller runs it."
          }
        }
      },
      "BatchRun": {
        "type": "object",
        "description": "What a batch did.",
        "required": [
          "results"
        ],
        "properties": {
          "results": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/BatchJob"
            },
            "description": "One entry per job asked for, in the same order."
          }
        }
      },
      "BestDays": {
        "type": "object",
        "description": "`POST /v1/schedule/best-days`.",
        "required": [
          "stops"
        ],
        "properties": {
          "stops": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/StopDistance"
            },
            "description": "The job's calendar's events of the range that start after now and\nhave an address Google can find. Empty when the job has no address,\nGoogle cannot find it, or Google Maps is not set up."
          }
        }
      },
      "BestDaysInput": {
        "type": "object",
        "description": "Body of `POST /v1/schedule/best-days`.",
        "required": [
          "event_id",
          "start",
          "end"
        ],
        "properties": {
          "event_id": {
            "type": "integer",
            "format": "int32",
            "description": "The waiting job being dragged."
          },
          "start": {
            "type": "string",
            "format": "date-time",
            "description": "Range start (ISO 8601); nothing before now is looked at."
          },
          "end": {
            "type": "string",
            "format": "date-time",
            "description": "Range end (ISO 8601)."
          }
        }
      },
      "BillingDay": {
        "type": "object",
        "description": "Body of `PUT /v1/superuser/companies/{id}/billing-day`.",
        "required": [
          "day"
        ],
        "properties": {
          "day": {
            "type": "integer",
            "format": "int32",
            "description": "The day of the month it is charged, 1 to 28.",
            "minimum": 0
          }
        }
      },
      "BillingGate": {
        "allOf": [
          {
            "$ref": "#/components/schemas/BillingNotice"
          },
          {
            "type": "object",
            "required": [
              "can_manage"
            ],
            "properties": {
              "can_manage": {
                "type": "boolean",
                "description": "The caller is a manager of the company or a superuser (manages billing)."
              }
            }
          }
        ],
        "description": "`GET /v1/billing/gate`."
      },
      "BillingNotice": {
        "type": "object",
        "description": "What a page shows about billing.",
        "required": [
          "show_warning",
          "days_remaining",
          "restricted",
          "first_payment_due"
        ],
        "properties": {
          "show_warning": {
            "type": "boolean",
            "description": "Show the past-due banner (managers only)."
          },
          "days_remaining": {
            "type": "integer",
            "format": "int64",
            "description": "Days left in the grace period."
          },
          "restricted": {
            "type": "boolean",
            "description": "Access is paused: only billing pages work."
          },
          "first_payment_due": {
            "type": "boolean",
            "description": "A company that signed itself up and has not paid for its first\nsubscription yet: `restricted` too, and the billing page asks it to\npay (`POST /v1/billing/first-payment/checkout`) or to write to\nGranite Manager for a free month."
          }
        }
      },
      "BillingOverview": {
        "type": "object",
        "description": "`GET /v1/billing`.",
        "required": [
          "invoices",
          "plans",
          "restricted",
          "starts_checkout",
          "needs_new_subscription",
          "billing_configured"
        ],
        "properties": {
          "subscription": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/Subscription",
                "description": "The subscription, or null when the company never had one."
              },
              {
                "type": "null"
              }
            ]
          },
          "card": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/Card",
                "description": "The card subscriptions are charged to, or null."
              },
              {
                "type": "null"
              }
            ]
          },
          "invoices": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Invoice"
            },
            "description": "Paid and open invoices, newest payment first."
          },
          "plans": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Plan"
            },
            "description": "Plans to subscribe or switch to."
          },
          "restricted": {
            "type": "boolean",
            "description": "Access is paused until the company pays."
          },
          "starts_checkout": {
            "type": "boolean",
            "description": "The subscription ended (or never started): subscribing goes through\nCheckout (`POST /v1/billing/checkout`), not a plan change."
          },
          "needs_new_subscription": {
            "type": "boolean",
            "description": "Paused and without a running subscription: pay on the restore page\n(`GET /v1/billing/reactivation`)."
          },
          "billing_configured": {
            "type": "boolean",
            "description": "Stripe is configured on the server."
          }
        }
      },
      "BlankCandidate": {
        "type": "object",
        "description": "A blank found in the PDF.",
        "required": [
          "id",
          "page",
          "x",
          "y",
          "width",
          "height",
          "before",
          "after",
          "previousLine"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int64",
            "description": "The browser's id for it (0 or more)."
          },
          "page": {
            "type": "integer",
            "format": "int64",
            "description": "Its page, from 1."
          },
          "x": {
            "type": "number",
            "format": "double",
            "description": "Position on the page (unused here; the editor keeps it)."
          },
          "y": {
            "type": "number",
            "format": "double",
            "description": "Position on the page."
          },
          "width": {
            "type": "number",
            "format": "double",
            "description": "Size on the page."
          },
          "height": {
            "type": "number",
            "format": "double",
            "description": "Size on the page."
          },
          "before": {
            "type": "string",
            "description": "Words right before it on its line (up to 200 characters)."
          },
          "after": {
            "type": "string",
            "description": "Words right after it on its line (up to 200 characters)."
          },
          "previousLine": {
            "type": "string",
            "description": "The line above (up to 300 characters)."
          }
        }
      },
      "BlockedAction": {
        "type": "string",
        "description": "What a blocked caller gets: `announce` (the announcement, then hang\nup), `hangup`, or `voicemail`.",
        "enum": [
          "Announce",
          "Hangup",
          "Voicemail"
        ]
      },
      "Board": {
        "type": "object",
        "description": "`GET /v1/sales-playbook/board`.",
        "required": [
          "group_id",
          "stages",
          "deals"
        ],
        "properties": {
          "group_id": {
            "type": "integer",
            "format": "int32",
            "description": "The pipeline shown."
          },
          "stages": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/BoardStage"
            },
            "description": "Its stages with their playbook."
          },
          "deals": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/BoardDeal"
            },
            "description": "The pipeline's open deals."
          }
        }
      },
      "BoardColumn": {
        "type": "object",
        "description": "A column of the board, in board order.",
        "required": [
          "stage_code",
          "name"
        ],
        "properties": {
          "id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "The company's own column; null for a stage's built-in column."
          },
          "stage_code": {
            "$ref": "#/components/schemas/Stage",
            "description": "The stage it is in."
          },
          "name": {
            "type": "string",
            "description": "Its title."
          },
          "default_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "A built-in column's usual title, when the company renamed it."
          }
        }
      },
      "BoardColumnInput": {
        "type": "object",
        "description": "A new column of the company's own.",
        "required": [
          "stage",
          "name"
        ],
        "properties": {
          "stage": {
            "$ref": "#/components/schemas/Stage",
            "description": "The stage it is in (it comes after that stage's column): not Paid & Completed."
          },
          "name": {
            "type": "string",
            "description": "Its title."
          },
          "after_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "The company column of that stage it goes right after; left out: right\nafter the stage's built-in column."
          }
        }
      },
      "BoardColumnName": {
        "type": "object",
        "description": "A column's new title.",
        "required": [
          "name"
        ],
        "properties": {
          "name": {
            "type": "string",
            "description": "Its title; for a built-in column, empty brings back its usual one."
          }
        }
      },
      "BoardDeal": {
        "type": "object",
        "description": "A deal card of the board.",
        "required": [
          "id",
          "list_id",
          "position",
          "outcome",
          "customer_id",
          "has_images",
          "has_emails",
          "has_notes",
          "open_activity_count"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int64",
            "description": "Deal id."
          },
          "title": {
            "type": [
              "string",
              "null"
            ],
            "description": "Short name of the job."
          },
          "amount": {
            "type": [
              "string",
              "null"
            ],
            "description": "Expected value in dollars, a decimal string (`\"2500.50\"`), or null."
          },
          "list_id": {
            "type": "integer",
            "format": "int32",
            "description": "Stage the deal is in."
          },
          "position": {
            "type": "integer",
            "format": "int32",
            "description": "Order inside the stage, ascending."
          },
          "status": {
            "type": [
              "string",
              "null"
            ],
            "description": "Stage name when the deal last moved (legacy label)."
          },
          "outcome": {
            "$ref": "#/components/schemas/DealStatus",
            "description": "`open`, `won` or `lost`."
          },
          "lost_reason": {
            "type": [
              "string",
              "null"
            ],
            "description": "Why a lost deal was lost."
          },
          "due_date": {
            "type": [
              "string",
              "null"
            ],
            "description": "Expected close date `YYYY-MM-DD`, or null."
          },
          "customer_id": {
            "type": "integer",
            "format": "int32",
            "description": "Customer id (also when the customer was deleted)."
          },
          "customer": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/DealCustomer",
                "description": "The customer; null when the customer was deleted."
              },
              {
                "type": "null"
              }
            ]
          },
          "has_images": {
            "type": "boolean",
            "description": "Photos were attached to the deal."
          },
          "has_emails": {
            "type": "boolean",
            "description": "Emails were exchanged on the deal or with its customer."
          },
          "has_notes": {
            "type": "boolean",
            "description": "The deal has notes."
          },
          "open_activity_count": {
            "type": "integer",
            "format": "int64",
            "description": "Unfinished activities."
          },
          "earliest_activity_deadline": {
            "type": [
              "string",
              "null"
            ],
            "description": "Earliest deadline among the unfinished activities (store wall time), or null."
          },
          "next_activity": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/NextActivity",
                "description": "The unfinished activity due first (activities without a deadline come last)."
              },
              {
                "type": "null"
              }
            ]
          },
          "sms_flow_phone": {
            "type": [
              "string",
              "null"
            ],
            "description": "Phone digits of an active or paused SMS follow-up flow for the customer."
          },
          "sales_rep": {
            "type": [
              "string",
              "null"
            ],
            "description": "Name of the sales rep who owns the deal."
          }
        }
      },
      "BoardStage": {
        "type": "object",
        "description": "A stage on the board.",
        "required": [
          "list_id",
          "next_touch_required",
          "sub_stages"
        ],
        "properties": {
          "list_id": {
            "type": "integer",
            "format": "int32",
            "description": "The stage (deal list) id."
          },
          "limit_days": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Days a deal may stay idle; null: no limit."
          },
          "next_touch_required": {
            "type": "boolean",
            "description": "True: a deal needs an open next touch to leave this stage."
          },
          "instructions": {
            "type": [
              "string",
              "null"
            ],
            "description": "What the sales rep does on this stage (plain text); null: none. A\nsub-stage with its own instructions shows those instead."
          },
          "sub_stages": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SubStage"
            },
            "description": "Its live sub-stages, in order."
          }
        }
      },
      "BookVisitInput": {
        "type": "object",
        "description": "`POST /v1/public/customer-view/{company_id}/{view_id}/visits`.",
        "required": [
          "kind",
          "start"
        ],
        "properties": {
          "kind": {
            "$ref": "#/components/schemas/VisitKind",
            "description": "The kind of visit."
          },
          "start": {
            "type": "string",
            "description": "The start the customer picked: one of the `times` of\n`GET .../visits/options` (ISO 8601, UTC, e.g. `2026-12-01T15:00:00Z`)."
          },
          "address": {
            "type": [
              "string",
              "null"
            ],
            "description": "Where an in-home estimate happens (default the customer's address on\nfile; required when there is none). Ignored for a showroom visit."
          },
          "notes": {
            "type": [
              "string",
              "null"
            ],
            "description": "Anything the customer wants the salesperson to know, up to 1000\ncharacters."
          },
          "salesperson_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "The salesperson to book with (`salespeople` of the options); they\nmust be free then. Omitted: anyone free then."
          }
        }
      },
      "BookedEstimate": {
        "type": "object",
        "description": "`POST /v1/events/estimates`.",
        "required": [
          "id"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int64",
            "description": "The new event (0 for the onboarding sample customer).",
            "minimum": 0
          },
          "notification_channel": {
            "type": [
              "string",
              "null"
            ],
            "description": "`sms` or `email`; null when the confirmation could not be sent."
          }
        }
      },
      "BookedVisit": {
        "type": "object",
        "description": "`POST /v1/public/customer-view/{company_id}/{view_id}/visits`.",
        "required": [
          "id",
          "kind",
          "start",
          "end",
          "salesperson"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "The new event on the Estimates calendar."
          },
          "kind": {
            "$ref": "#/components/schemas/VisitKind",
            "description": "The kind of visit."
          },
          "start": {
            "type": "string",
            "description": "When it starts, ISO 8601 UTC."
          },
          "end": {
            "type": "string",
            "description": "When it ends (an hour later), ISO 8601 UTC."
          },
          "location": {
            "type": [
              "string",
              "null"
            ],
            "description": "Where it happens: the customer's address for an estimate, the\nshowroom's for a showroom visit (null when unknown)."
          },
          "salesperson": {
            "type": "string",
            "description": "The salesperson it was given to."
          },
          "confirmation": {
            "type": [
              "string",
              "null"
            ],
            "description": "`email` or `sms`: how the confirmation went; null when it could not\nbe sent."
          },
          "emailed_to": {
            "type": [
              "string",
              "null"
            ],
            "description": "The address the confirmation was emailed to, when it was."
          }
        }
      },
      "BookingHours": {
        "type": "object",
        "description": "`GET /v1/schedule/booking-hours`.",
        "required": [
          "tz",
          "days",
          "is_default"
        ],
        "properties": {
          "tz": {
            "type": "string",
            "description": "IANA time zone of the hours."
          },
          "days": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/WorkingDay"
            },
            "description": "Open time ranges per weekday (0 = Sunday); empty: online booking is\noff."
          },
          "is_default": {
            "type": "boolean",
            "description": "No admin saved hours yet: these are the defaults (Monday to Friday\n9:00 to 18:00, Saturday 10:00 to 15:00)."
          }
        }
      },
      "BookingHoursInput": {
        "type": "object",
        "description": "`PUT /v1/schedule/booking-hours`: when customers can book visits online.",
        "required": [
          "tz"
        ],
        "properties": {
          "tz": {
            "type": "string",
            "description": "IANA time zone the hours are in, e.g. `America/Chicago`."
          },
          "days": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/WorkingDay"
            },
            "description": "The open time ranges, any number per weekday (at most 28 in all); a\nweekday without a range is closed. Empty: customers cannot book\nonline."
          }
        }
      },
      "Bootstrap": {
        "type": "object",
        "description": "`GET /v1/support/agent/bootstrap`.",
        "required": [
          "me",
          "agents",
          "categories",
          "statuses",
          "priorities",
          "posthog_project_url",
          "telegram_missing"
        ],
        "properties": {
          "me": {
            "$ref": "#/components/schemas/Agent",
            "description": "The signed-in team member."
          },
          "agents": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Agent"
            },
            "description": "The team: every superuser (for the inbox's \"Assigned to\" filter)."
          },
          "categories": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Choice"
            },
            "description": "Request types (`category`)."
          },
          "statuses": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Choice"
            },
            "description": "Statuses."
          },
          "priorities": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Choice"
            },
            "description": "Priorities, lowest first."
          },
          "posthog_project_url": {
            "type": "string",
            "description": "The PostHog project the CRM records to."
          },
          "telegram_missing": {
            "type": "boolean",
            "description": "The signed-in member gets support alerts (new requests or\nescalations) but linked no Telegram bot in the CRM, so they reach only\nthe Granite Manager app: the app asks them to connect Telegram."
          }
        }
      },
      "BugReport": {
        "type": "object",
        "description": "A report as super admins list it.",
        "required": [
          "id",
          "user_id",
          "company_id",
          "title",
          "description",
          "image_urls"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "Report id."
          },
          "user_id": {
            "type": "integer",
            "format": "int32",
            "description": "Reporter."
          },
          "company_id": {
            "type": "integer",
            "format": "int32",
            "description": "Reporter's company."
          },
          "title": {
            "type": "string",
            "description": "First line of the description."
          },
          "description": {
            "type": "string",
            "description": "What happened."
          },
          "created_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When it was filed."
          },
          "user_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "Reporter's name."
          },
          "user_email": {
            "type": [
              "string",
              "null"
            ],
            "description": "Reporter's email."
          },
          "company_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "Company name."
          },
          "image_urls": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Files attached."
          }
        }
      },
      "BuiltInTitles": {
        "type": "object",
        "description": "`GET|PUT /v1/quote-sale-built-in-titles`: how the company names the\ntemplate and installation events a sale adds.",
        "required": [
          "template",
          "installation"
        ],
        "properties": {
          "template": {
            "$ref": "#/components/schemas/SaleEventName",
            "description": "The template event (default: the quote's name alone)."
          },
          "installation": {
            "$ref": "#/components/schemas/SaleEventName",
            "description": "The installation event (default: the quote's name alone)."
          }
        },
        "additionalProperties": false
      },
      "BuyNumber": {
        "type": "object",
        "description": "Body of `POST /v1/phone/admin/numbers/buy`.",
        "required": [
          "e164"
        ],
        "properties": {
          "e164": {
            "type": "string",
            "description": "The number to buy, from `GET /v1/phone/admin/numbers/available`."
          }
        }
      },
      "BuyableNumber": {
        "type": "object",
        "description": "A number the company can buy.",
        "required": [
          "e164"
        ],
        "properties": {
          "e164": {
            "type": "string",
            "description": "E.164, like `+13175550101`."
          },
          "locality": {
            "type": [
              "string",
              "null"
            ],
            "description": "Its town, when Telnyx gives one."
          },
          "region": {
            "type": [
              "string",
              "null"
            ],
            "description": "Its state, like `IN`."
          },
          "monthlyCost": {
            "type": [
              "string",
              "null"
            ],
            "description": "Dollars a month (`\"1.00\"`), when Telnyx gives it."
          },
          "upfrontCost": {
            "type": [
              "string",
              "null"
            ],
            "description": "Dollars up front, when Telnyx gives it."
          }
        }
      },
      "BuyableNumbers": {
        "type": "object",
        "description": "Numbers for sale in an area code.",
        "required": [
          "numbers"
        ],
        "properties": {
          "numbers": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/BuyableNumber"
            },
            "description": "At most 12, in Telnyx's order."
          }
        }
      },
      "CadenceChannel": {
        "type": "string",
        "description": "SMS or email.",
        "enum": [
          "sms",
          "email"
        ]
      },
      "CadenceError": {
        "type": "object",
        "description": "Why nothing was written.",
        "required": [
          "error"
        ],
        "properties": {
          "error": {
            "type": "string",
            "description": "`nothing_to_send` (blocked), `customer_not_found`, `missing_target`,\n`invalid_phone`, `missing_email`, `generate_failed`, ..."
          },
          "reason_code": {
            "type": [
              "string",
              "null"
            ],
            "description": "The block's reason (e.g. `CUSTOMER_WILL_RECONTACT`)."
          },
          "reason_message": {
            "type": [
              "string",
              "null"
            ],
            "description": "The block explained for the rep."
          },
          "can_force_generate": {
            "type": [
              "boolean",
              "null"
            ],
            "description": "\"Generate anyway\" may override the block."
          }
        }
      },
      "Calendar": {
        "type": "object",
        "description": "A calendar its appointments go on.",
        "required": [
          "id",
          "slug",
          "name"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "Its id."
          },
          "slug": {
            "type": "string",
            "description": "`templates` or `installations`."
          },
          "name": {
            "type": "string",
            "description": "Its name."
          }
        }
      },
      "CalendarHidden": {
        "type": "object",
        "description": "Body of `PUT /v1/calendars/{id}/hidden`.",
        "required": [
          "hidden"
        ],
        "properties": {
          "hidden": {
            "type": "boolean",
            "description": "Hidden from everyone's schedule."
          }
        }
      },
      "CalendarInput": {
        "type": "object",
        "description": "Body of `POST /v1/calendars` and `PUT /v1/calendars/{id}`.",
        "required": [
          "name"
        ],
        "properties": {
          "name": {
            "type": "string",
            "description": "1 to 100 characters; ignored for built-in calendars."
          },
          "color": {
            "type": [
              "string",
              "null"
            ],
            "description": "Color name, e.g. `blue` (the default)."
          },
          "hidden": {
            "type": "boolean",
            "description": "Hidden from everyone's schedule (create only)."
          }
        }
      },
      "CalendlyUrl": {
        "type": "object",
        "description": "`GET /v1/public/calendly-url`.",
        "properties": {
          "url": {
            "type": [
              "string",
              "null"
            ],
            "description": "The demo booking page."
          }
        }
      },
      "CallActivities": {
        "type": "object",
        "description": "`POST /v1/ai/call-activities`.",
        "required": [
          "activities"
        ],
        "properties": {
          "activities": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CallActivity"
            },
            "description": "Activities to add to the deal."
          }
        }
      },
      "CallActivitiesInput": {
        "type": "object",
        "description": "Body of `POST /v1/ai/call-activities`.",
        "required": [
          "transcript"
        ],
        "properties": {
          "transcript": {
            "type": "string",
            "description": "The call's transcript."
          },
          "call_started_at": {
            "type": [
              "string",
              "null"
            ],
            "description": "When the call started (ISO 8601); relative deadlines count from it."
          },
          "committed_at": {
            "type": [
              "string",
              "null"
            ],
            "description": "When the activities are being created (ISO 8601); now when absent."
          },
          "is_voicemail": {
            "type": "boolean",
            "description": "The provider said it was a voicemail."
          }
        }
      },
      "CallActivity": {
        "type": "object",
        "description": "One call, as a row of the users-activity feed.",
        "required": [
          "id",
          "call_id",
          "source",
          "user_id",
          "user_name",
          "action",
          "created_at",
          "summary",
          "tags",
          "recorded",
          "is_voicemail",
          "talk_seconds"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int64",
            "description": "The `CloudTalk` call id, or our call id for a Granite Manager call; 0\nfor `RingCentral`, whose ids are not numbers."
          },
          "call_id": {
            "type": "string",
            "description": "The provider's call id as text."
          },
          "source": {
            "type": "string",
            "description": "`cloudtalk_call`, `ringcentral_call`, or `telnyx_call` for a Granite\nPhone call."
          },
          "user_id": {
            "type": "integer",
            "format": "int32",
            "description": "The rep (for a Granite Manager call nobody answered: the owner of the\ndirect line it rang)."
          },
          "user_name": {
            "type": "string",
            "description": "The rep's name."
          },
          "action": {
            "type": "string",
            "description": "`Made a call`, `Received a call` or `Missed a call`."
          },
          "created_at": {
            "type": "string",
            "description": "When the call started, as `CloudTalk` reports it (RFC 3339 for a\n`RingCentral` or Granite Manager call)."
          },
          "customer_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "The `CloudTalk` contact's name, for `RingCentral` the customer with\nthat number (else the caller-ID name), or the CRM customer of a\nGranite Manager call."
          },
          "customer_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int64",
            "description": "The customer with that number (`RingCentral`), or the CRM customer of\na Granite Manager call."
          },
          "contact": {
            "type": [
              "string",
              "null"
            ],
            "description": "The other party's number."
          },
          "summary": {
            "type": "string",
            "description": "Direction and outcome, like `Incoming · 2m 5s`."
          },
          "body": {
            "type": [
              "string",
              "null"
            ],
            "description": "The call's notes, one per line (a Granite Manager call's AI note)."
          },
          "tags": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Direction, outcome, `Recorded`, then `CloudTalk` tags (a Granite Manager\ncall: the label of our number)."
          },
          "recorded": {
            "type": "boolean",
            "description": "Whether there is a recording."
          },
          "recording_link": {
            "type": [
              "string",
              "null"
            ],
            "description": "`CloudTalk`'s recording link, a `RingCentral` media token (`rec_<id>`),\nor `tx_<id>` for a recorded Granite Manager call\n(`GET /v1/calls/telnyx/{media_id}/recording`)."
          },
          "is_voicemail": {
            "type": "boolean",
            "description": "The caller left a voicemail."
          },
          "talk_seconds": {
            "type": "integer",
            "format": "int64",
            "description": "Seconds talked; 0 when unanswered."
          }
        }
      },
      "CallBlocking": {
        "type": "object",
        "description": "The company's blocking, as the app shows and saves it.",
        "required": [
          "spamAction",
          "blockedAction",
          "announcement",
          "defaultAnnouncement",
          "blockNoCallerId",
          "blocked",
          "trusted"
        ],
        "properties": {
          "spamAction": {
            "$ref": "#/components/schemas/SpamAction",
            "description": "What happens to likely spam: `ring`, `block` or `voicemail`."
          },
          "blockedAction": {
            "$ref": "#/components/schemas/BlockedAction",
            "description": "What blocked callers get: `announce`, `hangup` or `voicemail`."
          },
          "announcement": {
            "type": "string",
            "description": "What they hear with `announce` (the default when none was saved)."
          },
          "defaultAnnouncement": {
            "type": "boolean",
            "description": "The announcement is the default one."
          },
          "blockNoCallerId": {
            "type": "boolean",
            "description": "Calls that hide their number are blocked."
          },
          "blocked": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Blocked numbers (E.164) and 3-digit area codes, sorted."
          },
          "trusted": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Trusted numbers (E.164, never blocked), sorted."
          }
        }
      },
      "CallBlockingInput": {
        "type": "object",
        "description": "Body of `PUT /v1/phone/call-blocking`: the whole setting (the screen's\nSAVE).",
        "required": [
          "spamAction",
          "blockedAction"
        ],
        "properties": {
          "spamAction": {
            "$ref": "#/components/schemas/SpamAction",
            "description": "What happens to likely spam: `ring` (allow to ring), `block` (the\naction for blocked calls) or `voicemail`."
          },
          "blockedAction": {
            "$ref": "#/components/schemas/BlockedAction",
            "description": "What blocked callers get: `announce` (the announcement, then hang\nup), `hangup` or `voicemail`."
          },
          "announcement": {
            "type": [
              "string",
              "null"
            ],
            "description": "What blocked callers hear with `announce`, at most 500 characters;\nnull, empty or the default text = the default announcement."
          },
          "blockNoCallerId": {
            "type": "boolean",
            "description": "Block calls that hide their number."
          },
          "blocked": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Blocked numbers (any US or Canada format, or E.164) and 3-digit US\nor Canada area codes; at most 1000; duplicates are dropped."
          },
          "trusted": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Trusted numbers, never blocked (numbers only); at most 1000."
          }
        }
      },
      "CallCheck": {
        "type": "object",
        "description": "A finished outbound call.",
        "required": [
          "company_id",
          "phone_digits",
          "call_id",
          "talking_time"
        ],
        "properties": {
          "company_id": {
            "type": "integer",
            "format": "int32",
            "description": "The rep's company."
          },
          "phone_digits": {
            "$ref": "#/components/schemas/PhoneDigits",
            "description": "The customer's phone."
          },
          "call_id": {
            "$ref": "#/components/schemas/CallId",
            "description": "The provider's call id: a number, or a Granite Manager call `tx_<id>`\n(whose kept transcript is checked)."
          },
          "talking_time": {
            "type": "integer",
            "format": "int64",
            "description": "Seconds of talk."
          },
          "is_voicemail": {
            "type": "boolean",
            "description": "The provider says the call reached voicemail."
          },
          "recording_link": {
            "type": [
              "string",
              "null"
            ],
            "description": "Where the provider keeps the recording."
          }
        }
      },
      "CallCheckResult": {
        "type": "object",
        "description": "What the check found.",
        "required": [
          "skipped",
          "reason",
          "cancelled",
          "customer_responded"
        ],
        "properties": {
          "skipped": {
            "type": "boolean",
            "description": "No conversation was found (`talking_time_too_short`,\n`transcription_unavailable`, `voicemail`)."
          },
          "reason": {
            "type": "string",
            "description": "Why: one of the above, `long_call` or `customer_conversation`."
          },
          "cancelled": {
            "type": "integer",
            "format": "int64",
            "description": "Flow runs stopped.",
            "minimum": 0
          },
          "customer_responded": {
            "type": "boolean",
            "description": "The customer talked: the deal moves to Contacted."
          },
          "transcript_preview": {
            "type": [
              "string",
              "null"
            ],
            "description": "The start of the transcript, when one was made."
          }
        }
      },
      "CallCustomer": {
        "type": "object",
        "description": "The customer of a call.",
        "required": [
          "id",
          "name"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "Customer id."
          },
          "name": {
            "type": "string",
            "description": "Name; empty when the customer has none."
          },
          "company": {
            "type": [
              "string",
              "null"
            ],
            "description": "Company name; null when empty."
          }
        }
      },
      "CallDirection": {
        "type": "string",
        "description": "`inbound` (to the company) or `outbound` (from it).",
        "enum": [
          "Inbound",
          "Outbound"
        ]
      },
      "CallHistoryRun": {
        "type": "object",
        "description": "What a run did.",
        "required": [
          "processed"
        ],
        "properties": {
          "processed": {
            "type": "integer",
            "description": "Calls saved or refreshed.",
            "minimum": 0
          }
        }
      },
      "CallId": {
        "oneOf": [
          {
            "type": "integer",
            "format": "int64"
          },
          {
            "type": "string"
          }
        ],
        "description": "A provider's call id: `CloudTalk`'s or `RingCentral`'s number, or a\nGranite Manager call `tx_<id>`."
      },
      "CallInput": {
        "type": "object",
        "description": "Body of `POST /v1/events/{id}/confirmation-call`.",
        "required": [
          "template_id"
        ],
        "properties": {
          "template_id": {
            "type": "integer",
            "format": "int32",
            "description": "An auto-confirm text of the company."
          },
          "text": {
            "type": [
              "string",
              "null"
            ],
            "description": "The text as edited before calling. Left out, the template goes as it\nis."
          }
        }
      },
      "CallList": {
        "type": "object",
        "description": "A page of Recents.",
        "required": [
          "calls"
        ],
        "properties": {
          "calls": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CallRow"
            },
            "description": "Calls, newest first."
          },
          "nextBefore": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int64",
            "description": "Pass as `?before=` for the next page; null on the last page."
          }
        }
      },
      "CallNote": {
        "type": "object",
        "description": "`POST /v1/ai/call-note`.",
        "required": [
          "content"
        ],
        "properties": {
          "content": {
            "type": "string",
            "description": "\"- **Label:** details\" bullets."
          }
        }
      },
      "CallNoteCreated": {
        "type": "object",
        "description": "`POST /v1/phone/calls/{id}/note`.",
        "required": [
          "noteId"
        ],
        "properties": {
          "noteId": {
            "type": "integer",
            "format": "int64",
            "description": "The new deal note."
          }
        }
      },
      "CallNoteInput": {
        "type": "object",
        "description": "Body of `POST /v1/ai/call-note`.",
        "required": [
          "transcript"
        ],
        "properties": {
          "transcript": {
            "type": "string",
            "description": "The call's transcript."
          },
          "voicemail": {
            "type": "boolean",
            "description": "It was a voicemail (a shorter note)."
          }
        }
      },
      "CallPlaced": {
        "type": "object",
        "description": "`POST /v1/events/{id}/confirmation-call`.",
        "required": [
          "phone"
        ],
        "properties": {
          "phone": {
            "type": "string",
            "description": "The 10 digits being called."
          }
        }
      },
      "CallPointsRun": {
        "type": "object",
        "description": "What a run did.",
        "required": [
          "processed",
          "classified"
        ],
        "properties": {
          "processed": {
            "type": "integer",
            "description": "Calls written or refreshed.",
            "minimum": 0
          },
          "classified": {
            "type": "integer",
            "description": "Calls classified from a transcript.",
            "minimum": 0
          }
        }
      },
      "CallRecording": {
        "type": "object",
        "description": "Where to load a call's audio.",
        "required": [
          "url",
          "content_type"
        ],
        "properties": {
          "url": {
            "type": "string",
            "description": "A link to the audio, valid an hour (5 minutes for a Granite Manager\nrecording: ask again when it runs out)."
          },
          "content_type": {
            "type": "string",
            "description": "Its type, e.g. `audio/mpeg` or `audio/wav`."
          }
        }
      },
      "CallReplyInput": {
        "type": "object",
        "description": "Body of `POST /v1/phone/calls/reply`.",
        "required": [
          "telnyxCallId",
          "text"
        ],
        "properties": {
          "telnyxCallId": {
            "type": "string",
            "description": "The call id of Telnyx's incoming-call push (as for\n`POST /v1/phone/calls/decline`)."
          },
          "text": {
            "type": "string",
            "description": "The text to send the caller, up to 1600 characters (\"I'll call you\nback.\")."
          }
        }
      },
      "CallRow": {
        "type": "object",
        "description": "One call, as Recents and the call details show it.",
        "required": [
          "id",
          "direction",
          "status",
          "startedAt",
          "otherNumber",
          "hasRecording",
          "transcriptStatus",
          "seen",
          "spamLikely",
          "viaCell"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int64",
            "description": "Our call id."
          },
          "direction": {
            "$ref": "#/components/schemas/CallDirection",
            "description": "`inbound` or `outbound`."
          },
          "status": {
            "$ref": "#/components/schemas/CallStatus",
            "description": "`ringing`, `in_progress`, `answered`, `missed`, `declined`,\n`voicemail`, `ai_message`, `busy`, `no_answer`, `failed` or\n`canceled`."
          },
          "startedAt": {
            "type": "string",
            "format": "date-time",
            "description": "When it started (RFC 3339)."
          },
          "answeredAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When it was answered; null when never."
          },
          "endedAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When it ended; null while live."
          },
          "durationSecs": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Talk time in seconds, from answer to hang-up; null when never\nanswered or still live."
          },
          "otherNumber": {
            "type": "string",
            "description": "The customer's (or other party's) number, E.164."
          },
          "customer": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/CallCustomer",
                "description": "The customer the number belongs to; null when unknown."
              },
              {
                "type": "null"
              }
            ]
          },
          "dealId": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int64",
            "description": "The deal the call belongs to; null when none."
          },
          "ourNumber": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/OurNumber",
                "description": "The company number called or calling; null when unknown."
              },
              {
                "type": "null"
              }
            ]
          },
          "userId": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Who placed or answered it; null when nobody did."
          },
          "userName": {
            "type": [
              "string",
              "null"
            ],
            "description": "That user's name; null when nobody or no name."
          },
          "hasRecording": {
            "type": "boolean",
            "description": "A recording can be played (`GET /v1/phone/calls/{id}/recording`):\nfalse also when the caller may not hear the call (only its user, the\nusers of its direct line, for an unanswered incoming call the users\nits line rings, its deal's owner, admins and sales managers may)."
          },
          "transcriptStatus": {
            "$ref": "#/components/schemas/TranscriptStatus",
            "description": "The AI note's progress."
          },
          "aiNote": {
            "type": [
              "string",
              "null"
            ],
            "description": "The AI note; null until it is written, and for a caller who may not\nhear the call (see `hasRecording`)."
          },
          "seen": {
            "type": "boolean",
            "description": "The caller has seen it (calls they placed or answered always are)."
          },
          "spamLikely": {
            "type": "boolean",
            "description": "The carrier flagged the caller as possible spam."
          },
          "viaCell": {
            "type": "boolean",
            "description": "Placed with \"Call via my cell\"."
          }
        }
      },
      "CallRule": {
        "type": "object",
        "description": "A custom incoming call rule.",
        "required": [
          "id",
          "name",
          "enabled",
          "action"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int64",
            "description": "The rule's id."
          },
          "name": {
            "type": "string",
            "description": "Its name, e.g. \"After hours\"."
          },
          "enabled": {
            "type": "boolean",
            "description": "The rule's switch: off rules are kept but never match."
          },
          "callers": {
            "type": [
              "array",
              "null"
            ],
            "items": {
              "$ref": "#/components/schemas/RuleCaller"
            },
            "description": "The callers it is for; null = any caller."
          },
          "schedule": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/WorkingHours",
                "description": "When it applies, as weekly local time ranges; null = any time."
              },
              {
                "type": "null"
              }
            ]
          },
          "numberIds": {
            "type": [
              "array",
              "null"
            ],
            "items": {
              "type": "integer",
              "format": "int32"
            },
            "description": "Which of my numbers was called (`numberId`s of my caller IDs and the\nlines that ring me); null = any of them."
          },
          "action": {
            "$ref": "#/components/schemas/RuleAction",
            "description": "What it does."
          },
          "forwardTo": {
            "type": [
              "string",
              "null"
            ],
            "description": "With `forward`: where to, E.164; else null."
          },
          "message": {
            "type": [
              "string",
              "null"
            ],
            "description": "With `message`: what the caller hears before the call ends; else\nnull."
          }
        }
      },
      "CallRules": {
        "type": "object",
        "description": "`GET /v1/phone/call-rules`.",
        "required": [
          "rules"
        ],
        "properties": {
          "rules": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CallRule"
            },
            "description": "My rules, in the order they are tried (the first that matches an\nincoming call decides)."
          }
        }
      },
      "CallSmsPointsRow": {
        "type": "object",
        "description": "A user's calls and hand-sent texts in a window.",
        "required": [
          "user_id",
          "name",
          "conversations",
          "voicemails",
          "attempts",
          "sms",
          "points"
        ],
        "properties": {
          "user_id": {
            "type": "integer",
            "format": "int32",
            "description": "The user."
          },
          "name": {
            "type": "string",
            "description": "Their name, else their email, else \"Colleague\"."
          },
          "conversations": {
            "type": "integer",
            "format": "int64",
            "description": "Real conversations."
          },
          "voicemails": {
            "type": "integer",
            "format": "int64",
            "description": "Voicemails left (capped per number and day)."
          },
          "attempts": {
            "type": "integer",
            "format": "int64",
            "description": "Unanswered attempts (capped per number and day)."
          },
          "sms": {
            "type": "integer",
            "format": "int64",
            "description": "Hand-sent texts (capped per number and day)."
          },
          "points": {
            "type": "integer",
            "format": "int64",
            "description": "Call and text points."
          }
        }
      },
      "CallStarted": {
        "type": "object",
        "description": "A call our server started.",
        "required": [
          "callId"
        ],
        "properties": {
          "callId": {
            "type": "integer",
            "format": "int64",
            "description": "Our call id (`GET /v1/phone/calls/{id}`)."
          }
        }
      },
      "CallStats": {
        "type": "object",
        "description": "`GET /v1/phone/calls/stats`: my answered calls.",
        "required": [
          "todaySecs",
          "weekSecs",
          "monthSecs",
          "todayCount",
          "weekCount",
          "monthCount"
        ],
        "properties": {
          "todaySecs": {
            "type": "integer",
            "format": "int64",
            "description": "Talk time today, in seconds."
          },
          "weekSecs": {
            "type": "integer",
            "format": "int64",
            "description": "Talk time this week (from Monday), in seconds."
          },
          "monthSecs": {
            "type": "integer",
            "format": "int64",
            "description": "Talk time this month, in seconds."
          },
          "todayCount": {
            "type": "integer",
            "format": "int64",
            "description": "Answered calls today."
          },
          "weekCount": {
            "type": "integer",
            "format": "int64",
            "description": "Answered calls this week."
          },
          "monthCount": {
            "type": "integer",
            "format": "int64",
            "description": "Answered calls this month."
          }
        }
      },
      "CallStatus": {
        "type": "string",
        "description": "Where a call stands.\n\n`ringing` and `in_progress` while live; then `answered`, `missed`\n(nobody answered), `declined`, `voicemail` or `ai_message` (the caller\nleft one), `busy`, `no_answer`, `failed` or `canceled` (the caller hung\nup first).",
        "enum": [
          "Ringing",
          "InProgress",
          "Answered",
          "Missed",
          "Declined",
          "Voicemail",
          "AiMessage",
          "Busy",
          "NoAnswer",
          "Failed",
          "Canceled"
        ]
      },
      "CallTranscript": {
        "type": "object",
        "description": "A call's transcript.",
        "required": [
          "text"
        ],
        "properties": {
          "text": {
            "type": "string",
            "description": "What was said."
          }
        }
      },
      "CallbackApplied": {
        "type": "object",
        "description": "What a callback did.",
        "required": [
          "changed"
        ],
        "properties": {
          "changed": {
            "type": "boolean",
            "description": "True when this call moved the run; false when the same report had\nalready been recorded (a retry), which is also a success."
          }
        }
      },
      "CallerId": {
        "type": "object",
        "description": "A company number the user may call from.",
        "required": [
          "numberId",
          "e164",
          "label",
          "kind"
        ],
        "properties": {
          "numberId": {
            "type": "integer",
            "format": "int32",
            "description": "The number (`telnyx_numbers.id`): send it as `callerNumberId`."
          },
          "e164": {
            "type": "string",
            "description": "The number, E.164 (`+13175550101`)."
          },
          "label": {
            "type": "string",
            "description": "Its label, e.g. \"Main line\"; may be empty."
          },
          "kind": {
            "$ref": "#/components/schemas/NumberKind",
            "description": "`direct`, `shared` or `main`."
          }
        }
      },
      "CallerIds": {
        "type": "object",
        "description": "`GET /v1/phone/caller-ids`.",
        "required": [
          "callerIds"
        ],
        "properties": {
          "callerIds": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CallerId"
            },
            "description": "The numbers the user may call from: their direct lines first, then\nshared lines, then the main line."
          },
          "defaultNumberId": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "The one to preselect: the user's chosen default while it is still\ntheirs, else their first direct line, else the first one; null when\nthey may call from none."
          }
        }
      },
      "Calls": {
        "type": "object",
        "description": "`GET /v1/calls/{provider}`.",
        "required": [
          "items"
        ],
        "properties": {
          "items": {
            "type": "array",
            "items": {},
            "description": "Calls in the `CloudTalk` shape (`Cdr`, `Contact`, `Agent`, …). A\n`telnyx` call's `Cdr.id` and `Cdr.recording_link` are `tx_<call id>`\n(for `POST /v1/call-transcripts` and the recording route; the link\nis empty when not recorded), times are RFC 3339 UTC, `Agent` is the\nuser who placed or answered it, `CallNumber.internal_name` our\nnumber's label, and a `Telnyx` part adds `call_id`, `status`\n(`answered`, `missed`, `voicemail`, `ai_message`, `declined`,\n`busy`, `no_answer`, `failed`, `canceled`), `line_label`,\n`our_number`, `customer_id`, `deal_id`, `transcript_status`,\n`ai_note` (null until written), `note_added` (the AI note is on the\ndeal), `via_cell`, `spam_likely` and `may_hear`: false when the\ncaller may not hear the call (only its user, the users of its direct\nline, for an unanswered incoming call the users its line rings, its\ndeal's owner, admins and sales managers may), and then `recorded` is\nfalse, `recording_link` empty and `ai_note` null. A `CloudTalk` or\n`RingCentral` call has `provider`: the one that carried it."
          }
        }
      },
      "Campaign": {
        "type": "object",
        "description": "A marketing campaign's customers.",
        "required": [
          "customers_acquired",
          "closed_deals",
          "won_deals"
        ],
        "properties": {
          "compaign_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "The campaign (`customers.compaign_name`)."
          },
          "customers_acquired": {
            "type": "integer",
            "format": "int64",
            "description": "Customers it brought."
          },
          "closed_deals": {
            "type": "integer",
            "format": "int64",
            "description": "Won and lost deals."
          },
          "won_deals": {
            "type": "integer",
            "format": "int64",
            "description": "Won deals."
          },
          "conversion_percent": {
            "type": [
              "number",
              "null"
            ],
            "format": "double",
            "description": "Won out of closed, in percent; null with no closed deals."
          }
        }
      },
      "CancelInput": {
        "type": "object",
        "description": "Body of `POST /v1/signature-requests/{id}/cancel`.",
        "properties": {
          "notify_customer": {
            "type": "boolean",
            "description": "Email the signer that the request was cancelled (default false)."
          }
        },
        "additionalProperties": false
      },
      "Cancelled": {
        "type": "object",
        "description": "A cancelled request, when the customer was to be told.",
        "required": [
          "customer_notified"
        ],
        "properties": {
          "customer_notified": {
            "type": "boolean",
            "description": "False when the email to the customer could not be sent."
          }
        }
      },
      "Card": {
        "type": "object",
        "description": "A saved card.",
        "required": [
          "id",
          "brand",
          "last4",
          "exp_month",
          "exp_year"
        ],
        "properties": {
          "id": {
            "type": "string",
            "description": "Stripe payment method id (`pm_...`)."
          },
          "brand": {
            "type": "string",
            "description": "`visa`, `mastercard`, ..."
          },
          "last4": {
            "type": "string",
            "description": "Last four digits of the card number."
          },
          "exp_month": {
            "type": "integer",
            "format": "int64",
            "description": "Expiry month (1-12)."
          },
          "exp_year": {
            "type": "integer",
            "format": "int64",
            "description": "Expiry year (e.g. 2030)."
          }
        }
      },
      "CardContact": {
        "allOf": [
          {
            "$ref": "#/components/schemas/IndexContact"
          },
          {
            "type": "object",
            "properties": {
              "email": {
                "type": [
                  "string",
                  "null"
                ],
                "description": "The primary email (else the oldest one); null when none."
              },
              "repName": {
                "type": [
                  "string",
                  "null"
                ],
                "description": "The sales rep's name; null when unassigned."
              },
              "address": {
                "type": [
                  "string",
                  "null"
                ],
                "description": "Street, city, state and ZIP on one line; null when none."
              }
            }
          }
        ],
        "description": "The contact card's customer: the index fields and more."
      },
      "CardDeal": {
        "type": "object",
        "description": "A deal on the contact card.",
        "required": [
          "id",
          "stage",
          "status"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int64",
            "description": "The deal."
          },
          "stage": {
            "type": "string",
            "description": "Its stage."
          },
          "status": {
            "$ref": "#/components/schemas/DealStatus",
            "description": "`open`, `won` or `lost`."
          },
          "amount": {
            "type": [
              "string",
              "null"
            ],
            "description": "Its amount, as a decimal string (`\"1500.25\"`); null when not set."
          },
          "lastNote": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/CardNote",
                "description": "Its newest note; null when it has none."
              },
              {
                "type": "null"
              }
            ]
          }
        }
      },
      "CardNote": {
        "type": "object",
        "description": "A deal's newest note.",
        "required": [
          "content",
          "createdAt"
        ],
        "properties": {
          "content": {
            "type": "string",
            "description": "The note."
          },
          "createdAt": {
            "type": "string",
            "format": "date-time",
            "description": "When it was written."
          },
          "createdBy": {
            "type": [
              "string",
              "null"
            ],
            "description": "Who wrote it (a name); null when unknown."
          }
        }
      },
      "CatalogExtra": {
        "type": "object",
        "description": "A catalog extra.",
        "required": [
          "id",
          "item"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int64",
            "description": "Extra id."
          },
          "item": {
            "type": "object",
            "description": "The extra (`OtherItem`: name, category, options or per-unit tiers)."
          }
        }
      },
      "CatchUpReport": {
        "type": "object",
        "description": "What a catch-up call read, and what is left for the next call.",
        "required": [
          "done",
          "remaining"
        ],
        "properties": {
          "done": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ExtensionReport"
            },
            "description": "The extensions read in this call."
          },
          "remaining": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Extensions for a next call: all of them when none were sent, else\nthe ones this call had no time for."
          }
        }
      },
      "CatchUpRequest": {
        "type": "object",
        "description": "Body of the `RingCentral` texts catch-up: the window and the extensions to read.",
        "required": [
          "since"
        ],
        "properties": {
          "since": {
            "type": "string",
            "description": "Start of the window, RFC 3339 (`2026-11-07T00:15:00Z`), at most 30\ndays back."
          },
          "until": {
            "type": [
              "string",
              "null"
            ],
            "description": "End of the window, RFC 3339; now when left out."
          },
          "extensions": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "The extensions to read. Left out or empty, nothing is read and\n`remaining` lists every extension of the company: its enabled users,\nthen each rep's own sign-in."
          }
        }
      },
      "CellConfirm": {
        "type": "object",
        "description": "Body of `POST /v1/phone/cell/confirm`.",
        "required": [
          "code"
        ],
        "properties": {
          "code": {
            "type": "string",
            "description": "The 6-digit code our call read out."
          }
        }
      },
      "CellVerify": {
        "type": "object",
        "description": "Body of `POST /v1/phone/cell/verify`.",
        "required": [
          "cellNumber"
        ],
        "properties": {
          "cellNumber": {
            "type": "string",
            "description": "My cell number, US or Canada (E.164 or 10 digits)."
          }
        }
      },
      "ChangePayment": {
        "type": "object",
        "description": "Body of `PATCH /v1/payments/{payment_id}`.",
        "required": [
          "amount_cents"
        ],
        "properties": {
          "amount_cents": {
            "type": "integer",
            "format": "int64",
            "description": "What goes toward the job from now on, in US cents (see `POST\n/v1/customers/{id}/payments`)."
          }
        },
        "additionalProperties": false
      },
      "Channel": {
        "type": "string",
        "description": "How a template reaches the customer.",
        "enum": [
          "sms",
          "email"
        ]
      },
      "ChatInput": {
        "type": "object",
        "description": "Body of `POST /v1/ai/chat`.",
        "required": [
          "query"
        ],
        "properties": {
          "query": {
            "type": "string",
            "description": "The question."
          },
          "mode": {
            "type": [
              "string",
              "null"
            ],
            "description": "`instructions` (default), `priceLists` or `assistant`. A question\nabout the company's records goes to the assistant anyway. The\nassistant reads customers, deals and notes: employees only (403 for\nothers, whose record questions are answered from the instructions)."
          },
          "isNew": {
            "type": "boolean",
            "description": "The first question of a conversation."
          },
          "specialOrder": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/SpecialOrderInput",
                "description": "The special order the slabs and delivery in the question are for."
              },
              {
                "type": "null"
              }
            ]
          },
          "images": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Pictures added to the question, as `data:image/…` URLs (at most\n[`MAX_IMAGES`])."
          },
          "page": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/PageInput",
                "description": "The page the user is on, with its text: the server decides whether\nthe model reads it (`chat::page`)."
              },
              {
                "type": "null"
              }
            ]
          }
        },
        "additionalProperties": false
      },
      "ChatList": {
        "type": "object",
        "description": "`GET /v1/projects/{id}/questions` and `GET /v1/events/{id}/chats`: a\nproject's chats with the people to pick from, for someone who may not\nopen the whole project (an installer or template maker on its jobs).",
        "required": [
          "user_id",
          "people",
          "involved",
          "questions"
        ],
        "properties": {
          "project_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "The project; null when the job is on no project the caller may use."
          },
          "project_title": {
            "type": [
              "string",
              "null"
            ],
            "description": "Its name."
          },
          "user_id": {
            "type": "integer",
            "format": "int32",
            "description": "The caller."
          },
          "people": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Person"
            },
            "description": "The company's people to pick from."
          },
          "involved": {
            "type": "array",
            "items": {
              "type": "integer",
              "format": "int32"
            },
            "description": "The people involved in the project (shown first)."
          },
          "questions": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/QuestionSummary"
            },
            "description": "Its chats, the caller's first."
          }
        }
      },
      "ChatRole": {
        "type": "string",
        "description": "Who wrote a message of the conversation.",
        "enum": [
          "user",
          "assistant"
        ]
      },
      "ChatTurn": {
        "type": "object",
        "description": "One turn of the chat.",
        "required": [
          "role",
          "content"
        ],
        "properties": {
          "role": {
            "type": "string",
            "description": "`user` (the rep) or `assistant` (an earlier answer)."
          },
          "content": {
            "type": "string",
            "description": "What the rep wrote, or the AI's answer to the rep."
          },
          "draft": {
            "type": [
              "string",
              "null"
            ],
            "description": "The AI's message for the customer in that answer (assistant turns)."
          },
          "images": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Pictures the rep added to that turn, as `data:image/…` URLs."
          }
        },
        "additionalProperties": false
      },
      "Check": {
        "type": "object",
        "description": "A check of a piece of equipment; its usage fields override the equipment's.",
        "required": [
          "id",
          "maintenance_item_id",
          "name"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "Check id."
          },
          "maintenance_item_id": {
            "type": "integer",
            "format": "int32",
            "description": "Its equipment."
          },
          "name": {
            "type": "string",
            "description": "Name."
          },
          "notes": {
            "type": [
              "string",
              "null"
            ],
            "description": "Notes."
          },
          "last_completed_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "Last done."
          },
          "hours_per_day": {
            "type": [
              "number",
              "null"
            ],
            "format": "double",
            "description": "Own usage per working day; null uses the equipment's."
          },
          "days_per_month": {
            "type": [
              "number",
              "null"
            ],
            "format": "double",
            "description": "Own working days per month."
          },
          "starting_hours": {
            "type": [
              "number",
              "null"
            ],
            "format": "double",
            "description": "Own meter reading."
          },
          "usage_unit": {
            "type": [
              "string",
              "null"
            ],
            "description": "Own unit; null uses the equipment's."
          }
        }
      },
      "CheckInput": {
        "type": "object",
        "description": "Body of creating or saving a check.",
        "required": [
          "maintenance_item_id",
          "name",
          "conditions"
        ],
        "properties": {
          "maintenance_item_id": {
            "type": "integer",
            "format": "int32",
            "description": "Its equipment (creating only; ignored when saving)."
          },
          "name": {
            "type": "string",
            "description": "Name; 1 to 255 characters."
          },
          "notes": {
            "type": [
              "string",
              "null"
            ],
            "description": "Notes; at most 5000 characters."
          },
          "hours_per_day": {
            "type": [
              "number",
              "null"
            ],
            "format": "double",
            "description": "Own usage per working day; null uses the equipment's."
          },
          "days_per_month": {
            "type": [
              "number",
              "null"
            ],
            "format": "double",
            "description": "Own working days per month."
          },
          "starting_hours": {
            "type": [
              "number",
              "null"
            ],
            "format": "double",
            "description": "Own meter reading."
          },
          "usage_unit": {
            "type": [
              "string",
              "null"
            ],
            "description": "Own unit, `hours` (default) or `miles`."
          },
          "conditions": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ConditionInput"
            },
            "description": "At least one; at most one `hours` and one `days`. Saving replaces\nthe conditions (their counts start over)."
          }
        },
        "additionalProperties": false
      },
      "Checklist": {
        "type": "object",
        "description": "A post-installation checklist: what the installer checked on site after\ninstalling countertops, signed by the customer.",
        "required": [
          "id",
          "customer_name",
          "installation_address",
          "checks"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "Checklist id; its PDF is at `GET /v1/checklists/{id}/pdf`."
          },
          "customer_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Customer record the checklist belongs to; null when the installer\ntyped a name without picking a customer, or the customer was deleted."
          },
          "customer_name": {
            "type": "string",
            "description": "Customer name as written on the checklist."
          },
          "installation_address": {
            "type": "string",
            "description": "Address of the installation."
          },
          "email": {
            "type": [
              "string",
              "null"
            ],
            "description": "Customer email the satisfaction survey goes to; null if not given."
          },
          "installer_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "User id of the installer who filled it in; null if unknown."
          },
          "installer_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "Installer's name, also for installers who were deleted since; null\nwhen there is no installer."
          },
          "checks": {
            "$ref": "#/components/schemas/ChecklistChecks",
            "description": "Each item of the checklist, `true` when it passed."
          },
          "comments": {
            "type": [
              "string",
              "null"
            ],
            "description": "Installer's or customer's comments; null or empty when none."
          },
          "created_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When the checklist was submitted (ISO 8601, UTC)."
          }
        }
      },
      "ChecklistChecks": {
        "type": "object",
        "description": "The items the customer confirms with the installer (labels as on the\nform); `true` means it passed.",
        "required": [
          "material_correct",
          "seams_satisfaction",
          "appliances_fit",
          "backsplashes_correct",
          "edges_correct",
          "holes_drilled",
          "cleanup_completed"
        ],
        "properties": {
          "material_correct": {
            "type": "boolean",
            "description": "\"Material is correct\"."
          },
          "seams_satisfaction": {
            "type": "boolean",
            "description": "\"Seams meet my satisfaction\" (the customer's)."
          },
          "appliances_fit": {
            "type": "boolean",
            "description": "\"Appliances fit properly\"."
          },
          "backsplashes_correct": {
            "type": "boolean",
            "description": "\"Backsplashes placed correctly\"."
          },
          "edges_correct": {
            "type": "boolean",
            "description": "\"Edges and corners are correct\"."
          },
          "holes_drilled": {
            "type": "boolean",
            "description": "\"Holes for fixtures are drilled\"."
          },
          "cleanup_completed": {
            "type": "boolean",
            "description": "\"Clean up completed\"."
          }
        }
      },
      "ChecklistItemInput": {
        "oneOf": [
          {
            "type": "string",
            "description": "Just the text: the sales rep follows it up."
          },
          {
            "type": "object",
            "description": "The text and who follows it up (null: the sales rep).",
            "required": [
              "label"
            ],
            "properties": {
              "label": {
                "type": "string",
                "description": "1 to 200 characters."
              },
              "assigned_user_id": {
                "type": [
                  "integer",
                  "null"
                ],
                "format": "int32",
                "description": "Someone in the company; null for the sales rep."
              }
            }
          }
        ],
        "description": "One to-do of a list to save: its text, or its text and person."
      },
      "Choice": {
        "type": "object",
        "description": "A value with its label, for a select.",
        "required": [
          "value",
          "label"
        ],
        "properties": {
          "value": {
            "type": "string",
            "description": "The value to send."
          },
          "label": {
            "type": "string",
            "description": "What to show."
          }
        }
      },
      "ChoiceInput": {
        "type": "object",
        "description": "An answer of a question being saved.",
        "required": [
          "text",
          "is_correct"
        ],
        "properties": {
          "id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "An existing answer to keep; omitted for a new one."
          },
          "text": {
            "type": "string",
            "description": "Its text; a blank answer is dropped."
          },
          "is_correct": {
            "type": "boolean",
            "description": "The right answer."
          }
        }
      },
      "ClaimInput": {
        "type": "object",
        "description": "Body of `POST /v1/me/onboarding/claim`.",
        "required": [
          "task_id"
        ],
        "properties": {
          "task_id": {
            "type": "string",
            "description": "A setup task (`setup-email-name`, `setup-email-signature`, `setup-telegram`)."
          }
        }
      },
      "ClaimResult": {
        "type": "object",
        "description": "The claim's outcome.",
        "required": [
          "status"
        ],
        "properties": {
          "status": {
            "type": "string",
            "description": "`credited`, `already-completed`, `not-done` (open its page instead) or\n`unavailable` (guided tours are off)."
          },
          "task_id": {
            "type": [
              "string",
              "null"
            ],
            "description": "The task credited."
          },
          "state": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/OnboardingState",
                "description": "The saved state (credited and already-completed)."
              },
              {
                "type": "null"
              }
            ]
          }
        }
      },
      "ClassSales": {
        "type": "object",
        "description": "`GET /v1/qbo/class-sales`.",
        "required": [
          "status",
          "classes"
        ],
        "properties": {
          "status": {
            "$ref": "#/components/schemas/ClassSalesStatus",
            "description": "Whether the report came back."
          },
          "report": {
            "type": [
              "object",
              "null"
            ],
            "description": "The `ClassSales` report as `QuickBooks` returns it (with `ok`)."
          },
          "classes": {
            "type": "array",
            "items": {
              "type": "object"
            },
            "description": "The company's `Class` entities (empty when they could not be read)."
          }
        }
      },
      "ClassSalesStatus": {
        "type": "string",
        "description": "`ok`, `not_connected` or `error`.",
        "enum": [
          "ok",
          "not_connected",
          "error"
        ]
      },
      "ClientInfo": {
        "type": "object",
        "description": "Who wrote, for the team: what helps answer without asking.",
        "required": [
          "user_id",
          "email",
          "is_admin",
          "is_employee",
          "uses_phone_app",
          "company_id",
          "company_name",
          "source",
          "user_count",
          "customer_count"
        ],
        "properties": {
          "user_id": {
            "type": "integer",
            "format": "int32",
            "description": "User id (also their PostHog person id)."
          },
          "name": {
            "type": [
              "string",
              "null"
            ],
            "description": "Name."
          },
          "email": {
            "type": "string",
            "description": "Login email."
          },
          "phone_number": {
            "type": [
              "string",
              "null"
            ],
            "description": "Personal phone number."
          },
          "is_admin": {
            "type": "boolean",
            "description": "Company admin."
          },
          "is_employee": {
            "type": "boolean",
            "description": "Staff member of the company."
          },
          "positions": {
            "type": [
              "string",
              "null"
            ],
            "description": "Their positions in the company, comma separated (`sales_rep, shop_worker`)."
          },
          "user_created_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When the account was made."
          },
          "last_sign_in_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "Their latest sign-in on the website."
          },
          "uses_phone_app": {
            "type": "boolean",
            "description": "They use the phone app (a phone signed in)."
          },
          "company_id": {
            "type": "integer",
            "format": "int32",
            "description": "Their company."
          },
          "company_name": {
            "type": "string",
            "description": "Its name."
          },
          "subdomain": {
            "type": [
              "string",
              "null"
            ],
            "description": "Its web address label (`acme` of acme.granite-manager.com); null when none."
          },
          "source": {
            "type": "string",
            "description": "`superuser` (set up by Granite Manager) or `signup_page` (signed itself up)."
          },
          "signed_up_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When it signed itself up; null for companies Granite Manager set up."
          },
          "free_access_until": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "Free access granted until; null when none."
          },
          "user_count": {
            "type": "integer",
            "format": "int64",
            "description": "Live users of the company."
          },
          "max_users": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Its user limit."
          },
          "customer_count": {
            "type": "integer",
            "format": "int64",
            "description": "Its customers (leads included)."
          },
          "subscription_status": {
            "type": [
              "string",
              "null"
            ],
            "description": "Stripe subscription status (`active`, `past_due`, `canceled`, `none`, ...); null when never billed."
          },
          "plan_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "Its plan name."
          },
          "monthly_price_cents": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "What it pays a month, in cents."
          },
          "current_period_end": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When the paid period ends."
          }
        }
      },
      "ClosedDeal": {
        "type": "object",
        "description": "A won or lost deal.",
        "required": [
          "id",
          "outcome"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int64",
            "description": "Deal id."
          },
          "outcome": {
            "type": "string",
            "description": "`won` or `lost`."
          },
          "lost_reason": {
            "type": [
              "string",
              "null"
            ],
            "description": "Why it was lost."
          },
          "closed_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When it left its last stage."
          }
        }
      },
      "CloseupPlace": {
        "type": "object",
        "description": "Where the admin put the close-up circle (dragged and sized in Edit image).",
        "required": [
          "x",
          "y",
          "size"
        ],
        "properties": {
          "x": {
            "type": "number",
            "format": "double",
            "description": "Middle of the circle, as a share of the picture's width (0 to 1)."
          },
          "y": {
            "type": "number",
            "format": "double",
            "description": "Middle of the circle, as a share of the picture's height (0 to 1)."
          },
          "size": {
            "type": "number",
            "format": "double",
            "description": "Circle across, as a share of the picture's shorter side (0.1 to 1)."
          }
        },
        "additionalProperties": false
      },
      "Coaching": {
        "type": "object",
        "description": "`GET`/`POST /v1/me/call-coaching`.",
        "required": [
          "eligible",
          "analyzing",
          "calls"
        ],
        "properties": {
          "eligible": {
            "type": "boolean",
            "description": "The caller has a `CloudTalk` line (agent and number), a `RingCentral`\nline (extension and number) or a Granite Manager number (calling\nswitched on for the company)."
          },
          "analyzing": {
            "type": "boolean",
            "description": "Some call is being scored."
          },
          "calls": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CoachingCall"
            },
            "description": "Newest first."
          }
        }
      },
      "CoachingCall": {
        "type": "object",
        "description": "A call the coach can score.",
        "required": [
          "call_id",
          "status",
          "started_at",
          "talking_time",
          "call_type",
          "phone_display"
        ],
        "properties": {
          "call_id": {
            "type": "string",
            "description": "`CloudTalk` or `RingCentral` call id, or `tx_<id>` for a Granite Manager\ncall."
          },
          "status": {
            "$ref": "#/components/schemas/CoachingStatus"
          },
          "started_at": {
            "type": "string",
            "description": "When it started (`CloudTalk` time, or RFC 3339 for `RingCentral` and\nGranite Manager)."
          },
          "talking_time": {
            "type": "number",
            "format": "double",
            "description": "Seconds talked."
          },
          "call_type": {
            "type": "string",
            "description": "`incoming` or `outgoing`."
          },
          "customer_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "The customer, from the CRM or the phone system."
          },
          "phone_display": {
            "type": "string",
            "description": "The other party's number, dashed."
          },
          "score": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "1–100 once scored.",
            "minimum": 0
          },
          "advice": {
            "type": [
              "string",
              "null"
            ],
            "description": "What to do differently."
          },
          "summary": {
            "type": [
              "string",
              "null"
            ],
            "description": "What the call was about."
          },
          "error_message": {
            "type": [
              "string",
              "null"
            ],
            "description": "Why it could not be scored."
          }
        }
      },
      "CoachingStatus": {
        "type": "string",
        "description": "Where a call's score stands.",
        "enum": [
          "idle",
          "pending",
          "ready",
          "error"
        ]
      },
      "CodeChannel": {
        "type": "string",
        "description": "How a code is sent.",
        "enum": [
          "email",
          "sms"
        ]
      },
      "CodeInput": {
        "type": "object",
        "description": "Body of `POST /v1/auth/login/code` and\n`POST /v1/auth/login/authenticator/confirm`.",
        "required": [
          "token",
          "code"
        ],
        "properties": {
          "token": {
            "type": "string",
            "description": "The sign-in's token (`LoginChallenge.token`)."
          },
          "code": {
            "type": "string",
            "description": "The 6-digit code the authenticator app shows now (spaces ignored)."
          }
        }
      },
      "CodeRequest": {
        "type": "object",
        "description": "How the visitor wants their code.",
        "properties": {
          "channel": {
            "$ref": "#/components/schemas/CodeChannel",
            "description": "`email` (the default) or `sms` (a text to the customer's phone)."
          }
        }
      },
      "Color": {
        "type": "object",
        "description": "A stone color tag.",
        "required": [
          "id",
          "name",
          "hex_code"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "Color id."
          },
          "name": {
            "type": "string",
            "description": "Color name, e.g. \"Black\"."
          },
          "hex_code": {
            "type": "string",
            "description": "Display color, `#RRGGBB`."
          }
        }
      },
      "ColorInUse": {
        "type": "object",
        "description": "409 body of `DELETE /v1/colors/{id}`: stones or materials have the color.",
        "required": [
          "error",
          "stones",
          "materials"
        ],
        "properties": {
          "error": {
            "type": "string",
            "description": "\"Stones or materials have this color, so it cannot be deleted.\""
          },
          "stones": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/StoneUsingType"
            },
            "description": "Live stones (bundles) tagged with it, by name; untag them first."
          },
          "materials": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/StoneUsingType"
            },
            "description": "Materials tagged with it, by name; untag them first."
          }
        }
      },
      "ColorInput": {
        "type": "object",
        "description": "Body of `POST /v1/colors` and `PATCH /v1/colors/{id}`.",
        "required": [
          "name",
          "hex_code"
        ],
        "properties": {
          "name": {
            "type": "string",
            "description": "1 to 60 characters, unique in the company ignoring case. Use a plain\ncolor word (\"Taupe\", \"Charcoal\"): the AI that tags a stone's colors\nfrom its photo goes by the name."
          },
          "hex_code": {
            "type": "string",
            "description": "The shade shown in the color dot, `#RRGGBB` (the `#` may be left out)."
          }
        },
        "additionalProperties": false
      },
      "CommentInput": {
        "type": "object",
        "description": "Body of the comment routes.",
        "required": [
          "content"
        ],
        "properties": {
          "content": {
            "type": "string",
            "description": "1 to 2000 characters (trimmed)."
          }
        }
      },
      "CommissionEdit": {
        "type": "object",
        "description": "An admin's own contract, commission and payroll date for a row.",
        "properties": {
          "quoteTotal": {
            "type": [
              "number",
              "null"
            ],
            "format": "double",
            "description": "The contract (none: the calculated one)."
          },
          "commission": {
            "type": [
              "number",
              "null"
            ],
            "format": "double",
            "description": "The commission (none: the calculated one)."
          },
          "payrollDate": {
            "type": [
              "string",
              "null"
            ],
            "description": "The payroll it is paid with, YYYY-MM-DD (none: not in the salary)."
          }
        },
        "additionalProperties": false
      },
      "CommissionPart": {
        "type": "object",
        "description": "One rule's share of a quote's commission.",
        "required": [
          "ruleId",
          "rule",
          "base",
          "baseLabel",
          "amount",
          "note"
        ],
        "properties": {
          "ruleId": {
            "type": "integer",
            "format": "int64",
            "description": "The rule."
          },
          "rule": {
            "type": "string",
            "description": "Its name."
          },
          "base": {
            "type": "number",
            "format": "double",
            "description": "What it was applied to: dollars, sq ft or units."
          },
          "baseLabel": {
            "type": "string",
            "description": "What `base` counts."
          },
          "amount": {
            "type": "number",
            "format": "double",
            "description": "Earned."
          },
          "note": {
            "type": "string",
            "description": "Where it applied, e.g. the area or the line."
          }
        }
      },
      "CommissionRow": {
        "type": "object",
        "description": "A sold quote's commission, or a row with no quote (a rep's sheet, a\nbonus) (`CommissionRow`).",
        "required": [
          "id",
          "quoteName",
          "customerName",
          "rep",
          "quoteTotal",
          "calculatedTotal",
          "commission",
          "calculatedCommission",
          "adjusted",
          "noRule",
          "parts",
          "features",
          "status",
          "extra"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "Row id."
          },
          "quoteId": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "The quote (none: a row with no quote)."
          },
          "quoteName": {
            "type": "string",
            "description": "Its name."
          },
          "customerName": {
            "type": "string",
            "description": "The customer: the CRM's, else the row's own name (a rep's sheet)."
          },
          "customerId": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "The CRM customer (none: a row with only its own name)."
          },
          "label": {
            "type": [
              "string",
              "null"
            ],
            "description": "The row's own name for the job (a rep's sheet), e.g. \"Smith (cabinets)\"."
          },
          "userId": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "The rep."
          },
          "rep": {
            "type": "string",
            "description": "Their name (\"Unassigned\" when none)."
          },
          "signedAt": {
            "type": [
              "string",
              "null"
            ],
            "description": "When the quote was sold or signed (YYYY-MM-DD)."
          },
          "quoteTotal": {
            "type": "number",
            "format": "double",
            "description": "The contract: the admin's own amount, else the option's total."
          },
          "calculatedTotal": {
            "type": "number",
            "format": "double",
            "description": "The option's total as calculated."
          },
          "commission": {
            "type": "number",
            "format": "double",
            "description": "Earned: the admin's own amount, else what the rules work out."
          },
          "calculatedCommission": {
            "type": "number",
            "format": "double",
            "description": "What the rules work out."
          },
          "adjusted": {
            "type": "boolean",
            "description": "An admin set the contract or the commission by hand."
          },
          "noRule": {
            "type": "boolean",
            "description": "A sold quote no rule pays anything on, which looks like a mistake; an\nadmin can type its commission, and it stays marked."
          },
          "parts": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CommissionPart"
            },
            "description": "How."
          },
          "features": {
            "type": "object",
            "description": "Dollars of each extra sold on the quote (`waterfall`, `miter`,\n`phantom_seam`, `custom_edge`, `support`, `faucet`,\n`soap_dispenser`), as of its last sync; empty without a quote.",
            "additionalProperties": {
              "type": "number",
              "format": "double"
            },
            "propertyNames": {
              "type": "string"
            }
          },
          "status": {
            "type": "string",
            "description": "`paid`, `partial`, `unpaid` or `no_invoice`."
          },
          "paidDate": {
            "type": [
              "string",
              "null"
            ],
            "description": "When the customer paid (YYYY-MM-DD)."
          },
          "installedDate": {
            "type": [
              "string",
              "null"
            ],
            "description": "When the job was installed: its last Installations event, once all\nof them are dated and gone by (YYYY-MM-DD)."
          },
          "payrollDate": {
            "type": [
              "string",
              "null"
            ],
            "description": "The payroll it is paid with, once added to the salary (YYYY-MM-DD)."
          },
          "paidOutAt": {
            "type": [
              "string",
              "null"
            ],
            "description": "When it was paid out (YYYY-MM-DD)."
          },
          "extra": {
            "type": "boolean",
            "description": "An extra an admin added by hand (review, gas, vacation day, deduction):\npaid in the paycheck's Extras column."
          }
        }
      },
      "CommissionRule": {
        "type": "object",
        "description": "A commission rule (`CommissionRule`).",
        "required": [
          "id",
          "name",
          "applies",
          "rateType",
          "rate",
          "priority",
          "stop",
          "materials",
          "colors",
          "lineMatch",
          "active"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int64",
            "description": "Rule id."
          },
          "name": {
            "type": "string",
            "description": "Name."
          },
          "applies": {
            "type": "string",
            "description": "`material` (the stone of each room: a percent of everything in the\nroom, or dollars per sq ft of stone), `quote` (the whole quote before\ntax), `lines` (price lines matching `lineMatch`) or `monthly_goal`."
          },
          "rateType": {
            "type": "string",
            "description": "`percent` or `flat` (dollars per sq ft, unit, quote or goal)."
          },
          "rate": {
            "type": "number",
            "format": "double",
            "description": "Percent or dollars."
          },
          "priority": {
            "type": "integer",
            "format": "int64",
            "description": "Higher goes first."
          },
          "stop": {
            "type": "boolean",
            "description": "Material rules: a match keeps lower rules from paying on the same area.\nLine rules: the lines it matches earn only this rule, not the room's\nstone percent too."
          },
          "materials": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Material rules: only these materials (empty: any); `Special order` is\nevery stone ordered for the quote, whatever its material."
          },
          "colors": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Material rules: only these colors (empty: any)."
          },
          "levelMin": {
            "type": [
              "number",
              "null"
            ],
            "format": "double",
            "description": "Material rules: lowest stone level."
          },
          "levelMax": {
            "type": [
              "number",
              "null"
            ],
            "format": "double",
            "description": "Material rules: highest stone level."
          },
          "lineMatch": {
            "type": "string",
            "description": "Line rules: text the line's key or description contains."
          },
          "threshold": {
            "type": [
              "number",
              "null"
            ],
            "format": "double",
            "description": "Monthly goals: the month's paid sales that earn the bonus."
          },
          "discountMin": {
            "type": [
              "number",
              "null"
            ],
            "format": "double",
            "description": "Only when the quote's discount is over this percent."
          },
          "discountMax": {
            "type": [
              "number",
              "null"
            ],
            "format": "double",
            "description": "Only when the quote's discount is at most this percent."
          },
          "madeBy": {
            "type": "string",
            "description": "Who made the quote: `any`, `rep` (the rep themself) or `other`\n(someone else made it for them)."
          },
          "paidOnly": {
            "type": "boolean",
            "description": "Line rules: only lines the customer pays for (a free line earns nothing)."
          },
          "active": {
            "type": "boolean",
            "description": "Off rules pay nothing."
          }
        }
      },
      "CommissionSettings": {
        "type": "object",
        "description": "The payroll week (base pay has its own schedules: `/v1/commission-base-pay`).",
        "required": [
          "payrollWeekday"
        ],
        "properties": {
          "payrollWeekday": {
            "type": "integer",
            "format": "int32",
            "description": "0 = Sunday … 6 = Saturday: the day payroll goes out.",
            "minimum": 0
          },
          "lastSyncedAt": {
            "type": [
              "string",
              "null"
            ],
            "description": "When the sync last ran (UTC, `YYYY-MM-DDTHH:MM:SSZ`); never: null.\nRead only: a saved value is ignored."
          },
          "jobPaySameWeek": {
            "type": [
              "boolean",
              "null"
            ],
            "description": "Template and install pay goes into the first payroll on or after the\nday the job was finished (true), or the payroll of the week after\n(false, the default). Left out of a save: unchanged."
          },
          "jobPayFrom": {
            "type": [
              "string",
              "null"
            ],
            "description": "Templates and installs finished from this day on are paid\n(YYYY-MM-DD); null until the company's first pay rule, which sets it\nto that day. Left out of a save: unchanged."
          }
        },
        "additionalProperties": false
      },
      "Commissions": {
        "type": "object",
        "description": "Commissions and paychecks.",
        "required": [
          "rows",
          "weeks",
          "nextPayday"
        ],
        "properties": {
          "rows": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CommissionRow"
            },
            "description": "Signed quotes, newest first."
          },
          "weeks": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PayrollWeek"
            },
            "description": "Paychecks per payroll date, newest first."
          },
          "nextPayday": {
            "type": "string",
            "description": "The next payday from today (YYYY-MM-DD; today when it is one)."
          }
        }
      },
      "CompanyDetails": {
        "type": "object",
        "description": "A company's settings as super admins edit them.",
        "required": [
          "id",
          "name",
          "raptor_password_set",
          "quickbooks_enabled",
          "signature_enabled",
          "billing_required",
          "customer_payments_enabled",
          "onboarding_enabled",
          "leaderboard_enabled"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "Company id."
          },
          "name": {
            "type": "string",
            "description": "Company name."
          },
          "subdomain": {
            "type": [
              "string",
              "null"
            ],
            "description": "Subdomain, or null."
          },
          "address": {
            "type": [
              "string",
              "null"
            ],
            "description": "Address, or null."
          },
          "domain": {
            "type": [
              "string",
              "null"
            ],
            "description": "Email domain, or null."
          },
          "logo_url": {
            "type": [
              "string",
              "null"
            ],
            "description": "Logo, or null."
          },
          "logo_height": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Logo height in pixels as saved, or null."
          },
          "sales_tax_percent": {
            "type": [
              "number",
              "null"
            ],
            "format": "double",
            "description": "Sales tax in percent, or null."
          },
          "max_users": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "User limit, or null."
          },
          "cloudtalk_access_key": {
            "type": [
              "string",
              "null"
            ],
            "description": "`CloudTalk` API key id, or null."
          },
          "cloudtalk_access_secret": {
            "type": [
              "string",
              "null"
            ],
            "description": "`CloudTalk` API secret, or null."
          },
          "ringcentral_client_id": {
            "type": [
              "string",
              "null"
            ],
            "description": "`RingCentral` JWT app client id, or null."
          },
          "ringcentral_client_secret": {
            "type": [
              "string",
              "null"
            ],
            "description": "`RingCentral` JWT app client secret, or null."
          },
          "ringcentral_jwt": {
            "type": [
              "string",
              "null"
            ],
            "description": "`RingCentral` JWT, or null."
          },
          "ringcentral_server_url": {
            "type": [
              "string",
              "null"
            ],
            "description": "`RingCentral` server override, or null."
          },
          "qbo_realm_id": {
            "type": [
              "string",
              "null"
            ],
            "description": "Linked `QuickBooks` company, or null."
          },
          "signwell_api_key": {
            "type": [
              "string",
              "null"
            ],
            "description": "`SignWell` API key, or null."
          },
          "raptor_email": {
            "type": [
              "string",
              "null"
            ],
            "description": "Raptor (templator.com) login email, or null: new projects become\nRaptor jobs."
          },
          "raptor_password_set": {
            "type": "boolean",
            "description": "A Raptor password is saved (it is never sent back)."
          },
          "quickbooks_enabled": {
            "type": "boolean",
            "description": "QuickBooks switch."
          },
          "signature_enabled": {
            "type": "boolean",
            "description": "The old company eSignatures switch; no longer used (eSignatures are\ngiven per user)."
          },
          "billing_required": {
            "type": "boolean",
            "description": "Stripe payment required."
          },
          "customer_payments_enabled": {
            "type": "boolean",
            "description": "Customer payments switch: the company may connect a bank account and\ntake its customers' payments by card or ACH. Off unless turned on."
          },
          "onboarding_enabled": {
            "type": "boolean",
            "description": "Guided tours switch (own setting, else the platform default)."
          },
          "leaderboard_enabled": {
            "type": "boolean",
            "description": "Points leaderboard switch (own setting, else the platform default)."
          }
        }
      },
      "CompanyFeatures": {
        "type": "object",
        "description": "What the company the request acts in has switched on or set up. Pages use\nit to decide which features, widgets and links to offer.",
        "required": [
          "quickbooks_enabled",
          "quickbooks_connected",
          "onboarding",
          "leaderboard",
          "e_signature",
          "inbound_email",
          "cloudtalk",
          "ringcentral",
          "telnyx",
          "telnyx_sms",
          "auto_sale",
          "auto_unscheduled_jobs",
          "sale_template_job",
          "sale_installation_job",
          "auto_invoice",
          "quote_invoice_sync",
          "qbo_invoice_copy",
          "auto_project",
          "auto_sales_order",
          "quote_link_signing",
          "sale_opens_invoice",
          "invoice_opens_payment",
          "sale_event_templates",
          "sales_playbook"
        ],
        "properties": {
          "quickbooks_enabled": {
            "type": "boolean",
            "description": "The QuickBooks feature is switched on for the company (on unless a\nplatform admin turned it off)."
          },
          "quickbooks_connected": {
            "type": "boolean",
            "description": "The company has connected a QuickBooks account (OAuth tokens saved).\nQuickBooks data is only usable when both this and `quickbooks_enabled`\nare true."
          },
          "onboarding": {
            "type": "boolean",
            "description": "Guided tours and their points (the company's own switch, else the\nplatform-wide default)."
          },
          "leaderboard": {
            "type": "boolean",
            "description": "The points leaderboard (the company's own switch, else the\nplatform-wide default). See `GET /v1/points-leaderboard`."
          },
          "e_signature": {
            "type": "boolean",
            "description": "E-signatures: the company has a SignWell API key. Each user still needs\ntheir own `is_signature_available` flag."
          },
          "inbound_email": {
            "type": "boolean",
            "description": "Inbound email is set up (the company has a mail domain): the Emails\ninbox and email widgets are offered."
          },
          "cloudtalk": {
            "type": "boolean",
            "description": "The company has CloudTalk credentials (calls and texts)."
          },
          "ringcentral": {
            "type": "boolean",
            "description": "The company is connected to RingCentral (OAuth, or JWT credentials).\nWhen both are set up, texts go through RingCentral."
          },
          "telnyx": {
            "type": "boolean",
            "description": "Granite Manager is switched on (`telnyx_company_config.enabled`): calls\nthrough Telnyx, and texts from the company's Telnyx numbers."
          },
          "telnyx_sms": {
            "type": "boolean",
            "description": "Texting through Telnyx is on: Granite Manager is on and the company's\nTelnyx messaging profile is set. Users with a Telnyx line text through\nit (`/v1/sms/telnyx/...`)."
          },
          "auto_sale": {
            "type": "boolean",
            "description": "Marking a deal won or a quote sold opens the sale form, filled from\nthe quote (Admin › Quotes › Automation, `PUT /v1/company/auto-sale`)."
          },
          "auto_unscheduled_jobs": {
            "type": "boolean",
            "description": "Marking a quote sold adds its template and installation to the\nschedule's Unscheduled list (Admin › Quotes › Automation,\n`PUT /v1/company/auto-unscheduled-jobs`)."
          },
          "sale_template_job": {
            "type": "boolean",
            "description": "With `auto_unscheduled_jobs`, a sold quote adds its template event\n(Admin › Quotes › Automation › Event templates, where it can be\nremoved: `PUT /v1/company/sale-built-in-jobs`). Mark as Sold may\nstill untick it."
          },
          "sale_installation_job": {
            "type": "boolean",
            "description": "With `auto_unscheduled_jobs`, a sold quote adds its installation event\n(as `sale_template_job`)."
          },
          "auto_invoice": {
            "type": "boolean",
            "description": "Marking a quote sold opens its QuickBooks invoice, filled from the sold\noption; confirming it creates the invoice in QuickBooks (Admin › Quotes ›\nAutomation, `PUT /v1/company/auto-invoice`)."
          },
          "quote_invoice_sync": {
            "type": "boolean",
            "description": "A new invoice from a quote starts with \"Keep in sync with the quote\"\nticked (Admin › Quotes › Automation,\n`PUT /v1/company/quote-invoice-sync`)."
          },
          "qbo_invoice_copy": {
            "type": "boolean",
            "description": "Every Order's own invoice is copied to `QuickBooks` by itself, with\nits changes and payments (Admin › Quotes › Invoices,\n`PUT /v1/company/qbo-invoice-copy`). On until a manager turns it off."
          },
          "auto_project": {
            "type": "boolean",
            "description": "Marking a deal won or a quote sold starts its project in Projects\n(Admin › Quotes › Automation \"Project on a sale\",\n`PUT /v1/company/auto-project`)."
          },
          "auto_sales_order": {
            "type": "boolean",
            "description": "Marking a quote sold makes its sales order for the Inventory Manager\n(Admin › Quotes › Automation \"Sales order on a sale\",\n`PUT /v1/company/auto-sales-order`)."
          },
          "quote_link_signing": {
            "type": "boolean",
            "description": "The customer's quote link shows Accept & Sign (Admin › Quotes ›\nAutomation \"Sign on the quote link\",\n`PUT /v1/company/quote-link-signing`)."
          },
          "sale_opens_invoice": {
            "type": "boolean",
            "description": "After Create an order, the invoice opens by itself (Admin › Quotes ›\nAutomation, `PUT /v1/company/sale-opens-invoice`). Off by default."
          },
          "invoice_opens_payment": {
            "type": "boolean",
            "description": "After the Order's invoice is made, Record payment opens for its first\npayment (Admin › Quotes › Automation,\n`PUT /v1/company/invoice-opens-payment`). Off by default."
          },
          "sale_event_templates": {
            "type": "boolean",
            "description": "The company has event templates: Mark as Sold offers them as Extra\nevents, and each one ticked adds an event to the schedule's Unscheduled\nlist, whatever `auto_unscheduled_jobs` says (`GET /v1/quote-sale-events`)."
          },
          "sales_playbook": {
            "type": "boolean",
            "description": "Deals › Task Settings \"Sales playbook\": sub-stages, touch plans,\nstage time limits and sales KPIs (`PUT /v1/company/sales-playbook`).\nOff by default; while off, none of it shows."
          }
        }
      },
      "CompanyFrame": {
        "type": "object",
        "description": "The frame of a company's pages.",
        "required": [
          "stone_types",
          "sink_types",
          "stone_suppliers",
          "sink_suppliers",
          "faucet_suppliers",
          "colors",
          "stone_levels"
        ],
        "properties": {
          "name": {
            "type": [
              "string",
              "null"
            ],
            "description": "Company name."
          },
          "logo_url": {
            "type": [
              "string",
              "null"
            ],
            "description": "Logo."
          },
          "logo_height": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Logo height in pixels (the app clamps it)."
          },
          "stone_types": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/NamedRow"
            },
            "description": "Stone types, by name."
          },
          "sink_types": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/NamedRow"
            },
            "description": "Sink types, oldest first."
          },
          "stone_suppliers": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/FrameSupplier"
            },
            "description": "Suppliers of its stones."
          },
          "sink_suppliers": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/FrameSupplier"
            },
            "description": "Suppliers of its sinks."
          },
          "faucet_suppliers": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/FrameSupplier"
            },
            "description": "Suppliers of its faucets."
          },
          "colors": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/FrameColor"
            },
            "description": "Its stone colors by name, for the color filter: the shared list until\nit edits its colors in Materials Setup, then its own."
          },
          "stone_levels": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/FrameLevel"
            },
            "description": "Its stone levels by number, for the level filter: 1 to 7 without\nnames until it changes them in Materials Setup."
          }
        }
      },
      "CompanyGoal": {
        "type": "object",
        "description": "The company's monthly sales goal.",
        "properties": {
          "monthly_sales_goal": {
            "type": [
              "number",
              "null"
            ],
            "format": "double",
            "description": "Null when not set."
          }
        }
      },
      "CompanyHours": {
        "type": "object",
        "description": "When the company's main line rings: `GET` and `PUT /v1/phone/admin/hours`.",
        "properties": {
          "businessHours": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/WorkingHours",
                "description": "The main line's hours (a valid IANA `tz`, at least one range, `HH:MM`\nwith start before end); null = always."
              },
              {
                "type": "null"
              }
            ]
          },
          "holidays": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Dates the main line rings nobody, `YYYY-MM-DD` in the company time\nzone (at most 366; sorted, repeats dropped)."
          }
        }
      },
      "CompanyInput": {
        "type": "object",
        "description": "Body of `POST /v1/superuser/companies` and `PUT /v1/superuser/companies/{id}`.",
        "required": [
          "name",
          "subdomain"
        ],
        "properties": {
          "name": {
            "type": "string",
            "description": "Company name (required)."
          },
          "subdomain": {
            "type": "string",
            "description": "Subdomain: lowercase letters, digits and inner hyphens (required, unique)."
          },
          "address": {
            "type": [
              "string",
              "null"
            ],
            "description": "Address."
          },
          "domain": {
            "type": [
              "string",
              "null"
            ],
            "description": "Email domain."
          },
          "sales_tax_percent": {
            "type": [
              "number",
              "null"
            ],
            "format": "double",
            "description": "Ignored: the sales tax is worked out from the address. Kept so older\npages that still send it are not refused."
          },
          "max_users": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "User limit (1 or more); edit only."
          },
          "logo_url": {
            "type": [
              "string",
              "null"
            ],
            "description": "A new logo uploaded to `company-logos`; edit only, omit to keep it."
          },
          "logo_height": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Logo height, 32-192; edit only (default 48)."
          },
          "cloudtalk_access_key": {
            "type": [
              "string",
              "null"
            ],
            "description": "`CloudTalk` API key id."
          },
          "cloudtalk_access_secret": {
            "type": [
              "string",
              "null"
            ],
            "description": "`CloudTalk` API secret."
          },
          "ringcentral_client_id": {
            "type": [
              "string",
              "null"
            ],
            "description": "`RingCentral` JWT app client id."
          },
          "ringcentral_client_secret": {
            "type": [
              "string",
              "null"
            ],
            "description": "`RingCentral` JWT app client secret."
          },
          "ringcentral_jwt": {
            "type": [
              "string",
              "null"
            ],
            "description": "`RingCentral` JWT."
          },
          "ringcentral_server_url": {
            "type": [
              "string",
              "null"
            ],
            "description": "`RingCentral` server override."
          },
          "signwell_api_key": {
            "type": [
              "string",
              "null"
            ],
            "description": "`SignWell` API key; edit only."
          },
          "raptor_email": {
            "type": [
              "string",
              "null"
            ],
            "description": "Raptor (templator.com) login email; edit only. Empty turns Raptor off."
          },
          "raptor_password": {
            "type": [
              "string",
              "null"
            ],
            "description": "A new Raptor password; edit only. Omit or leave empty to keep it."
          },
          "quickbooks_enabled": {
            "type": [
              "boolean",
              "null"
            ],
            "description": "QuickBooks switch; edit only (default on)."
          },
          "signature_enabled": {
            "type": [
              "boolean",
              "null"
            ],
            "description": "The old company eSignatures switch; edit only (omit to leave it). No\nlonger used: eSignatures are given per user."
          }
        },
        "additionalProperties": false
      },
      "CompanyModelPick": {
        "type": "object",
        "description": "A company's own pick for a step.",
        "required": [
          "company_id",
          "model"
        ],
        "properties": {
          "company_id": {
            "type": "integer",
            "format": "int32",
            "description": "The company the pick is for."
          },
          "company_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "Null when the company is gone."
          },
          "model": {
            "type": "string",
            "description": "The model the step uses for this company."
          },
          "reasoning_effort": {
            "type": [
              "string",
              "null"
            ],
            "description": "The reasoning effort picked with it; null keeps the code's."
          },
          "changed_by": {
            "type": [
              "string",
              "null"
            ],
            "description": "Who picked it; null when the user is gone."
          },
          "changed_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When it was picked (UTC)."
          }
        }
      },
      "CompanyName": {
        "type": "object",
        "description": "A company to pick.",
        "required": [
          "id"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "Company id."
          },
          "name": {
            "type": [
              "string",
              "null"
            ],
            "description": "Name."
          }
        }
      },
      "CompanyOption": {
        "type": "object",
        "description": "A company with signatures on.",
        "required": [
          "id"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "Company id."
          },
          "name": {
            "type": [
              "string",
              "null"
            ],
            "description": "Its name."
          }
        }
      },
      "CompanyPaymentSettings": {
        "type": "object",
        "description": "A company's customer payment settings.",
        "required": [
          "bank",
          "fees",
          "enabled"
        ],
        "properties": {
          "bank": {
            "$ref": "#/components/schemas/BankAccount",
            "description": "The bank account customers' money goes to."
          },
          "fees": {
            "$ref": "#/components/schemas/PaymentFees",
            "description": "The fee on each payment method and who pays it."
          },
          "enabled": {
            "type": "boolean",
            "description": "Customer payments are turned on for the company (by the platform,\ncompany by company). While false nothing can be set up and no link\ncan be made (403); links made before stay payable."
          }
        }
      },
      "CompanyPayments": {
        "type": "object",
        "description": "A company on the superuser payments screen.",
        "required": [
          "id",
          "name",
          "subscription_price_cents",
          "payment_link"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "Company id."
          },
          "name": {
            "type": "string",
            "description": "Company name."
          },
          "subscription_price_cents": {
            "type": "integer",
            "format": "int32",
            "description": "The monthly price its next new subscription starts at, in US cents\n(default 80000 = $800). A running subscription keeps its own price."
          },
          "payment_link": {
            "type": "string",
            "description": "The payments page link to send the company."
          },
          "stripe_customer_id": {
            "type": [
              "string",
              "null"
            ],
            "description": "Its Stripe customer (`cus_...`); null until its first checkout."
          },
          "subscription": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/SubscriptionSummary",
                "description": "Its live subscription, else its latest ended one; null when it never\nsubscribed."
              },
              {
                "type": "null"
              }
            ]
          },
          "last_payment_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When its last successful payment was made; null when none."
          },
          "last_payment_cents": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int64",
            "description": "What that payment was, in US cents."
          },
          "stripe_error": {
            "type": [
              "string",
              "null"
            ],
            "description": "Why Stripe could not be read for this company; null when it was."
          },
          "first_payment_on": {
            "type": [
              "string",
              "null"
            ],
            "format": "date",
            "description": "The day its first charge is set for (its card is saved at checkout);\nnull to charge at checkout. Read when it subscribes."
          },
          "payment_method": {
            "type": [
              "string",
              "null"
            ],
            "description": "How it pays, as \"Visa •••• 4242\", \"Chase •••• 6789\" or \"Link\"; null\nwhen none is saved or Stripe could not say."
          },
          "paid_through_us": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/PaidThroughUs",
                "description": "How many of the jobs it sold lately its customers paid through\nGranite Manager's payment links (card or ACH). Read from the\ndatabase, so it is there even when Stripe could not be read; null\nonly when the database could not count them (the rest still shows)."
              },
              {
                "type": "null"
              }
            ]
          }
        }
      },
      "CompanyRecording": {
        "type": "object",
        "description": "Which calls the company records: `GET` and `PUT /v1/phone/admin/recording`.",
        "required": [
          "recordingMode"
        ],
        "properties": {
          "recordingMode": {
            "$ref": "#/components/schemas/RecordingMode",
            "description": "`off`, `inbound` (incoming calls) or `both` (incoming and outgoing).\nCallers hear \"This call may be recorded\" before it rings."
          },
          "recordingNoticeUrl": {
            "type": [
              "string",
              "null"
            ],
            "description": "The notice played to the customer on recorded outgoing calls, an\naudio file URL (`http(s)://`, at most 512 characters); null or blank\n= \"This call may be recorded.\" is said instead."
          }
        }
      },
      "CompanyRow": {
        "allOf": [
          {
            "$ref": "#/components/schemas/CustomerRow"
          },
          {
            "type": "object",
            "required": [
              "projects_count",
              "company_phones"
            ],
            "properties": {
              "revenue_generated": {
                "type": [
                  "string",
                  "null"
                ],
                "description": "Sum of the prices of the sales that were not cancelled, as a decimal\nstring (e.g. `\"1500.00\"`), the way mysql2 returns DECIMAL; null when\nthere are none."
              },
              "projects_count": {
                "type": "integer",
                "format": "int64",
                "description": "Number of sales that were not cancelled."
              },
              "company_phones": {
                "type": "array",
                "items": {
                  "type": "string"
                },
                "description": "Every phone number of the company's contacts, once each (same digits\n= same number), this row's own numbers first."
              }
            }
          }
        ],
        "description": "A company of the `companies` view: the contact named like the company,\nelse its oldest, with totals over every contact of the company and their child customers."
      },
      "CompanySettings": {
        "type": "object",
        "description": "`GET /v1/company/settings`.",
        "required": [
          "company_id",
          "can_request_api_token",
          "quickbooks",
          "ringcentral"
        ],
        "properties": {
          "company_id": {
            "type": "integer",
            "format": "int32",
            "description": "The company these settings are of."
          },
          "name": {
            "type": [
              "string",
              "null"
            ],
            "description": "Company name, or null."
          },
          "address": {
            "type": [
              "string",
              "null"
            ],
            "description": "Company address, or null."
          },
          "logo_url": {
            "type": [
              "string",
              "null"
            ],
            "description": "Logo shown in the header, or null."
          },
          "logo_height": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Logo height in pixels as saved (32-192), or null."
          },
          "sales_tax_percent": {
            "type": [
              "number",
              "null"
            ],
            "format": "double",
            "description": "Sales tax in percent (e.g. 7.25), worked out from the address; null\nwhen there is no address or it could not be placed."
          },
          "can_request_api_token": {
            "type": "boolean",
            "description": "The caller holds the Manager position in the company (may request the\nAPI bearer token)."
          },
          "quickbooks": {
            "$ref": "#/components/schemas/QuickbooksSettings"
          },
          "ringcentral": {
            "$ref": "#/components/schemas/RingcentralSettings"
          }
        }
      },
      "CompanySettingsInput": {
        "type": "object",
        "description": "Body of `PUT /v1/company/settings`.",
        "required": [
          "name",
          "logo_height"
        ],
        "properties": {
          "name": {
            "type": "string",
            "description": "Company name (required)."
          },
          "address": {
            "type": [
              "string",
              "null"
            ],
            "description": "Address; blank clears it."
          },
          "logo_url": {
            "type": [
              "string",
              "null"
            ],
            "description": "A new logo uploaded to the `company-logos` folder; omit to keep the\ncurrent one."
          },
          "logo_height": {
            "type": "integer",
            "format": "int32",
            "description": "Logo height in pixels, 32 to 192."
          },
          "sales_tax_percent": {
            "type": [
              "number",
              "null"
            ],
            "format": "double",
            "description": "Ignored: the sales tax is worked out from the address. Kept so older\npages that still send it are not refused."
          }
        },
        "additionalProperties": false
      },
      "CompanySkill": {
        "type": "object",
        "description": "A company's change to one General skill.",
        "required": [
          "key",
          "deleted",
          "name",
          "description",
          "updated_at"
        ],
        "properties": {
          "key": {
            "type": "string",
            "description": "The General skill's key, e.g. `general:sales-month`."
          },
          "deleted": {
            "type": "boolean",
            "description": "True when the company deleted it from its list."
          },
          "name": {
            "type": "string",
            "description": "The changed name (empty when deleted)."
          },
          "description": {
            "type": "string",
            "description": "The changed description."
          },
          "prompt": {
            "type": [
              "string",
              "null"
            ],
            "description": "The changed question, or null when deleted."
          },
          "fields": {
            "type": [
              "array",
              "null"
            ],
            "items": {
              "type": "object"
            },
            "description": "The changed template fields, or null."
          },
          "updated_at": {
            "type": "string",
            "format": "date-time",
            "description": "When it was changed."
          }
        }
      },
      "CompanyStatus": {
        "type": "object",
        "description": "The slower checks of one company, as the companies list shows them.",
        "required": [
          "id",
          "ses_inbound",
          "setup_checklist"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "Company id."
          },
          "domain_trust": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/DomainTrust",
                "description": "Its domain's email deliverability, as `GET .../{id}/domain-trust`\nanswers it; null when the company has no usable domain."
              },
              {
                "type": "null"
              }
            ]
          },
          "ses_inbound": {
            "$ref": "#/components/schemas/SesInbound",
            "description": "Whether it receives email through SES, as `GET .../{id}/ses-inbound`\nanswers it."
          },
          "setup_checklist": {
            "$ref": "#/components/schemas/Checklist",
            "description": "Its setup checklist, as `GET .../{id}/setup-checklist` answers it."
          }
        }
      },
      "CompanySummary": {
        "type": "object",
        "description": "One company in the list.",
        "required": [
          "id",
          "name",
          "user_count",
          "onboarding_finished",
          "onboarding_eligible",
          "cloudtalk_connected",
          "quickbooks_connected",
          "billing_required",
          "source",
          "features"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "Company id."
          },
          "name": {
            "type": "string",
            "description": "Company name."
          },
          "subdomain": {
            "type": [
              "string",
              "null"
            ],
            "description": "Its subdomain (`acme` of `acme.granite-manager.com`), or null."
          },
          "domain": {
            "type": [
              "string",
              "null"
            ],
            "description": "Its email domain, or null."
          },
          "logo_url": {
            "type": [
              "string",
              "null"
            ],
            "description": "Logo, or null."
          },
          "max_users": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "User limit, or null."
          },
          "user_count": {
            "type": "integer",
            "format": "int64",
            "description": "Active users counting toward the limit."
          },
          "onboarding_finished": {
            "type": "integer",
            "format": "int64",
            "description": "Users who finished the first-run tour."
          },
          "onboarding_eligible": {
            "type": "integer",
            "format": "int64",
            "description": "Users who run the tours."
          },
          "cloudtalk_connected": {
            "type": "boolean",
            "description": "`CloudTalk` keys are saved."
          },
          "quickbooks_connected": {
            "type": "boolean",
            "description": "A `QuickBooks` company is linked."
          },
          "billing_required": {
            "type": "boolean",
            "description": "Access depends on the Stripe subscription."
          },
          "source": {
            "type": "string",
            "description": "Where the company came from: `superuser` (created here) or\n`signup_page` (signed itself up; no access until its Stripe\nsubscription is paid)."
          },
          "signed_up_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When the company signed itself up (ISO 8601); null when a superuser\ncreated it."
          },
          "requested_subdomain": {
            "type": [
              "string",
              "null"
            ],
            "description": "The web address it asked for at sign-up (`acme`), until a superuser\nsets its subdomain; null otherwise."
          },
          "free_access_until": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "A sign-up company is let in free until then (ISO 8601); null: no free\ntime. Set with `PUT /v1/superuser/companies/{id}/free-access`."
          },
          "features": {
            "$ref": "#/components/schemas/Features"
          }
        }
      },
      "CompanyTaxesRun": {
        "type": "object",
        "description": "What a run did.",
        "required": [
          "processed",
          "changed"
        ],
        "properties": {
          "processed": {
            "type": "integer",
            "description": "Companies looked up (0 or 1).",
            "minimum": 0
          },
          "changed": {
            "type": "integer",
            "description": "Companies whose rate changed.",
            "minimum": 0
          }
        }
      },
      "CompanyTimeRules": {
        "type": "object",
        "description": "`GET /v1/schedule/time-rules`.",
        "required": [
          "installations",
          "templates"
        ],
        "properties": {
          "installations": {
            "$ref": "#/components/schemas/TimeRules",
            "description": "The Installations calendar's jobs."
          },
          "templates": {
            "$ref": "#/components/schemas/TimeRules",
            "description": "The Templates calendar's jobs."
          }
        }
      },
      "CompanyUser": {
        "type": "object",
        "description": "A user of a company.",
        "required": [
          "id",
          "is_admin",
          "is_superuser",
          "can_manage_users",
          "runs_onboarding",
          "counts_toward_user_limit",
          "onboarding_started",
          "progress"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "User id."
          },
          "name": {
            "type": [
              "string",
              "null"
            ],
            "description": "Name, or null."
          },
          "email": {
            "type": [
              "string",
              "null"
            ],
            "description": "Email, or null."
          },
          "phone_number": {
            "type": [
              "string",
              "null"
            ],
            "description": "Phone, or null."
          },
          "is_admin": {
            "type": "boolean",
            "description": "Admin access."
          },
          "is_superuser": {
            "type": "boolean",
            "description": "Platform superuser."
          },
          "cloudtalk_agent_id": {
            "type": [
              "string",
              "null"
            ],
            "description": "`CloudTalk` agent id as saved, or null."
          },
          "cloudtalk_phone_number": {
            "type": [
              "string",
              "null"
            ],
            "description": "`CloudTalk` number as saved, or null."
          },
          "can_manage_users": {
            "type": "boolean",
            "description": "Holds the Manager position (manages users)."
          },
          "runs_onboarding": {
            "type": "boolean",
            "description": "Runs the guided tours (not an installer or walk-in account)."
          },
          "counts_toward_user_limit": {
            "type": "boolean",
            "description": "Counts toward the user limit (not walk-in only)."
          },
          "onboarding_completed_at": {
            "type": [
              "string",
              "null"
            ],
            "description": "When the first-run tour was completed (ISO 8601), or null."
          },
          "onboarding_started": {
            "type": "boolean",
            "description": "A tours record exists (`progress` is saved, not the empty default)."
          },
          "progress": {
            "$ref": "#/components/schemas/OnboardingState",
            "description": "Saved tours progress."
          }
        }
      },
      "CompanyUsers": {
        "type": "object",
        "description": "`GET /v1/superuser/companies/{id}/users`.",
        "required": [
          "users",
          "deleted_count",
          "has_cloudtalk_api"
        ],
        "properties": {
          "users": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CompanyUser"
            },
            "description": "Active users, by name."
          },
          "deleted_count": {
            "type": "integer",
            "format": "int64",
            "description": "Deleted users."
          },
          "has_cloudtalk_api": {
            "type": "boolean",
            "description": "The company has `CloudTalk` keys (the tours read it)."
          }
        }
      },
      "Completion": {
        "type": "object",
        "description": "A check done.",
        "required": [
          "id",
          "maintenance_sub_item_id"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "Completion id."
          },
          "maintenance_sub_item_id": {
            "type": "integer",
            "format": "int32",
            "description": "The check."
          },
          "completed_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When."
          },
          "notes": {
            "type": [
              "string",
              "null"
            ],
            "description": "Notes (with the meter reading when given)."
          },
          "completed_by_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "Who did it; null when unknown."
          }
        }
      },
      "CompletionInput": {
        "type": "object",
        "description": "Body of completing a check.",
        "properties": {
          "notes": {
            "type": [
              "string",
              "null"
            ],
            "description": "Notes; at most 5000 characters."
          },
          "total_hours_of_work": {
            "type": [
              "number",
              "null"
            ],
            "format": "double",
            "description": "The meter reading now (checks with an hour condition); becomes the\nstarting reading of the check (if it has its own usage) or of the\nequipment."
          }
        },
        "additionalProperties": false
      },
      "ComposeChannel": {
        "type": "string",
        "description": "SMS or email.",
        "enum": [
          "sms",
          "email"
        ]
      },
      "ComposeTarget": {
        "type": "object",
        "description": "Whose thread the composer is in.",
        "required": [
          "channel"
        ],
        "properties": {
          "channel": {
            "$ref": "#/components/schemas/ComposeChannel"
          },
          "customer_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "The customer."
          },
          "customer_email": {
            "type": [
              "string",
              "null"
            ],
            "description": "The email recipient, when there is no customer."
          },
          "phone_digits": {
            "type": [
              "string",
              "null"
            ],
            "description": "The SMS thread's phone digits."
          },
          "deal_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "The deal the composer is on."
          }
        }
      },
      "Conclusion": {
        "type": "string",
        "description": "How the workflow run ended.",
        "enum": [
          "completed",
          "failed",
          "usage_limited"
        ]
      },
      "Condition": {
        "type": "object",
        "description": "When a check is due.",
        "required": [
          "id",
          "maintenance_sub_item_id",
          "condition_type",
          "interval_value",
          "next_due_date",
          "hours_done"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "Condition id."
          },
          "maintenance_sub_item_id": {
            "type": "integer",
            "format": "int32",
            "description": "Its check."
          },
          "condition_type": {
            "type": "string",
            "description": "`hours` (of usage) or `days`."
          },
          "interval_value": {
            "type": "number",
            "format": "double",
            "description": "Every this many hours or days."
          },
          "next_due_date": {
            "type": "string",
            "description": "Next due day, `YYYY-MM-DD`."
          },
          "hours_done": {
            "type": "number",
            "format": "double",
            "description": "Hours used since the last time (hour conditions)."
          }
        }
      },
      "ConditionInput": {
        "type": "object",
        "description": "A condition of a check being saved.",
        "required": [
          "type",
          "interval_value"
        ],
        "properties": {
          "type": {
            "type": "string",
            "description": "`hours` or `days`."
          },
          "interval_value": {
            "type": "number",
            "format": "double",
            "description": "Every this many hours or days; more than 0."
          }
        },
        "additionalProperties": false
      },
      "ConfirmBank": {
        "type": "object",
        "description": "How the customer confirms a bank account they typed by hand.",
        "required": [
          "url",
          "deposit"
        ],
        "properties": {
          "url": {
            "type": "string",
            "description": "Stripe's page where the customer types what the deposit shows."
          },
          "deposit": {
            "$ref": "#/components/schemas/DepositKind",
            "description": "`code`: one 1-cent deposit whose description has a 6-digit code\nstarting with SM; `amounts`: two deposits under a dollar."
          },
          "arrives_at": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int64",
            "description": "When the deposit reaches the bank account, Unix seconds; null when\nStripe does not say."
          }
        }
      },
      "ConfirmationInput": {
        "type": "object",
        "description": "Body of `POST /v1/events/{id}/confirmation`.",
        "required": [
          "template_id"
        ],
        "properties": {
          "template_id": {
            "type": "integer",
            "format": "int32",
            "description": "A template of the company."
          },
          "text": {
            "type": [
              "string",
              "null"
            ],
            "description": "The text as edited before sending; replaces a text template's body.\nLeft out, the template goes as it is."
          }
        }
      },
      "ConfirmationSent": {
        "type": "object",
        "description": "`POST /v1/events/{id}/confirmation`.",
        "required": [
          "channel"
        ],
        "properties": {
          "channel": {
            "$ref": "#/components/schemas/Channel",
            "description": "How it reached the customer: `sms` or `email`."
          }
        }
      },
      "ConnectHorus": {
        "type": "object",
        "description": "Body of `PUT /v1/horus`.",
        "required": [
          "license"
        ],
        "properties": {
          "license": {
            "type": "string",
            "description": "The FusionDrive key: the 32-character `license=` value of a Horus\nmatch report link, or the whole link."
          }
        },
        "additionalProperties": false
      },
      "ConnectWebhookReceived": {
        "type": "object",
        "description": "Answer to Stripe.",
        "required": [
          "received"
        ],
        "properties": {
          "received": {
            "type": "boolean",
            "description": "Always true."
          }
        }
      },
      "Connected": {
        "type": "object",
        "description": "After connecting: where the company lives.",
        "properties": {
          "company_subdomain": {
            "type": [
              "string",
              "null"
            ],
            "description": "The company's subdomain, to go back to its settings there; null when\nit has none."
          }
        }
      },
      "ConnectionStatus": {
        "type": "string",
        "description": "What a test call says about a saved connection.",
        "enum": [
          "connected",
          "disconnected",
          "texts_off",
          "unverified"
        ]
      },
      "ContactCard": {
        "type": "object",
        "description": "`GET /v1/phone/contacts/{id}`.",
        "required": [
          "contact",
          "deals",
          "calls",
          "crmUrl"
        ],
        "properties": {
          "contact": {
            "$ref": "#/components/schemas/CardContact",
            "description": "The customer."
          },
          "deals": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CardDeal"
            },
            "description": "Their live deals, open ones first, then newest (at most 20)."
          },
          "calls": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CallRow"
            },
            "description": "The last 20 calls with them (anyone's), newest first; recordings and\nAI notes only of the calls the caller may hear."
          },
          "crmUrl": {
            "type": "string",
            "description": "The customer's page in the CRM."
          }
        }
      },
      "ContactGroup": {
        "type": "object",
        "description": "One of the company's contact groups, as I see it.",
        "required": [
          "id",
          "name",
          "hidden",
          "customerIds",
          "userIds",
          "shared",
          "canEdit"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int64",
            "description": "The group's id."
          },
          "name": {
            "type": "string",
            "description": "Its name, e.g. \"Installers\" (1 to 60 characters)."
          },
          "hidden": {
            "type": "boolean",
            "description": "I hid it from the top of my Contacts (it still exists, with its\nmembers, and other users still see it at their top)."
          },
          "customerIds": {
            "type": "array",
            "items": {
              "type": "integer",
              "format": "int32"
            },
            "description": "The customers in it (ids of `GET /v1/phone/contacts/index`\n`contacts`), ascending. Deleted customers are left out."
          },
          "userIds": {
            "type": "array",
            "items": {
              "type": "integer",
              "format": "int32"
            },
            "description": "The coworkers in it (user ids, as `coworkers[].userId` of the\ncontact index), ascending. Deleted users are left out; I may be one of\nthem."
          },
          "createdBy": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "The user who made the group; null once that user is gone."
          },
          "shared": {
            "type": "boolean",
            "description": "True: the company's group, every user sees it. False: my own group,\nonly I see it."
          },
          "canEdit": {
            "type": "boolean",
            "description": "I may rename it, delete it and change who is in it: always for my\nown group; for the company's only a Manager, a Sales Manager, an\nadmin or a superuser."
          }
        }
      },
      "ContactGroups": {
        "type": "object",
        "description": "`GET /v1/phone/contact-groups`.",
        "required": [
          "coworkersHidden",
          "canShare",
          "groups"
        ],
        "properties": {
          "coworkersHidden": {
            "type": "boolean",
            "description": "I hid the built-in Coworkers group (everyone at the company with a\nphone number) from the top of my Contacts."
          },
          "canShare": {
            "type": "boolean",
            "description": "A group I make now is the company's, seen by every user (I am a\nManager, a Sales Manager, an admin or a superuser). False: it is my\nown, seen only by me."
          },
          "groups": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ContactGroup"
            },
            "description": "The company's groups and my own, by name."
          }
        }
      },
      "ContactIndex": {
        "type": "object",
        "description": "`GET /v1/phone/contacts/index`.",
        "required": [
          "full",
          "contacts",
          "deleted",
          "cursor",
          "coworkers"
        ],
        "properties": {
          "full": {
            "type": "boolean",
            "description": "True: a full download; replace the phone's copy with this page and\nthe following ones (`nextAfter`). False: changes to apply."
          },
          "contacts": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/IndexContact"
            },
            "description": "Contacts, by id: a page of the full download, or the ones changed,\nadded or called since the cursor."
          },
          "deleted": {
            "type": "array",
            "items": {
              "type": "integer",
              "format": "int32"
            },
            "description": "Since-sync only: ids of customers deleted since the cursor."
          },
          "nextAfter": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int64",
            "description": "Full download: pass as `?after=` for the next page; null on the last\npage (and for a since-sync)."
          },
          "cursor": {
            "type": "string",
            "description": "Pass as `?since=` next time (opaque). Keep the one of a full\ndownload's first page."
          },
          "coworkers": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Coworker"
            },
            "description": "Coworkers with a direct line (first page and since-sync only; empty\non later pages)."
          }
        }
      },
      "ContactLookup": {
        "type": "object",
        "description": "`POST /v1/phone/contacts/lookup`.",
        "required": [
          "matches"
        ],
        "properties": {
          "matches": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/LookupMatch"
            },
            "description": "One match per number, in the order sent."
          }
        }
      },
      "ContactSyncRun": {
        "type": "object",
        "description": "What a run did.",
        "required": [
          "processed",
          "ringcentral",
          "cloudtalk",
          "ringcentral_subscriptions"
        ],
        "properties": {
          "processed": {
            "type": "integer",
            "description": "Customers synced.",
            "minimum": 0
          },
          "ringcentral": {
            "type": "integer",
            "description": "Pushed to `RingCentral`.",
            "minimum": 0
          },
          "cloudtalk": {
            "type": "integer",
            "description": "Pushed to `CloudTalk`: always 0, it is no longer used (kept so the\nanswer keeps its shape).",
            "minimum": 0
          },
          "ringcentral_subscriptions": {
            "type": "integer",
            "description": "`RingCentral` SMS subscriptions renewed with the current webhooks\ntoken.",
            "minimum": 0
          }
        }
      },
      "ContactsVersion": {
        "type": "object",
        "description": "The contact index on the server, to tell whether the phone's copy is\ncurrent.",
        "required": [
          "count",
          "etag"
        ],
        "properties": {
          "count": {
            "type": "integer",
            "format": "int64",
            "description": "Customers in the index."
          },
          "etag": {
            "type": "string",
            "description": "The index's current ETag (as `GET /v1/phone/contacts/index` sends\nit): when it differs from the phone's, sync."
          }
        }
      },
      "ContentInput": {
        "type": "object",
        "description": "Body creating a note or a comment.",
        "required": [
          "content"
        ],
        "properties": {
          "content": {
            "type": "string",
            "description": "Text (notes up to 5000 characters, comments up to 2000)."
          }
        }
      },
      "Conversation": {
        "type": "object",
        "description": "`GET /v1/emails/{id}/conversation`.",
        "required": [
          "messages",
          "truncated"
        ],
        "properties": {
          "thread_id": {
            "type": [
              "string",
              "null"
            ],
            "description": "The thread."
          },
          "messages": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ConversationMessage"
            },
            "description": "Oldest first, the latest 50."
          },
          "truncated": {
            "type": "boolean",
            "description": "Older messages were left out."
          }
        }
      },
      "ConversationChange": {
        "type": "object",
        "description": "Body of `PATCH /v1/support/agent/conversations/{id}`; fields left out\nstay as they are.",
        "properties": {
          "subject": {
            "type": [
              "string",
              "null"
            ],
            "description": "A new subject (what the request is about; at most 200 characters)."
          },
          "status": {
            "type": [
              "string",
              "null"
            ],
            "description": "`open`, `waiting` or `resolved`."
          },
          "category": {
            "type": [
              "string",
              "null"
            ],
            "description": "A request type (see the bootstrap's `categories`), or null to clear."
          },
          "priority": {
            "type": [
              "string",
              "null"
            ],
            "description": "`low`, `normal`, `high` or `urgent`."
          }
        },
        "additionalProperties": false
      },
      "ConversationChatAnswer": {
        "type": "object",
        "description": "The AI's answer.",
        "required": [
          "reply"
        ],
        "properties": {
          "reply": {
            "type": "string",
            "description": "The answer to the rep."
          },
          "draft": {
            "type": [
              "string",
              "null"
            ],
            "description": "A message ready to send to the customer; null when this answer has\nnone."
          }
        }
      },
      "ConversationChatInput": {
        "type": "object",
        "description": "Body of `POST /v1/ai/conversation-reply/chat`.",
        "required": [
          "channel",
          "messages"
        ],
        "properties": {
          "channel": {
            "type": "string",
            "description": "`sms` or `email`: the channel the message is written for."
          },
          "customer_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "The customer."
          },
          "customer_email": {
            "type": [
              "string",
              "null"
            ],
            "description": "For an email to someone not on file yet."
          },
          "phone_digits": {
            "type": [
              "string",
              "null"
            ],
            "description": "The SMS thread's phone (5 to 15 digits)."
          },
          "deal_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int64",
            "description": "The deal to focus on."
          },
          "messages": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ChatTurn"
            },
            "description": "The chat so far, oldest first, ending with the rep's new turn (at\nmost 40 turns of 8000 characters, 4 pictures in all)."
          }
        },
        "additionalProperties": false
      },
      "ConversationDetail": {
        "type": "object",
        "description": "`GET /v1/support/agent/conversations/{id}`.",
        "required": [
          "conversation",
          "messages",
          "typing",
          "reactions"
        ],
        "properties": {
          "conversation": {
            "$ref": "#/components/schemas/ConversationSummary",
            "description": "The request."
          },
          "messages": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SupportMessage"
            },
            "description": "Its messages, oldest first, internal notes included, each with the\npage the client was on and the link to their PostHog recording."
          },
          "client": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/ClientInfo",
                "description": "Who wrote; left out with `after`."
              },
              {
                "type": "null"
              }
            ]
          },
          "posthog_person_url": {
            "type": [
              "string",
              "null"
            ],
            "description": "The client's PostHog person page (every recording of theirs); left out with `after`."
          },
          "history": {
            "type": [
              "array",
              "null"
            ],
            "items": {
              "$ref": "#/components/schemas/ConversationSummary"
            },
            "description": "The company's other requests, latest first (at most 20); left out with `after`."
          },
          "typing": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TypingAgent"
            },
            "description": "The other members writing an answer to it right now (never the caller)."
          },
          "reactions": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SupportReaction"
            },
            "description": "Every reaction in it (also on messages older than `after`), oldest first."
          }
        }
      },
      "ConversationFile": {
        "type": "object",
        "description": "A file of the message.",
        "required": [
          "id",
          "filename",
          "url"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int64",
            "description": "The attachment."
          },
          "filename": {
            "type": "string",
            "description": "File name."
          },
          "url": {
            "type": "string",
            "description": "A link that opens it (presigned for stored mail)."
          }
        }
      },
      "ConversationMessage": {
        "type": "object",
        "description": "One message of the conversation.",
        "required": [
          "id",
          "body",
          "is_from_customer",
          "attachments"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int64",
            "description": "The email."
          },
          "subject": {
            "type": [
              "string",
              "null"
            ],
            "description": "Subject."
          },
          "body": {
            "type": "string",
            "description": "Body as stored (HTML or text)."
          },
          "signature": {
            "type": [
              "string",
              "null"
            ],
            "description": "The sending employee's signature."
          },
          "sent_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When it was sent."
          },
          "from": {
            "type": [
              "string",
              "null"
            ],
            "description": "Sender address."
          },
          "to": {
            "type": [
              "string",
              "null"
            ],
            "description": "Recipient address."
          },
          "sender_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "The sending employee's name."
          },
          "is_from_customer": {
            "type": "boolean",
            "description": "Sent by the customer, not an employee."
          },
          "opened_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "First time the customer opened it."
          },
          "attachments": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ConversationFile"
            },
            "description": "Its files."
          }
        }
      },
      "ConversationReply": {
        "type": "object",
        "description": "The draft.",
        "required": [
          "body"
        ],
        "properties": {
          "body": {
            "type": "string",
            "description": "The message (an email's body, without a subject line)."
          }
        }
      },
      "ConversationReplyInput": {
        "type": "object",
        "description": "Body of `POST /v1/ai/conversation-reply`.",
        "required": [
          "channel"
        ],
        "properties": {
          "channel": {
            "type": "string",
            "description": "`sms` or `email`."
          },
          "customer_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "The customer."
          },
          "customer_email": {
            "type": [
              "string",
              "null"
            ],
            "description": "For an email to someone not on file yet."
          },
          "phone_digits": {
            "type": [
              "string",
              "null"
            ],
            "description": "The SMS thread's phone (5 to 15 digits)."
          },
          "deal_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int64",
            "description": "The deal to focus on."
          },
          "mode": {
            "$ref": "#/components/schemas/ReplyMode"
          },
          "custom_request": {
            "type": [
              "string",
              "null"
            ],
            "description": "What the rep asks for (custom drafts, at most 2000 characters)."
          },
          "previous_draft": {
            "type": [
              "string",
              "null"
            ],
            "description": "The draft to revise (at most 8000 characters)."
          },
          "revision_instruction": {
            "type": [
              "string",
              "null"
            ],
            "description": "What to change in it (at most 2000 characters)."
          },
          "instruction_history": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Every instruction so far, oldest first (at most 12)."
          },
          "include_instructions": {
            "type": [
              "boolean",
              "null"
            ],
            "description": "Custom drafts: follow the company's instructions (default true)."
          },
          "email_thread_id": {
            "type": [
              "string",
              "null"
            ],
            "description": "The email thread open on the page (`emails.thread_id`, at most 255\ncharacters). Email Follow up drafts from this thread only, without\nthe customer's texts and other email threads; ignored by other modes\nand on SMS. Null, or a thread with no emails: the whole history."
          }
        },
        "additionalProperties": false
      },
      "ConversationSummary": {
        "type": "object",
        "description": "A support request as the inbox lists it.",
        "required": [
          "id",
          "status",
          "priority",
          "subject",
          "last_from_support",
          "last_message_at",
          "created_at",
          "unread",
          "user_id",
          "user_email",
          "company_id",
          "company_name"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "Conversation id."
          },
          "status": {
            "type": "string",
            "description": "`open` (the team owes an answer), `waiting` (on the client), `resolved`."
          },
          "category": {
            "type": [
              "string",
              "null"
            ],
            "description": "Request type (see `categories` of the bootstrap); null until set."
          },
          "priority": {
            "type": "string",
            "description": "`low`, `normal`, `high` or `urgent`."
          },
          "assignee_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "The team member handling it; null when unassigned."
          },
          "assignee_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "Their name."
          },
          "subject": {
            "type": "string",
            "description": "The first line of the first message."
          },
          "last_message": {
            "type": [
              "string",
              "null"
            ],
            "description": "The start of the latest message."
          },
          "last_from_support": {
            "type": "boolean",
            "description": "The latest message is the team's (an answer or a note)."
          },
          "last_message_at": {
            "type": "string",
            "format": "date-time",
            "description": "When the latest message was written."
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "description": "When the request began."
          },
          "unread": {
            "type": "boolean",
            "description": "The client wrote since the team last read it."
          },
          "user_id": {
            "type": "integer",
            "format": "int32",
            "description": "The client (user id)."
          },
          "user_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "The client's name."
          },
          "user_email": {
            "type": "string",
            "description": "The client's email."
          },
          "company_id": {
            "type": "integer",
            "format": "int32",
            "description": "The client's company."
          },
          "company_name": {
            "type": "string",
            "description": "Its name."
          }
        }
      },
      "ConversionCount": {
        "type": "object",
        "description": "Won deals out of all deals of one group.",
        "required": [
          "won",
          "created"
        ],
        "properties": {
          "won": {
            "type": "integer",
            "format": "int64",
            "description": "Deals marked won."
          },
          "created": {
            "type": "integer",
            "format": "int64",
            "description": "All deals, whatever their state."
          }
        }
      },
      "ConversionMetrics": {
        "type": "object",
        "description": "A rep's deals made and sold, by customer source.",
        "required": [
          "total_sold",
          "total_created",
          "leads_sold_same_month",
          "leads_created",
          "walkin_sold_same_month",
          "walkin_created",
          "callin_sold_same_month",
          "callin_created"
        ],
        "properties": {
          "rep_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "The rep's name."
          },
          "total_sold": {
            "type": "integer",
            "format": "int64",
            "description": "Won deals."
          },
          "total_created": {
            "type": "integer",
            "format": "int64",
            "description": "Deals made."
          },
          "leads_sold_same_month": {
            "type": "integer",
            "format": "int64",
            "description": "Leads' won deals."
          },
          "leads_created": {
            "type": "integer",
            "format": "int64",
            "description": "Leads' deals."
          },
          "walkin_sold_same_month": {
            "type": "integer",
            "format": "int64",
            "description": "Walk-ins' won deals."
          },
          "walkin_created": {
            "type": "integer",
            "format": "int64",
            "description": "Walk-ins' deals."
          },
          "callin_sold_same_month": {
            "type": "integer",
            "format": "int64",
            "description": "Call-ins' won deals."
          },
          "callin_created": {
            "type": "integer",
            "format": "int64",
            "description": "Call-ins' deals."
          }
        }
      },
      "ConvertedDeal": {
        "type": "object",
        "description": "`POST /v1/deals/{id}/project`.",
        "required": [
          "project_id",
          "created"
        ],
        "properties": {
          "project_id": {
            "type": "integer",
            "format": "int32",
            "description": "The project it belongs to."
          },
          "created": {
            "type": "boolean",
            "description": "False when the deal had a project already."
          }
        }
      },
      "CopiedUpload": {
        "type": "object",
        "description": "A picture copied into storage.",
        "required": [
          "url"
        ],
        "properties": {
          "url": {
            "type": "string",
            "description": "Public URL of the stored copy; use it in place of the original\naddress."
          }
        }
      },
      "CorrectionOut": {
        "type": "object",
        "description": "A corrected answer (`dislike`).",
        "required": [
          "correction",
          "attempt",
          "escalate"
        ],
        "properties": {
          "correction": {
            "type": "string",
            "description": "The corrected answer."
          },
          "attempt": {
            "type": "integer",
            "format": "int64",
            "description": "The attempt it answers."
          },
          "sectionId": {
            "type": [
              "string",
              "null"
            ],
            "description": "The manual section it belongs to."
          },
          "proposedManualChange": {
            "type": [
              "string",
              "null"
            ],
            "description": "The change it suggests for that section."
          },
          "escalate": {
            "type": "boolean",
            "description": "Always false."
          }
        }
      },
      "Count": {
        "type": "object",
        "description": "A reason (or objection) and how many deals had it.",
        "required": [
          "label",
          "deals"
        ],
        "properties": {
          "label": {
            "type": "string",
            "description": "The reason or objection."
          },
          "deals": {
            "type": "integer",
            "format": "int64",
            "description": "How many deals had it."
          }
        }
      },
      "Coworker": {
        "type": "object",
        "description": "A coworker the user can call: a user of the company with at least one\nphone number.",
        "required": [
          "userId",
          "name",
          "phones"
        ],
        "properties": {
          "userId": {
            "type": "integer",
            "format": "int32",
            "description": "User id."
          },
          "name": {
            "type": "string",
            "description": "Name (the email when the user has none)."
          },
          "e164": {
            "type": [
              "string",
              "null"
            ],
            "description": "Their first number (`phones[0]`), E.164; the one to call."
          },
          "label": {
            "type": [
              "string",
              "null"
            ],
            "description": "That number's label; null when empty."
          },
          "phones": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CoworkerPhone"
            },
            "description": "Every number they have, first the Granite Manager direct lines, then\nRingCentral, CloudTalk and their own phone; no number twice."
          }
        }
      },
      "CoworkerPhone": {
        "type": "object",
        "description": "One of a coworker's numbers.",
        "required": [
          "e164"
        ],
        "properties": {
          "e164": {
            "type": "string",
            "description": "The number, E.164."
          },
          "label": {
            "type": [
              "string",
              "null"
            ],
            "description": "What it is: a direct line's own label (null when it has none),\n`Work` (their `RingCentral` number), `Office` (their `CloudTalk`\nnumber) or `Mobile` (their own phone). The app never names the provider."
          }
        }
      },
      "CoworkersChange": {
        "type": "object",
        "description": "Body of `PATCH /v1/phone/contact-groups/coworkers`.",
        "required": [
          "hidden"
        ],
        "properties": {
          "hidden": {
            "type": "boolean",
            "description": "True hides Coworkers from the top of my Contacts, false shows it\nagain. Only for me."
          }
        }
      },
      "CreateCrewChecklistInput": {
        "type": "object",
        "description": "Body of `POST /v1/crew-checklists`.",
        "required": [
          "kind",
          "name"
        ],
        "properties": {
          "kind": {
            "$ref": "#/components/schemas/CrewChecklistKind",
            "description": "Whose it is."
          },
          "name": {
            "type": "string",
            "description": "The name: 1 to 120 characters (trimmed)."
          },
          "items": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "The checks, in order: each 1 to 200 characters (trimmed; blank ones\nare dropped), at most 80."
          }
        }
      },
      "Created": {
        "type": "object",
        "description": "`POST /v1/schedule/notifications/templates` and `…/flows`.",
        "required": [
          "id"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int64",
            "description": "The new template or flow.",
            "minimum": 0
          }
        }
      },
      "CreatedCalendar": {
        "type": "object",
        "description": "`POST /v1/calendars`.",
        "required": [
          "id"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int64",
            "description": "The new calendar.",
            "minimum": 0
          }
        }
      },
      "CreatedCheck": {
        "type": "object",
        "description": "Response of adding a check.",
        "required": [
          "id"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "Check id."
          }
        }
      },
      "CreatedChecklist": {
        "type": "object",
        "description": "`POST /v1/checklists`.",
        "required": [
          "id"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int64",
            "description": "The new checklist.",
            "minimum": 0
          }
        }
      },
      "CreatedCustomer": {
        "type": "object",
        "description": "Result of `POST /v1/customers`.",
        "required": [
          "id"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "New customer id."
          },
          "deal_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int64",
            "description": "The open deal of an assigned customer."
          }
        }
      },
      "CreatedDeal": {
        "type": "object",
        "description": "A deal created for the customer.",
        "required": [
          "id"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int64",
            "description": "Deal id."
          },
          "created_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When."
          },
          "created_by": {
            "type": [
              "string",
              "null"
            ],
            "description": "By whom (name)."
          }
        }
      },
      "CreatedEvent": {
        "type": "object",
        "description": "`POST /v1/events`.",
        "required": [
          "id"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int64",
            "description": "The new event.",
            "minimum": 0
          }
        }
      },
      "CreatedFlow": {
        "type": "object",
        "description": "`POST /v1/sms-flows`.",
        "required": [
          "id"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "The new flow."
          }
        }
      },
      "CreatedId": {
        "type": "object",
        "description": "The id of the row just created.",
        "required": [
          "id"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int64",
            "description": "Id of the new row."
          }
        }
      },
      "CreatedInstruction": {
        "type": "object",
        "description": "`{ id }` of a new instruction.",
        "required": [
          "id"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "The new instruction."
          }
        }
      },
      "CreatedLead": {
        "type": "object",
        "description": "Response of creating a lead.",
        "required": [
          "id"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "Customer id."
          }
        }
      },
      "CreatedMaterial": {
        "type": "object",
        "description": "Response of `POST /v1/stones/materials`.",
        "required": [
          "id"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "Id of the new material."
          }
        }
      },
      "CreatedModel": {
        "type": "object",
        "description": "Response of the create routes.",
        "required": [
          "id"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "Id of the new model."
          }
        }
      },
      "CreatedSale": {
        "type": "object",
        "description": "Response of `POST /v1/sales`.",
        "required": [
          "id"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "Id of the new sale."
          }
        }
      },
      "CreatedSaleEvent": {
        "type": "object",
        "description": "`POST /v1/quote-sale-events`.",
        "required": [
          "id"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int64",
            "description": "The new template.",
            "minimum": 0
          }
        }
      },
      "CreatedSlab": {
        "type": "object",
        "description": "A slab just added.",
        "required": [
          "id",
          "bundle",
          "length",
          "width"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int64",
            "description": "Slab id."
          },
          "bundle": {
            "type": "string",
            "description": "Bundle label."
          },
          "url": {
            "type": [
              "string",
              "null"
            ],
            "description": "Photo URL; null when none."
          },
          "length": {
            "type": "string",
            "description": "Length in inches as stored, e.g. \"110\"."
          },
          "width": {
            "type": "string",
            "description": "Width in inches as stored."
          }
        }
      },
      "CreatedSource": {
        "type": "object",
        "description": "`POST /v1/customer-sources`.",
        "required": [
          "id"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int64",
            "description": "The new source.",
            "minimum": 0
          }
        }
      },
      "CreatedStone": {
        "type": "object",
        "description": "Response of `POST /v1/stones`.",
        "required": [
          "id"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "Id of the new stone."
          }
        }
      },
      "CreatedTodo": {
        "type": "object",
        "description": "`POST /v1/me/todos`.",
        "required": [
          "id"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "The new to-do."
          }
        }
      },
      "CreatedType": {
        "type": "object",
        "description": "`POST /v1/customer-types`.",
        "required": [
          "id"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int64",
            "description": "The new type.",
            "minimum": 0
          }
        }
      },
      "CreatedUser": {
        "type": "object",
        "description": "A new user and their invite.",
        "required": [
          "id",
          "invite_url",
          "email_sent"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "The new user."
          },
          "invite_url": {
            "type": "string",
            "description": "The invite link, to share another way if the email does not arrive."
          },
          "email_sent": {
            "type": "boolean",
            "description": "The invite was emailed to them."
          }
        }
      },
      "CredentialsSource": {
        "type": "string",
        "description": "Where the app's credentials come from.",
        "enum": [
          "company-app",
          "shared-app",
          "none"
        ]
      },
      "Credit": {
        "type": "object",
        "description": "Setup tasks credited by this request.",
        "required": [
          "task_ids",
          "state"
        ],
        "properties": {
          "task_ids": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "The tasks now completed."
          },
          "state": {
            "$ref": "#/components/schemas/OnboardingState",
            "description": "The saved state after the credit."
          }
        }
      },
      "CrewButton": {
        "type": "string",
        "description": "What the crew taps.",
        "enum": [
          "on_my_way",
          "completed",
          "paid"
        ]
      },
      "CrewChecklist": {
        "type": "object",
        "description": "A list of checks.",
        "required": [
          "id",
          "kind",
          "name",
          "items"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "The list's id."
          },
          "kind": {
            "$ref": "#/components/schemas/CrewChecklistKind",
            "description": "Whose it is."
          },
          "name": {
            "type": "string",
            "description": "Its name, e.g. \"Kitchen template\"."
          },
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CrewChecklistItem"
            },
            "description": "Its checks, in order."
          }
        }
      },
      "CrewChecklistItem": {
        "type": "object",
        "description": "One check on a list.",
        "required": [
          "id",
          "label"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "The check's id."
          },
          "label": {
            "type": "string",
            "description": "What to check, e.g. \"Measure the sink cabinet\"."
          }
        }
      },
      "CrewChecklistKind": {
        "type": "string",
        "description": "Whose checklist it is.",
        "enum": [
          "template",
          "install"
        ]
      },
      "CrewMember": {
        "type": "object",
        "description": "Someone on a project's template or installation.",
        "required": [
          "user_id",
          "kind"
        ],
        "properties": {
          "user_id": {
            "type": "integer",
            "format": "int32",
            "description": "The crew member (`users.id`)."
          },
          "kind": {
            "type": "string",
            "description": "`templates` or `installations`."
          }
        }
      },
      "CrewPaymentForm": {
        "type": "object",
        "description": "`GET /v1/qbo/invoices/{invoice_id}/crew-payment`.",
        "required": [
          "methods"
        ],
        "properties": {
          "balance": {
            "type": [
              "number",
              "null"
            ],
            "format": "double",
            "description": "What the customer still owes on the invoice."
          },
          "methods": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PaymentMethodOption"
            },
            "description": "The company's `QuickBooks` payment methods, by name."
          }
        }
      },
      "CrewPaymentInput": {
        "type": "object",
        "description": "Body of `POST /v1/qbo/invoices/{invoice_id}/crew-payment`.",
        "required": [
          "method_id",
          "request_id"
        ],
        "properties": {
          "amount": {
            "type": [
              "number",
              "null"
            ],
            "format": "double",
            "description": "What the customer paid, in dollars; above 0, at most the balance.\nLeft out: the whole open balance."
          },
          "method_id": {
            "type": "string",
            "description": "The `QuickBooks` payment method's id, from the form's `methods`."
          },
          "reference": {
            "type": [
              "string",
              "null"
            ],
            "description": "A check number or other reference; at most 21 characters."
          },
          "request_id": {
            "type": "string",
            "description": "Kept by the app while it retries one payment (letters, digits, `-`)."
          }
        }
      },
      "CrewPaymentSaved": {
        "type": "object",
        "description": "`POST /v1/qbo/invoices/{invoice_id}/crew-payment`.",
        "properties": {
          "balance": {
            "type": [
              "number",
              "null"
            ],
            "format": "double",
            "description": "What the customer still owes now."
          }
        }
      },
      "CrewPosition": {
        "type": "object",
        "description": "An installer or template maker and where their phone last was.",
        "required": [
          "user_id",
          "name",
          "role",
          "at_shop"
        ],
        "properties": {
          "user_id": {
            "type": "integer",
            "format": "int32",
            "description": "Their user id."
          },
          "name": {
            "type": "string",
            "description": "Their name."
          },
          "role": {
            "type": "string",
            "description": "`installer` or `template`."
          },
          "latitude": {
            "type": [
              "number",
              "null"
            ],
            "format": "double",
            "description": "Degrees; null when their phone never sent a position."
          },
          "longitude": {
            "type": [
              "number",
              "null"
            ],
            "format": "double",
            "description": "Degrees; null when their phone never sent a position."
          },
          "recorded_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When the phone sent it."
          },
          "at_shop": {
            "type": "boolean",
            "description": "They are at the shop."
          },
          "place_event_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "The job they are at."
          },
          "place_title": {
            "type": [
              "string",
              "null"
            ],
            "description": "That job's title."
          },
          "place_since": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "Since when they are at the shop or that job."
          }
        }
      },
      "CrewStatus": {
        "type": "string",
        "description": "The crew's progress on a job.",
        "enum": [
          "on_my_way",
          "arrived",
          "completed"
        ]
      },
      "CrewStatusInput": {
        "type": "object",
        "description": "Body of `POST /v1/events/{id}/crew-status`.",
        "required": [
          "status"
        ],
        "properties": {
          "status": {
            "$ref": "#/components/schemas/CrewButton",
            "description": "`on_my_way` (today's jobs), `completed`, or `paid` (a completed job)."
          }
        }
      },
      "CrewStatusSaved": {
        "type": "object",
        "description": "`POST /v1/events/{id}/crew-status`.",
        "required": [
          "status"
        ],
        "properties": {
          "status": {
            "$ref": "#/components/schemas/CrewStatus",
            "description": "The job's status now."
          },
          "customer_told": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/Channel",
                "description": "On my way: how the customer was told just now (`sms` or `email`);\nnull when nothing went out."
              },
              {
                "type": "null"
              }
            ]
          },
          "message_error": {
            "type": [
              "string",
              "null"
            ],
            "description": "On my way: why the customer was not told, for the crew to read."
          }
        }
      },
      "CrmInvoice": {
        "type": "object",
        "description": "A whole invoice.",
        "required": [
          "id",
          "invoice_number",
          "status",
          "invoice_date",
          "bill_to_name",
          "lines",
          "subtotal",
          "tax",
          "total",
          "paid",
          "balance"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "Invoice id."
          },
          "invoice_number": {
            "type": "integer",
            "format": "int32",
            "description": "Invoice number, unique in the company."
          },
          "status": {
            "$ref": "#/components/schemas/InvoiceStatus",
            "description": "`draft`, `sent`, `partial`, `paid` or `void`."
          },
          "customer_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "The CRM customer billed; null when the invoice bills someone else."
          },
          "customer_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "That customer's current name in the CRM; null without a customer."
          },
          "quote_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "The quote it was made from; null for an invoice made by hand."
          },
          "quote_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "That quote's name; null without a quote."
          },
          "invoice_date": {
            "type": "string",
            "description": "Invoice date, `YYYY-MM-DD`."
          },
          "due_date": {
            "type": [
              "string",
              "null"
            ],
            "description": "Due date, `YYYY-MM-DD`; null when due on receipt."
          },
          "bill_to_name": {
            "type": "string",
            "description": "Name under \"Bill to\"."
          },
          "bill_to_email": {
            "type": [
              "string",
              "null"
            ],
            "description": "Email it is sent to; null when none."
          },
          "project_address": {
            "type": [
              "string",
              "null"
            ],
            "description": "Job site address; null when none."
          },
          "lines": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/InvoiceLine"
            },
            "description": "The lines, in order."
          },
          "subtotal": {
            "type": "number",
            "format": "double",
            "description": "Sum of the line amounts, in dollars."
          },
          "tax": {
            "type": "number",
            "format": "double",
            "description": "Sales tax, in dollars."
          },
          "total": {
            "type": "number",
            "format": "double",
            "description": "`subtotal` + `tax`, in dollars."
          },
          "paid": {
            "type": "number",
            "format": "double",
            "description": "What is paid on it, in dollars: its recorded payments, or the whole\ntotal once it is marked paid."
          },
          "balance": {
            "type": "number",
            "format": "double",
            "description": "What is still owed, in dollars; 0 when paid or void."
          },
          "customer_memo": {
            "type": [
              "string",
              "null"
            ],
            "description": "Message to the customer printed on the invoice; null when none."
          },
          "private_note": {
            "type": [
              "string",
              "null"
            ],
            "description": "Internal note, never printed; null when none."
          },
          "payment_method": {
            "type": [
              "string",
              "null"
            ],
            "description": "How the customer will pay; null when none is picked."
          },
          "sent_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When it was first sent (ISO 8601, UTC); null while a draft."
          },
          "paid_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When it was marked paid (ISO 8601, UTC); null unless `paid`."
          },
          "created_by_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "Name of the user who created it; null when unknown."
          },
          "created_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When it was created (ISO 8601, UTC)."
          },
          "updated_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When it last changed (ISO 8601, UTC)."
          }
        }
      },
      "CustomFieldValue": {
        "type": "object",
        "description": "One custom field of an invoice.",
        "required": [
          "definition_id",
          "value"
        ],
        "properties": {
          "definition_id": {
            "type": "string",
            "description": "`QuickBooks`' id of the field."
          },
          "name": {
            "type": [
              "string",
              "null"
            ],
            "description": "Its name, e.g. \"Room & Color\"."
          },
          "value": {
            "type": "string",
            "description": "The text (at most 31 characters are kept)."
          }
        }
      },
      "CustomerChecklist": {
        "type": "object",
        "description": "A list of to-dos the template maker picks from.",
        "required": [
          "id",
          "name",
          "items"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "The list's id."
          },
          "name": {
            "type": "string",
            "description": "Its name, e.g. \"Before install\"."
          },
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CustomerChecklistItem"
            },
            "description": "Its to-dos, in order."
          }
        }
      },
      "CustomerChecklistInput": {
        "type": "object",
        "description": "Body of `POST /v1/customer-checklists` and `PUT /v1/customer-checklists/{id}`.",
        "required": [
          "name"
        ],
        "properties": {
          "name": {
            "type": "string",
            "description": "The name: 1 to 120 characters (trimmed)."
          },
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ChecklistItemInput"
            },
            "description": "The to-dos, in order: each 1 to 200 characters (trimmed; blank ones\nare dropped), at most 60, each a string or `{label, assigned_user_id}`.\nSaving replaces the list's to-dos; to-dos already sent to customers\nstay as they are."
          }
        }
      },
      "CustomerChecklistItem": {
        "type": "object",
        "description": "One to-do on a list.",
        "required": [
          "id",
          "label"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "The to-do's id."
          },
          "label": {
            "type": "string",
            "description": "What the customer must do, e.g. \"Level the cabinets\"."
          },
          "assigned_user_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Who follows it up; null means the job's sales rep."
          }
        }
      },
      "CustomerDeal": {
        "type": "object",
        "description": "A deal of a customer, with a preview of its notes and activities.",
        "required": [
          "id",
          "notes",
          "activities"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int64",
            "description": "Deal id."
          },
          "title": {
            "type": [
              "string",
              "null"
            ],
            "description": "Short name of the job."
          },
          "status": {
            "type": [
              "string",
              "null"
            ],
            "description": "Stage name when the deal last moved."
          },
          "amount": {
            "type": [
              "string",
              "null"
            ],
            "description": "Expected value, a decimal string."
          },
          "list_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "Name of the deal's current stage."
          },
          "is_won": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "1 won, 0 lost, null still open."
          },
          "notes": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/NotePreview"
            },
            "description": "Up to two notes, pinned first, then newest."
          },
          "activities": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ActivityPreview"
            },
            "description": "Up to two activities, unfinished first, then by deadline."
          }
        }
      },
      "CustomerDetail": {
        "type": "object",
        "description": "One customer with contact details, as the customer picker shows it.",
        "required": [
          "id",
          "emails",
          "lead"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "Customer id."
          },
          "name": {
            "type": [
              "string",
              "null"
            ],
            "description": "Contact person's name."
          },
          "address": {
            "type": [
              "string",
              "null"
            ],
            "description": "Billing address."
          },
          "phone": {
            "type": [
              "string",
              "null"
            ],
            "description": "Main phone number."
          },
          "phone_2": {
            "type": [
              "string",
              "null"
            ],
            "description": "Second phone number."
          },
          "email": {
            "type": [
              "string",
              "null"
            ],
            "description": "Primary email address; null when the customer has none."
          },
          "emails": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Every email address, primary first."
          },
          "company_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "Company name for business customers; null or empty for private ones."
          },
          "source": {
            "type": [
              "string",
              "null"
            ],
            "description": "Where the lead came from, e.g. `leads`, `check-in`, `other`."
          },
          "referral_source": {
            "type": [
              "string",
              "null"
            ],
            "description": "Referral source, free text."
          },
          "your_message": {
            "type": [
              "string",
              "null"
            ],
            "description": "Message the customer left when signing up."
          },
          "sales_rep": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Assigned sales rep (user id); null when unassigned."
          },
          "sales_rep_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "Name of the assigned sales rep; null when unassigned or deleted."
          },
          "city": {
            "type": [
              "string",
              "null"
            ],
            "description": "City of the address."
          },
          "state": {
            "type": [
              "string",
              "null"
            ],
            "description": "State of the address."
          },
          "postal_code": {
            "type": [
              "string",
              "null"
            ],
            "description": "ZIP code."
          },
          "customer_temperature": {
            "type": [
              "string",
              "null"
            ],
            "description": "Lead temperature: `hot`, `medium`, `cold`, or null."
          },
          "notes": {
            "type": [
              "string",
              "null"
            ],
            "description": "Internal notes about the customer."
          },
          "qbo_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "QuickBooks customer id when linked."
          },
          "attached_file": {
            "type": [
              "string",
              "null"
            ],
            "description": "File the lead attached to the web form (URL)."
          },
          "created_date": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When the customer was created."
          },
          "invalid_lead": {
            "type": [
              "string",
              "null"
            ],
            "description": "Why the lead was marked invalid; null or empty for a valid one."
          },
          "customer_type_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "The company's customer type of this customer (`GET /v1/customer-types`)."
          },
          "customer_type": {
            "type": [
              "string",
              "null"
            ],
            "description": "That type's name."
          },
          "lead": {
            "$ref": "#/components/schemas/LeadAnswers",
            "description": "Lead form answers, as the lead sources send them (free text)."
          }
        }
      },
      "CustomerFile": {
        "type": "object",
        "description": "A file kept on a customer.",
        "required": [
          "id",
          "name",
          "kind",
          "url"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int64",
            "description": "The file."
          },
          "name": {
            "type": "string",
            "description": "Its name."
          },
          "kind": {
            "type": "string",
            "description": "`invoice`, `signed_contract`, `signed_invoice` or `upload`."
          },
          "label": {
            "type": [
              "string",
              "null"
            ],
            "description": "What it belongs to, e.g. `Quote #11934` or `Invoice #11162`."
          },
          "file_date": {
            "type": [
              "string",
              "null"
            ],
            "description": "Its date (`YYYY-MM-DD`)."
          },
          "url": {
            "type": "string",
            "description": "Where to open it."
          }
        }
      },
      "CustomerHistory": {
        "type": "object",
        "description": "Everything the customer dialog shows besides the contact details\n(`GET /v1/customers/{id}`).",
        "required": [
          "deals",
          "reassignments",
          "created_deals",
          "deleted_deals",
          "closed_deals",
          "emails",
          "activities",
          "notes"
        ],
        "properties": {
          "created_by": {
            "type": [
              "string",
              "null"
            ],
            "description": "Who created the customer (name), if recorded."
          },
          "assigned_date": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When the customer was first assigned to a sales rep."
          },
          "deleted_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When the customer was deleted; null when live."
          },
          "parent_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Parent customer (a project of another customer)."
          },
          "first_rep_deal_created_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When the first live deal was created (the lead reached a sales rep)."
          },
          "initial_sales_rep_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "Sales rep of that first deal."
          },
          "deals": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/HistoryDeal"
            },
            "description": "Live deals in live stages, newest first."
          },
          "reassignments": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Reassignment"
            },
            "description": "Reassignments of the customer, oldest first."
          },
          "created_deals": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CreatedDeal"
            },
            "description": "Every deal ever made for the customer, oldest first."
          },
          "deleted_deals": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/DeletedDeal"
            },
            "description": "Deleted deals."
          },
          "closed_deals": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ClosedDeal"
            },
            "description": "Won or lost deals."
          },
          "emails": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/HistoryEmail"
            },
            "description": "Email history (by address and as a participant), newest first."
          },
          "activities": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/HistoryActivity"
            },
            "description": "Activities of the live deals, latest first."
          },
          "notes": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/HistoryNote"
            },
            "description": "Notes of the live deals, pinned first, with comments."
          }
        }
      },
      "CustomerInput": {
        "type": "object",
        "description": "Body of `POST /v1/customers` and `PUT /v1/customers/{id}`.",
        "required": [
          "name",
          "source"
        ],
        "properties": {
          "name": {
            "type": "string",
            "description": "Contact name (required, at most 255 characters)."
          },
          "phone": {
            "type": [
              "string",
              "null"
            ],
            "description": "Main phone (at most 50 characters)."
          },
          "phone_2": {
            "type": [
              "string",
              "null"
            ],
            "description": "Second phone (at most 255 characters)."
          },
          "emails": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Every email address, primary first (replaces the saved ones); each at\nmost 255 characters."
          },
          "address": {
            "type": [
              "string",
              "null"
            ],
            "description": "Address (empty, or 3 to 255 characters)."
          },
          "your_message": {
            "type": [
              "string",
              "null"
            ],
            "description": "The customer's message (at most 65,535 bytes)."
          },
          "company_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "Company of a business customer (at most 255 characters)."
          },
          "referral_source": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/ReferralSource",
                "description": "How they heard of the company (create only)."
              },
              {
                "type": "null"
              }
            ]
          },
          "source": {
            "type": "string",
            "description": "Lead source: built in (`check-in`, `leads`, `call-in`, `other`) or one\nof the company's sources (1–255 characters)."
          },
          "sales_rep": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Assigned sales rep (user id), or null."
          },
          "customer_type_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "One of the company's customer types (`GET /v1/customer-types`), or\nnull for none. Left out: an update keeps the saved type."
          }
        },
        "additionalProperties": false
      },
      "CustomerInvoices": {
        "type": "object",
        "description": "`GET /v1/customers/{id}/qbo-invoices`.",
        "required": [
          "status",
          "invoices"
        ],
        "properties": {
          "status": {
            "$ref": "#/components/schemas/InvoicesStatus"
          },
          "invoices": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/InvoiceSummary"
            },
            "description": "Newest first."
          },
          "qbo_id": {
            "type": [
              "string",
              "null"
            ],
            "description": "The `QuickBooks` customer id."
          },
          "synced_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When our copy of the invoices last took `QuickBooks`' changes; null\nwhen the list was read from `QuickBooks` itself."
          }
        }
      },
      "CustomerOnlineQuote": {
        "type": "object",
        "description": "One of a customer's online quotes, as their own page shows it.",
        "required": [
          "id",
          "name",
          "doc",
          "prices"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "Quote id."
          },
          "name": {
            "type": "string",
            "description": "Its name."
          },
          "created_date": {
            "type": [
              "string",
              "null"
            ],
            "description": "When it was made (ISO 8601, UTC)."
          },
          "expiration_date": {
            "type": [
              "string",
              "null"
            ],
            "description": "Prices good until (YYYY-MM-DD)."
          },
          "doc": {
            "type": "object",
            "description": "The drawing (the quote document, no supplier costs): its `counters`\nare the pieces."
          },
          "prices": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/OnlinePrice"
            },
            "description": "Each color's total, as on the quote; no breakdown."
          },
          "sent_at": {
            "type": [
              "string",
              "null"
            ],
            "description": "When the company last emailed or printed the quote (ISO 8601, UTC);\nnull until it has. The customer's own emailed copy does not count."
          },
          "sent_doc": {
            "type": [
              "object",
              "null"
            ],
            "description": "The drawing as the company last emailed or printed it (the quote\ndocument, no supplier costs); null until it has."
          }
        }
      },
      "CustomerPayment": {
        "type": "object",
        "description": "One payment, or payment link, of a customer's job.",
        "required": [
          "id",
          "project_key",
          "method",
          "status",
          "amount_cents",
          "fee_cents",
          "customer_fee_cents",
          "customer_fee_bps",
          "company_fee_cents",
          "refunded_cents",
          "url",
          "created_at"
        ],
        "properties": {
          "id": {
            "type": "string",
            "description": "The payment's id (`pay_...`), also the last part of its link."
          },
          "project_key": {
            "type": "string",
            "description": "The job it is for, as `GET /v1/customers/{id}/projects` lists them:\n`deal-<deal id>`, or `sale-<sale id>` for a sale that is not part of\na deal; `invoice-<QuickBooks invoice id>` for a payment taken for one\n`QuickBooks` invoice."
          },
          "method": {
            "$ref": "#/components/schemas/PaymentMethod",
            "description": "How the customer pays."
          },
          "status": {
            "$ref": "#/components/schemas/CustomerPaymentStatus",
            "description": "Where the payment is."
          },
          "amount_cents": {
            "type": "integer",
            "format": "int32",
            "description": "What goes toward the job, in US cents."
          },
          "fee_cents": {
            "type": "integer",
            "format": "int32",
            "description": "The whole fee on it, in US cents, as split when the link was made."
          },
          "customer_fee_cents": {
            "type": "integer",
            "format": "int32",
            "description": "The part of the fee added to what the customer pays."
          },
          "customer_fee_bps": {
            "type": "integer",
            "format": "int32",
            "description": "The customer's share of the fee in basis points (50 = 0.5%), as set\nwhen the link was made."
          },
          "company_fee_cents": {
            "type": "integer",
            "format": "int32",
            "description": "The part of the fee taken from what the company receives."
          },
          "refunded_cents": {
            "type": "integer",
            "format": "int32",
            "description": "What was given back of what the customer was charged, in US cents: 0\nunless refunded. Above 0 on a `paid` payment, it was refunded in part."
          },
          "url": {
            "type": "string",
            "description": "The page the customer pays on. It never expires."
          },
          "failure_reason": {
            "type": [
              "string",
              "null"
            ],
            "description": "Why it failed, as a short plain phrase of our own, never Stripe's\ntext (\"insufficient funds\", \"the bank account is closed\", \"the bank\ndeclined the transfer\"); null unless `failed`."
          },
          "created_at": {
            "type": "string",
            "description": "When the link was made (ISO 8601, UTC)."
          }
        }
      },
      "CustomerPaymentStatus": {
        "type": "string",
        "description": "Where a payment is.",
        "enum": [
          "created",
          "canceled",
          "pending",
          "paid",
          "failed",
          "refunded",
          "disputed",
          "lost"
        ]
      },
      "CustomerProjects": {
        "type": "object",
        "description": "The projects of a customer's family.",
        "required": [
          "parent_id",
          "customers"
        ],
        "properties": {
          "parent_id": {
            "type": "integer",
            "format": "int32",
            "description": "The parent of the family (the customer itself when it has none)."
          },
          "customers": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ProjectCustomer"
            },
            "description": "The parent and its projects, by name."
          }
        }
      },
      "CustomerRow": {
        "type": "object",
        "description": "One row of the customers table. Field names match the Remix\n`CustomersListCustomer` type exactly, including `customerTemperature`.",
        "required": [
          "id"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "Customer id."
          },
          "name": {
            "type": [
              "string",
              "null"
            ],
            "description": "Contact person's name."
          },
          "email": {
            "type": [
              "string",
              "null"
            ],
            "description": "Primary email address; all addresses come from\n`POST /v1/customers/emails/batch`."
          },
          "phone": {
            "type": [
              "string",
              "null"
            ],
            "description": "Main phone number."
          },
          "phone_2": {
            "type": [
              "string",
              "null"
            ],
            "description": "Secondary phone number."
          },
          "address": {
            "type": [
              "string",
              "null"
            ],
            "description": "Street address."
          },
          "sales_rep": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "User id of the assigned sales rep."
          },
          "created_date": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When the customer was created."
          },
          "assigned_date": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When the current sales rep was assigned."
          },
          "sales_rep_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "Name of the assigned sales rep; null if unassigned or the rep was deleted."
          },
          "company_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Company (tenant) the customer belongs to."
          },
          "source": {
            "type": [
              "string",
              "null"
            ],
            "description": "Lead source, e.g. a website form or referral."
          },
          "invalid_lead": {
            "type": [
              "string",
              "null"
            ],
            "description": "Reason the lead was marked invalid. Null or empty means valid."
          },
          "company_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "Business name when the customer is a company (contractor, designer...)."
          },
          "customerTemperature": {
            "type": [
              "string",
              "null"
            ],
            "description": "Lead temperature: `hot`, `medium` or `cold`; null if not set."
          }
        }
      },
      "CustomerSale": {
        "type": "object",
        "description": "A sale to the customer, as the customer view lists it.",
        "required": [
          "id",
          "cancelled"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "Sale id."
          },
          "sale_date": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When it was sold."
          },
          "price": {
            "type": [
              "string",
              "null"
            ],
            "description": "Price, a decimal string."
          },
          "seller_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "Seller's name."
          },
          "deal_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int64",
            "description": "The deal the sale is part of."
          },
          "cancelled": {
            "type": "boolean",
            "description": "Unsold (the slabs went back to stock)."
          }
        }
      },
      "CustomerSales": {
        "type": "object",
        "description": "A customer's sales to the rep this month.",
        "required": [
          "name",
          "amount",
          "invoices"
        ],
        "properties": {
          "name": {
            "type": "string",
            "description": "Customer name as `QuickBooks` has it."
          },
          "amount": {
            "type": "number",
            "format": "double",
            "description": "Sales this month."
          },
          "qbo_customer_id": {
            "type": [
              "string",
              "null"
            ],
            "description": "`QuickBooks` customer id."
          },
          "invoices": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SalesInvoice"
            },
            "description": "This month's invoices, oldest first."
          }
        }
      },
      "CustomerSearchRow": {
        "type": "object",
        "description": "A customer matching a search, with their latest deal.",
        "required": [
          "id",
          "emails"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "Customer id."
          },
          "name": {
            "type": [
              "string",
              "null"
            ],
            "description": "Contact person's name."
          },
          "address": {
            "type": [
              "string",
              "null"
            ],
            "description": "Billing address."
          },
          "city": {
            "type": [
              "string",
              "null"
            ],
            "description": "City of the address."
          },
          "state": {
            "type": [
              "string",
              "null"
            ],
            "description": "State of the address."
          },
          "postal_code": {
            "type": [
              "string",
              "null"
            ],
            "description": "ZIP code."
          },
          "phone": {
            "type": [
              "string",
              "null"
            ],
            "description": "Main phone number."
          },
          "phone_2": {
            "type": [
              "string",
              "null"
            ],
            "description": "Second phone number."
          },
          "email": {
            "type": [
              "string",
              "null"
            ],
            "description": "Primary email address."
          },
          "emails": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Every email address, primary first."
          },
          "company_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "Company name for business customers."
          },
          "deal_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int64",
            "description": "The customer's most recent live deal; null when none."
          },
          "deal_is_won": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "That deal's outcome: 1 won, 0 lost, null open or no deal."
          },
          "deal_group_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Board group of that deal's list; null when there is no deal."
          }
        }
      },
      "CustomerSource": {
        "type": "object",
        "description": "A customer source.",
        "required": [
          "id",
          "source_key",
          "label",
          "is_system",
          "is_walkin"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int64",
            "description": "The source."
          },
          "source_key": {
            "type": "string",
            "description": "Stored on customers (`customers.source`)."
          },
          "label": {
            "type": "string",
            "description": "Shown in the dropdown."
          },
          "is_system": {
            "type": "boolean",
            "description": "Built in: can be renamed but not deleted."
          },
          "is_walkin": {
            "type": "boolean",
            "description": "Counts as a walk-in (Walk-in filter, walk-in statistics). The\nbuilt-in walk-in always does, whatever this says."
          }
        }
      },
      "CustomerTodo": {
        "type": "object",
        "description": "One to-do of one customer.",
        "required": [
          "id",
          "customer_id",
          "label"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "The to-do's id."
          },
          "customer_id": {
            "type": "integer",
            "format": "int32",
            "description": "The customer who must do it."
          },
          "event_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "The template appointment it came from; null once that is deleted."
          },
          "project_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "The project it is for; null when the customer had no open project."
          },
          "label": {
            "type": "string",
            "description": "What the customer must do."
          },
          "note": {
            "type": [
              "string",
              "null"
            ],
            "description": "The template maker's note, e.g. \"Island, 2 corbels on the seating side\"."
          },
          "created_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When it was sent (UTC)."
          },
          "created_by_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "The sender's user id; null once that user is gone."
          },
          "created_by": {
            "type": [
              "string",
              "null"
            ],
            "description": "The sender's name."
          },
          "done_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When it was ticked off (UTC); null while the customer still has to do it."
          },
          "done_by": {
            "type": [
              "string",
              "null"
            ],
            "description": "Who ticked it off."
          },
          "assigned_user_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Who follows it up; null for nobody."
          },
          "assigned_user_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "Their name."
          }
        }
      },
      "CustomerTodoDoneInput": {
        "type": "object",
        "description": "Body of `PUT /v1/customer-todos/{id}`.",
        "required": [
          "done"
        ],
        "properties": {
          "done": {
            "type": "boolean",
            "description": "Done, or not done again."
          }
        }
      },
      "CustomerTodoInput": {
        "type": "object",
        "description": "One to-do sent from a template appointment.",
        "required": [
          "label"
        ],
        "properties": {
          "label": {
            "type": "string",
            "description": "What the customer must do: 1 to 200 characters (trimmed)."
          },
          "note": {
            "type": [
              "string",
              "null"
            ],
            "description": "A note for the sales rep: at most 1000 characters; blank means none."
          },
          "assigned_user_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Who follows it up: someone in the company; null for the job's sales rep."
          }
        }
      },
      "CustomerType": {
        "type": "object",
        "description": "A customer type.",
        "required": [
          "id",
          "name"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "The type (`customers.customer_type_id`)."
          },
          "name": {
            "type": "string",
            "description": "Shown in the dropdown."
          }
        }
      },
      "CustomerViewPayments": {
        "type": "object",
        "description": "What the customer paid and still owes.",
        "required": [
          "enabled",
          "total_cents",
          "paid_cents",
          "pending_cents",
          "balance_cents",
          "projects",
          "payments",
          "can_pay",
          "card_fee_bps",
          "ach_fee_bps"
        ],
        "properties": {
          "enabled": {
            "type": "boolean",
            "description": "Customer payments are turned on for the company. While false the\ncustomer's page shows payments only when there are some (links made\nbefore it was turned off): no balance for a company that takes its\nmoney another way."
          },
          "total_cents": {
            "type": "integer",
            "format": "int64",
            "description": "What their jobs cost together (`projects`), in US cents."
          },
          "paid_cents": {
            "type": "integer",
            "format": "int64",
            "description": "What they paid through payment links, less what was refunded. A\ndisputed payment counts until the bank decides; a lost one does not."
          },
          "pending_cents": {
            "type": "integer",
            "format": "int64",
            "description": "ACH transfers on their way."
          },
          "balance_cents": {
            "type": "integer",
            "format": "int64",
            "description": "`total_cents` minus `paid_cents`, never below zero. Money paid\nanother way (a check, cash) is not counted."
          },
          "projects": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ViewJob"
            },
            "description": "Their jobs, oldest first: each deal that is won or has a sale, then\neach sale that is not part of such a deal. Cancelled sales are left\nout."
          },
          "payments": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ViewPayment"
            },
            "description": "Their payments and open payment links, newest first."
          },
          "can_pay": {
            "type": "boolean",
            "description": "The customer can pay on the page (`POST .../payments`): payments are\non and the company's bank account is connected."
          },
          "card_fee_bps": {
            "type": "integer",
            "format": "int32",
            "description": "The customer's part of the fee on a card payment, in basis points\n(300 = 3%, added on top), and of an ACH one."
          },
          "ach_fee_bps": {
            "type": "integer",
            "format": "int32"
          },
          "ach_fee_max_cents": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int64",
            "description": "The most the customer's part of an ACH fee can be, in US cents."
          }
        }
      },
      "CustomersByRep": {
        "type": "object",
        "description": "A rep's valid customers by source.",
        "required": [
          "walkin",
          "callin",
          "leads",
          "manual",
          "total"
        ],
        "properties": {
          "rep_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "The rep's name."
          },
          "walkin": {
            "type": "integer",
            "format": "int64",
            "description": "Walk-ins."
          },
          "callin": {
            "type": "integer",
            "format": "int64",
            "description": "Call-ins."
          },
          "leads": {
            "type": "integer",
            "format": "int64",
            "description": "Leads."
          },
          "manual": {
            "type": "integer",
            "format": "int64",
            "description": "Added by hand."
          },
          "total": {
            "type": "integer",
            "format": "int64",
            "description": "Customers."
          }
        }
      },
      "CustomersBySource": {
        "type": "object",
        "description": "Valid customers from a source.",
        "required": [
          "total"
        ],
        "properties": {
          "source": {
            "type": [
              "string",
              "null"
            ],
            "description": "Customer source (`leads`, `check-in`, ...)."
          },
          "total": {
            "type": "integer",
            "format": "int64",
            "description": "Customers."
          }
        }
      },
      "CustomersPage": {
        "type": "object",
        "description": "One page of the customers table.",
        "required": [
          "rows",
          "emails",
          "total",
          "page",
          "month_rows"
        ],
        "properties": {
          "rows": {
            "$ref": "#/components/schemas/ListResponse",
            "description": "The page's rows, shaped as in `GET /v1/customers`."
          },
          "emails": {
            "type": "object",
            "description": "Every email of the page's customers, primary first, keyed by customer id.",
            "additionalProperties": {
              "type": "array",
              "items": {
                "type": "string"
              }
            },
            "propertyNames": {
              "type": "string"
            }
          },
          "total": {
            "type": "integer",
            "format": "int64",
            "description": "Rows over all pages."
          },
          "page": {
            "type": "integer",
            "format": "int32",
            "description": "The page returned: the last one when `page` was past it.",
            "minimum": 0
          },
          "month_rows": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CustomerRow"
            },
            "description": "For the \"this month\" counts per sales rep: the tab's customers whose\ntab date falls in the current UTC month. Empty in the companies view\nand the `other` tab, which show no counts."
          }
        }
      },
      "CustomersStatus": {
        "type": "string",
        "description": "`ok`, `error` or `not_connected`.",
        "enum": [
          "ok",
          "error",
          "not_connected"
        ]
      },
      "CustomersTotals": {
        "type": "object",
        "description": "The company's customers.",
        "required": [
          "total",
          "without_rep",
          "invalid",
          "last_30"
        ],
        "properties": {
          "total": {
            "type": "integer",
            "format": "int64",
            "description": "Customers."
          },
          "without_rep": {
            "type": "integer",
            "format": "int64",
            "description": "Without a sales rep."
          },
          "invalid": {
            "type": "integer",
            "format": "int64",
            "description": "Marked invalid."
          },
          "last_30": {
            "type": "integer",
            "format": "int64",
            "description": "Added in the last 30 days."
          }
        }
      },
      "CutOptions": {
        "type": "object",
        "description": "Body of the cut and uncut operations.",
        "properties": {
          "with_remnants": {
            "type": "boolean",
            "description": "Admins and the shop: on cut, drop the slab's unsold remnants; on\nuncut, give the whole size back to its parent and remnants."
          }
        },
        "additionalProperties": false
      },
      "CutSlab": {
        "type": "object",
        "description": "A cut whole slab with its stone, supplier and sale.",
        "required": [
          "id",
          "stone_id",
          "supplier_id"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int64",
            "description": "Slab id."
          },
          "bundle": {
            "type": [
              "string",
              "null"
            ],
            "description": "Bundle label."
          },
          "stone_id": {
            "type": "integer",
            "format": "int32",
            "description": "Stone id."
          },
          "stone_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "Stone name."
          },
          "supplier_id": {
            "type": "integer",
            "format": "int32",
            "description": "Supplier id."
          },
          "supplier_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "Supplier name."
          },
          "cut_date": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When it was cut."
          },
          "sale_date": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When it was sold; null when the sale is missing."
          },
          "seller_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "Who sold it; null when unknown."
          }
        }
      },
      "CutStats": {
        "type": "object",
        "description": "Cutting over a range of days.",
        "required": [
          "start",
          "end",
          "days",
          "materials",
          "total_sqft"
        ],
        "properties": {
          "start": {
            "type": "string",
            "description": "The range used, `YYYY-MM-DD`."
          },
          "end": {
            "type": "string",
            "description": "The range used, `YYYY-MM-DD`."
          },
          "days": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/DayCut"
            },
            "description": "Days with cutting, oldest first."
          },
          "materials": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/MaterialSqft"
            },
            "description": "The whole range by material, most first."
          },
          "total_sqft": {
            "type": "number",
            "format": "double",
            "description": "Square feet over the range."
          }
        }
      },
      "DailySale": {
        "type": "object",
        "description": "One sale of the day.",
        "required": [
          "id",
          "sale_date",
          "stones",
          "sinks"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "Sale id; its sales order is `GET /v1/sales/{id}/contract`."
          },
          "sale_date": {
            "type": "string",
            "format": "date-time",
            "description": "When it was sold."
          },
          "customer_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Null for a sale without a customer."
          },
          "customer_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "The customer's name."
          },
          "seller_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "The sales rep who sold it."
          },
          "stones": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Stone colors of its slabs, by name."
          },
          "sinks": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SinkCount"
            },
            "description": "Sinks sold with it, by model."
          },
          "package": {
            "type": [
              "string",
              "null"
            ],
            "description": "The price list of the deal's quote (the signed one, else the newest);\nnull when the sale's deal has no quote."
          },
          "price": {
            "type": [
              "string",
              "null"
            ],
            "description": "Sale amount, decimal string in USD."
          },
          "deposit": {
            "type": [
              "string",
              "null"
            ],
            "description": "The deposit its sales order asks for: half of a price over $1,000,\nelse all of it. Decimal string in USD."
          },
          "signed_order": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/SignedOrder",
                "description": "The customer's signed contract (the one of the sale's deal first,\nelse the newest); null when nothing was signed."
              },
              {
                "type": "null"
              }
            ]
          }
        }
      },
      "DashboardLayout": {
        "type": "object",
        "description": "The signed-in user's dashboard layout in the company the request acts in.",
        "required": [
          "widget_ids"
        ],
        "properties": {
          "widget_ids": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/DashboardWidget"
            },
            "description": "Widgets in screen order. Empty when the user never saved a layout in\nthis company (show the default widgets) or removed every widget."
          }
        }
      },
      "DashboardStats": {
        "type": "object",
        "description": "`GET /v1/me/dashboard/stats`: the parts asked for; a part not asked for is\nabsent. Each part is exactly what its own route returns.",
        "properties": {
          "sales": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/SalesStats",
                "description": "`sales`: the signed-in user's deals this month, as\n`GET /v1/me/stats/sales`."
              },
              {
                "type": "null"
              }
            ]
          },
          "deal_conversion": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/DealConversion",
                "description": "`deal_conversion`: won out of all their deals by customer source, as\n`GET /v1/me/stats/deal-conversion`."
              },
              {
                "type": "null"
              }
            ]
          },
          "top_stones": {
            "type": [
              "array",
              "null"
            ],
            "items": {
              "$ref": "#/components/schemas/TopSoldStone"
            },
            "description": "`top_stones`: up to 3 stones they sold most this month, as\n`GET /v1/me/stats/top-stones`."
          },
          "sent_emails": {
            "type": [
              "array",
              "null"
            ],
            "items": {
              "$ref": "#/components/schemas/MonthlyCount"
            },
            "description": "`sent_emails`: emails they sent per month, as\n`GET /v1/me/stats/sent-emails`."
          },
          "sent_sms": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/SentSms",
                "description": "`sent_sms`: their texting provider and texts sent per month, as\n`GET /v1/me/stats/sent-sms`."
              },
              {
                "type": "null"
              }
            ]
          },
          "sales_goal": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/SalesGoal",
                "description": "`sales_goal`: their monthly sales goal, as `GET /v1/me/sales-goal`."
              },
              {
                "type": "null"
              }
            ]
          },
          "leaderboard": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/PointsLeaderboard",
                "description": "`leaderboard`: the company's points leaderboard over\n`leaderboard_period`, as `GET /v1/points-leaderboard`. While the\ncompany's leaderboard is switched off it is absent and named in\n`failed` (that route answers 404 then)."
              },
              {
                "type": "null"
              }
            ]
          },
          "failed": {
            "type": [
              "array",
              "null"
            ],
            "items": {
              "$ref": "#/components/schemas/StatsPart"
            },
            "description": "The parts asked for that could not be read this time, left out\nabove: ask their own routes, or again later. Absent when every part\nwas read. When every part asked fails the answer is the first part's\nerror instead."
          }
        }
      },
      "DashboardWidget": {
        "type": "string",
        "description": "A widget of the employee dashboard. Must match `EmployeeDashboardWidgetId`\nin the frontend (`app/utils/employeeDashboardWidgets.ts`).",
        "enum": [
          "unread-messages",
          "leaderboard",
          "call-coaching",
          "qbo-sales",
          "won-deals",
          "my-sales",
          "conversion-metrics",
          "quick-links",
          "onboarding",
          "top-sold-colors",
          "emails-per-month",
          "sms-per-month",
          "daily-sales",
          "available-inventory",
          "feature-sales",
          "outreach-activity"
        ]
      },
      "DayCut": {
        "type": "object",
        "description": "One day with cutting finished.",
        "required": [
          "day",
          "total",
          "materials"
        ],
        "properties": {
          "day": {
            "type": "string",
            "description": "The day, `YYYY-MM-DD`."
          },
          "total": {
            "type": "number",
            "format": "double",
            "description": "Square feet that day."
          },
          "materials": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/MaterialSqft"
            },
            "description": "By material, most first."
          }
        }
      },
      "DayMap": {
        "type": "object",
        "description": "`GET /v1/schedule/day-map`.",
        "required": [
          "stops"
        ],
        "properties": {
          "image": {
            "type": [
              "string",
              "null"
            ],
            "description": "PNG as a `data:` URL; null when nothing could be placed."
          },
          "home_address": {
            "type": [
              "string",
              "null"
            ],
            "description": "The company address the route starts from."
          },
          "home": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/Point",
                "description": "Where the company address is."
              },
              {
                "type": "null"
              }
            ]
          },
          "stops": {
            "type": "array",
            "items": {
              "oneOf": [
                {
                  "$ref": "#/components/schemas/Point"
                },
                {
                  "type": "null"
                }
              ]
            },
            "description": "Where each asked stop is, in order; null where it cannot be found."
          },
          "route": {
            "type": [
              "string",
              "null"
            ],
            "description": "The driving route from the company through the stops (Google encoded\npolyline); null when there is none."
          },
          "drives": {
            "type": "array",
            "items": {
              "type": [
                "integer",
                "null"
              ],
              "format": "int32",
              "minimum": 0
            },
            "description": "Minutes driving to each asked stop from the found stop before it;\nnull for the first stop or without a route. Empty when there is none."
          }
        }
      },
      "DealConversion": {
        "type": "object",
        "description": "How many of the signed-in user's deals were won, overall and by how the\ncustomer came in. All time; deals of deleted customers or in deleted lists\nare left out.",
        "required": [
          "total",
          "leads",
          "walk_in",
          "call_in"
        ],
        "properties": {
          "total": {
            "$ref": "#/components/schemas/ConversionCount",
            "description": "Every deal."
          },
          "leads": {
            "$ref": "#/components/schemas/ConversionCount",
            "description": "Customers from leads (`source = leads`)."
          },
          "walk_in": {
            "$ref": "#/components/schemas/ConversionCount",
            "description": "Walk-in customers: `source = check-in` or a source ticked as a walk-in."
          },
          "call_in": {
            "$ref": "#/components/schemas/ConversionCount",
            "description": "Customers who called in (`source = call-in`)."
          }
        }
      },
      "DealCreate": {
        "type": "object",
        "description": "Body of `POST /v1/deals`.",
        "required": [
          "customer_id",
          "list_id"
        ],
        "properties": {
          "customer_id": {
            "type": "integer",
            "format": "int32",
            "description": "Customer the deal is for."
          },
          "list_id": {
            "type": "integer",
            "format": "int32",
            "description": "Stage to put it in."
          },
          "title": {
            "type": [
              "string",
              "null"
            ],
            "description": "Short name of the job, at most 255 characters."
          },
          "amount": {
            "type": [
              "number",
              "null"
            ],
            "format": "double",
            "description": "Expected value in dollars, 0 to 99,999,999.99."
          },
          "position": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Order inside the stage. Default 1."
          },
          "outcome": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/DealStatus",
                "description": "Create it already closed: `won` or `lost`. Default `open`."
              },
              {
                "type": "null"
              }
            ]
          }
        }
      },
      "DealCreated": {
        "type": "object",
        "description": "Result of `POST /v1/deals`.",
        "required": [
          "id",
          "created"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int64",
            "description": "The new deal."
          },
          "created": {
            "type": "boolean",
            "description": "Always true: a create never reuses an existing deal."
          }
        }
      },
      "DealCustomer": {
        "type": "object",
        "description": "The customer a deal is for, as the board card shows it.",
        "required": [
          "id"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "Customer id."
          },
          "name": {
            "type": [
              "string",
              "null"
            ],
            "description": "Contact name."
          },
          "company_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "Company of the contact, when it is a business."
          },
          "temperature": {
            "type": [
              "string",
              "null"
            ],
            "description": "Lead temperature: `hot`, `medium`, `cold`, or null when unrated."
          }
        }
      },
      "DealDetail": {
        "type": "object",
        "description": "One deal in full.",
        "required": [
          "id",
          "list_id",
          "group_id",
          "position",
          "outcome",
          "customer_id",
          "customer_deal_count",
          "files_count"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int64",
            "description": "Deal id."
          },
          "title": {
            "type": [
              "string",
              "null"
            ],
            "description": "Short name of the job."
          },
          "amount": {
            "type": [
              "string",
              "null"
            ],
            "description": "Expected value in dollars, a decimal string, or null."
          },
          "list_id": {
            "type": "integer",
            "format": "int32",
            "description": "Current stage."
          },
          "group_id": {
            "type": "integer",
            "format": "int32",
            "description": "Group of the current stage (the deal's pipeline)."
          },
          "position": {
            "type": "integer",
            "format": "int32",
            "description": "Order inside the stage."
          },
          "outcome": {
            "$ref": "#/components/schemas/DealStatus",
            "description": "`open`, `won` or `lost`."
          },
          "lost_reason": {
            "type": [
              "string",
              "null"
            ],
            "description": "Why a lost deal was lost."
          },
          "due_date": {
            "type": [
              "string",
              "null"
            ],
            "description": "Expected close date `YYYY-MM-DD`."
          },
          "user_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Owner (a user id)."
          },
          "customer_id": {
            "type": "integer",
            "format": "int32",
            "description": "Customer id."
          },
          "customer_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "Customer name."
          },
          "customer_deal_count": {
            "type": "integer",
            "format": "int64",
            "description": "Live deals of the same customer, this one included."
          },
          "files_count": {
            "type": "integer",
            "format": "int64",
            "description": "Photos plus documents attached to the deal."
          },
          "created_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When the deal was created."
          },
          "closed_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When the deal was marked won or lost; null while open."
          }
        }
      },
      "DealDocument": {
        "type": "object",
        "description": "A document of a deal.",
        "required": [
          "id",
          "url"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "Row id within `source`."
          },
          "url": {
            "type": "string",
            "description": "URL the browser can open (presigned for private files)."
          },
          "created_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When it was attached."
          },
          "source": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/FileSource",
                "description": "Where the row lives."
              },
              {
                "type": "null"
              }
            ]
          },
          "name": {
            "type": [
              "string",
              "null"
            ],
            "description": "Display name; null for older documents (show the file name)."
          }
        }
      },
      "DealEmails": {
        "type": "object",
        "description": "Email history of a deal.",
        "required": [
          "emails",
          "customer_emails",
          "thread_emails"
        ],
        "properties": {
          "emails": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/HistoryEmail"
            },
            "description": "What the deal page lists: the deal's conversations and those with the\ncustomer; when the customer has only this deal, also any mail to or\nfrom their addresses. Newest first."
          },
          "customer_emails": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/HistoryEmail"
            },
            "description": "Mail with the customer's addresses, when some of it is outside `emails`."
          },
          "thread_emails": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/HistoryEmail"
            },
            "description": "The deal's and the customer's conversations only (the History tab)."
          }
        }
      },
      "DealFileUrls": {
        "type": "object",
        "description": "URLs of deal files.",
        "required": [
          "urls"
        ],
        "properties": {
          "urls": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Photo and document URLs."
          }
        }
      },
      "DealFiles": {
        "type": "object",
        "description": "Photos and documents of a deal, newest first.",
        "required": [
          "images",
          "documents"
        ],
        "properties": {
          "images": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/DealImage"
            },
            "description": "Photos."
          },
          "documents": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/DealDocument"
            },
            "description": "Documents."
          }
        }
      },
      "DealGroup": {
        "type": "object",
        "description": "A pipeline (a set of stages) on the deals board.",
        "required": [
          "id",
          "name",
          "has_overdue_activity"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "Group id; pass it as `group_id` to `GET /v1/deals` and `GET /v1/deal-lists`."
          },
          "name": {
            "type": "string",
            "description": "Display name."
          },
          "has_overdue_activity": {
            "type": "boolean",
            "description": "One of the caller's deals in this group (with the requested status)\nhas an unfinished activity whose deadline day has passed."
          }
        }
      },
      "DealImage": {
        "type": "object",
        "description": "A photo of a deal.",
        "required": [
          "id",
          "url"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "Row id (in `images`)."
          },
          "url": {
            "type": "string",
            "description": "URL the browser can show (presigned for private files)."
          },
          "created_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When it was attached."
          }
        }
      },
      "DealList": {
        "type": "object",
        "description": "A stage (board column) of a group.",
        "required": [
          "id",
          "name",
          "position",
          "group_id",
          "group_name"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "Stage id (`list_id` of a deal)."
          },
          "name": {
            "type": "string",
            "description": "Column title."
          },
          "position": {
            "type": "integer",
            "format": "int32",
            "description": "Order inside the group, ascending."
          },
          "group_id": {
            "type": "integer",
            "format": "int32",
            "description": "Group the stage belongs to."
          },
          "group_name": {
            "type": "string",
            "description": "Name of that group."
          }
        }
      },
      "DealOdds": {
        "type": "object",
        "description": "The model's estimate that an open deal ends in a sale.",
        "required": [
          "deal_id",
          "probability",
          "verdict",
          "reasons",
          "model_version",
          "predicted_at"
        ],
        "properties": {
          "deal_id": {
            "type": "integer",
            "format": "int64",
            "description": "The deal these odds are for."
          },
          "probability": {
            "type": "number",
            "format": "double",
            "description": "Chance of a sale from 0 to 1, calibrated on past deals (0.4 means\nabout 40 of 100 such deals were won)."
          },
          "verdict": {
            "$ref": "#/components/schemas/OddsVerdict"
          },
          "reasons": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/OddsReason"
            },
            "description": "Up to three biggest reasons, biggest first."
          },
          "confidence": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/OddsConfidence",
                "description": "How far to trust `probability`; null from a model without a\nconfidence table."
              },
              {
                "type": "null"
              }
            ]
          },
          "model_version": {
            "type": "string",
            "description": "The model that answered, e.g. `v1`."
          },
          "predicted_at": {
            "type": "string",
            "format": "date-time",
            "description": "When the model made this estimate. An estimate younger than 3 hours\nis answered again from the log instead of asking the model."
          }
        }
      },
      "DealPage": {
        "type": "object",
        "description": "The deal page's data.",
        "required": [
          "deal",
          "stage_history",
          "activities",
          "notes"
        ],
        "properties": {
          "deal": {
            "$ref": "#/components/schemas/DealDetail",
            "description": "The deal, as `GET /v1/deals/{id}` returns it."
          },
          "stage_history": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/StageVisit"
            },
            "description": "Stage visits, oldest first, as `GET /v1/deals/{id}/stage-history`."
          },
          "activities": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Activity"
            },
            "description": "Live activities, newest first, as `GET /v1/deals/{id}/activities`."
          },
          "notes": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Note"
            },
            "description": "Live notes with comments, newest first, as `GET /v1/deals/{id}/notes`."
          },
          "emails": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/DealEmails",
                "description": "The email history, as `GET /v1/deals/{id}/emails`. Null when it could\nnot be read; the rest of the page is still returned."
              },
              {
                "type": "null"
              }
            ]
          },
          "document_events": {
            "type": [
              "array",
              "null"
            ],
            "items": {
              "$ref": "#/components/schemas/DocumentEvent"
            },
            "description": "Quote and contract events, unsorted, as\n`GET /v1/deals/{id}/document-events`. Null when they could not be read."
          }
        }
      },
      "DealPatch": {
        "type": "object",
        "description": "Body of `PATCH /v1/deals/{id}`; only the fields sent change.",
        "properties": {
          "title": {
            "type": [
              "string",
              "null"
            ],
            "description": "New title, at most 255 characters; null clears it."
          },
          "amount": {
            "type": [
              "number",
              "null"
            ],
            "format": "double",
            "description": "New amount in dollars, 0 to 99,999,999.99; null clears it."
          },
          "due_date": {
            "type": [
              "string",
              "null"
            ],
            "description": "Expected close date `YYYY-MM-DD`; null clears it."
          },
          "list_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Move to this stage. A won or lost deal stays closed (reopen it with\n`PUT /v1/deals/{id}/outcome`)."
          },
          "group_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Move to the first stage of this group (ignored when the deal is\nalready in it, or when `list_id` is sent)."
          },
          "position": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Order inside the stage."
          },
          "customer_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Give the deal to another customer of the company."
          }
        }
      },
      "DealPlaybook": {
        "type": "object",
        "description": "`GET /v1/deals/{id}/playbook`.",
        "required": [
          "list_id",
          "stage_name",
          "sub_stages",
          "days_in_stage",
          "over_limit",
          "next_touch_required",
          "plan",
          "sync_todos"
        ],
        "properties": {
          "list_id": {
            "type": "integer",
            "format": "int32",
            "description": "The deal's stage (deal list)."
          },
          "stage_name": {
            "type": "string",
            "description": "The stage's name."
          },
          "sub_stage_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Its sub-stage; null: the stage has none."
          },
          "sub_stages": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SubStage"
            },
            "description": "The stage's live sub-stages, in order."
          },
          "days_in_stage": {
            "type": "integer",
            "format": "int32",
            "description": "Whole days since the deal entered its stage."
          },
          "limit_days": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "The stage's time limit in days; null when it has none."
          },
          "over_limit": {
            "type": "boolean",
            "description": "True when idle at least the limit and not put off."
          },
          "next_touch_required": {
            "type": "boolean",
            "description": "True: the deal needs an open next touch to leave the stage."
          },
          "stage_instructions": {
            "type": [
              "string",
              "null"
            ],
            "description": "What the sales rep does on the stage (plain text); null: none. The\ndeal's sub-stage's own `instructions`, when set, come first."
          },
          "objection": {
            "type": [
              "string",
              "null"
            ],
            "description": "`price`, `timing`, `spouse`, `competitor` or `trust`."
          },
          "plan": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PlanItem"
            },
            "description": "The plan of the current (sub-)stage, by due date."
          },
          "sync_todos": {
            "type": "boolean",
            "description": "The caller keeps \"Sync to my Todo List\" on."
          }
        }
      },
      "DealProject": {
        "type": "object",
        "description": "`GET /v1/deals/{id}/project`.",
        "required": [
          "can_convert"
        ],
        "properties": {
          "project_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "The deal's project, if it has one."
          },
          "can_convert": {
            "type": "boolean",
            "description": "Projects are on for the company and the caller may create one."
          }
        }
      },
      "DealQuestionnaire": {
        "type": "object",
        "description": "A questionnaire with the deal's answers.",
        "required": [
          "id",
          "name",
          "questions"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "Questionnaire id."
          },
          "name": {
            "type": "string",
            "description": "Name."
          },
          "questions": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/AnsweredQuestion"
            },
            "description": "Questions in creation order."
          }
        }
      },
      "DealStatus": {
        "type": "string",
        "description": "Where a deal is in its life: still being worked (`open`), `won` or `lost`.",
        "enum": [
          "open",
          "won",
          "lost"
        ]
      },
      "DealsByRep": {
        "type": "object",
        "description": "A rep's deals.",
        "required": [
          "rep_id",
          "deals_count",
          "avg_amount",
          "avg_amount_won",
          "won_count",
          "lost_count",
          "won_lost_ratio",
          "pipeline_amount",
          "won_count_walkin",
          "lost_count_walkin",
          "won_lost_ratio_walkin",
          "won_count_leads",
          "lost_count_leads",
          "won_lost_ratio_leads"
        ],
        "properties": {
          "rep_id": {
            "type": "integer",
            "format": "int32",
            "description": "The rep (user id)."
          },
          "rep_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "The rep's name."
          },
          "deals_count": {
            "type": "integer",
            "format": "int64",
            "description": "Deals counted."
          },
          "avg_amount": {
            "type": "number",
            "format": "double",
            "description": "Average amount of deals with one."
          },
          "avg_amount_won": {
            "type": "number",
            "format": "double",
            "description": "Average amount of won deals with one."
          },
          "won_count": {
            "type": "integer",
            "format": "int64",
            "description": "Won deals."
          },
          "lost_count": {
            "type": "integer",
            "format": "int64",
            "description": "Lost deals."
          },
          "won_lost_ratio": {
            "type": "number",
            "format": "double",
            "description": "Won out of closed, in percent."
          },
          "pipeline_amount": {
            "type": "number",
            "format": "double",
            "description": "Open deals' amount."
          },
          "won_count_walkin": {
            "type": "integer",
            "format": "int64",
            "description": "Won deals of walk-in customers."
          },
          "lost_count_walkin": {
            "type": "integer",
            "format": "int64",
            "description": "Lost deals of walk-in customers."
          },
          "won_lost_ratio_walkin": {
            "type": "number",
            "format": "double",
            "description": "Walk-in won out of closed, in percent."
          },
          "won_count_leads": {
            "type": "integer",
            "format": "int64",
            "description": "Won deals of leads."
          },
          "lost_count_leads": {
            "type": "integer",
            "format": "int64",
            "description": "Lost deals of leads."
          },
          "won_lost_ratio_leads": {
            "type": "number",
            "format": "double",
            "description": "Leads won out of closed, in percent."
          }
        }
      },
      "DealsByStage": {
        "type": "object",
        "description": "Open deals in a stage.",
        "required": [
          "list_id",
          "deals_count",
          "total_amount"
        ],
        "properties": {
          "list_id": {
            "type": "integer",
            "format": "int32",
            "description": "The stage."
          },
          "list_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "The stage's name."
          },
          "deals_count": {
            "type": "integer",
            "format": "int64",
            "description": "Deals counted."
          },
          "total_amount": {
            "type": "number",
            "format": "double",
            "description": "Their amounts summed."
          }
        }
      },
      "DealsList": {
        "type": "object",
        "description": "A pipeline stage.",
        "required": [
          "id"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "Id."
          },
          "name": {
            "type": [
              "string",
              "null"
            ],
            "description": "Name."
          },
          "position": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Order on the board."
          }
        }
      },
      "DeclineInput": {
        "type": "object",
        "description": "Body of `POST /v1/phone/calls/decline`.",
        "required": [
          "telnyxCallId"
        ],
        "properties": {
          "telnyxCallId": {
            "type": "string",
            "description": "The call id of Telnyx's incoming-call push."
          }
        }
      },
      "DefaultPriceList": {
        "type": "object",
        "description": "A list to star.",
        "required": [
          "id"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "Price list id."
          }
        },
        "additionalProperties": false
      },
      "DefaultQuestionnaire": {
        "type": "object",
        "description": "The caller's default questionnaire.",
        "properties": {
          "questionnaire_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Questionnaire id, or null when none is set."
          }
        }
      },
      "DeletedDeal": {
        "type": "object",
        "description": "A deleted deal.",
        "required": [
          "id"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int64",
            "description": "Deal id."
          },
          "deleted_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When."
          },
          "deleted_by": {
            "type": [
              "string",
              "null"
            ],
            "description": "By whom (name), when recorded."
          }
        }
      },
      "DemoOutcome": {
        "type": "string",
        "description": "What the demo payment page reports.",
        "enum": [
          "paid",
          "pending",
          "failed"
        ]
      },
      "DemoPayment": {
        "type": "object",
        "description": "Body of `POST /v1/public/pay/{payment_id}/demo`.",
        "required": [
          "outcome"
        ],
        "properties": {
          "outcome": {
            "$ref": "#/components/schemas/DemoOutcome",
            "description": "What happened to the payment."
          }
        },
        "additionalProperties": false
      },
      "DepositAccount": {
        "type": "object",
        "description": "A `QuickBooks` account a payment can be deposited to.",
        "required": [
          "id",
          "name"
        ],
        "properties": {
          "id": {
            "type": "string",
            "description": "The `QuickBooks` account id."
          },
          "name": {
            "type": "string",
            "description": "The account's name in QuickBooks, e.g. Business Checking."
          }
        }
      },
      "DepositAccountInput": {
        "type": "object",
        "description": "Body of `PUT /v1/payment-options/deposit-account`.",
        "properties": {
          "account_id": {
            "type": [
              "string",
              "null"
            ],
            "description": "The `QuickBooks` account Record payment starts with; null for none."
          }
        }
      },
      "DepositKind": {
        "type": "string",
        "description": "What Stripe sent to confirm a bank account typed by hand.",
        "enum": [
          "code",
          "amounts"
        ]
      },
      "DesignDeal": {
        "type": "object",
        "description": "A deal a design can be saved to.",
        "required": [
          "id",
          "customer_name"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int64",
            "description": "The deal."
          },
          "title": {
            "type": [
              "string",
              "null"
            ],
            "description": "Its title, when it has one."
          },
          "customer_name": {
            "type": "string",
            "description": "Its customer."
          }
        }
      },
      "DesignInput": {
        "type": "object",
        "description": "Body of `POST /v1/ai/design`.",
        "required": [
          "kitchen",
          "stoneIds"
        ],
        "properties": {
          "kitchen": {
            "type": "string",
            "description": "The kitchen photo as a `data:image/...;base64,` URL (at most 4 MB)."
          },
          "stoneIds": {
            "type": "array",
            "items": {
              "type": "integer",
              "format": "int64"
            },
            "description": "The stones to show it in (one to three)."
          },
          "surfaces": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "`countertops` (default), `fireplace`, `full_height_backsplash`."
          },
          "instructions": {
            "type": "string",
            "description": "What else to change, in the user's words."
          }
        },
        "additionalProperties": false
      },
      "DesignStoneRow": {
        "type": "object",
        "description": "A stone AI Design can show.",
        "required": [
          "id",
          "name"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int64",
            "description": "The stone."
          },
          "name": {
            "type": "string",
            "description": "Its name."
          },
          "type": {
            "type": [
              "string",
              "null"
            ],
            "description": "Its material (granite, quartz…)."
          }
        }
      },
      "DesignStones": {
        "type": "object",
        "description": "The stones.",
        "required": [
          "stones"
        ],
        "properties": {
          "stones": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/DesignStoneRow"
            },
            "description": "By name."
          }
        }
      },
      "DesktopAlert": {
        "type": "object",
        "description": "An unread conversation whose latest message is from the customer.",
        "required": [
          "id",
          "phone_digits",
          "title",
          "message",
          "href",
          "sent_at"
        ],
        "properties": {
          "id": {
            "type": "string",
            "description": "`sms-<phone>`."
          },
          "phone_digits": {
            "type": "string",
            "description": "The other party's phone."
          },
          "title": {
            "type": "string",
            "description": "The customer's name, else the phone."
          },
          "message": {
            "type": "string",
            "description": "The latest message."
          },
          "href": {
            "type": "string",
            "description": "The conversation's page."
          },
          "sent_at": {
            "type": "string",
            "format": "date-time",
            "description": "When the latest message arrived."
          }
        }
      },
      "DesktopAlerts": {
        "type": "object",
        "description": "`GET /v1/sms/{provider}/desktop-alerts`.",
        "required": [
          "alerts"
        ],
        "properties": {
          "alerts": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/DesktopAlert"
            },
            "description": "Newest first."
          }
        }
      },
      "DetectInput": {
        "type": "object",
        "description": "Body of `POST /v1/ai/signature-fields`.",
        "required": [
          "candidates"
        ],
        "properties": {
          "candidates": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/BlankCandidate"
            },
            "description": "Up to 300 blanks."
          }
        }
      },
      "DetectedField": {
        "type": "object",
        "description": "One blank, labeled.",
        "required": [
          "id",
          "type",
          "label"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int64",
            "description": "The blank's id from the request."
          },
          "type": {
            "$ref": "#/components/schemas/FieldType",
            "description": "What it is for."
          },
          "label": {
            "type": "string",
            "description": "A short label from the document's wording; empty when the AI gave none\n(or more than 80 characters)."
          }
        }
      },
      "DetectedFields": {
        "type": "object",
        "description": "Body of the answer.",
        "required": [
          "fields"
        ],
        "properties": {
          "fields": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/DetectedField"
            },
            "description": "The blanks the AI labeled (only ids that were sent)."
          }
        }
      },
      "DevicePlatform": {
        "type": "string",
        "description": "What a signed-in phone is: `android` or `ios` (the Granite Manager app),\nor `web` (a browser, signed in by the CRM's phone dock).",
        "enum": [
          "android",
          "ios",
          "web"
        ]
      },
      "DeviceRegistration": {
        "type": "object",
        "description": "Body of `POST /v1/phone/devices`.",
        "required": [
          "platform",
          "appVersion",
          "deviceName"
        ],
        "properties": {
          "platform": {
            "$ref": "#/components/schemas/Platform",
            "description": "`android` or `ios`."
          },
          "appVersion": {
            "type": "string",
            "description": "The app's version, e.g. `1.4.0` (cut to 32 characters; empty =\nunknown)."
          },
          "deviceName": {
            "type": "string",
            "description": "Shown in \"Signed-in devices\", e.g. \"Rita's Pixel 9\" (cut to 100\ncharacters)."
          },
          "pushToken": {
            "type": [
              "string",
              "null"
            ],
            "description": "The phone's FCM registration token, for our pushes; null when it has\nnone yet (send it later with `PUT /v1/phone/devices/{id}/push-token`)."
          }
        }
      },
      "DeviceSession": {
        "type": "object",
        "description": "`POST /v1/auth/device-sessions`: a phone just signed in.",
        "required": [
          "token",
          "callKey",
          "sessionId",
          "expiresAt",
          "user"
        ],
        "properties": {
          "token": {
            "type": "string",
            "description": "The device token: send it as the `X-Granite-Device` header on every\nrequest. Shown only this once (43 characters, base64url)."
          },
          "callKey": {
            "type": "string",
            "description": "The phone's call key: it signs every call the app places (the\n`X-Granite-Call-Auth` SIP header, an HMAC-SHA256 keyed with these 32\nbytes; see the Telnyx `outbound` webhook). Shown only this once (43\ncharacters, base64url of 32 bytes). The server derives it from\n`SESSION_SECRET` and the session id and stores nothing."
          },
          "sessionId": {
            "type": "integer",
            "format": "int64",
            "description": "The device session (`SignedInDevice.id`)."
          },
          "expiresAt": {
            "type": "string",
            "format": "date-time",
            "description": "12 months from now, for display only: the sign-in never ends by time,\nonly when the phone signs out or is revoked."
          },
          "user": {
            "$ref": "#/components/schemas/PhoneUser",
            "description": "Who signed in."
          }
        }
      },
      "DeviceSignIn": {
        "type": "object",
        "description": "Body of `POST /v1/auth/device-sessions`.",
        "required": [
          "email",
          "password",
          "deviceName",
          "platform",
          "appVersion"
        ],
        "properties": {
          "email": {
            "type": "string",
            "description": "The CRM login email (any case, spaces around it ignored)."
          },
          "password": {
            "type": "string",
            "description": "The CRM password."
          },
          "deviceName": {
            "type": "string",
            "description": "Shown in \"Signed-in devices\", e.g. \"Rita's Pixel 9\"; cut to 100\ncharacters."
          },
          "platform": {
            "$ref": "#/components/schemas/Platform",
            "description": "`android` or `ios`."
          },
          "appVersion": {
            "type": "string",
            "description": "The app's version, e.g. `1.4.0`; cut to 32 characters."
          },
          "steps": {
            "type": "boolean",
            "description": "The app can do the sign-in steps (an authenticator code, a new\npassword, setting up the authenticator): when the account needs one,\nthe answer is 202 with a `LoginChallenge`. Without it (older apps)\nsuch an account gets 403 asking to update the app."
          }
        }
      },
      "DeviceToken": {
        "type": "object",
        "description": "`POST /v1/phone/devices/{id}/token`.",
        "required": [
          "jwt",
          "expiresAt"
        ],
        "properties": {
          "jwt": {
            "type": "string",
            "description": "The Telnyx login JWT for this phone's SIP credential."
          },
          "expiresAt": {
            "type": "string",
            "format": "date-time",
            "description": "When the JWT stops working (RFC 3339): about 24 hours from now."
          }
        }
      },
      "DialogMessage": {
        "type": "object",
        "description": "One message of the conversation the feedback is about.",
        "required": [
          "role",
          "content"
        ],
        "properties": {
          "role": {
            "$ref": "#/components/schemas/DialogRole",
            "description": "`user` or `assistant`."
          },
          "content": {
            "type": "string",
            "description": "What was said."
          },
          "correctionAttempt": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int64",
            "description": "Which correction this is (1 or 2), for a corrected answer."
          },
          "correctionLiked": {
            "type": [
              "boolean",
              "null"
            ],
            "description": "Whether the user liked this correction."
          }
        }
      },
      "DialogRole": {
        "type": "string",
        "description": "Who said a dialog message.",
        "enum": [
          "user",
          "assistant"
        ]
      },
      "DigestRun": {
        "type": "object",
        "description": "What a run did.",
        "required": [
          "processed",
          "sent",
          "failed",
          "skipped"
        ],
        "properties": {
          "processed": {
            "type": "integer",
            "description": "Shop workers and managers with checks due today.",
            "minimum": 0
          },
          "sent": {
            "type": "integer",
            "description": "Digests sent.",
            "minimum": 0
          },
          "failed": {
            "type": "integer",
            "description": "Digests neither Telegram nor a phone took (retried next run).",
            "minimum": 0
          },
          "skipped": {
            "type": "boolean",
            "description": "Not 9 AM store time: nothing was looked at."
          }
        }
      },
      "Direction": {
        "type": "string",
        "description": "Which way a message went, seen from the company.",
        "enum": [
          "inbound",
          "outbound"
        ]
      },
      "DisplayNumber": {
        "type": "string",
        "description": "What my phones show for an incoming call: `caller` (the caller's\nnumber) or `called` (the company number they called).",
        "enum": [
          "Caller",
          "Called"
        ]
      },
      "DocumentEvent": {
        "type": "object",
        "description": "One quote or contract event of a deal.",
        "required": [
          "id",
          "kind",
          "title",
          "at"
        ],
        "properties": {
          "id": {
            "type": "string",
            "description": "Stable key, e.g. `quote-email-12` or `contract-signed-7`."
          },
          "kind": {
            "$ref": "#/components/schemas/DocumentEventKind",
            "description": "What happened."
          },
          "title": {
            "type": "string",
            "description": "The quote's name (`Quote` when it has none), or the contract's file\nname without `.pdf`."
          },
          "detail": {
            "type": [
              "string",
              "null"
            ],
            "description": "Recipients of an emailed quote, the form a quote was printed with, or\nthe contract's signer. Null when unknown."
          },
          "at": {
            "type": "string",
            "description": "When it happened, UTC (`2026-05-01T14:30:00Z`)."
          },
          "by": {
            "type": [
              "string",
              "null"
            ],
            "description": "Who sent or printed it. Null for a signing, or when unknown."
          },
          "quote_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int64",
            "description": "The quote to open, for quote events; null for contracts."
          }
        }
      },
      "DocumentEventKind": {
        "type": "string",
        "description": "What happened to the document.",
        "enum": [
          "quote_emailed",
          "quote_printed",
          "contract_sent",
          "contract_signed"
        ]
      },
      "DocumentRename": {
        "type": "object",
        "description": "Body of `PATCH /v1/deals/{id}/documents/{document_id}`.",
        "required": [
          "name"
        ],
        "properties": {
          "name": {
            "type": "string",
            "description": "New display name, 1 to 255 characters."
          }
        }
      },
      "DocumentUpdate": {
        "type": "object",
        "description": "Body of `PUT /v1/documents/{id}`.",
        "required": [
          "name"
        ],
        "properties": {
          "name": {
            "type": "string",
            "description": "New name (1–100 characters)."
          },
          "url": {
            "type": [
              "string",
              "null"
            ],
            "description": "A newly uploaded file replacing the old one; leave out to keep it."
          }
        },
        "additionalProperties": false
      },
      "DomainTrust": {
        "type": "object",
        "description": "A company domain's deliverability.",
        "required": [
          "domain",
          "risk_level",
          "reputation_reasons",
          "checked_at"
        ],
        "properties": {
          "domain": {
            "type": "string",
            "description": "The domain checked."
          },
          "reputation_score": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int64",
            "description": "0-100, higher = more spam risk; null when the check failed."
          },
          "risk_level": {
            "$ref": "#/components/schemas/RiskLevel",
            "description": "`GOOD`, `REVIEW`, `HIGH_RISK` or `UNKNOWN`."
          },
          "reputation_reasons": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "A summary line, a confidence line, then the DNS changes to make."
          },
          "checked_at": {
            "type": "string",
            "format": "date-time",
            "description": "When it was checked (ISO 8601)."
          }
        }
      },
      "DoneInput": {
        "type": "object",
        "description": "Body of `POST /v1/notifications/done`.",
        "properties": {
          "clear_all": {
            "type": "boolean",
            "description": "Dismiss everything: the activity notifications that are due (later\nreminders stay), billing notifications, every unread incoming email,\nand the Granite Manager calls the bell lists (marked seen)."
          },
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/NotificationRef"
            },
            "description": "The notifications to dismiss, 200 at most."
          },
          "hide_only": {
            "type": "boolean",
            "description": "Remove email threads from the bell without marking them read. They\nshow again when a newer message arrives."
          }
        }
      },
      "DoneStep": {
        "type": "object",
        "description": "A process step a project has done.",
        "required": [
          "project_id",
          "step_id",
          "done_at",
          "skipped"
        ],
        "properties": {
          "project_id": {
            "type": "integer",
            "format": "int32",
            "description": "The project."
          },
          "step_id": {
            "type": "integer",
            "format": "int32",
            "description": "The step."
          },
          "part_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "The part it was done for; null on a project without parts."
          },
          "done_by": {
            "type": [
              "string",
              "null"
            ],
            "description": "Who checked it off (\"Auto\" when its rule did; \"Mike · Marked cut on the\nschedule\" when the job's status on the schedule checked it off)."
          },
          "done_at": {
            "type": "string",
            "description": "When (UTC ISO)."
          },
          "skipped": {
            "type": "boolean",
            "description": "Not needed (a No to the question of the step it depends on), not done."
          }
        }
      },
      "DraftAddresses": {
        "type": "object",
        "description": "The addresses a new invoice opens with.",
        "properties": {
          "bill": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/Address",
                "description": "The billing address, written as the company's invoices write it: the\ncustomer's name, then their address, or the address alone. Null\nleaves it to `QuickBooks`, which fills in the billing address its\ncustomer already has."
              },
              {
                "type": "null"
              }
            ]
          },
          "ship": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/Address",
                "description": "The shipping (job) address. Null when the company's invoices carry\nnone and the job is at the billing address."
              },
              {
                "type": "null"
              }
            ]
          }
        }
      },
      "DraftAttachment": {
        "type": "object",
        "description": "A file of a draft.",
        "required": [
          "url",
          "filename",
          "content_type"
        ],
        "properties": {
          "url": {
            "type": "string",
            "description": "File URL."
          },
          "filename": {
            "type": "string",
            "description": "File name (at most 255 characters)."
          },
          "content_type": {
            "type": "string",
            "description": "MIME type, e.g. `application/pdf`."
          }
        },
        "additionalProperties": false
      },
      "DraftField": {
        "type": "object",
        "description": "One custom field of a new invoice.",
        "required": [
          "definition_id",
          "name",
          "examples"
        ],
        "properties": {
          "definition_id": {
            "type": "string",
            "description": "`QuickBooks`' id of the field: sent back with the value when the\ninvoice is created."
          },
          "name": {
            "type": "string",
            "description": "Its name, e.g. \"Room & Color\"."
          },
          "value": {
            "type": [
              "string",
              "null"
            ],
            "description": "The value for this quote, written the company's way (at most 31\ncharacters); null when the AI could not tell, or did not answer."
          },
          "examples": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "A few values the company gave it on recent invoices."
          }
        }
      },
      "DraftFields": {
        "type": "object",
        "description": "`POST /v1/quotes/{id}/invoice-fields`.",
        "required": [
          "fields"
        ],
        "properties": {
          "fields": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/DraftField"
            },
            "description": "The custom fields the company's invoices usually fill, in\n`QuickBooks`' order; empty when it uses none."
          }
        }
      },
      "DraftInput": {
        "type": "object",
        "description": "Body of `POST /v1/emails/drafts` and `PUT /v1/emails/drafts/{id}`.",
        "properties": {
          "subject": {
            "type": "string",
            "description": "Subject (at most 255 characters)."
          },
          "body": {
            "type": "string",
            "description": "Note (at most 65,535 bytes). A draft needs a subject or a note."
          },
          "to": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Recipients."
          },
          "cc": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Copy recipients."
          },
          "bcc": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Blind copy recipients."
          },
          "deal_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Deal it is about."
          },
          "send_together": {
            "type": "boolean",
            "description": "One message to all `to` recipients."
          },
          "attachments": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/DraftAttachment"
            },
            "description": "Files attached so far."
          }
        },
        "additionalProperties": false
      },
      "DraftRules": {
        "type": "object",
        "description": "`POST /v1/quotes/{id}/invoice-draft`.",
        "required": [
          "lines",
          "removed",
          "style_due"
        ],
        "properties": {
          "lines": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Line"
            },
            "description": "The lines with the company's usual changes made."
          },
          "removed": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Line"
            },
            "description": "Text lines the company usually leaves out, for the editor to offer back."
          },
          "class_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "The class the company's invoices usually get."
          },
          "bill_email_cc": {
            "type": [
              "string",
              "null"
            ],
            "description": "The CC they usually get."
          },
          "item_id": {
            "type": [
              "string",
              "null"
            ],
            "description": "The product their priced lines usually use."
          },
          "item_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "Its name."
          },
          "addresses": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/DraftAddresses",
                "description": "The billing and shipping addresses the invoice opens with, placed\nwhere the company's invoices put them; null keeps the draft's own\n(the CRM knows no address)."
              },
              {
                "type": "null"
              }
            ]
          },
          "due_days": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int64",
            "description": "The company's invoices are usually due this many days after their\ndate (0: on the day); null when they follow no one habit."
          },
          "style_due": {
            "type": "boolean",
            "description": "The AI has not read the company's invoice wording yet, or not for a\nday: `POST /v1/qbo/invoice-style` is worth calling in the background."
          }
        }
      },
      "DraftedEmail": {
        "type": "object",
        "description": "A drafted email.",
        "required": [
          "subject",
          "body"
        ],
        "properties": {
          "subject": {
            "type": "string",
            "description": "Short, sentence case."
          },
          "body": {
            "type": "string",
            "description": "The email text (the signature is added when sent)."
          }
        }
      },
      "Drip": {
        "type": "object",
        "description": "When a template sends itself.",
        "properties": {
          "lead_list_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "The deal list that starts it, a live list of the company; null: no\ndrip."
          },
          "hour_delay": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Hours after a deal enters the list, 0 to 8760."
          },
          "minute_delay": {
            "type": "integer",
            "format": "int32",
            "description": "Minutes on top of `hour_delay`, 0 to 59."
          },
          "customer_sources": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Customer sources that get it; empty or left out: only leads."
          },
          "sales_rep_ids": {
            "type": [
              "array",
              "null"
            ],
            "items": {
              "type": "integer",
              "format": "int32"
            },
            "description": "Company templates: sales reps whose deals get it; empty: every\nrep's. Left out keeps the template's reps. Ignored for a personal\ntemplate, which goes to its owner's deals."
          }
        }
      },
      "DripList": {
        "type": "object",
        "description": "A deal list a drip can start from.",
        "required": [
          "id",
          "name",
          "group_name"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "The list."
          },
          "name": {
            "type": "string",
            "description": "Its name."
          },
          "group_name": {
            "type": "string",
            "description": "Its pipeline."
          }
        }
      },
      "DripRun": {
        "type": "object",
        "description": "Drip texts looked at, sent and failed.",
        "required": [
          "processed",
          "sent",
          "failed"
        ],
        "properties": {
          "processed": {
            "type": "integer",
            "description": "Due texts looked at.",
            "minimum": 0
          },
          "sent": {
            "type": "integer",
            "description": "Texts sent.",
            "minimum": 0
          },
          "failed": {
            "type": "integer",
            "description": "Texts that failed (with the reason on the row).",
            "minimum": 0
          }
        }
      },
      "DriveMiles": {
        "type": "object",
        "description": "`GET /v1/company/drive-miles`.",
        "properties": {
          "miles": {
            "type": [
              "number",
              "null"
            ],
            "format": "double",
            "description": "Driving miles, one decimal; null when unknown."
          }
        }
      },
      "DriveTime": {
        "type": "object",
        "description": "`GET /v1/schedule/drive-time`.",
        "required": [
          "legs"
        ],
        "properties": {
          "minutes": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Minutes driving from the company address through the stops in order\n(no drive back); null without a company address, Google Maps or a route.",
            "minimum": 0
          },
          "legs": {
            "type": "array",
            "items": {
              "type": "integer",
              "format": "int32",
              "minimum": 0
            },
            "description": "Minutes of each drive: the shop to the first stop, then each stop to\nthe next (blank stops skipped). Empty when `minutes` is null."
          }
        }
      },
      "DueRun": {
        "type": "object",
        "description": "Due messages looked at (emails, texts).",
        "required": [
          "emails",
          "sms"
        ],
        "properties": {
          "emails": {
            "type": "integer",
            "description": "Due emails looked at.",
            "minimum": 0
          },
          "sms": {
            "type": "integer",
            "description": "Due texts looked at.",
            "minimum": 0
          }
        }
      },
      "DuplicateCustomer": {
        "type": "object",
        "description": "A live customer with one of the given contacts.",
        "required": [
          "id"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "Customer id."
          },
          "name": {
            "type": [
              "string",
              "null"
            ],
            "description": "Name."
          },
          "phone": {
            "type": [
              "string",
              "null"
            ],
            "description": "Phone."
          },
          "email": {
            "type": [
              "string",
              "null"
            ],
            "description": "Primary email address."
          },
          "sales_rep_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "Assigned sales rep's name."
          }
        }
      },
      "E911Input": {
        "type": "object",
        "description": "Body of `POST /v1/phone/e911`.",
        "required": [
          "number"
        ],
        "properties": {
          "number": {
            "type": "string",
            "description": "The emergency or service code dialed: 911, 112, 933, 988, 211 ... 811."
          }
        }
      },
      "EditPending": {
        "type": "object",
        "description": "Body of `PUT /v1/delayed/{kind}/{id}`.",
        "required": [
          "text",
          "send_at"
        ],
        "properties": {
          "text": {
            "type": "string",
            "description": "The new text (email body)."
          },
          "send_at": {
            "type": "string",
            "format": "date-time",
            "description": "When to send it: in the future, within 90 days."
          }
        }
      },
      "EditableInvoice": {
        "type": "object",
        "description": "An invoice as the editor shows it.",
        "required": [
          "id",
          "sync_token",
          "lines"
        ],
        "properties": {
          "id": {
            "type": "string",
            "description": "`QuickBooks` invoice id."
          },
          "sync_token": {
            "type": "string",
            "description": "`QuickBooks`' version; an update must send the current one."
          },
          "doc_number": {
            "type": [
              "string",
              "null"
            ],
            "description": "Invoice number."
          },
          "txn_date": {
            "type": [
              "string",
              "null"
            ],
            "description": "Invoice date (`YYYY-MM-DD`)."
          },
          "due_date": {
            "type": [
              "string",
              "null"
            ],
            "description": "Due date (`YYYY-MM-DD`)."
          },
          "total_amt": {
            "type": [
              "number",
              "null"
            ],
            "format": "double",
            "description": "Total."
          },
          "balance": {
            "type": [
              "number",
              "null"
            ],
            "format": "double",
            "description": "Still owed."
          },
          "currency": {
            "type": [
              "string",
              "null"
            ],
            "description": "Currency code."
          },
          "customer_memo": {
            "type": [
              "string",
              "null"
            ],
            "description": "Message shown on the invoice."
          },
          "private_note": {
            "type": [
              "string",
              "null"
            ],
            "description": "Internal note."
          },
          "bill_addr": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/Address",
                "description": "Billing address."
              },
              {
                "type": "null"
              }
            ]
          },
          "ship_addr": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/Address",
                "description": "Shipping (project) address."
              },
              {
                "type": "null"
              }
            ]
          },
          "lines": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Line"
            },
            "description": "The lines, in order."
          },
          "class_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "`QuickBooks` class (by name; set on a new invoice only)."
          },
          "bill_email_cc": {
            "type": [
              "string",
              "null"
            ],
            "description": "CC of the invoice email (set on a new invoice only)."
          },
          "bill_email_bcc": {
            "type": [
              "string",
              "null"
            ],
            "description": "BCC of the invoice email (set on a new invoice only)."
          },
          "email_status": {
            "type": [
              "string",
              "null"
            ],
            "description": "Whether `QuickBooks` emailed it: `EmailSent`, `NeedToSend` or\n`NotSet` (read only)."
          },
          "custom_fields": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CustomFieldValue"
            },
            "description": "The text custom fields the company's invoices fill (e.g. \"Room &\nColor\"; from `POST /v1/quotes/{id}/invoice-fields`). Set on a new\ninvoice only; saving an existing invoice leaves them as they are."
          }
        }
      },
      "EditableLead": {
        "type": "object",
        "description": "A lead as its edit form shows it.",
        "required": [
          "id",
          "emails"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "Customer id."
          },
          "name": {
            "type": [
              "string",
              "null"
            ],
            "description": "Name."
          },
          "phone": {
            "type": [
              "string",
              "null"
            ],
            "description": "Phone."
          },
          "phone_2": {
            "type": [
              "string",
              "null"
            ],
            "description": "Second phone."
          },
          "address": {
            "type": [
              "string",
              "null"
            ],
            "description": "Address."
          },
          "source": {
            "type": [
              "string",
              "null"
            ],
            "description": "`leads` or `check-in`."
          },
          "your_message": {
            "type": [
              "string",
              "null"
            ],
            "description": "What the customer wrote."
          },
          "emails": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Email addresses, primary first."
          }
        }
      },
      "EditedCatalog": {
        "type": "object",
        "description": "The catalog as edited.",
        "required": [
          "extras"
        ],
        "properties": {
          "extras": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CatalogExtra"
            },
            "description": "Every extra kept, in order; extras left out are deleted."
          }
        },
        "additionalProperties": false
      },
      "EditedRepeats": {
        "type": "object",
        "description": "`PUT /v1/events/{id}` that changed only some repeats.",
        "required": [
          "id"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "The new event holding the changed repeats."
          }
        }
      },
      "EditedUser": {
        "type": "object",
        "description": "The edit form's user.",
        "required": [
          "id",
          "company_id",
          "is_admin",
          "is_superuser",
          "is_employee",
          "invite_pending"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "User id."
          },
          "name": {
            "type": [
              "string",
              "null"
            ],
            "description": "Name."
          },
          "email": {
            "type": [
              "string",
              "null"
            ],
            "description": "Email."
          },
          "phone_number": {
            "type": [
              "string",
              "null"
            ],
            "description": "Phone."
          },
          "company_id": {
            "type": "integer",
            "format": "int32",
            "description": "Their company."
          },
          "is_admin": {
            "type": "boolean",
            "description": "Admin access."
          },
          "is_superuser": {
            "type": "boolean",
            "description": "A superuser."
          },
          "is_employee": {
            "type": "boolean",
            "description": "An employee."
          },
          "cloudtalk_agent_id": {
            "type": [
              "string",
              "null"
            ],
            "description": "`CloudTalk` agent id."
          },
          "cloudtalk_phone_number": {
            "type": [
              "string",
              "null"
            ],
            "description": "`CloudTalk` outbound number."
          },
          "ringcentral_extension_id": {
            "type": [
              "string",
              "null"
            ],
            "description": "`RingCentral` extension id."
          },
          "ringcentral_phone_number": {
            "type": [
              "string",
              "null"
            ],
            "description": "`RingCentral` outbound number."
          },
          "invite_pending": {
            "type": "boolean",
            "description": "Has not set up their account from the invite yet (no password)."
          }
        }
      },
      "EmailBadge": {
        "type": "object",
        "description": "The inbox badge.",
        "required": [
          "count"
        ],
        "properties": {
          "count": {
            "type": "integer",
            "format": "int64",
            "description": "Unread inbox threads; 0 when the company has no inbound email."
          },
          "latest_inbound_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int64",
            "description": "Newest unread message id, to notice new mail between polls; null when\nnothing is unread."
          }
        }
      },
      "EmailDraft": {
        "type": "object",
        "description": "An unsent email of the caller.",
        "required": [
          "id",
          "thread_id",
          "subject",
          "body",
          "to",
          "cc",
          "bcc",
          "send_together",
          "attachments"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "Draft id (an `emails` row with `is_draft`)."
          },
          "thread_id": {
            "type": "string",
            "description": "Conversation it will start."
          },
          "subject": {
            "type": "string",
            "description": "Subject."
          },
          "body": {
            "type": "string",
            "description": "Note as written (editor HTML or plain text)."
          },
          "deal_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int64",
            "description": "Deal it is about."
          },
          "to": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Recipients."
          },
          "cc": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Copy recipients."
          },
          "bcc": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Blind copy recipients."
          },
          "send_together": {
            "type": "boolean",
            "description": "One message to all `to` recipients."
          },
          "attachments": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/DraftAttachment"
            },
            "description": "Files attached so far."
          }
        }
      },
      "EmailImage": {
        "type": "object",
        "description": "A picture sent with an email.",
        "required": [
          "id",
          "url"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "The attachment."
          },
          "url": {
            "type": "string",
            "description": "A URL the browser can show."
          }
        }
      },
      "EmailLink": {
        "type": "object",
        "description": "An email link on or off.",
        "required": [
          "active"
        ],
        "properties": {
          "active": {
            "type": "boolean",
            "description": "Whether the link opens the quote."
          }
        },
        "additionalProperties": false
      },
      "EmailRead": {
        "type": "object",
        "description": "One time the recipient opened the email.",
        "required": [
          "read_at"
        ],
        "properties": {
          "read_at": {
            "type": "string",
            "description": "When it was opened (ISO 8601, UTC)."
          },
          "user_agent": {
            "type": [
              "string",
              "null"
            ],
            "description": "The reader's mail app or browser (`User-Agent`), when known."
          }
        }
      },
      "EmailTemplate": {
        "type": "object",
        "description": "An email template as the composer's picker shows it.",
        "required": [
          "id",
          "template_name",
          "template_subject",
          "template_body",
          "attachments",
          "scope",
          "can_edit",
          "sales_rep_ids"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "Template id."
          },
          "template_name": {
            "type": "string",
            "description": "Name in the picker."
          },
          "template_subject": {
            "type": "string",
            "description": "Subject (may hold `{{variables}}`)."
          },
          "template_body": {
            "type": "string",
            "description": "Body HTML (may hold `{{variables}}`)."
          },
          "attachments": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TemplateAttachment"
            },
            "description": "Files sent with it."
          },
          "scope": {
            "$ref": "#/components/schemas/TemplateScope",
            "description": "Company-wide or the caller's own."
          },
          "can_edit": {
            "type": "boolean",
            "description": "The caller may edit or delete it (only their own templates)."
          },
          "lead_list_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "The deal list whose deals get it automatically: a company template\ngoes to the reps who use the company's automations, a personal one to\nits owner's deals when they use their own. Null: never automatic."
          },
          "hour_delay": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Hours after a deal enters `lead_list_id` that it is sent."
          },
          "sales_rep_ids": {
            "type": "array",
            "items": {
              "type": "integer",
              "format": "int32"
            },
            "description": "Company drip: sales reps whose deals get it; empty: every rep's."
          },
          "list_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "Name of that list (null when it was deleted)."
          },
          "group_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "Name of the list's group."
          },
          "created_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When it was made."
          }
        }
      },
      "EmailTemplateDraft": {
        "type": "object",
        "description": "A drafted template.",
        "required": [
          "template_name",
          "template_subject",
          "template_body"
        ],
        "properties": {
          "template_name": {
            "type": "string",
            "description": "A short name for the template."
          },
          "template_subject": {
            "type": "string",
            "description": "Subject line; may hold `{{variables}}`."
          },
          "template_body": {
            "type": "string",
            "description": "HTML body; may hold `{{variables}}`."
          }
        }
      },
      "EmailTemplateInput": {
        "type": "object",
        "description": "Body of `POST /v1/email-templates` and `PUT /v1/email-templates/{id}`.",
        "required": [
          "template_name",
          "template_subject",
          "template_body"
        ],
        "properties": {
          "template_name": {
            "type": "string",
            "description": "Name (1–255 characters)."
          },
          "template_subject": {
            "type": "string",
            "description": "Subject (1–255 characters)."
          },
          "template_body": {
            "type": "string",
            "description": "Body, at most 65,535 bytes; `{{` and `}}` must pair up."
          },
          "scope": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/TemplateScope",
                "description": "Create only: `company` (admins) or `personal` (default)."
              },
              {
                "type": "null"
              }
            ]
          },
          "lead_list_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Send it automatically when a deal enters this list (with\n`hour_delay`); null for no automation. A personal template sends for\nits owner's deals once they use their own automations\n(`PUT /v1/me/lead-automation`)."
          },
          "hour_delay": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Hours to wait (0–8760); required with `lead_list_id`."
          },
          "sales_rep_ids": {
            "type": [
              "array",
              "null"
            ],
            "items": {
              "type": "integer",
              "format": "int32"
            },
            "description": "Company templates with `lead_list_id`: sales reps whose deals get\nit; empty: every rep's. Left out keeps the template's reps. Ignored\nfor a personal template."
          }
        },
        "additionalProperties": false
      },
      "EmailedPicture": {
        "type": "object",
        "description": "A picture a customer emailed.",
        "required": [
          "id",
          "filename",
          "sender_email"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int64",
            "description": "The attachment's id."
          },
          "filename": {
            "type": "string",
            "description": "Its file name (`customer-image-<id>` when it has none)."
          },
          "sent_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When the email arrived."
          },
          "sender_email": {
            "type": "string",
            "description": "Who sent it."
          },
          "customer_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "The customer with that address, when known."
          }
        }
      },
      "EmailedPictures": {
        "type": "object",
        "description": "A page of pictures.",
        "required": [
          "pictures",
          "has_more"
        ],
        "properties": {
          "pictures": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/EmailedPicture"
            },
            "description": "Newest first."
          },
          "has_more": {
            "type": "boolean",
            "description": "More pictures follow."
          }
        }
      },
      "EmailsBatchRequest": {
        "type": "object",
        "description": "Body of `POST /v1/customers/emails/batch`.",
        "required": [
          "customer_ids"
        ],
        "properties": {
          "customer_ids": {
            "type": "array",
            "items": {
              "type": "integer",
              "format": "int32"
            },
            "description": "Customer ids to look up, at most 20000. Ids of other companies are ignored."
          }
        }
      },
      "EmployeeTest": {
        "type": "object",
        "description": "`GET /v1/teach-mode`.",
        "required": [
          "questions",
          "answer_choices",
          "instructions"
        ],
        "properties": {
          "questions": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TestQuestion"
            },
            "description": "Visible questions, newest first."
          },
          "answer_choices": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/AnswerChoice"
            },
            "description": "Their answers, by question."
          },
          "instructions": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TestInstruction"
            },
            "description": "Instructions with visible questions, by title."
          }
        }
      },
      "EnteredCode": {
        "type": "object",
        "description": "A code the visitor typed.",
        "required": [
          "code"
        ],
        "properties": {
          "code": {
            "type": "string",
            "description": "The 6 digits from the email or text."
          }
        }
      },
      "EntityType": {
        "type": "string",
        "description": "The form of business behind the brand.",
        "enum": [
          "PrivateProfit",
          "PublicProfit",
          "NonProfit",
          "Government"
        ]
      },
      "Equipment": {
        "type": "object",
        "description": "A piece of equipment.",
        "required": [
          "id",
          "name",
          "usage_unit"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "Equipment id."
          },
          "name": {
            "type": "string",
            "description": "Name."
          },
          "hours_per_day": {
            "type": [
              "number",
              "null"
            ],
            "format": "double",
            "description": "Usage per working day (hours or miles)."
          },
          "days_per_month": {
            "type": [
              "number",
              "null"
            ],
            "format": "double",
            "description": "Working days per month."
          },
          "starting_hours": {
            "type": [
              "number",
              "null"
            ],
            "format": "double",
            "description": "Meter reading at the start."
          },
          "usage_unit": {
            "type": "string",
            "description": "`hours` or `miles`."
          }
        }
      },
      "EquipmentInput": {
        "type": "object",
        "description": "Body of creating or saving equipment.",
        "required": [
          "name"
        ],
        "properties": {
          "name": {
            "type": "string",
            "description": "Name; 1 to 255 characters."
          },
          "hours_per_day": {
            "type": [
              "number",
              "null"
            ],
            "format": "double",
            "description": "Usage per working day, more than 0 (at most 24 hours)."
          },
          "days_per_month": {
            "type": [
              "number",
              "null"
            ],
            "format": "double",
            "description": "Working days per month, more than 0, at most 31."
          },
          "starting_hours": {
            "type": [
              "number",
              "null"
            ],
            "format": "double",
            "description": "Meter reading, 0 or more."
          },
          "usage_unit": {
            "type": [
              "string",
              "null"
            ],
            "description": "`hours` (default) or `miles`."
          }
        },
        "additionalProperties": false
      },
      "ErrorBody": {
        "type": "object",
        "description": "Body of every error response.",
        "required": [
          "error"
        ],
        "properties": {
          "error": {
            "type": "string",
            "description": "Short reason: `unauthorized`, `forbidden`, `not found`, `database error`, or the\nbad-request message (e.g. `invalid sales_rep: abc`)."
          }
        }
      },
      "EstimateInput": {
        "allOf": [
          {
            "$ref": "#/components/schemas/EventInput",
            "description": "The event; `calendar_id` must be the company's estimates calendar\n(`GET /v1/schedule/settings`)."
          },
          {
            "type": "object",
            "required": [
              "customer_id"
            ],
            "properties": {
              "customer_id": {
                "type": "integer",
                "format": "int32",
                "description": "The customer the estimate is for."
              },
              "deal_id": {
                "type": [
                  "integer",
                  "null"
                ],
                "format": "int32",
                "description": "The deal it is for: the user it is assigned to is the event's person\nand the rep's reminders link to it (default the customer's newest deal)."
              },
              "customer_email": {
                "type": [
                  "string",
                  "null"
                ],
                "description": "Where to email the confirmation when it cannot be texted (default the\ncustomer's primary email)."
              },
              "showroom": {
                "type": "boolean",
                "description": "A showroom appointment instead of an in-home estimate: the customer's\nmessages say \"showroom appointment\" (default false)."
              }
            }
          }
        ],
        "description": "Body of `POST /v1/events/estimates`."
      },
      "EstimateTime": {
        "type": "object",
        "description": "`GET /v1/customers/{id}/estimate-time`.",
        "properties": {
          "time": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/AgreedTime",
                "description": "Null when no exact time was agreed (or the AI did not answer)."
              },
              {
                "type": "null"
              }
            ]
          }
        }
      },
      "EvaluateInput": {
        "type": "object",
        "description": "Body of `POST /v1/me/call-coaching`.",
        "required": [
          "call_id"
        ],
        "properties": {
          "call_id": {
            "type": "string",
            "description": "One of the calls `GET` listed."
          }
        }
      },
      "EventAttachment": {
        "type": "object",
        "description": "A document or image attached to the event.",
        "required": [
          "id",
          "event_id",
          "url",
          "name",
          "kind"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "The attachment."
          },
          "event_id": {
            "type": "integer",
            "format": "int32",
            "description": "Its event."
          },
          "url": {
            "type": "string",
            "description": "Where it is stored."
          },
          "name": {
            "type": "string",
            "description": "File name."
          },
          "kind": {
            "type": "string",
            "description": "`document` or `image`."
          },
          "created_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When it was attached."
          },
          "created_by": {
            "type": [
              "string",
              "null"
            ],
            "description": "Who attached it."
          }
        }
      },
      "EventComment": {
        "type": "object",
        "description": "A comment on an event.",
        "required": [
          "id",
          "event_id",
          "content"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "The comment."
          },
          "event_id": {
            "type": "integer",
            "format": "int32",
            "description": "Its event."
          },
          "content": {
            "type": "string",
            "description": "The text."
          },
          "created_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When it was written."
          },
          "created_by": {
            "type": [
              "string",
              "null"
            ],
            "description": "Author's name."
          }
        }
      },
      "EventCrewCheck": {
        "type": "object",
        "description": "One check of an appointment.",
        "required": [
          "id",
          "label",
          "checked"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "The check's id."
          },
          "label": {
            "type": "string",
            "description": "What was checked."
          },
          "checked": {
            "type": "boolean",
            "description": "Ticked: it is right."
          },
          "note": {
            "type": [
              "string",
              "null"
            ],
            "description": "The crew's note, e.g. \"Sink cabinet is 1/2 inch short\"."
          }
        }
      },
      "EventCrewCheckInput": {
        "type": "object",
        "description": "One check to save.",
        "required": [
          "label"
        ],
        "properties": {
          "label": {
            "type": "string",
            "description": "What was checked: 1 to 200 characters (trimmed)."
          },
          "checked": {
            "type": "boolean",
            "description": "Ticked: it is right."
          },
          "note": {
            "type": [
              "string",
              "null"
            ],
            "description": "A note: at most 1000 characters; blank means none."
          }
        }
      },
      "EventCrewChecks": {
        "type": "object",
        "description": "An appointment's crew checks.",
        "required": [
          "items"
        ],
        "properties": {
          "kind": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/CrewChecklistKind",
                "description": "Whose they are; null until saved."
              },
              {
                "type": "null"
              }
            ]
          },
          "checklist_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "The list they came from; null when none."
          },
          "saved_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When they were last saved (UTC); null until then."
          },
          "saved_by": {
            "type": [
              "string",
              "null"
            ],
            "description": "Who saved them."
          },
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/EventCrewCheck"
            },
            "description": "The checks, in order."
          }
        }
      },
      "EventCustomerTodos": {
        "type": "object",
        "description": "A template appointment's to-dos.",
        "required": [
          "nothing_to_do",
          "todos",
          "people"
        ],
        "properties": {
          "sent_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When the template maker sent them (UTC); null until then."
          },
          "sent_by": {
            "type": [
              "string",
              "null"
            ],
            "description": "Who sent them."
          },
          "nothing_to_do": {
            "type": "boolean",
            "description": "True when they said there is nothing to do."
          },
          "todos": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CustomerTodo"
            },
            "description": "The to-dos sent from this appointment, in the order they were sent."
          },
          "sales_rep_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "The job's sales rep: a list item with no person goes to them."
          },
          "people": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TodoPerson"
            },
            "description": "The people involved in the job's project (the sales rep first), to\ngive a to-do to."
          }
        }
      },
      "EventDetails": {
        "type": "object",
        "description": "`GET /v1/events/{id}/details`.",
        "required": [
          "comments",
          "photos",
          "attachments",
          "issues",
          "customer_todos",
          "crew_checks",
          "history",
          "creator",
          "automated"
        ],
        "properties": {
          "comments": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/EventComment"
            },
            "description": "Oldest first."
          },
          "photos": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/EventPhoto"
            },
            "description": "Files posted in the comments, oldest first."
          },
          "attachments": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/EventAttachment"
            },
            "description": "Attachments, oldest first."
          },
          "issues": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/EventIssue"
            },
            "description": "Problems reported on the job (`POST /v1/events/{id}/issues`), oldest\nfirst, each with its pictures."
          },
          "customer_todos": {
            "$ref": "#/components/schemas/EventCustomerTodos",
            "description": "What the customer must do before install, sent from this template\nappointment (`POST /v1/events/{id}/customer-todos`)."
          },
          "crew_checks": {
            "$ref": "#/components/schemas/EventCrewChecks",
            "description": "What Template Guy checked in the template, or the installer at the\ninstall (`PUT /v1/events/{id}/crew-checks`); no items until saved."
          },
          "history": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/EventHistoryItem"
            },
            "description": "History, oldest first."
          },
          "creator": {
            "$ref": "#/components/schemas/EventPerson",
            "description": "Who made the event. For an `automated` event, whoever sold the quote."
          },
          "automated": {
            "type": "boolean",
            "description": "Added by the CRM on its own when a quote was sold (Mark as Sold's\njobs and extra events), not by a person: show it as made by the\nsystem. Its history line \"Added when the quote was sold\" has no author."
          },
          "assignee": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/EventPerson",
                "description": "Who it is assigned to."
              },
              {
                "type": "null"
              }
            ]
          },
          "viewer_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "The caller's name (comments are theirs when the author matches)."
          }
        }
      },
      "EventHistoryItem": {
        "type": "object",
        "description": "A line of the event's history.",
        "required": [
          "id",
          "event_id",
          "action",
          "message"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "The line."
          },
          "event_id": {
            "type": "integer",
            "format": "int32",
            "description": "Its event."
          },
          "action": {
            "type": "string",
            "description": "e.g. `created`, `date_updated`."
          },
          "message": {
            "type": "string",
            "description": "Shown text."
          },
          "body": {
            "type": [
              "string",
              "null"
            ],
            "description": "The full text the customer got, for a line about a text or email\nsent to them (its subject, a blank line, then its body for an\nemail). None on other lines and on lines older than this field."
          },
          "created_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When."
          },
          "created_by": {
            "type": [
              "string",
              "null"
            ],
            "description": "Who."
          },
          "created_by_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Who, by user id (their picture); None on older lines and lines no\nperson made."
          },
          "from_value": {
            "type": [
              "string",
              "null"
            ],
            "description": "The value before the change, on lines of an edit (newer than this\nfield): a readiness key (`not_ready`, `called`, `ready`,\n`confirmed`, `scheduled`), a label color key, a title, a calendar\nname, an address, or for `date_updated` the dates as\n`start/end` (UTC `YYYY-MM-DDTHH:MM:SSZ`, or `YYYY-MM-DD` all day) or\n`unscheduled`. None when it was empty or the line is not a change."
          },
          "to_value": {
            "type": [
              "string",
              "null"
            ],
            "description": "The value after the change, in the same form as `from_value`."
          },
          "field": {
            "type": [
              "string",
              "null"
            ],
            "description": "What changed: `status`, `date`, `label`, `title`, `calendar` or\n`location`. None on other lines."
          }
        }
      },
      "EventInput": {
        "type": "object",
        "description": "Body of `POST /v1/events` and `PUT /v1/events/{id}`.",
        "required": [
          "title",
          "start_date",
          "end_date"
        ],
        "properties": {
          "title": {
            "type": "string",
            "description": "1 to 255 characters."
          },
          "description": {
            "type": [
              "string",
              "null"
            ],
            "description": "Sent by old apps only: never stored, it goes on top of `notes`."
          },
          "notes": {
            "type": [
              "string",
              "null"
            ],
            "description": "The event's text (events have no other text field)."
          },
          "location": {
            "type": [
              "string",
              "null"
            ],
            "description": "Address, up to 500 characters."
          },
          "color": {
            "type": [
              "string",
              "null"
            ],
            "description": "Label color (default `blue`)."
          },
          "status": {
            "type": [
              "string",
              "null"
            ],
            "description": "Default `scheduled`."
          },
          "urgent": {
            "type": [
              "boolean",
              "null"
            ],
            "description": "Red flag: it must be scheduled fast. Leave out to keep it (a new\nevent: not urgent)."
          },
          "all_day": {
            "type": "boolean",
            "description": "All-day event."
          },
          "unscheduled": {
            "type": "boolean",
            "description": "Waiting for its day: off the calendar, in the unscheduled list. The\ndates may then be left empty (they become now)."
          },
          "calendar_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "The company calendar it is on; required."
          },
          "rrule": {
            "type": [
              "string",
              "null"
            ],
            "description": "iCalendar repeat rule, up to 500 characters."
          },
          "recurrence_until": {
            "type": [
              "string",
              "null"
            ],
            "description": "Last repeat, UTC `YYYY-MM-DD HH:MM:SS` (only with `rrule`)."
          },
          "start_date": {
            "type": "string",
            "description": "Start, UTC `YYYY-MM-DD HH:MM:SS`."
          },
          "end_date": {
            "type": "string",
            "description": "End, UTC `YYYY-MM-DD HH:MM:SS`; not before the start."
          },
          "assigned_user_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "The user it is assigned to."
          },
          "people_ids": {
            "type": [
              "array",
              "null"
            ],
            "items": {
              "type": "integer",
              "format": "int32"
            },
            "description": "People of the company added to it (user ids from\n`GET /v1/schedule/team`, at most 50): it shows on each one's own\nschedule. Exactly these are saved; `[]` removes everyone. Left out:\nan edit keeps the saved ones, a new event gets its creator."
          },
          "sale_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "The sale it is for."
          },
          "customer_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "The customer it is for, one of the company's; null unlinks them,\nleave out to keep them. The title stays the event's own name."
          },
          "contact_phone": {
            "type": [
              "string",
              "null"
            ],
            "description": "Phone for this event only (a spouse, a homeowner on a contractor's\naccount), up to 50 characters; empty or null uses the customer's,\nleave out to keep it. Never changes the customer."
          },
          "contact_email": {
            "type": [
              "string",
              "null"
            ],
            "description": "Email for this event only, up to 255 characters; like `contact_phone`."
          },
          "contact_phone_2": {
            "type": [
              "string",
              "null"
            ],
            "description": "A second phone for this event; every automated text goes to both.\nEmpty or null clears it, leave out to keep it."
          },
          "contact_email_2": {
            "type": [
              "string",
              "null"
            ],
            "description": "A second email for this event; every automated email goes to both."
          },
          "qbo_invoice": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/EventInvoice",
                "description": "Link or unlink the QuickBooks invoice; leave out to keep it."
              },
              {
                "type": "null"
              }
            ]
          },
          "copy_from_event_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Create only: copy comments, comment files and these attachments\nfrom this event of the company."
          },
          "copy_attachment_ids": {
            "type": [
              "array",
              "null"
            ],
            "items": {
              "type": "integer",
              "format": "int32"
            },
            "description": "Create only: attachments of `copy_from_event_id` to copy. On an edit\nof some repeats (`scope=one` or `following`): the repeating event's\nattachments the new event keeps (left out: all of them)."
          },
          "skipped_notification_flow_ids": {
            "type": [
              "array",
              "null"
            ],
            "items": {
              "type": "integer",
              "format": "int32"
            },
            "description": "Its calendar's default notification flow, turned off for this\nevent; leave out to keep the saved choice."
          },
          "picked_notification_flow_ids": {
            "type": [
              "array",
              "null"
            ],
            "items": {
              "type": "integer",
              "format": "int32"
            },
            "description": "Its calendar's other notification flows picked for this event;\nleave out to keep the saved choice."
          },
          "project_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Create only: the project this template or installation is for."
          },
          "project_part_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Create only: the part of that project it is for."
          }
        }
      },
      "EventInvoice": {
        "type": "object",
        "description": "The QuickBooks invoice shown on an event.",
        "properties": {
          "id": {
            "type": [
              "string",
              "null"
            ],
            "description": "QuickBooks invoice id (digits); empty or null unlinks the invoice."
          },
          "number": {
            "type": [
              "string",
              "null"
            ],
            "description": "Its number as shown in QuickBooks."
          }
        }
      },
      "EventIssue": {
        "type": "object",
        "description": "A problem reported on an event.",
        "required": [
          "id",
          "event_id",
          "description",
          "photos",
          "comments"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "The issue's id."
          },
          "event_id": {
            "type": "integer",
            "format": "int32",
            "description": "The event it is on."
          },
          "description": {
            "type": "string",
            "description": "What is wrong, as the reporter wrote it (1 to 2000 characters)."
          },
          "created_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When it was reported (UTC)."
          },
          "created_by_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "The reporter's user id; null once that user is gone."
          },
          "created_by": {
            "type": [
              "string",
              "null"
            ],
            "description": "The reporter's name."
          },
          "solved_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When it was marked solved (UTC); null while it is open."
          },
          "solved_by": {
            "type": [
              "string",
              "null"
            ],
            "description": "Who marked it solved."
          },
          "in_progress_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When someone marked it in progress (UTC); null while nobody has."
          },
          "in_progress_by": {
            "type": [
              "string",
              "null"
            ],
            "description": "Who marked it in progress."
          },
          "photos": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/IssuePhoto"
            },
            "description": "Its pictures, in the order they were sent."
          },
          "comments": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/IssueComment"
            },
            "description": "Comments under it, oldest first (`POST /v1/issues/{issue_id}/comments`)."
          }
        }
      },
      "EventPerson": {
        "type": "object",
        "description": "A user on the event.",
        "required": [
          "id",
          "name"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "The user."
          },
          "name": {
            "type": "string",
            "description": "Their name."
          }
        }
      },
      "EventPhoto": {
        "type": "object",
        "description": "A file posted in the event's comments.",
        "required": [
          "id",
          "event_id",
          "url",
          "name",
          "source"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "The file."
          },
          "event_id": {
            "type": "integer",
            "format": "int32",
            "description": "Its event."
          },
          "url": {
            "type": "string",
            "description": "Where it is stored."
          },
          "name": {
            "type": "string",
            "description": "Last part of the URL."
          },
          "created_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When it was posted."
          },
          "created_by": {
            "type": [
              "string",
              "null"
            ],
            "description": "Poster's name."
          },
          "source": {
            "type": "string",
            "description": "Always `photo`."
          },
          "stage": {
            "type": [
              "string",
              "null"
            ],
            "description": "On the crew's job page: `before` (Before photos) or `installed`\n(Installed photos); null for any other comment file."
          }
        }
      },
      "EventProjectLink": {
        "type": "object",
        "description": "`GET /v1/projects/event-links/{event_id}`.",
        "required": [
          "projects",
          "events"
        ],
        "properties": {
          "project_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "The project the event is linked to."
          },
          "projects": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/LinkProject"
            },
            "description": "The customer's open projects the caller can see."
          },
          "events": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/LinkEvent"
            },
            "description": "The customer's events (this one included), soonest first; only this\none when the event has no customer."
          }
        }
      },
      "EventProjectLinkInput": {
        "type": "object",
        "description": "`PUT /v1/projects/event-links/{event_id}`.",
        "properties": {
          "project_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "The project; null unlinks."
          },
          "event_ids": {
            "type": "array",
            "items": {
              "type": "integer",
              "format": "int32"
            },
            "description": "The customer's other events to link (or unlink) with it."
          }
        }
      },
      "EventSale": {
        "type": "object",
        "description": "`GET /v1/events/{id}/sale`.",
        "required": [
          "sale_ids"
        ],
        "properties": {
          "sale_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "The project's newest sale (it holds the notes); null when none."
          },
          "sale_ids": {
            "type": "array",
            "items": {
              "type": "integer",
              "format": "int32"
            },
            "description": "Every sale of the project, newest first: one per area when they were\nsold apart."
          }
        }
      },
      "EventsInput": {
        "type": "object",
        "description": "Body of `POST /v1/me/onboarding/events`.",
        "required": [
          "events"
        ],
        "properties": {
          "events": {
            "type": "array",
            "items": {
              "type": "object"
            },
            "description": "1 to 200 events, oldest first. Each has a `type` and an ISO 8601 `at`:\n`journey.position` (`moduleId`, `stepKey`), `journey.module_step`,\n`journey.module_completed`, `journey.module_reopened` (`moduleId`),\n`journey.dismissed`, `journey.resumed`, `journey.completed`,\n`journey.feedback_dismissed`, `task.position` (`taskId`, `version`,\n`stepKey`, optional `usageSkipped`: true when the tour is a replay of a\nfeature the user already uses, which then pays 0 points; optional\n`trigger`: `auto` | `user` | `gesture`, what started the tour) and\n`task.closed` (`taskId`, `version`, `stepKey`), `task.step_done` (`taskId`,\n`version`, `steps`: step key → `action` | `manual`), `task.completed`\n(`taskId`, `version`), `task.sighted` (`taskId`: the user met the tour's\nopening control on its own page before the tour ever ran; the first one\nis kept, replays change nothing, and it creates no tour progress)."
          }
        }
      },
      "ExportsRun": {
        "type": "object",
        "description": "What one call did.",
        "required": [
          "processed",
          "sent",
          "failed",
          "alerts",
          "deleted"
        ],
        "properties": {
          "processed": {
            "type": "integer",
            "description": "Exports sent (what the scheduler logs).",
            "minimum": 0
          },
          "sent": {
            "type": "integer",
            "description": "Exports sent.",
            "minimum": 0
          },
          "failed": {
            "type": "integer",
            "description": "Export attempts that failed (tried again a few minutes later).",
            "minimum": 0
          },
          "alerts": {
            "type": "integer",
            "description": "Failure alerts sent.",
            "minimum": 0
          },
          "deleted": {
            "type": "integer",
            "description": "Old zips deleted from storage.",
            "minimum": 0
          }
        }
      },
      "ExtendInput": {
        "type": "object",
        "description": "Body of `POST /v1/deals/{id}/extend-limit`.",
        "required": [
          "days"
        ],
        "properties": {
          "days": {
            "type": "integer",
            "format": "int32",
            "description": "1–30 days."
          }
        },
        "additionalProperties": false
      },
      "ExtensionReport": {
        "type": "object",
        "description": "The texts of one extension in the window.",
        "required": [
          "extension",
          "texts",
          "known",
          "handed_over",
          "failed"
        ],
        "properties": {
          "extension": {
            "type": "string",
            "description": "The `RingCentral` extension id."
          },
          "texts": {
            "type": "integer",
            "description": "Texts `RingCentral` keeps for the window.",
            "minimum": 0
          },
          "known": {
            "type": "integer",
            "description": "Of those, the ones the CRM already had.",
            "minimum": 0
          },
          "handed_over": {
            "type": "integer",
            "description": "The others, handed to the webhook to store.",
            "minimum": 0
          },
          "failed": {
            "type": "integer",
            "description": "Hand-overs the webhook refused or that failed (logged).",
            "minimum": 0
          },
          "error": {
            "type": [
              "string",
              "null"
            ],
            "description": "Why the extension's texts could not be read, when they could not."
          }
        }
      },
      "ExtrasCatalog": {
        "type": "object",
        "description": "The catalog.",
        "required": [
          "catalog",
          "list_only"
        ],
        "properties": {
          "catalog": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CatalogExtra"
            },
            "description": "In order."
          },
          "list_only": {
            "type": "integer",
            "description": "Extras the price lists still keep only for themselves (to move here).",
            "minimum": 0
          }
        }
      },
      "FailedAttachment": {
        "type": "object",
        "description": "A file that could not be prepared.",
        "required": [
          "filename",
          "error"
        ],
        "properties": {
          "filename": {
            "type": "string",
            "description": "The name it was picked with."
          },
          "error": {
            "type": "string",
            "description": "Why: `invalid_upload`, `upload_missing`, `empty_file`,\n`file_too_large`, `unsupported_image`, `image_too_large` or `upload_failed`."
          }
        }
      },
      "Faucet": {
        "type": "object",
        "description": "A faucet model the company sells, with how many units are free to sell.",
        "required": [
          "id",
          "name",
          "type",
          "url",
          "is_display",
          "regular_stock",
          "available"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "Faucet model id."
          },
          "name": {
            "type": "string",
            "description": "Model name, e.g. \"Pull-Down Chrome\"."
          },
          "type": {
            "type": "string",
            "description": "Faucet type, e.g. `single handle` or `double handle`."
          },
          "url": {
            "type": "string",
            "description": "Image URL; may be empty."
          },
          "supplier_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Supplier id; null if unknown."
          },
          "is_display": {
            "type": "boolean",
            "description": "Shown to customers in the showroom catalog."
          },
          "regular_stock": {
            "type": "boolean",
            "description": "Always orderable from the supplier, so never sold out even with no units."
          },
          "retail_price": {
            "type": [
              "string",
              "null"
            ],
            "description": "Retail price as a decimal string, e.g. `\"129.99\"`; null if not set."
          },
          "cost": {
            "type": [
              "string",
              "null"
            ],
            "description": "Purchase cost as a decimal string; null if not set."
          },
          "available": {
            "type": "integer",
            "format": "int64",
            "description": "Units in stock that are not installed on a sold slab."
          }
        }
      },
      "Feature": {
        "type": "object",
        "description": "A feature a company can pay for.",
        "required": [
          "id",
          "name"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "The feature's id, used in the paid-features routes."
          },
          "name": {
            "type": "string",
            "description": "Its name as the superuser screen shows it, e.g. \"E-signatures\"."
          },
          "usage_metric": {
            "type": [
              "string",
              "null"
            ],
            "description": "The usage count shown for it (a `metrics` key); null: none."
          },
          "monthly_price_cents": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "What it costs a month, in USD cents; null: no price. Bookkeeping for\npricing by feature later: self sign-up charges a flat price for now."
          }
        }
      },
      "FeatureCall": {
        "type": "object",
        "description": "A recent call.",
        "required": [
          "id",
          "model",
          "api_kind",
          "cost_usd",
          "success",
          "created_at"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int64",
            "description": "The log row."
          },
          "model": {
            "type": "string",
            "description": "Model used."
          },
          "api_kind": {
            "type": "string",
            "description": "`chat`, `image` or `transcription`."
          },
          "user_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "Who made it; null for background jobs."
          },
          "input_tokens": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int64",
            "description": "Input tokens."
          },
          "output_tokens": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int64",
            "description": "Output tokens."
          },
          "cost_usd": {
            "type": "number",
            "format": "double",
            "description": "Cost (USD)."
          },
          "success": {
            "type": "boolean",
            "description": "It succeeded."
          },
          "duration_ms": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int64",
            "description": "How long it took."
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "description": "When."
          }
        }
      },
      "FeatureInput": {
        "type": "object",
        "description": "Body of `POST /v1/superuser/paid-features` and `PUT .../{id}`.",
        "required": [
          "name"
        ],
        "properties": {
          "name": {
            "type": "string",
            "description": "1 to 128 characters, unique."
          },
          "usage_metric": {
            "type": [
              "string",
              "null"
            ],
            "description": "A `metrics` key, or null for no usage count."
          },
          "monthly_price_cents": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Monthly price in USD cents (50 to 10,000,000), or null for no price.\nLeave it out to keep the price as it is."
          }
        }
      },
      "FeatureMetrics": {
        "type": "object",
        "description": "Totals of the feature in the range.",
        "required": [
          "requests",
          "avg_cost_usd",
          "total_cost_usd"
        ],
        "properties": {
          "requests": {
            "type": "integer",
            "format": "int64",
            "description": "Calls."
          },
          "success_rate": {
            "type": [
              "number",
              "null"
            ],
            "format": "double",
            "description": "Share that succeeded, 0 to 1; null without calls."
          },
          "avg_input_tokens": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int64",
            "description": "Average input tokens."
          },
          "avg_output_tokens": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int64",
            "description": "Average output tokens."
          },
          "avg_cost_usd": {
            "type": "number",
            "format": "double",
            "description": "Average cost per call (USD)."
          },
          "total_cost_usd": {
            "type": "number",
            "format": "double",
            "description": "Total cost (USD)."
          }
        }
      },
      "FeatureSale": {
        "type": "object",
        "description": "One sold quote's extras.",
        "required": [
          "quoteId",
          "rep",
          "features"
        ],
        "properties": {
          "quoteId": {
            "type": "integer",
            "format": "int32",
            "description": "The quote."
          },
          "userId": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "The rep: its salesperson, else who made it."
          },
          "rep": {
            "type": "string",
            "description": "Their name (\"Unassigned\" when none)."
          },
          "signedAt": {
            "type": [
              "string",
              "null"
            ],
            "description": "When it was sold or signed (YYYY-MM-DD)."
          },
          "features": {
            "type": "object",
            "description": "Dollars of each extra on the accepted option (`waterfall`, `miter`,\n`phantom_seam`, `custom_edge`, `support`, `faucet`, `soap_dispenser`).",
            "additionalProperties": {
              "type": "number",
              "format": "double"
            },
            "propertyNames": {
              "type": "string"
            }
          }
        }
      },
      "FeatureSales": {
        "type": "object",
        "description": "Sold quotes' extras.",
        "required": [
          "rows"
        ],
        "properties": {
          "rows": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/FeatureSale"
            },
            "description": "Sold quotes with at least one extra, newest first."
          }
        }
      },
      "FeatureUsage": {
        "type": "object",
        "description": "`GET /v1/ai-usage/feature`.",
        "required": [
          "metrics",
          "top_users",
          "recent_calls",
          "has_more_recent_calls"
        ],
        "properties": {
          "metrics": {
            "$ref": "#/components/schemas/FeatureMetrics",
            "description": "Totals."
          },
          "top_users": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/FeatureUser"
            },
            "description": "The five costliest users."
          },
          "recent_calls": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/FeatureCall"
            },
            "description": "Newest calls first."
          },
          "has_more_recent_calls": {
            "type": "boolean",
            "description": "More calls than `call_limit` (under 200)."
          }
        }
      },
      "FeatureUser": {
        "type": "object",
        "description": "One of the five costliest users.",
        "required": [
          "requests",
          "cost_usd"
        ],
        "properties": {
          "user_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "The user; null for background jobs."
          },
          "name": {
            "type": [
              "string",
              "null"
            ],
            "description": "Their name."
          },
          "requests": {
            "type": "integer",
            "format": "int64",
            "description": "Calls."
          },
          "cost_usd": {
            "type": "number",
            "format": "double",
            "description": "Cost (USD)."
          }
        }
      },
      "Features": {
        "type": "object",
        "description": "A company's switches.",
        "required": [
          "quickbooks",
          "signature",
          "onboarding",
          "leaderboard",
          "customer_payments"
        ],
        "properties": {
          "quickbooks": {
            "type": "boolean",
            "description": "QuickBooks is on."
          },
          "signature": {
            "type": "boolean",
            "description": "The old company eSignatures switch; no longer used (eSignatures are\ngiven per user)."
          },
          "onboarding": {
            "type": "boolean",
            "description": "Guided tours are on (own switch, else the platform default)."
          },
          "leaderboard": {
            "type": "boolean",
            "description": "The points leaderboard is on (own switch, else the platform default)."
          },
          "customer_payments": {
            "type": "boolean",
            "description": "Customer payments are on: the company may connect a bank account and\ntake its customers' payments by card or ACH. Off unless turned on."
          }
        }
      },
      "FeedbackInput": {
        "type": "object",
        "description": "Body of `POST /v1/ai/crm-manual-feedback`.",
        "required": [
          "intent"
        ],
        "properties": {
          "intent": {
            "$ref": "#/components/schemas/Intent",
            "description": "`dislike`, `approve` or `escalate`."
          },
          "question": {
            "type": "string",
            "description": "The user's question (`dislike`)."
          },
          "originalAnswer": {
            "type": "string",
            "description": "The answer they disliked (`dislike`)."
          },
          "attempt": {
            "type": "integer",
            "format": "int64",
            "description": "The correction attempt, 1 or 2 (`dislike`, `approve`)."
          },
          "previousCorrections": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Corrections already disliked (`dislike`)."
          },
          "dialog": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/DialogMessage"
            },
            "description": "The conversation (`approve`, `escalate`)."
          },
          "correctedAnswer": {
            "type": "string",
            "description": "The approved answer (`approve`)."
          },
          "sectionId": {
            "type": [
              "string",
              "null"
            ],
            "description": "The manual section it is about."
          },
          "proposedManualChange": {
            "type": [
              "string",
              "null"
            ],
            "description": "A suggested change for that section."
          },
          "feedbackText": {
            "type": [
              "string",
              "null"
            ],
            "description": "What the user wrote."
          }
        },
        "additionalProperties": false
      },
      "FeedbackOut": {
        "oneOf": [
          {
            "$ref": "#/components/schemas/CorrectionOut",
            "description": "For `dislike`."
          },
          {
            "$ref": "#/components/schemas/SavedFeedback",
            "description": "For `approve` and `escalate`."
          }
        ],
        "description": "The answer to a feedback call."
      },
      "FeedbackReview": {
        "type": "object",
        "description": "A thread waiting for review.",
        "required": [
          "id",
          "history",
          "status"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "Feedback id."
          },
          "user_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Who rated the answer, or null."
          },
          "company_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Their company, or null."
          },
          "company_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "Company name, or null."
          },
          "user_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "User name, or null."
          },
          "history": {
            "type": "object",
            "description": "The conversation as the chat saved it (`question`, `originalAnswer`,\n`corrections`, or `dialog`)."
          },
          "feedback_text": {
            "type": [
              "string",
              "null"
            ],
            "description": "What the user wrote, or null."
          },
          "status": {
            "type": "string",
            "description": "`user_approved` or `escalated`."
          },
          "manual_section_id": {
            "type": [
              "string",
              "null"
            ],
            "description": "The manual section to change, or null."
          },
          "proposed_manual_change": {
            "type": [
              "string",
              "null"
            ],
            "description": "The section's proposed new text, or null."
          },
          "created_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When it was sent (ISO 8601), or null."
          }
        }
      },
      "FieldKind": {
        "type": "string",
        "description": "What a field holds.",
        "enum": [
          "signature",
          "date",
          "text",
          "autofill_date_signed",
          "checkmark"
        ]
      },
      "FieldType": {
        "type": "string",
        "description": "What a blank is for.",
        "enum": [
          "signature",
          "date",
          "text",
          "skip"
        ]
      },
      "FieldsInput": {
        "type": "object",
        "description": "Body of `POST /v1/quotes/{id}/invoice-fields`.",
        "properties": {
          "lines": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "The texts of the draft's lines, as the quote makes them."
          }
        }
      },
      "FileConfirmationsRun": {
        "type": "object",
        "description": "What a run did.",
        "required": [
          "processed",
          "failed",
          "skipped"
        ],
        "properties": {
          "processed": {
            "type": "integer",
            "description": "Reports emailed (what the scheduler logs).",
            "minimum": 0
          },
          "failed": {
            "type": "integer",
            "description": "Reports that could not be sent (tried again the next minute).",
            "minimum": 0
          },
          "skipped": {
            "type": "boolean",
            "description": "Not report time: nothing was looked at."
          }
        }
      },
      "FileReadiness": {
        "type": "object",
        "description": "How far the company's price files for the searched suppliers are processed.",
        "required": [
          "total",
          "ready",
          "processing",
          "failed"
        ],
        "properties": {
          "total": {
            "type": "integer",
            "format": "int64",
            "description": "Price files."
          },
          "ready": {
            "type": "integer",
            "format": "int64",
            "description": "Processed and searchable."
          },
          "processing": {
            "type": "integer",
            "format": "int64",
            "description": "Waiting or being processed."
          },
          "failed": {
            "type": "integer",
            "format": "int64",
            "description": "Could not be processed."
          }
        }
      },
      "FileSource": {
        "type": "string",
        "description": "Where a file row lives; pass it back when deleting.",
        "enum": [
          "images",
          "documents"
        ]
      },
      "FiledBugReport": {
        "type": "object",
        "description": "The filed report.",
        "required": [
          "id",
          "notified"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "Report id."
          },
          "notified": {
            "type": "boolean",
            "description": "The team was emailed (false when the email failed; the report is saved)."
          }
        }
      },
      "FillRequest": {
        "type": "object",
        "description": "Body of `POST /v1/templates/fill`.",
        "required": [
          "template"
        ],
        "properties": {
          "template": {
            "type": "string",
            "description": "Text with `{{variables}}`."
          },
          "deal_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Deal the message is about."
          },
          "customer_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Customer the message is for."
          },
          "recipient_email": {
            "type": [
              "string",
              "null"
            ],
            "description": "Without `customer_id`: the company's customer with this address."
          }
        },
        "additionalProperties": false
      },
      "Filled": {
        "type": "object",
        "description": "Result of `POST /v1/templates/fill`.",
        "required": [
          "text"
        ],
        "properties": {
          "text": {
            "type": "string",
            "description": "The text with its variables filled."
          }
        }
      },
      "FinishReactivation": {
        "type": "object",
        "description": "Body of `POST /v1/billing/reactivation/finish`.",
        "properties": {
          "subscription_id": {
            "type": [
              "string",
              "null"
            ],
            "description": "The subscription the start call created (`sub_...`); omit when it\nanswered `paid`."
          }
        }
      },
      "FinishedImage": {
        "type": "object",
        "description": "The image to put on the form.",
        "required": [
          "url"
        ],
        "properties": {
          "url": {
            "type": "string",
            "description": "Its URL."
          }
        }
      },
      "FirstContactRequest": {
        "type": "object",
        "description": "`POST /v1/ai/first-contact-email`.",
        "properties": {
          "deal_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "The lead's deal."
          },
          "customer_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "The lead, when there is no deal."
          }
        }
      },
      "FirstPayment": {
        "type": "object",
        "description": "`GET /v1/billing/first-payment`.",
        "required": [
          "monthly_price_cents",
          "contact_email",
          "subscribed"
        ],
        "properties": {
          "monthly_price_cents": {
            "type": "integer",
            "format": "int64",
            "description": "What the company pays a month, in USD cents (80000: $800)."
          },
          "contact_email": {
            "type": "string",
            "description": "Who to write to for a free month and a demo instead of paying now."
          },
          "free_access_until": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "Granite Manager let the company in free until then (ISO 8601); its\nfirst charge waits for it. Null: no free time."
          },
          "subscribed": {
            "type": "boolean",
            "description": "A subscription is running already."
          }
        }
      },
      "FirstPaymentDate": {
        "type": "object",
        "description": "Body of `PUT /v1/superuser/companies/{id}/first-payment-date`.",
        "properties": {
          "first_payment_on": {
            "type": [
              "string",
              "null"
            ],
            "format": "date",
            "description": "The day of the first charge (`YYYY-MM-DD`), 3 to 700 days from today;\nnull to charge at checkout."
          }
        }
      },
      "FixtureInput": {
        "type": "object",
        "description": "Body of the create and edit routes of sink and faucet models.",
        "required": [
          "name",
          "type"
        ],
        "properties": {
          "name": {
            "type": "string",
            "description": "Model name; required, at most 255 characters."
          },
          "type": {
            "type": "string",
            "description": "Sinks: one of the company's sink types (`GET /v1/sink-types`), e.g.\n`stainless 18 gauge`, `composite`, `farm house`; case and outer\nspaces are ignored. Faucets: `single handle`, `double handle`."
          },
          "image_url": {
            "type": [
              "string",
              "null"
            ],
            "description": "Image: an upload to the model's folder (`POST /v1/uploads`). A new\nsink without one gets a placeholder image; faucets need one. Omit to\nkeep the image when editing."
          },
          "is_display": {
            "type": "boolean",
            "description": "Shown in the catalogs."
          },
          "regular_stock": {
            "type": "boolean",
            "description": "Always orderable."
          },
          "supplier_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Supplier of the company; null for none."
          },
          "length": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Length in whole inches (sinks only; ignored for faucets)."
          },
          "width": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Width in whole inches (sinks only; ignored for faucets)."
          },
          "retail_price": {
            "type": [
              "number",
              "null"
            ],
            "format": "double",
            "description": "Retail price in dollars; 0 or more, below 100,000,000."
          },
          "cost": {
            "type": [
              "number",
              "null"
            ],
            "format": "double",
            "description": "Cost in dollars; 0 or more, below 100,000,000."
          },
          "units": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int64",
            "description": "Units the model should have (free plus installed). Free units are\nadded or removed to match; units installed on sales are never\nremoved. Omit to leave the stock as is (creating: no units)."
          }
        },
        "additionalProperties": false
      },
      "FixtureModel": {
        "type": "object",
        "description": "A sink or faucet model with its stock, as the edit form shows it.",
        "required": [
          "id",
          "name",
          "type",
          "url",
          "is_display",
          "regular_stock",
          "units",
          "installed_units"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "Model id."
          },
          "name": {
            "type": "string",
            "description": "Model name."
          },
          "type": {
            "type": "string",
            "description": "Model type, e.g. `composite` or `single handle`."
          },
          "url": {
            "type": "string",
            "description": "Image URL; may be empty."
          },
          "is_display": {
            "type": "boolean",
            "description": "Shown to customers in the showroom catalog."
          },
          "regular_stock": {
            "type": "boolean",
            "description": "Always orderable, never sold out."
          },
          "supplier_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Supplier id; null for none."
          },
          "length": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Length in inches (sinks); null for faucets."
          },
          "width": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Width in inches (sinks); null for faucets."
          },
          "retail_price": {
            "type": [
              "string",
              "null"
            ],
            "description": "Retail price, decimal string; null if not set."
          },
          "cost": {
            "type": [
              "string",
              "null"
            ],
            "description": "Cost, decimal string; null if not set."
          },
          "units": {
            "type": "integer",
            "format": "int64",
            "description": "Units in stock or installed on sales (not deleted)."
          },
          "installed_units": {
            "type": "integer",
            "format": "int64",
            "description": "Units installed on sales (included in `units`)."
          }
        }
      },
      "FixturePhoto": {
        "type": "object",
        "description": "A photo of a model installed in a project.",
        "required": [
          "id"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "Photo id."
          },
          "url": {
            "type": [
              "string",
              "null"
            ],
            "description": "Photo URL."
          }
        }
      },
      "Flow": {
        "type": "object",
        "description": "A flow.",
        "required": [
          "id",
          "name",
          "scope",
          "can_edit",
          "steps"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "The flow."
          },
          "name": {
            "type": "string",
            "description": "Its name."
          },
          "scope": {
            "$ref": "#/components/schemas/TemplateScope"
          },
          "can_edit": {
            "type": "boolean",
            "description": "The caller may change it."
          },
          "steps": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/FlowStep"
            },
            "description": "In order."
          },
          "created_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When it was made."
          },
          "updated_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When it last changed."
          }
        }
      },
      "FlowAction": {
        "type": "object",
        "description": "`POST .../flow`.",
        "required": [
          "intent"
        ],
        "properties": {
          "intent": {
            "$ref": "#/components/schemas/FlowIntent"
          },
          "flow_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "The flow to start or switch to."
          }
        }
      },
      "FlowIntent": {
        "type": "string",
        "description": "What to do with the flow.",
        "enum": [
          "start",
          "switch",
          "pause",
          "resume",
          "stop",
          "dispatch",
          "send_now"
        ]
      },
      "FlowState": {
        "type": "object",
        "description": "The flow on a customer or thread.",
        "properties": {
          "active_flow": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/ActiveFlow",
                "description": "Running, paused or last failed; `None` when there is none (or the\ncaller may not see it)."
              },
              {
                "type": "null"
              }
            ]
          }
        }
      },
      "FlowStep": {
        "type": "object",
        "description": "One step of a flow.",
        "required": [
          "id",
          "position",
          "channel",
          "delay_minutes"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "The step."
          },
          "position": {
            "type": "integer",
            "format": "int32",
            "description": "1 = first."
          },
          "channel": {
            "$ref": "#/components/schemas/StepChannel"
          },
          "template_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "The template it sends, if any."
          },
          "template_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "The template's name (null when it is gone or not the company's)."
          },
          "custom_text": {
            "type": [
              "string",
              "null"
            ],
            "description": "Its own text, when it has no template."
          },
          "template_body": {
            "type": [
              "string",
              "null"
            ],
            "description": "The template's text, for display."
          },
          "subject": {
            "type": [
              "string",
              "null"
            ],
            "description": "Email subject of the step."
          },
          "template_subject": {
            "type": [
              "string",
              "null"
            ],
            "description": "The email template's subject, for display."
          },
          "delay_minutes": {
            "type": "integer",
            "format": "int32",
            "description": "Minutes after the previous step (or the start)."
          }
        }
      },
      "FlowStepInput": {
        "type": "object",
        "description": "A step of `NotificationFlowInput`.",
        "required": [
          "template_id",
          "offset_value",
          "offset_unit"
        ],
        "properties": {
          "id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "The step being edited; leave out for a new one."
          },
          "template_id": {
            "type": "integer",
            "format": "int32",
            "description": "A reminder template of the company."
          },
          "offset_value": {
            "type": "integer",
            "format": "int32",
            "description": "1 to 30 days' worth of `offset_unit`."
          },
          "offset_unit": {
            "$ref": "#/components/schemas/OffsetUnit"
          },
          "direction": {
            "$ref": "#/components/schemas/Direction",
            "description": "Default `before`."
          },
          "send_time": {
            "type": [
              "string",
              "null"
            ],
            "description": "`days` steps only: `HH:MM` store time."
          }
        }
      },
      "FlowUpdate": {
        "type": "object",
        "description": "Body of `PUT /v1/sms-flows/{id}`.",
        "required": [
          "name",
          "steps"
        ],
        "properties": {
          "name": {
            "type": "string",
            "description": "Up to 255 characters."
          },
          "steps": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/StepInput"
            },
            "description": "1 to 20 steps; they replace the old ones."
          }
        }
      },
      "Flows": {
        "type": "object",
        "description": "`GET /v1/sms-flows`.",
        "required": [
          "flows",
          "can_manage_company"
        ],
        "properties": {
          "flows": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Flow"
            },
            "description": "Company flows first, newest first."
          },
          "can_manage_company": {
            "type": "boolean",
            "description": "The caller may create and change company flows."
          }
        }
      },
      "Folder": {
        "type": "object",
        "description": "A folder (without its images).",
        "required": [
          "id",
          "name"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "Folder id."
          },
          "name": {
            "type": "string",
            "description": "Its name."
          }
        }
      },
      "FolderCounts": {
        "type": "object",
        "description": "Thread counts of the caller's folders.",
        "required": [
          "inbox_unread",
          "trash",
          "drafts"
        ],
        "properties": {
          "inbox_unread": {
            "type": "integer",
            "format": "int64",
            "description": "Unread inbox threads."
          },
          "trash": {
            "type": "integer",
            "format": "int64",
            "description": "Threads in the trash."
          },
          "drafts": {
            "type": "integer",
            "format": "int64",
            "description": "Draft threads."
          }
        }
      },
      "FolderInput": {
        "type": "object",
        "description": "Body of `POST /v1/image-folders` and `PATCH /v1/image-folders/{id}`.",
        "required": [
          "name"
        ],
        "properties": {
          "name": {
            "type": "string",
            "description": "Name (1–255 characters)."
          }
        },
        "additionalProperties": false
      },
      "Followup": {
        "type": "object",
        "description": "An AI text's follow-up: sent when the customer has not replied\n`after_hours` after it, within the company's texting hours.",
        "required": [
          "after_hours"
        ],
        "properties": {
          "template_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Another AI text of the company; null sends the same text again."
          },
          "after_hours": {
            "type": "integer",
            "format": "int32",
            "description": "1 to 168 (7 days)."
          }
        }
      },
      "FollowupInstruction": {
        "type": "object",
        "description": "The company's AI follow-up instruction.",
        "required": [
          "instruction"
        ],
        "properties": {
          "instruction": {
            "type": "string",
            "description": "The rule as plain text, trimmed; empty when the company has none."
          }
        }
      },
      "FollowupTimeline": {
        "type": "object",
        "description": "The conversation.",
        "required": [
          "timeline"
        ],
        "properties": {
          "timeline": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TimelineMessage"
            },
            "description": "Oldest first."
          }
        }
      },
      "FormImage": {
        "type": "object",
        "description": "An uploaded form image.",
        "required": [
          "url"
        ],
        "properties": {
          "url": {
            "type": "string",
            "description": "Its URL, from `POST /v1/uploads` with folder `quote-forms`."
          },
          "trim_border": {
            "type": "boolean",
            "description": "A header logo: cut off its blank border, which would push the form down."
          }
        },
        "additionalProperties": false
      },
      "FormOrder": {
        "type": "object",
        "description": "Forms in their new order.",
        "required": [
          "ids"
        ],
        "properties": {
          "ids": {
            "type": "array",
            "items": {
              "type": "integer",
              "format": "int32"
            },
            "description": "Form ids, first to last; other companies' ids are ignored."
          }
        },
        "additionalProperties": false
      },
      "FormStatus": {
        "type": "object",
        "description": "A form's status.",
        "required": [
          "status"
        ],
        "properties": {
          "status": {
            "type": "string",
            "description": "`active` or `inactive`."
          }
        },
        "additionalProperties": false
      },
      "ForwardAllTo": {
        "type": "string",
        "description": "Where \"Forward all calls\" sends calls: `voicemail` or `number`.",
        "enum": [
          "Voicemail",
          "Number"
        ]
      },
      "FoundEvent": {
        "type": "object",
        "description": "An event found by the search.",
        "required": [
          "id",
          "title",
          "start_date",
          "end_date",
          "all_day",
          "unscheduled",
          "created_user_id",
          "urgent"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "The event."
          },
          "title": {
            "type": "string",
            "description": "The event's name."
          },
          "location": {
            "type": [
              "string",
              "null"
            ],
            "description": "Address."
          },
          "notes": {
            "type": [
              "string",
              "null"
            ],
            "description": "Internal notes."
          },
          "start_date": {
            "type": "string",
            "format": "date-time",
            "description": "Start (UTC)."
          },
          "end_date": {
            "type": "string",
            "format": "date-time",
            "description": "End (UTC)."
          },
          "all_day": {
            "type": "boolean",
            "description": "All-day event."
          },
          "unscheduled": {
            "type": "boolean",
            "description": "Not on the calendar yet; its dates are only when it was made."
          },
          "color": {
            "type": [
              "string",
              "null"
            ],
            "description": "Label color."
          },
          "status": {
            "type": [
              "string",
              "null"
            ],
            "description": "e.g. `scheduled`."
          },
          "calendar_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Its calendar."
          },
          "rrule": {
            "type": [
              "string",
              "null"
            ],
            "description": "Repeat rule."
          },
          "recurrence_until": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "Last repeat (UTC)."
          },
          "created_user_id": {
            "type": "integer",
            "format": "int32",
            "description": "Who made it."
          },
          "assigned_user_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Who it is assigned to."
          },
          "sale_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Its sale."
          },
          "customer_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "The customer it is for."
          },
          "customer_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "That customer's name."
          },
          "contact_phone": {
            "type": [
              "string",
              "null"
            ],
            "description": "Phone for this event only; null uses the customer's."
          },
          "contact_email": {
            "type": [
              "string",
              "null"
            ],
            "description": "Email for this event only; null uses the customer's."
          },
          "urgent": {
            "type": "boolean",
            "description": "Red flag: it must be scheduled fast."
          },
          "contact_phone_2": {
            "type": [
              "string",
              "null"
            ],
            "description": "A second phone for this event."
          },
          "contact_email_2": {
            "type": [
              "string",
              "null"
            ],
            "description": "A second email for this event."
          }
        }
      },
      "FrameColor": {
        "type": "object",
        "description": "A stone color of the catalog filter (`GET /v1/colors`).",
        "required": [
          "id",
          "name",
          "hex_code"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "Color id: what stones carry in `color_ids`."
          },
          "name": {
            "type": "string",
            "description": "Color name, e.g. \"Black\"."
          },
          "hex_code": {
            "type": "string",
            "description": "Display color, `#RRGGBB`."
          }
        }
      },
      "FrameLevel": {
        "type": "object",
        "description": "A stone level of the catalog filter (`GET /v1/stone-levels`).",
        "required": [
          "number"
        ],
        "properties": {
          "number": {
            "type": "integer",
            "format": "int32",
            "description": "The level number stones store in `level`."
          },
          "name": {
            "type": [
              "string",
              "null"
            ],
            "description": "Its name (\"Standard\"); null shows just \"Level N\"."
          }
        }
      },
      "FrameSupplier": {
        "type": "object",
        "description": "A supplier of the catalog filters (`ISupplier`).",
        "required": [
          "id"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "Supplier id."
          },
          "supplier_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "Name."
          }
        }
      },
      "FreeAccess": {
        "type": "object",
        "description": "Body of `PUT /v1/superuser/companies/{id}/free-access`.",
        "properties": {
          "until": {
            "type": [
              "string",
              "null"
            ],
            "format": "date",
            "description": "Let the company in free until the end of this day (`YYYY-MM-DD`, UTC),\nat most 400 days ahead; null ends the free time now."
          }
        }
      },
      "GeocodeInput": {
        "type": "object",
        "description": "Body of `POST /v1/schedule/geocode`.",
        "required": [
          "addresses"
        ],
        "properties": {
          "addresses": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "The addresses, at most 50."
          }
        }
      },
      "Geocoded": {
        "type": "object",
        "description": "`POST /v1/schedule/geocode`.",
        "required": [
          "points"
        ],
        "properties": {
          "points": {
            "type": "array",
            "items": {
              "oneOf": [
                {
                  "$ref": "#/components/schemas/Point"
                },
                {
                  "type": "null"
                }
              ]
            },
            "description": "Where each address is, in the order asked; null where Google cannot\nfind it or Google Maps is not set up."
          }
        }
      },
      "GmailAppConnected": {
        "type": "object",
        "description": "`POST /v1/me/gmail/app`.",
        "required": [
          "email"
        ],
        "properties": {
          "email": {
            "type": "string",
            "description": "The Gmail address the caller's emails go out from now."
          }
        }
      },
      "GmailAppSignIn": {
        "type": "object",
        "description": "Body of `POST /v1/me/gmail/app`.",
        "required": [
          "server_auth_code"
        ],
        "properties": {
          "server_auth_code": {
            "type": "string",
            "description": "The `serverAuthCode` Google's own sign-in in the Granite Manager app\nreturned (issued for Granite Manager's web client, with send-only\nGmail access)."
          }
        }
      },
      "GmailConnected": {
        "type": "object",
        "description": "`POST /v1/me/gmail`.",
        "required": [
          "email"
        ],
        "properties": {
          "email": {
            "type": "string",
            "description": "The Gmail address the caller's emails go out from now."
          },
          "company_subdomain": {
            "type": [
              "string",
              "null"
            ],
            "description": "The company's subdomain, to go back to My Account there; null when it\nhas none."
          }
        }
      },
      "GmailReturn": {
        "type": "object",
        "description": "Body of `POST /v1/me/gmail`.",
        "required": [
          "state"
        ],
        "properties": {
          "state": {
            "type": "string",
            "description": "`state` as Google returned it."
          },
          "code": {
            "type": [
              "string",
              "null"
            ],
            "description": "`code` as Google returned it; absent when the user cancelled."
          },
          "error": {
            "type": [
              "string",
              "null"
            ],
            "description": "`error` as Google returned it (the user cancelled)."
          }
        }
      },
      "GmailSignIn": {
        "type": "object",
        "description": "`POST /v1/me/gmail/start`.",
        "required": [
          "url"
        ],
        "properties": {
          "url": {
            "type": "string",
            "description": "Google's sign-in page."
          }
        }
      },
      "GroupChange": {
        "type": "object",
        "description": "Body of `PATCH /v1/phone/contact-groups/{id}`: what to change; a field\nleft out stays as it is.",
        "properties": {
          "name": {
            "type": [
              "string",
              "null"
            ],
            "description": "A new name, as for `POST /v1/phone/contact-groups`."
          },
          "hidden": {
            "type": [
              "boolean",
              "null"
            ],
            "description": "True hides the group from the top of my Contacts, false shows it\nagain. Only for me: other users' tops are left alone."
          }
        }
      },
      "GroupMembers": {
        "type": "object",
        "description": "Who is in a group: customers and coworkers of my company.",
        "properties": {
          "customerIds": {
            "type": "array",
            "items": {
              "type": "integer",
              "format": "int32"
            },
            "description": "Customer ids of my company's live customers (400 `unknown_contact`\nfor any other id, or a deleted customer). Repeats count once."
          },
          "userIds": {
            "type": "array",
            "items": {
              "type": "integer",
              "format": "int32"
            },
            "description": "User ids of my company's users (400 `unknown_coworker` for any other\nid, or a deleted user). Repeats count once."
          }
        }
      },
      "Handover": {
        "type": "object",
        "description": "How much of a user's work moves to the colleague taking over.",
        "required": [
          "customers",
          "deals",
          "quotes",
          "projects",
          "events",
          "todos",
          "followups"
        ],
        "properties": {
          "customers": {
            "type": "integer",
            "format": "int64",
            "description": "Customers they are the sales rep of."
          },
          "deals": {
            "type": "integer",
            "format": "int64",
            "description": "Deals (open and closed)."
          },
          "quotes": {
            "type": "integer",
            "format": "int64",
            "description": "Quotes they are the salesperson of."
          },
          "projects": {
            "type": "integer",
            "format": "int64",
            "description": "Projects they own or sell."
          },
          "events": {
            "type": "integer",
            "format": "int64",
            "description": "Upcoming events they are assigned to or on the crew of."
          },
          "todos": {
            "type": "integer",
            "format": "int64",
            "description": "Open customer to-dos and project tasks."
          },
          "followups": {
            "type": "integer",
            "format": "int64",
            "description": "Texts, emails and text flows still waiting to go out."
          }
        }
      },
      "HelpState": {
        "type": "object",
        "description": "Whether the chat offers help planning the instructions.",
        "required": [
          "offer",
          "declined"
        ],
        "properties": {
          "offer": {
            "type": "boolean",
            "description": "The first time the admin opens Add with AI, then after the 5th,\n10th, 15th, 20th and 25th request; never once the admin took it or said not to ask."
          },
          "declined": {
            "type": "boolean",
            "description": "The admin said not to offer help (\"Don't ask again\", \"Stop\nsuggestions\", or in their own words): the chat suggests nothing it\nwas not asked for."
          }
        }
      },
      "HiddenSuggestion": {
        "type": "object",
        "description": "A suggestion taken out with the x, still not offered.",
        "required": [
          "kind",
          "text"
        ],
        "properties": {
          "kind": {
            "type": "string",
            "description": "`area` (an area name), `misc` or `text` (a custom item's description)."
          },
          "text": {
            "type": "string",
            "description": "The text as it was shown when it was taken out."
          }
        }
      },
      "HiddenUser": {
        "type": "object",
        "description": "A calendar an admin hid from one user.",
        "required": [
          "calendar_id",
          "user_id"
        ],
        "properties": {
          "calendar_id": {
            "type": "integer",
            "format": "int32",
            "description": "The calendar."
          },
          "user_id": {
            "type": "integer",
            "format": "int32",
            "description": "The user it is hidden from."
          }
        }
      },
      "HideSuggestionInput": {
        "type": "object",
        "description": "Body of `POST /v1/quotes/suggestions/hide`.",
        "required": [
          "kind",
          "text"
        ],
        "properties": {
          "kind": {
            "type": "string",
            "description": "`area` for an area name, `misc` or `text` for a custom item's description."
          },
          "text": {
            "type": "string",
            "description": "The suggestion as shown (any case; spaces around and inside are tidied)."
          }
        }
      },
      "History": {
        "type": "object",
        "description": "`GET /v1/sms/{provider}/history`.",
        "required": [
          "items",
          "customer_phone_digits"
        ],
        "properties": {
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/HistoryText"
            },
            "description": "Newest first, at most 200."
          },
          "customer_phone_digits": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "The customer's phones (with and without the country code); a text\nfrom one of them is inbound."
          }
        }
      },
      "HistoryActivity": {
        "type": "object",
        "description": "An activity of one of the customer's deals.",
        "required": [
          "id",
          "deal_id",
          "company_id",
          "name",
          "priority",
          "is_completed"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int64",
            "description": "Activity id."
          },
          "deal_id": {
            "type": "integer",
            "format": "int64",
            "description": "Deal."
          },
          "company_id": {
            "type": "integer",
            "format": "int32",
            "description": "Company."
          },
          "name": {
            "type": "string",
            "description": "What to do."
          },
          "deadline": {
            "type": [
              "string",
              "null"
            ],
            "description": "Store wall time `YYYY-MM-DDTHH:MM:SS`, or null."
          },
          "priority": {
            "type": "string",
            "description": "`low`, `medium` or `high`."
          },
          "is_completed": {
            "type": "integer",
            "format": "int32",
            "description": "1 when done."
          },
          "completed_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When it was done."
          },
          "created_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When it was created."
          },
          "created_by": {
            "type": [
              "string",
              "null"
            ],
            "description": "By whom (name)."
          },
          "deal_list_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "Stage the deal is in."
          }
        }
      },
      "HistoryComment": {
        "type": "object",
        "description": "A comment on a note.",
        "required": [
          "id",
          "note_id",
          "content"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int64",
            "description": "Comment id."
          },
          "note_id": {
            "type": "integer",
            "format": "int64",
            "description": "Note."
          },
          "content": {
            "type": "string",
            "description": "Text."
          },
          "created_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When."
          },
          "created_by": {
            "type": [
              "string",
              "null"
            ],
            "description": "By whom (name)."
          }
        }
      },
      "HistoryDeal": {
        "type": "object",
        "description": "A live deal of the customer.",
        "required": [
          "id",
          "list_name"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int64",
            "description": "Deal id."
          },
          "amount": {
            "type": [
              "string",
              "null"
            ],
            "description": "Amount, a decimal string."
          },
          "lost_reason": {
            "type": [
              "string",
              "null"
            ],
            "description": "Why it was lost."
          },
          "list_name": {
            "type": "string",
            "description": "Stage name."
          },
          "created_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When it was created."
          }
        }
      },
      "HistoryEmail": {
        "type": "object",
        "description": "A message of a deal's or customer's email history.",
        "required": [
          "id",
          "thread_id",
          "body",
          "read_count",
          "has_attachments",
          "is_automated",
          "thread_has_attachments"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "Message id."
          },
          "deal_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int64",
            "description": "Deal the message was sent on, if any."
          },
          "thread_id": {
            "type": "string",
            "description": "Conversation id."
          },
          "subject": {
            "type": [
              "string",
              "null"
            ],
            "description": "Subject."
          },
          "body": {
            "type": "string",
            "description": "Plain text body."
          },
          "sent_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When it was sent."
          },
          "read_count": {
            "type": "integer",
            "format": "int64",
            "description": "Real opens by the recipient (not proxies firing right after the send)."
          },
          "has_attachments": {
            "type": "boolean",
            "description": "The message has attachments."
          },
          "sender_user_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Sending user; null for mail from the customer."
          },
          "sender_email": {
            "type": [
              "string",
              "null"
            ],
            "description": "From header."
          },
          "sender_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "Sending user's name."
          },
          "employee_read_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When an employee opened it."
          },
          "is_automated": {
            "type": "boolean",
            "description": "Sent by the system (a reminder, an invoice), not typed by a person."
          },
          "thread_has_attachments": {
            "type": "boolean",
            "description": "Some message of the conversation has attachments."
          }
        }
      },
      "HistoryNote": {
        "type": "object",
        "description": "A note of one of the customer's deals.",
        "required": [
          "id",
          "deal_id",
          "company_id",
          "content",
          "is_pinned",
          "comments"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int64",
            "description": "Note id."
          },
          "deal_id": {
            "type": "integer",
            "format": "int64",
            "description": "Deal."
          },
          "company_id": {
            "type": "integer",
            "format": "int32",
            "description": "Company."
          },
          "content": {
            "type": "string",
            "description": "Text."
          },
          "is_pinned": {
            "type": "integer",
            "format": "int32",
            "description": "1 when pinned."
          },
          "created_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When."
          },
          "created_by": {
            "type": [
              "string",
              "null"
            ],
            "description": "By whom (name)."
          },
          "comments": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/HistoryComment"
            },
            "description": "Comments, oldest first."
          }
        }
      },
      "HistoryText": {
        "type": "object",
        "description": "One text.",
        "required": [
          "id",
          "recipient",
          "text",
          "attachment_count",
          "attachments"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "The SMS row."
          },
          "provider_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int64",
            "description": "The provider's message id; null for Telnyx (its ids are not numbers)."
          },
          "sender": {
            "type": [
              "string",
              "null"
            ],
            "description": "Sending phone (digits as stored)."
          },
          "recipient": {
            "type": "string",
            "description": "Receiving phone."
          },
          "text": {
            "type": "string",
            "description": "The message."
          },
          "agent": {
            "type": [
              "string",
              "null"
            ],
            "description": "The rep's name when the agent id is known, else the raw agent id."
          },
          "agent_id": {
            "type": [
              "string",
              "null"
            ],
            "description": "The agent id stored on the row."
          },
          "created_date": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When it was stored."
          },
          "attachment_count": {
            "type": "integer",
            "format": "int64",
            "description": "How many photos and files were sent with it."
          },
          "attachments": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Attachment"
            },
            "description": "The photos and files sent with it, in the order they were sent."
          }
        }
      },
      "HoldInput": {
        "type": "object",
        "description": "Body of `PUT /v1/phone/calls/hold`.",
        "required": [
          "held"
        ],
        "properties": {
          "held": {
            "type": "boolean",
            "description": "True: I just put the call on hold; false: I just resumed it."
          },
          "telnyxCallIds": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "The ids Telnyx's SDK knows the call by (its call id, call control\nid, call session id, leg id; at most 4 are read), to pick the call\nwhen I have more than one (call waiting, swapping); empty = the\nnewest."
          }
        }
      },
      "HoldMusicOptions": {
        "type": "object",
        "description": "`GET /v1/phone/hold-music`.",
        "required": [
          "tracks",
          "maxUploadBytes"
        ],
        "properties": {
          "tracks": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/HoldTrack"
            },
            "description": "The built-in tracks, the default (`calm`) first."
          },
          "maxUploadBytes": {
            "type": "integer",
            "format": "int64",
            "description": "The largest file `POST /v1/phone/hold-music/upload` takes, in bytes.",
            "minimum": 0
          }
        }
      },
      "HoldMusicUpload": {
        "type": "object",
        "description": "`POST /v1/phone/hold-music/upload`.",
        "required": [
          "uploadUrl",
          "contentType",
          "url"
        ],
        "properties": {
          "uploadUrl": {
            "type": "string",
            "description": "`PUT` the file here (straight to storage) with this `contentType`;\nvalid 15 minutes."
          },
          "contentType": {
            "type": "string",
            "description": "The `Content-Type` header the PUT must send."
          },
          "url": {
            "type": "string",
            "description": "The file's URL once put: send it as `holdMusicUrl` (with `holdMusic:\ncustom`) to `PUT /v1/phone/settings`."
          }
        }
      },
      "HoldMusicUploadInput": {
        "type": "object",
        "description": "Body of `POST /v1/phone/hold-music/upload`.",
        "required": [
          "fileName"
        ],
        "properties": {
          "fileName": {
            "type": "string",
            "description": "The file's name, e.g. `jingle.mp3`."
          },
          "contentType": {
            "type": "string",
            "description": "Its type: `audio/mpeg` or `audio/wav` (an `.mp3` / `.wav` name is\nenough)."
          }
        }
      },
      "HoldSlab": {
        "type": "object",
        "description": "Body of `PUT /v1/slabs/{id}/hold`: how long to hold the slab.",
        "required": [
          "days"
        ],
        "properties": {
          "days": {
            "type": "integer",
            "format": "int32",
            "description": "Days to hold it: 1 to 365."
          },
          "customer_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "The customer it is held for; absent or null for nobody in particular."
          }
        },
        "additionalProperties": false
      },
      "HoldState": {
        "type": "object",
        "description": "`PUT /v1/phone/calls/hold`.",
        "required": [
          "callId",
          "onHold",
          "music"
        ],
        "properties": {
          "callId": {
            "type": "integer",
            "format": "int64",
            "description": "Our call id."
          },
          "onHold": {
            "type": "boolean",
            "description": "The call is on hold now."
          },
          "music": {
            "type": "boolean",
            "description": "This request started my hold music for the other party (false:\nsilence, because I chose none or Telnyx did not take the music; also\non a resume and on a repeat, which change nothing)."
          }
        }
      },
      "HoldTrack": {
        "type": "object",
        "description": "A built-in hold music track.",
        "required": [
          "id",
          "name",
          "url"
        ],
        "properties": {
          "id": {
            "type": "string",
            "description": "Its id: send it as `holdMusic` to `PUT /v1/phone/settings`."
          },
          "name": {
            "type": "string",
            "description": "What to call it, e.g. \"Calm piano\"."
          },
          "url": {
            "type": "string",
            "description": "The MP3, public (for the preview button)."
          }
        }
      },
      "HorusName": {
        "type": "object",
        "description": "One stone name Horus uses.",
        "required": [
          "name",
          "slabs",
          "remnants",
          "by_hand"
        ],
        "properties": {
          "name": {
            "type": "string",
            "description": "The name as Horus spells it (\"\" when its slabs have none)."
          },
          "slabs": {
            "type": "integer",
            "format": "int32",
            "description": "Whole slabs with this name."
          },
          "remnants": {
            "type": "integer",
            "format": "int32",
            "description": "Remnants with this name."
          },
          "photo_url": {
            "type": [
              "string",
              "null"
            ],
            "description": "A Horus photo of one of them."
          },
          "stone_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "The Granite stone its slabs go under; null: kept out of Granite."
          },
          "stone_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "That stone's name."
          },
          "by_hand": {
            "type": "boolean",
            "description": "Picked by hand (else: the stone of the same name)."
          }
        }
      },
      "HorusStatus": {
        "type": "object",
        "description": "The company's Horus connection.",
        "required": [
          "connected",
          "syncing",
          "slabs_in_granite",
          "names",
          "stones",
          "left_horus"
        ],
        "properties": {
          "connected": {
            "type": "boolean",
            "description": "A FusionDrive key is saved."
          },
          "license_end": {
            "type": [
              "string",
              "null"
            ],
            "description": "The key's last 4 characters, to tell keys apart."
          },
          "synced_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When the slabs were last copied."
          },
          "syncing": {
            "type": "boolean",
            "description": "A sync is running or starts within the minute."
          },
          "error": {
            "type": [
              "string",
              "null"
            ],
            "description": "Why the last sync failed; null when it worked."
          },
          "horus_slabs": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Slabs and remnants Horus had at the last good sync."
          },
          "slabs_in_granite": {
            "type": "integer",
            "format": "int64",
            "description": "Horus slabs now in Granite (not sold, cut or hidden)."
          },
          "names": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/HorusName"
            },
            "description": "Horus's stone names at the last sync, unmatched first."
          },
          "stones": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/StoneChoice"
            },
            "description": "The company's stones a name can be matched to, by name."
          },
          "left_horus": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/LeftHorus"
            },
            "description": "Slabs that left Horus in the last 30 days, newest first (at most 200)."
          }
        }
      },
      "HorusSyncRun": {
        "type": "object",
        "description": "What a run did.",
        "required": [
          "processed",
          "failed"
        ],
        "properties": {
          "processed": {
            "type": "integer",
            "format": "int32",
            "description": "Companies whose slabs were copied.",
            "minimum": 0
          },
          "failed": {
            "type": "integer",
            "format": "int32",
            "description": "Companies whose sync failed (the error shows on Company settings).",
            "minimum": 0
          }
        }
      },
      "HoursInput": {
        "type": "object",
        "description": "Body of `PUT /v1/shop/maintenance/conditions/{id}/hours`.",
        "required": [
          "hours_done"
        ],
        "properties": {
          "hours_done": {
            "type": "number",
            "format": "double",
            "description": "Hours used since the check was last done; 0 to 100000 (capped at\nthe interval)."
          }
        },
        "additionalProperties": false
      },
      "Idea": {
        "type": "object",
        "description": "One subject to add.",
        "required": [
          "title",
          "question"
        ],
        "properties": {
          "title": {
            "type": "string",
            "description": "A short title: the new page's, or the part of `instruction_id` it\nadds."
          },
          "instruction_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "The existing page it belongs on; null for a new page."
          },
          "parent_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "A new page's parent; null at the top level or with `instruction_id`."
          },
          "question": {
            "type": "string",
            "description": "What the admin answers to write it."
          }
        }
      },
      "Ideas": {
        "type": "object",
        "description": "Subjects to add to the instructions.",
        "required": [
          "ideas"
        ],
        "properties": {
          "ideas": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Idea"
            },
            "description": "Most useful first; at most 4, may be empty."
          }
        }
      },
      "ImageChanges": {
        "type": "object",
        "description": "Body of `PATCH /v1/images/{id}`: what to change.",
        "properties": {
          "name": {
            "type": [
              "string",
              "null"
            ],
            "description": "New name (1–100 characters)."
          },
          "url": {
            "type": [
              "string",
              "null"
            ],
            "description": "A newly uploaded file replacing the old one (which stays in storage)."
          },
          "folder_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Folder to move it to."
          }
        },
        "additionalProperties": false
      },
      "ImageFolder": {
        "type": "object",
        "description": "A folder with its images, by name.",
        "required": [
          "id",
          "name",
          "images"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "Folder id."
          },
          "name": {
            "type": "string",
            "description": "Its name."
          },
          "images": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/LibraryImage"
            },
            "description": "Its images, by name."
          }
        }
      },
      "ImageLibrary": {
        "type": "object",
        "description": "The whole library.",
        "required": [
          "folders",
          "root_images"
        ],
        "properties": {
          "folders": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ImageFolder"
            },
            "description": "Folders by name."
          },
          "root_images": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/LibraryImage"
            },
            "description": "Images in no folder, by name."
          }
        }
      },
      "ImportedNumbers": {
        "type": "object",
        "description": "`POST /v1/phone/admin/numbers/import`.",
        "required": [
          "imported",
          "numbers"
        ],
        "properties": {
          "imported": {
            "type": "integer",
            "description": "How many numbers were added.",
            "minimum": 0
          },
          "numbers": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/AdminNumber"
            },
            "description": "The company's numbers now (as in `GET /v1/phone/admin/numbers`)."
          }
        }
      },
      "ImproveInput": {
        "type": "object",
        "description": "Body of `POST /v1/ai/improve`.",
        "required": [
          "body"
        ],
        "properties": {
          "body": {
            "type": "string",
            "description": "The draft."
          },
          "channel": {
            "$ref": "#/components/schemas/Channel",
            "description": "`email` (default) or `sms`."
          },
          "customer_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "The customer's name, to fix the spelling of their first name."
          },
          "partial": {
            "type": "boolean",
            "description": "`true` when `body` is only the part of a longer draft the user\nselected: the reply then fits back in its place (no greeting or\nsign-off, fragments stay fragments). Defaults to `false`."
          }
        }
      },
      "Improved": {
        "type": "object",
        "description": "`POST /v1/ai/improve`.",
        "required": [
          "body"
        ],
        "properties": {
          "body": {
            "type": "string",
            "description": "The rewritten draft."
          }
        }
      },
      "InboundMedia": {
        "type": "object",
        "description": "Body of `POST /v1/sms/ringcentral/inbound-media`.",
        "required": [
          "company_id",
          "sms_id",
          "message_id",
          "files"
        ],
        "properties": {
          "company_id": {
            "type": "integer",
            "format": "int32",
            "description": "The company the message belongs to: its `RingCentral` login is used."
          },
          "sms_id": {
            "type": "integer",
            "format": "int64",
            "description": "The stored `ringcentral_sms` row."
          },
          "message_id": {
            "type": "integer",
            "format": "int64",
            "description": "`RingCentral`'s message id."
          },
          "extension_id": {
            "type": [
              "string",
              "null"
            ],
            "description": "The extension whose message store holds it; the token's own when null."
          },
          "files": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/InboundMediaFile"
            },
            "description": "The message's pictures and files, in the order the customer sent them."
          }
        }
      },
      "InboundMediaFile": {
        "type": "object",
        "description": "One file of the message, still on `RingCentral`.",
        "required": [
          "id",
          "content_type"
        ],
        "properties": {
          "id": {
            "type": "string",
            "description": "The attachment id under the message's `content/`."
          },
          "content_type": {
            "type": "string",
            "description": "MIME type `RingCentral` gives the file (e.g. `image/jpeg`); it picks the\nstored file's extension."
          }
        }
      },
      "InboundMediaStored": {
        "type": "object",
        "description": "How many files were stored.",
        "required": [
          "stored"
        ],
        "properties": {
          "stored": {
            "type": "integer",
            "description": "Files downloaded and attached; a file that failed is left out.",
            "minimum": 0
          }
        }
      },
      "InboundPush": {
        "type": "object",
        "description": "Body of `POST /v1/emails/inbound-push`.",
        "required": [
          "email_id"
        ],
        "properties": {
          "email_id": {
            "type": "integer",
            "format": "int64",
            "description": "The stored inbound email (`emails` row id, the `id` of a message in\n`GET /v1/emails/threads`)."
          }
        }
      },
      "InboundPushSent": {
        "type": "object",
        "description": "How many phones were told.",
        "required": [
          "pushed"
        ],
        "properties": {
          "pushed": {
            "type": "integer",
            "description": "Phones FCM accepted the push for; 0 when nobody is told (unknown,\ndeleted, draft or outbound email, a company without inbound email,\nnobody whose inbox shows it, or no signed-in phone).",
            "minimum": 0
          }
        }
      },
      "InboundTextPush": {
        "type": "object",
        "description": "Body of `POST /v1/sms/inbound-push`.",
        "required": [
          "company_id",
          "provider",
          "sms_id"
        ],
        "properties": {
          "company_id": {
            "type": "integer",
            "format": "int32",
            "description": "The company the text came to."
          },
          "provider": {
            "type": "string",
            "description": "`ringcentral` or `cloudtalk` (Telnyx texts push on their own)."
          },
          "sms_id": {
            "type": "integer",
            "format": "int64",
            "description": "The stored row of the provider's SMS table."
          }
        }
      },
      "InboundTextPushed": {
        "type": "object",
        "description": "How many phones were told.",
        "required": [
          "pushed"
        ],
        "properties": {
          "pushed": {
            "type": "integer",
            "description": "Phones FCM accepted the push for; 0 when nobody's inbox shows it.",
            "minimum": 0
          }
        }
      },
      "Inbox": {
        "type": "object",
        "description": "`GET /v1/support/agent/conversations`.",
        "required": [
          "unchanged",
          "version"
        ],
        "properties": {
          "unchanged": {
            "type": "boolean",
            "description": "Nothing changed since the `version` asked with: the other fields are\nleft out."
          },
          "version": {
            "type": "string",
            "description": "Send back as `version` on the next poll."
          },
          "counts": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/InboxCounts",
                "description": "Counts per pile."
              },
              {
                "type": "null"
              }
            ]
          },
          "conversations": {
            "type": [
              "array",
              "null"
            ],
            "items": {
              "$ref": "#/components/schemas/ConversationSummary"
            },
            "description": "The requests, unread first, then the latest message first (at most\n200)."
          }
        }
      },
      "InboxCounts": {
        "type": "object",
        "description": "Requests per pile, for the app's sidebar (resolved ones not counted).",
        "required": [
          "active",
          "open",
          "waiting",
          "unassigned",
          "mine",
          "unread"
        ],
        "properties": {
          "active": {
            "type": "integer",
            "format": "int64",
            "description": "Open and waiting."
          },
          "open": {
            "type": "integer",
            "format": "int64",
            "description": "The team owes an answer."
          },
          "waiting": {
            "type": "integer",
            "format": "int64",
            "description": "Waiting on the client."
          },
          "unassigned": {
            "type": "integer",
            "format": "int64",
            "description": "Active ones nobody is assigned to."
          },
          "mine": {
            "type": "integer",
            "format": "int64",
            "description": "Active ones assigned to the caller."
          },
          "unread": {
            "type": "integer",
            "format": "int64",
            "description": "Active ones the client wrote in since the team last read them."
          }
        }
      },
      "InboxGroup": {
        "type": "object",
        "description": "A live pipeline (group) of the company, for the website's Leads page.",
        "required": [
          "id",
          "is_default",
          "lists"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "The group id (`PUT /v1/customers/{id}/sales-rep` takes it as `group_id`)."
          },
          "name": {
            "type": [
              "string",
              "null"
            ],
            "description": "Its name."
          },
          "is_default": {
            "type": "boolean",
            "description": "The pipeline new leads go to (\"Assign leads here\")."
          },
          "lists": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/InboxList"
            },
            "description": "Its live lists (stages) in board order; `PUT /v1/customers/{id}/sales-rep`\ntakes one as `list_id`."
          }
        }
      },
      "InboxLead": {
        "type": "object",
        "description": "A lead of the inbox.",
        "required": [
          "customer_id"
        ],
        "properties": {
          "customer_id": {
            "type": "integer",
            "format": "int32",
            "description": "The lead's customer id."
          },
          "name": {
            "type": [
              "string",
              "null"
            ],
            "description": "The customer's name (null when the lead has none)."
          },
          "phone": {
            "type": [
              "string",
              "null"
            ],
            "description": "The customer's phone (null when the lead has none)."
          },
          "created_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When the lead came in."
          },
          "assigned_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When it was first given a rep (null while it has none)."
          },
          "sales_rep_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "The sales rep's user id; null while the lead has no rep."
          },
          "sales_rep_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "The sales rep's name; null while the lead has no rep."
          },
          "deal_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int64",
            "description": "Its newest live deal, the one the app opens."
          },
          "email": {
            "type": [
              "string",
              "null"
            ],
            "description": "The customer's primary email (null when none)."
          },
          "referral_source": {
            "type": [
              "string",
              "null"
            ],
            "description": "How they found the company (\"Google\", \"Facebook\"…; null when unknown)."
          },
          "your_message": {
            "type": [
              "string",
              "null"
            ],
            "description": "What the customer wrote in the lead form (null when nothing)."
          },
          "address": {
            "type": [
              "string",
              "null"
            ],
            "description": "The customer's address (null when none)."
          },
          "customer_temperature": {
            "type": [
              "string",
              "null"
            ],
            "description": "`hot`, `medium` or `cold`; null when not rated."
          },
          "phone_2": {
            "type": [
              "string",
              "null"
            ],
            "description": "A second phone; null when the lead has none."
          },
          "company_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "The customer's company; null when the lead has none."
          },
          "city": {
            "type": [
              "string",
              "null"
            ],
            "description": "City; null when the lead has none."
          },
          "postal_code": {
            "type": [
              "string",
              "null"
            ],
            "description": "Zip code; null when the lead has none."
          },
          "remodal_type": {
            "type": [
              "string",
              "null"
            ],
            "description": "What they remodel (\"Kitchen\"…); null when the lead has none."
          },
          "project_size": {
            "type": [
              "string",
              "null"
            ],
            "description": "How big the project is; null when the lead has none."
          },
          "when_start": {
            "type": [
              "string",
              "null"
            ],
            "description": "When they want to start; null when the lead has none."
          },
          "contact_time": {
            "type": [
              "string",
              "null"
            ],
            "description": "The best time to contact them; null when the lead has none."
          },
          "remove_and_dispose": {
            "type": [
              "string",
              "null"
            ],
            "description": "Whether the old countertops are removed; null when the lead has none."
          },
          "improve_offer": {
            "type": [
              "string",
              "null"
            ],
            "description": "Their answer to the offer question; null when the lead has none."
          },
          "sink": {
            "type": [
              "string",
              "null"
            ],
            "description": "The sink they chose; null when the lead has none."
          },
          "kitchen_stove": {
            "type": [
              "string",
              "null"
            ],
            "description": "The stove they chose; null when the lead has none."
          },
          "backsplash": {
            "type": [
              "string",
              "null"
            ],
            "description": "The backsplash they chose; null when the lead has none."
          },
          "details": {
            "type": [
              "string",
              "null"
            ],
            "description": "Other answers of the form (a Facebook lead); null when the lead has none."
          },
          "attached_file": {
            "type": [
              "string",
              "null"
            ],
            "description": "The file they attached (a link); null when the lead has none."
          },
          "form_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "The form the lead came from; null when the lead has none."
          },
          "compaign_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "The ad campaign; null when the lead has none."
          },
          "adset_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "The ad set; null when the lead has none."
          },
          "ad_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "The ad; null when the lead has none."
          }
        }
      },
      "InboxList": {
        "type": "object",
        "description": "A live list (stage) of a pipeline, for the website's Leads page.",
        "required": [
          "id"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "The list id."
          },
          "name": {
            "type": [
              "string",
              "null"
            ],
            "description": "Its name."
          }
        }
      },
      "InboxRep": {
        "type": "object",
        "description": "A sales rep of the company and their lead count this month.",
        "required": [
          "id",
          "month_leads"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "The sales rep's user id (`PUT /v1/customers/{id}/sales-rep` takes it)."
          },
          "name": {
            "type": [
              "string",
              "null"
            ],
            "description": "Their name (null when the account has none)."
          },
          "month_leads": {
            "type": "integer",
            "format": "int64",
            "description": "Leads given to them this month (the Telegram button's count)."
          }
        }
      },
      "IndexContact": {
        "type": "object",
        "description": "A customer in the phone's contact index.",
        "required": [
          "id",
          "name",
          "phones",
          "mine"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "Customer id."
          },
          "name": {
            "type": "string",
            "description": "Name; empty when the customer has none."
          },
          "company": {
            "type": [
              "string",
              "null"
            ],
            "description": "Company name; null when empty."
          },
          "phones": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "The last 10 digits of the phone, then of phone 2 (missing, short or\nrepeated ones left out)."
          },
          "repId": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "The sales rep's user id; null when unassigned."
          },
          "mine": {
            "type": "boolean",
            "description": "The caller is the customer's sales rep."
          },
          "temperature": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/Temperature",
                "description": "`hot`, `medium` or `cold`; null when not set."
              },
              {
                "type": "null"
              }
            ]
          },
          "openDeal": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/OpenDeal",
                "description": "The oldest open deal (not won or lost); null when none."
              },
              {
                "type": "null"
              }
            ]
          },
          "lastCallAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When the last call with this customer started (RFC 3339); null when\nnever."
          }
        }
      },
      "Installed": {
        "type": "object",
        "description": "Body of `POST /v1/transactions/{id}/installed`.",
        "properties": {
          "installed_date": {
            "type": [
              "string",
              "null"
            ],
            "description": "When it was installed (`YYYY-MM-DD` or an ISO time); default now."
          },
          "paid": {
            "type": "boolean",
            "description": "It is also paid (on the same date)."
          }
        },
        "additionalProperties": false
      },
      "InstallerContext": {
        "type": "object",
        "description": "What the installer portal shows around the checklist form.",
        "required": [
          "company_id",
          "quickbooks"
        ],
        "properties": {
          "company_id": {
            "type": "integer",
            "format": "int32",
            "description": "The company the installer works for."
          },
          "logo_url": {
            "type": [
              "string",
              "null"
            ],
            "description": "The company logo for the form header; null when none."
          },
          "quickbooks": {
            "type": "boolean",
            "description": "QuickBooks is on and connected (the portal then shows invoices)."
          }
        }
      },
      "Instruction": {
        "type": "object",
        "description": "One instruction of the tree.",
        "required": [
          "id",
          "position_ids"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "Instruction id."
          },
          "title": {
            "type": [
              "string",
              "null"
            ],
            "description": "Title."
          },
          "parent_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Parent; null at the top level."
          },
          "after_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "The sibling it follows; null for the first."
          },
          "rich_text": {
            "type": [
              "string",
              "null"
            ],
            "description": "Body HTML."
          },
          "position_ids": {
            "type": "array",
            "items": {
              "type": "integer",
              "format": "int32"
            },
            "description": "Positions that may read it; empty for everyone."
          }
        }
      },
      "InstructionInput": {
        "type": "object",
        "description": "Body of `POST /v1/instructions` and `PUT /v1/instructions/{id}`.",
        "required": [
          "title"
        ],
        "properties": {
          "title": {
            "type": "string",
            "description": "Title (required)."
          },
          "parent_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Parent; null at the top level."
          },
          "after_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "The sibling it follows; null to come first."
          },
          "rich_text": {
            "type": "string",
            "description": "Body HTML."
          },
          "position_ids": {
            "type": "array",
            "items": {
              "type": "integer",
              "format": "int32"
            },
            "description": "Positions that may read it (empty for everyone); others are ignored."
          }
        },
        "additionalProperties": false
      },
      "InstructionOrder": {
        "type": "object",
        "description": "Body of `PUT /v1/instructions/order`.",
        "required": [
          "ordered_ids"
        ],
        "properties": {
          "parent_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "The parent whose children are reordered; null for the top level."
          },
          "ordered_ids": {
            "type": "array",
            "items": {
              "type": "integer",
              "format": "int32"
            },
            "description": "Every child of that parent, in the new order."
          },
          "scope": {
            "$ref": "#/components/schemas/InstructionScope",
            "description": "`company` (default) or `general`."
          }
        }
      },
      "InstructionRule": {
        "type": "object",
        "description": "One rule the AI made of the instructions.",
        "required": [
          "action"
        ],
        "properties": {
          "when_has": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Phrases the quote must all have."
          },
          "when_lacks": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Phrases the quote must not have."
          },
          "action": {
            "$ref": "#/components/schemas/Action"
          }
        }
      },
      "InstructionScope": {
        "type": "string",
        "description": "Which instructions to reorder.",
        "enum": [
          "company",
          "general"
        ]
      },
      "InstructionsInput": {
        "type": "object",
        "description": "Body of `PUT /v1/sales-playbook/stages/{id}/instructions` and\n`PUT /v1/sales-playbook/sub-stages/{id}/instructions`.",
        "properties": {
          "instructions": {
            "type": [
              "string",
              "null"
            ],
            "description": "What the sales rep does there: plain text, at most 2000 characters.\nNull or blank: none."
          }
        },
        "additionalProperties": false
      },
      "Intent": {
        "type": "string",
        "description": "What the feedback is.",
        "enum": [
          "dislike",
          "approve",
          "escalate"
        ]
      },
      "InvalidInput": {
        "type": "object",
        "description": "Body of `PUT /v1/customers/{id}/invalid`.",
        "required": [
          "reason"
        ],
        "properties": {
          "reason": {
            "type": "string",
            "description": "Why the lead is invalid, e.g. `Out of area` (1–255 characters)."
          }
        },
        "additionalProperties": false
      },
      "InvalidReasons": {
        "type": "object",
        "description": "Leads lost or marked invalid, by reason.",
        "required": [
          "too_expensive",
          "out_of_area",
          "never_responded",
          "wrong_contact",
          "accident_submission",
          "unrelated_service",
          "bought_elsewhere",
          "stopped_responding",
          "gave_up_on_the_project",
          "spam",
          "test_lead",
          "duplicate"
        ],
        "properties": {
          "too_expensive": {
            "type": "integer",
            "format": "int64",
            "description": "\"Too expensive\"."
          },
          "out_of_area": {
            "type": "integer",
            "format": "int64",
            "description": "\"Out of area\"."
          },
          "never_responded": {
            "type": "integer",
            "format": "int64",
            "description": "\"Never responded\"."
          },
          "wrong_contact": {
            "type": "integer",
            "format": "int64",
            "description": "\"Wrong number, email, etc.\"."
          },
          "accident_submission": {
            "type": "integer",
            "format": "int64",
            "description": "\"Accident submission\"."
          },
          "unrelated_service": {
            "type": "integer",
            "format": "int64",
            "description": "\"Looking for unrelated service\"."
          },
          "bought_elsewhere": {
            "type": "integer",
            "format": "int64",
            "description": "\"Bought somewhere else\"."
          },
          "stopped_responding": {
            "type": "integer",
            "format": "int64",
            "description": "\"Stopped responding\"."
          },
          "gave_up_on_the_project": {
            "type": "integer",
            "format": "int64",
            "description": "\"Gave up on the project\"."
          },
          "spam": {
            "type": "integer",
            "format": "int64",
            "description": "\"Spam\"."
          },
          "test_lead": {
            "type": "integer",
            "format": "int64",
            "description": "\"Test lead\"."
          },
          "duplicate": {
            "type": "integer",
            "format": "int64",
            "description": "\"Duplicate\"."
          }
        }
      },
      "InvalidStats": {
        "type": "object",
        "description": "Invalid leads by channel.",
        "required": [
          "facebook",
          "website",
          "total"
        ],
        "properties": {
          "facebook": {
            "type": "integer",
            "format": "int64",
            "description": "From Facebook."
          },
          "website": {
            "type": "integer",
            "format": "int64",
            "description": "From the website."
          },
          "total": {
            "type": "integer",
            "format": "int64",
            "description": "All."
          }
        }
      },
      "InventorySlab": {
        "type": "object",
        "description": "A free slab.",
        "required": [
          "id",
          "leftover"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int64",
            "description": "The slab."
          },
          "bundle": {
            "type": [
              "string",
              "null"
            ],
            "description": "Bundle label."
          },
          "width": {
            "type": [
              "number",
              "null"
            ],
            "format": "double",
            "description": "Width in inches."
          },
          "length": {
            "type": [
              "number",
              "null"
            ],
            "format": "double",
            "description": "Length in inches."
          },
          "url": {
            "type": [
              "string",
              "null"
            ],
            "description": "Slab photo."
          },
          "leftover": {
            "type": "boolean",
            "description": "A remnant, or what is left of a partly sold slab (its size and photo\nare the whole slab's)."
          }
        }
      },
      "InventorySlabs": {
        "type": "object",
        "description": "`GET /v1/quotes/inventory-slabs`.",
        "required": [
          "slabs"
        ],
        "properties": {
          "stone_url": {
            "type": [
              "string",
              "null"
            ],
            "description": "The stone's picture."
          },
          "slabs": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/InventorySlab"
            },
            "description": "Free slabs of the stone and of the stones it shows slabs from, by bundle."
          }
        }
      },
      "InventoryUrl": {
        "type": "object",
        "description": "The customer stones page.",
        "required": [
          "inventory_url"
        ],
        "properties": {
          "inventory_url": {
            "type": "string",
            "description": "`https://<subdomain>.granite-manager.com/customer/<company>/stones`."
          }
        }
      },
      "InvitationToken": {
        "type": "object",
        "description": "Body of `POST /v1/public/signing/{document_id}/session`.",
        "required": [
          "token"
        ],
        "properties": {
          "token": {
            "type": "string",
            "description": "`token` from the invitation link."
          }
        }
      },
      "InviteDetails": {
        "type": "object",
        "description": "`GET /v1/auth/invite/{token}`.",
        "required": [
          "email"
        ],
        "properties": {
          "email": {
            "type": "string",
            "description": "The account's email; they sign in with it."
          },
          "company_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "The company that added them."
          }
        }
      },
      "Invoice": {
        "type": "object",
        "description": "An invoice of the company.",
        "required": [
          "stripe_invoice_id",
          "status",
          "amount_due_cents",
          "amount_paid_cents"
        ],
        "properties": {
          "stripe_invoice_id": {
            "type": "string",
            "description": "Stripe invoice id (`in_...`)."
          },
          "status": {
            "type": "string",
            "description": "`paid` or `open`."
          },
          "amount_due_cents": {
            "type": "integer",
            "format": "int64",
            "description": "What is still owed, in cents (0 once paid)."
          },
          "amount_paid_cents": {
            "type": "integer",
            "format": "int64",
            "description": "What was paid, in cents."
          },
          "hosted_invoice_url": {
            "type": [
              "string",
              "null"
            ],
            "description": "Stripe's page to pay or view the invoice, or null."
          },
          "invoice_pdf": {
            "type": [
              "string",
              "null"
            ],
            "description": "The invoice PDF, or null."
          },
          "paid_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When it was paid (ISO 8601), or null."
          }
        }
      },
      "InvoiceBalance": {
        "type": "object",
        "description": "`GET /v1/qbo/invoices/{invoice_id}/balance`.",
        "properties": {
          "balance": {
            "type": [
              "number",
              "null"
            ],
            "format": "double",
            "description": "What the customer still owes on it."
          },
          "total": {
            "type": [
              "number",
              "null"
            ],
            "format": "double",
            "description": "The invoice's total."
          }
        }
      },
      "InvoiceCopiesRun": {
        "type": "object",
        "description": "What a run did.",
        "required": [
          "checked",
          "changed",
          "failed"
        ],
        "properties": {
          "checked": {
            "type": "integer",
            "description": "Invoices whose `QuickBooks` copy was read.",
            "minimum": 0
          },
          "changed": {
            "type": "integer",
            "description": "Invoices that took or lost a payment.",
            "minimum": 0
          },
          "failed": {
            "type": "integer",
            "description": "Invoices whose copy could not be read (tried again later).",
            "minimum": 0
          }
        }
      },
      "InvoiceCreate": {
        "type": "object",
        "description": "Body of `POST /v1/customers/{id}/qbo-invoices`.",
        "required": [
          "invoice"
        ],
        "properties": {
          "invoice": {
            "$ref": "#/components/schemas/EditableInvoice",
            "description": "The invoice as the editor left it (`id` and `sync_token` unused)."
          },
          "quote_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "The quote it is made from, which keeps the new invoice's id."
          },
          "draft": {
            "type": [
              "array",
              "null"
            ],
            "items": {
              "$ref": "#/components/schemas/Line"
            },
            "description": "The lines the editor opened with: what the rep changed in them is\nkept for the next drafts to learn from."
          },
          "parts": {
            "type": [
              "array",
              "null"
            ],
            "items": {
              "$ref": "#/components/schemas/Part"
            },
            "description": "Each line's part of the quote: the classes the rep gives them\nstart the rep's next invoices."
          }
        }
      },
      "InvoiceEdit": {
        "type": "object",
        "description": "`POST /v1/ai/invoice-edit`.",
        "required": [
          "invoice"
        ],
        "properties": {
          "invoice": {
            "$ref": "#/components/schemas/EditableInvoice",
            "description": "The proposed invoice, for the editor to preview and save."
          }
        }
      },
      "InvoiceEditInput": {
        "type": "object",
        "description": "Body of `POST /v1/ai/invoice-edit`.",
        "required": [
          "invoice",
          "instruction"
        ],
        "properties": {
          "invoice": {
            "$ref": "#/components/schemas/EditableInvoice",
            "description": "The invoice as the editor has it."
          },
          "instruction": {
            "type": "string",
            "description": "What to change."
          }
        }
      },
      "InvoiceInput": {
        "type": "object",
        "description": "Body of `POST /v1/invoices` and `PUT /v1/invoices/{id}`: the whole\ninvoice as the editor shows it. Totals are computed by the API.",
        "required": [
          "invoice_date",
          "bill_to_name",
          "lines"
        ],
        "properties": {
          "invoice_number": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Invoice number, unique in the company. Leave it out on create to\ntake the next one (`next_number` of `GET /v1/invoices`); on update,\nleaving it out keeps the current number."
          },
          "customer_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "The CRM customer billed (`GET /v1/customers`). Null bills someone\nwho is not a customer record; with a `quote_id` and no customer, the\nquote's customer is used."
          },
          "quote_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "The quote the invoice was made from, if any. It must be one of the\ncompany's quotes, and of `customer_id` when both are given."
          },
          "invoice_date": {
            "type": "string",
            "description": "Invoice date, `YYYY-MM-DD`."
          },
          "due_date": {
            "type": [
              "string",
              "null"
            ],
            "description": "Due date, `YYYY-MM-DD`, on or after `invoice_date`; null or empty for\nnone (due on receipt)."
          },
          "bill_to_name": {
            "type": "string",
            "description": "Name printed under \"Bill to\"; required."
          },
          "bill_to_email": {
            "type": [
              "string",
              "null"
            ],
            "description": "Email the invoice is sent to; null or empty for none."
          },
          "project_address": {
            "type": [
              "string",
              "null"
            ],
            "description": "Job site address printed on the invoice, on one line."
          },
          "lines": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/InvoiceLine"
            },
            "description": "The lines, in order; at least one must have a price. Blank lines\n(no text, no price) are dropped. At most 200."
          },
          "tax": {
            "type": [
              "number",
              "null"
            ],
            "format": "double",
            "description": "Sales tax in dollars, added to the subtotal; 0 when left out."
          },
          "customer_memo": {
            "type": [
              "string",
              "null"
            ],
            "description": "Message to the customer printed on the invoice."
          },
          "private_note": {
            "type": [
              "string",
              "null"
            ],
            "description": "Internal note; never printed or sent."
          },
          "payment_method": {
            "type": [
              "string",
              "null"
            ],
            "description": "How the customer will pay (a name from `GET /v1/payment-options`);\nempty for none. Left out (or null), an update keeps the current one,\nso a save that does not know it never clears it. Record payment\nstarts on it."
          }
        }
      },
      "InvoiceInstructions": {
        "type": "object",
        "description": "`GET`/`PUT /v1/qbo/invoice-instructions`.",
        "properties": {
          "instructions": {
            "type": "string",
            "description": "As the admin wrote them."
          },
          "rules": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/InstructionRule"
            },
            "description": "The rules made of them, in order."
          },
          "not_understood": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "What could not be made into a rule, and why."
          }
        }
      },
      "InvoiceLine": {
        "type": "object",
        "description": "One line of an invoice, in the order it is printed.\n\nA line with a `unit_price` is priced: `amount` = `qty` × `unit_price`,\nrounded to cents (a negative price makes a discount). A line without a\n`unit_price` is text only (a note under the line above) and has no `qty`\nor `amount`.",
        "required": [
          "description"
        ],
        "properties": {
          "description": {
            "type": "string",
            "description": "What was sold, or the note's text."
          },
          "qty": {
            "type": [
              "number",
              "null"
            ],
            "format": "double",
            "description": "Quantity; 1 when a priced line leaves it out. Null on a text line."
          },
          "unit_price": {
            "type": [
              "number",
              "null"
            ],
            "format": "double",
            "description": "Price of one unit, in dollars. Null makes the line text only."
          },
          "amount": {
            "type": [
              "number",
              "null"
            ],
            "format": "double",
            "description": "`qty` × `unit_price` in dollars, rounded to cents. Computed by the\nAPI: a value sent in a request is ignored. Null on a text line."
          }
        }
      },
      "InvoiceList": {
        "type": "object",
        "description": "`GET /v1/invoices`.",
        "required": [
          "invoices",
          "next_number"
        ],
        "properties": {
          "invoices": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/InvoiceSummary"
            },
            "description": "Matching invoices, highest number first; at most 500."
          },
          "next_number": {
            "type": "integer",
            "format": "int32",
            "description": "The number the next new invoice gets when none is given."
          }
        }
      },
      "InvoicePayLink": {
        "type": "object",
        "description": "The link to pay one of a customer's invoices.",
        "properties": {
          "url": {
            "type": [
              "string",
              "null"
            ],
            "description": "Our payment page for the invoice, to put in the email that sends it;\nnull while the customer cannot pay it online (payments off, the bank\naccount not connected, or the invoice on none of their jobs)."
          }
        }
      },
      "InvoicePayPage": {
        "type": "object",
        "description": "What the invoice's payment page (`/pay-invoice/<link id>`) shows.",
        "required": [
          "company_name",
          "total_cents",
          "balance_cents",
          "amount_cents",
          "can_pay",
          "card",
          "card_fee_bps",
          "ach_fee_bps",
          "card_total_cents",
          "ach_total_cents",
          "demo"
        ],
        "properties": {
          "company_name": {
            "type": "string",
            "description": "The company being paid."
          },
          "doc_number": {
            "type": [
              "string",
              "null"
            ],
            "description": "The invoice's number; null without one."
          },
          "invoice_date": {
            "type": [
              "string",
              "null"
            ],
            "description": "The invoice's date (`YYYY-MM-DD`); null without one."
          },
          "due_date": {
            "type": [
              "string",
              "null"
            ],
            "description": "When it is due (`YYYY-MM-DD`); null without a due date."
          },
          "total_cents": {
            "type": "integer",
            "format": "int64",
            "description": "The invoice's total, in US cents."
          },
          "balance_cents": {
            "type": "integer",
            "format": "int64",
            "description": "What is left to pay on it, in US cents (0 once paid)."
          },
          "amount_cents": {
            "type": "integer",
            "format": "int64",
            "description": "What the customer can pay on the page now, in US cents: the balance,\nless a payment on its way or just made that is not on the invoice\nyet. 0 while nothing can be paid."
          },
          "can_pay": {
            "type": "boolean",
            "description": "The customer can pay on the page: payments on, the bank account\nconnected, and something to pay."
          },
          "card": {
            "type": "boolean",
            "description": "A card payment is possible (at least $10)."
          },
          "card_fee_bps": {
            "type": "integer",
            "format": "int32",
            "description": "The customer's part of the fee on a card payment, in basis points\n(300 = 3%, added on top), and of an ACH one."
          },
          "ach_fee_bps": {
            "type": "integer",
            "format": "int32"
          },
          "card_total_cents": {
            "type": "integer",
            "format": "int64",
            "description": "What the customer is charged for `amount_cents` by card, and by bank\ntransfer, fees included."
          },
          "ach_total_cents": {
            "type": "integer",
            "format": "int64"
          },
          "demo": {
            "type": "boolean",
            "description": "Demo mode: nothing is charged."
          }
        }
      },
      "InvoicePayment": {
        "type": "object",
        "description": "Body of `POST /v1/public/invoice-pay/{link_id}/payments`.",
        "required": [
          "method"
        ],
        "properties": {
          "method": {
            "$ref": "#/components/schemas/PaymentMethod",
            "description": "How the customer pays."
          }
        },
        "additionalProperties": false
      },
      "InvoicePaymentMethod": {
        "type": "object",
        "description": "An invoice's payment method.",
        "properties": {
          "payment_method": {
            "type": [
              "string",
              "null"
            ],
            "description": "A name from `GET /v1/payment-options`; null (or empty, when saving)\nfor none."
          }
        }
      },
      "InvoicePayments": {
        "type": "object",
        "description": "An invoice's payments with what is still owed.",
        "required": [
          "payments"
        ],
        "properties": {
          "total": {
            "type": [
              "number",
              "null"
            ],
            "format": "double",
            "description": "The invoice's total."
          },
          "balance": {
            "type": [
              "number",
              "null"
            ],
            "format": "double",
            "description": "What is still owed on it."
          },
          "tax": {
            "type": [
              "number",
              "null"
            ],
            "format": "double",
            "description": "The sales tax `QuickBooks` charged on it; null for an own invoice."
          },
          "payments": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/RecordedPayment"
            },
            "description": "Newest first."
          },
          "payment_method": {
            "type": [
              "string",
              "null"
            ],
            "description": "How the customer will pay, as the invoice editor picked it; null when\nnone was. Record payment starts on it."
          }
        }
      },
      "InvoiceProblem": {
        "type": "object",
        "description": "One problem of a quote's invoices.",
        "required": [
          "id",
          "kind",
          "message"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int64",
            "description": "The problem's id, for `POST .../invoice-problems/{problem_id}/retry`.",
            "minimum": 0
          },
          "kind": {
            "type": "string",
            "description": "`sync`, `deposit`, `link` or `refund`: what failed."
          },
          "invoice_id": {
            "type": [
              "string",
              "null"
            ],
            "description": "The `QuickBooks` invoice it is about; null when it is about the quote."
          },
          "message": {
            "type": "string",
            "description": "What happened and how to fix it, in plain words."
          },
          "updated_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When it last failed (ISO 8601, UTC)."
          }
        }
      },
      "InvoiceStatus": {
        "type": "string",
        "description": "Where an invoice stands.\n\n- `draft`: saved, not emailed to the customer yet\n- `sent`: emailed to the customer (or handed over), not paid\n- `partial`: its recorded payments cover part of it (set by the payments,\n  never by hand)\n- `paid`: the customer paid it\n- `void`: cancelled; kept so its number is not reused",
        "enum": [
          "draft",
          "sent",
          "partial",
          "paid",
          "void"
        ]
      },
      "InvoiceStatusInput": {
        "type": "object",
        "description": "Body of `PUT /v1/invoices/{id}/status`.",
        "required": [
          "status"
        ],
        "properties": {
          "status": {
            "$ref": "#/components/schemas/InvoiceStatus",
            "description": "The new status. `sent` records when it was first sent; `paid` records\nwhen it was paid (cleared again by any other status)."
          }
        }
      },
      "InvoiceStyle": {
        "type": "object",
        "description": "`GET`/`POST /v1/qbo/invoice-style`.",
        "properties": {
          "rules": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/InstructionRule"
            },
            "description": "The rules every new invoice draft follows, each checked against the\ncompany's invoices: `hide` and `rename` only."
          },
          "notes": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "What the AI noticed and could not make a rule of."
          },
          "learned_at": {
            "type": [
              "string",
              "null"
            ],
            "description": "When it was last learned (UTC); null before the first time."
          },
          "invoices_read": {
            "type": "integer",
            "description": "How many of the company's `QuickBooks` invoices it was learned from.",
            "minimum": 0
          },
          "tidying": {
            "$ref": "#/components/schemas/Tidying",
            "description": "How many of the invoices created from quotes the office still changes\nin `QuickBooks` afterwards: whether the drafts are getting closer."
          }
        }
      },
      "InvoiceSummary": {
        "type": "object",
        "description": "An invoice in a list.",
        "required": [
          "id"
        ],
        "properties": {
          "id": {
            "type": "string",
            "description": "`QuickBooks` invoice id."
          },
          "doc_number": {
            "type": [
              "string",
              "null"
            ],
            "description": "Invoice number."
          },
          "txn_date": {
            "type": [
              "string",
              "null"
            ],
            "description": "Invoice date (`YYYY-MM-DD`)."
          },
          "due_date": {
            "type": [
              "string",
              "null"
            ],
            "description": "Due date (`YYYY-MM-DD`)."
          },
          "total_amt": {
            "type": [
              "number",
              "null"
            ],
            "format": "double",
            "description": "Total."
          },
          "balance": {
            "type": [
              "number",
              "null"
            ],
            "format": "double",
            "description": "Still owed."
          },
          "currency": {
            "type": [
              "string",
              "null"
            ],
            "description": "Currency code."
          },
          "project_address": {
            "type": [
              "string",
              "null"
            ],
            "description": "The shipping address, on one line."
          },
          "last_updated": {
            "type": [
              "string",
              "null"
            ],
            "description": "When `QuickBooks` last changed it (a paid invoice: about when it was paid)."
          },
          "total_tax": {
            "type": [
              "number",
              "null"
            ],
            "format": "double",
            "description": "The sales tax `QuickBooks` charged on it; null when it was not read."
          },
          "card_fees": {
            "type": [
              "number",
              "null"
            ],
            "format": "double",
            "description": "Card fees charged on it (\"3% CC Fee\", \"Credit card fee\"): the\ncustomer pays them, the job does not earn them."
          }
        }
      },
      "InvoiceSync": {
        "type": "object",
        "description": "A quote's invoice and how it is kept in step with the quote.",
        "required": [
          "option_index",
          "kind",
          "invoice_ids",
          "detail",
          "source_hash",
          "enabled"
        ],
        "properties": {
          "option_index": {
            "type": "integer",
            "format": "int32",
            "description": "The quote option invoiced."
          },
          "kind": {
            "type": "string",
            "description": "`qbo` (`QuickBooks` invoices) or `own` (`/v1/invoices`)."
          },
          "invoice_ids": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "`QuickBooks` invoice ids in order (several for a split), or the own\ninvoice's id."
          },
          "detail": {
            "type": "object",
            "description": "What rebuilding needs, as the CRM sent it (a split's shares, each\ninvoice's priced lines by part, what was emailed)."
          },
          "source_hash": {
            "type": "string",
            "description": "The quote's invoice lines when the invoice was last made or synced."
          },
          "enabled": {
            "type": "boolean",
            "description": "Off: the invoice is no longer changed with the quote."
          }
        }
      },
      "InvoiceUpdate": {
        "type": "object",
        "description": "Body of `PUT /v1/customers/{id}/qbo-invoices/{invoice_id}`.",
        "required": [
          "invoice"
        ],
        "properties": {
          "invoice": {
            "$ref": "#/components/schemas/EditableInvoice",
            "description": "The invoice as the editor left it."
          }
        }
      },
      "InvoicesStatus": {
        "type": "string",
        "description": "`ok`, or why there are no invoices.",
        "enum": [
          "ok",
          "not_connected",
          "missing_qbo_id",
          "error"
        ]
      },
      "IssueComment": {
        "type": "object",
        "description": "A comment under an issue.",
        "required": [
          "id",
          "issue_id",
          "body"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "Its id."
          },
          "issue_id": {
            "type": "integer",
            "format": "int32",
            "description": "The issue it is under."
          },
          "body": {
            "type": "string",
            "description": "What was written; marked people read `@Name`."
          },
          "author_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "The writer's user id; null once that user is gone."
          },
          "author": {
            "type": [
              "string",
              "null"
            ],
            "description": "The writer's name."
          },
          "created_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When it was written (UTC)."
          }
        }
      },
      "IssueCommentInput": {
        "type": "object",
        "description": "Body of `POST /v1/issues/{issue_id}/comments`.",
        "required": [
          "body"
        ],
        "properties": {
          "body": {
            "type": "string",
            "description": "What to say: 1 to 2000 characters (trimmed)."
          },
          "mention_ids": {
            "type": "array",
            "items": {
              "type": "integer",
              "format": "int32"
            },
            "description": "The people marked (`@Name` in `body`): user ids of the company, at\nmost 20. Each gets a notification."
          }
        }
      },
      "IssueInput": {
        "type": "object",
        "description": "Body of `POST /v1/events/{id}/issues`.",
        "required": [
          "description"
        ],
        "properties": {
          "description": {
            "type": "string",
            "description": "What is wrong: 1 to 2000 characters (trimmed)."
          },
          "urls": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Pictures of it: `url`s that `POST /v1/uploads` (folder `events`)\nreturned, after each file was `PUT` to its `upload_url`. At most 20;\nmay be empty."
          }
        }
      },
      "IssuePhoto": {
        "type": "object",
        "description": "A picture of an issue.",
        "required": [
          "id",
          "url"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "The picture's id."
          },
          "url": {
            "type": "string",
            "description": "Its public URL (a `-icon` thumbnail exists beside it)."
          }
        }
      },
      "IssueSolved": {
        "type": "object",
        "description": "Body of `PUT /v1/events/{id}/issues/{issue_id}`.",
        "properties": {
          "solved": {
            "type": [
              "boolean",
              "null"
            ],
            "description": "Solved, or open again (apps from before `status`)."
          },
          "status": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/IssueStatus",
                "description": "`open`, `in_progress` or `solved`; wins over `solved`."
              },
              {
                "type": "null"
              }
            ]
          }
        }
      },
      "IssueSolvedInput": {
        "type": "object",
        "description": "Body of `PUT .../issues/{issue_id}`.",
        "properties": {
          "solved": {
            "type": [
              "boolean",
              "null"
            ],
            "description": "Solved, or open again (apps from before `status`)."
          },
          "status": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/IssueStatus",
                "description": "`open`, `in_progress` or `solved`; wins over `solved`."
              },
              {
                "type": "null"
              }
            ]
          }
        }
      },
      "IssueStatus": {
        "type": "string",
        "description": "Where an issue is: just reported, someone took it on, or done.",
        "enum": [
          "open",
          "in_progress",
          "solved"
        ]
      },
      "Item": {
        "type": "object",
        "description": "One item.",
        "required": [
          "key",
          "label",
          "done",
          "auto",
          "manual",
          "source"
        ],
        "properties": {
          "key": {
            "type": "string",
            "description": "Item key (e.g. `users.manager`); `PUT .../setup-checklist/items/{key}` ticks it."
          },
          "label": {
            "type": "string",
            "description": "What to do."
          },
          "done": {
            "type": "boolean",
            "description": "Done automatically or by hand."
          },
          "auto": {
            "type": "boolean",
            "description": "Done automatically (from the database, DNS or SES)."
          },
          "manual": {
            "type": "boolean",
            "description": "Ticked by hand."
          },
          "source": {
            "type": "string",
            "description": "`auto`, `manual` or `none`."
          },
          "detail": {
            "type": [
              "string",
              "null"
            ],
            "description": "A hint (the domain, the expected DNS name), or null."
          }
        }
      },
      "ItemDone": {
        "type": "object",
        "description": "Body of `PUT /v1/projects/{id}/tasks/{task_id}/items/{item_id}` and\n`PUT /v1/projects/{id}/step-items/{item_id}`.",
        "required": [
          "done"
        ],
        "properties": {
          "done": {
            "type": "boolean",
            "description": "Ticked off (true) or open again (false)."
          },
          "part_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "The part, on a project with parts (step items only)."
          }
        }
      },
      "ItemSlabsInput": {
        "type": "object",
        "description": "The slabs of one color.",
        "required": [
          "id",
          "slabs"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "`SalesOrderItem.id`."
          },
          "slabs": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SlabInput"
            },
            "description": "The slabs set on the color, replacing those it had."
          }
        },
        "additionalProperties": false
      },
      "ItemSuggestion": {
        "type": "object",
        "description": "A miscellaneous or text item used on earlier quotes, with the values it\nhad the last time.",
        "required": [
          "kind",
          "description",
          "quantity",
          "hide_on_quote",
          "allow_discount",
          "taxable",
          "uses",
          "customers"
        ],
        "properties": {
          "kind": {
            "type": "string",
            "description": "`misc` (a priced line typed by hand) or `text` (a line of text, no price)."
          },
          "description": {
            "type": "string",
            "description": "The description, spelled as on the latest quote that used it."
          },
          "price": {
            "type": [
              "number",
              "null"
            ],
            "format": "double",
            "description": "Price in dollars the last time; null when it had none (always null for `text`)."
          },
          "quantity": {
            "type": "number",
            "format": "double",
            "description": "Quantity the last time (1 when not set)."
          },
          "hide_on_quote": {
            "type": "boolean",
            "description": "The line was hidden on the printed quote."
          },
          "allow_discount": {
            "type": "boolean",
            "description": "The project discount applied to it."
          },
          "taxable": {
            "type": "boolean",
            "description": "Tax applied to it."
          },
          "uses": {
            "type": "integer",
            "format": "int64",
            "description": "How many of the recent quotes use it."
          },
          "customers": {
            "type": "integer",
            "format": "int64",
            "description": "How many different customers those quotes are for (a quote with no\ncustomer counts by its deal, else on its own). Always 2 or more."
          },
          "last_used": {
            "type": [
              "string",
              "null"
            ],
            "description": "When the latest quote using it was last changed (UTC, ISO 8601); null if unknown."
          }
        }
      },
      "JobChips": {
        "type": "object",
        "description": "One job's stones and sq ft.",
        "required": [
          "event_id",
          "stones",
          "square_feet"
        ],
        "properties": {
          "event_id": {
            "type": "integer",
            "format": "int32",
            "description": "The event."
          },
          "stones": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Stone names of the project's sales (newest sale first, each sale's\nslabs in the order they were added), each once. Empty when the event\nhas no sale, or one of its sales can't be read."
          },
          "square_feet": {
            "type": "number",
            "format": "double",
            "description": "The project's countertop sq ft: its sold quotes' (as\n`GET /v1/quotes/square-feet` counts them), else its sales' rooms'.\n0 when unknown. Not rounded."
          }
        }
      },
      "JobKind": {
        "type": "string",
        "description": "The two calendars whose jobs have a length rule.",
        "enum": [
          "installations",
          "templates"
        ]
      },
      "JobMoneyList": {
        "type": "object",
        "description": "`GET /v1/customers/{id}/job-money`.",
        "required": [
          "connected",
          "jobs"
        ],
        "properties": {
          "connected": {
            "type": "boolean",
            "description": "False when `QuickBooks` is the company's books and did not answer:\nthen no job has an answer."
          },
          "jobs": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/JobMoneyRow"
            },
            "description": "The customer's deals, and the sales outside a deal that were paid\nthrough a payment link."
          }
        }
      },
      "JobMoneyRow": {
        "type": "object",
        "description": "One job's money on the customer's Projects tab.",
        "required": [
          "project_key",
          "paid"
        ],
        "properties": {
          "project_key": {
            "type": "string",
            "description": "The job, as `GET /v1/customers/{id}/projects` names it (`deal-12`,\n`sale-3`)."
          },
          "invoiced": {
            "type": [
              "number",
              "null"
            ],
            "format": "double",
            "description": "The total of its invoices; null when it has none (the Projects tab\nthen owes the job's price)."
          },
          "paid": {
            "type": "number",
            "format": "double",
            "description": "Everything paid toward it, counted once: on its invoices, deposits\nwaiting for an invoice, and payment links not recorded on one."
          },
          "balance": {
            "type": [
              "number",
              "null"
            ],
            "format": "double",
            "description": "What its invoices still owe after that; null when it has no invoice."
          },
          "unpaid_due_date": {
            "type": [
              "string",
              "null"
            ],
            "description": "The earliest due date among its invoices that still owe something."
          }
        }
      },
      "JobPayAdded": {
        "type": "object",
        "description": "Where a job went in the salary.",
        "required": [
          "payrollDate"
        ],
        "properties": {
          "payrollDate": {
            "type": "string",
            "description": "The payroll it is paid with (YYYY-MM-DD)."
          }
        }
      },
      "JobPayEdit": {
        "type": "object",
        "description": "An admin's own numbers for a job.",
        "properties": {
          "sqFt": {
            "type": [
              "number",
              "null"
            ],
            "format": "double",
            "description": "The sq ft paid; null: the quote's."
          },
          "amount": {
            "type": [
              "number",
              "null"
            ],
            "format": "double",
            "description": "The job's pay before extras; null: sq ft × rate."
          },
          "payrollDate": {
            "type": [
              "string",
              "null"
            ],
            "description": "The payroll it is paid with (YYYY-MM-DD); null: not in the salary."
          },
          "extras": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/JobPayExtra"
            },
            "description": "The extras: replaces the job's list."
          }
        },
        "additionalProperties": false
      },
      "JobPayExtra": {
        "type": "object",
        "description": "An extra on a job: a repair, a tear-out.",
        "required": [
          "label",
          "amount"
        ],
        "properties": {
          "label": {
            "type": "string",
            "description": "What it is for (1 to 120 characters)."
          },
          "amount": {
            "type": "number",
            "format": "double",
            "description": "Dollars; not negative."
          }
        },
        "additionalProperties": false
      },
      "JobPayRow": {
        "type": "object",
        "description": "A finished template or install and what it pays one person.",
        "required": [
          "id",
          "eventId",
          "work",
          "userId",
          "person",
          "job",
          "doneDate",
          "rate",
          "amount",
          "adjusted",
          "extras",
          "total",
          "paidOut"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "Row id."
          },
          "eventId": {
            "type": "integer",
            "format": "int32",
            "description": "The schedule event."
          },
          "work": {
            "type": "string",
            "description": "`template` or `install`."
          },
          "userId": {
            "type": "integer",
            "format": "int32",
            "description": "Who did it."
          },
          "person": {
            "type": "string",
            "description": "Their name."
          },
          "job": {
            "type": "string",
            "description": "The customer, or the event's title when it has none."
          },
          "doneDate": {
            "type": "string",
            "description": "The day it was finished (YYYY-MM-DD)."
          },
          "quoteSqFt": {
            "type": [
              "number",
              "null"
            ],
            "format": "double",
            "description": "The sq ft of stone on the event's quote; null: no quote, or no stone on it."
          },
          "sqFt": {
            "type": [
              "number",
              "null"
            ],
            "format": "double",
            "description": "The sq ft paid: an admin's own, else the quote's; null: not known yet."
          },
          "rate": {
            "type": "number",
            "format": "double",
            "description": "Dollars per sq ft."
          },
          "amount": {
            "type": "number",
            "format": "double",
            "description": "The job's pay before extras: an admin's own, else sq ft × rate."
          },
          "adjusted": {
            "type": "boolean",
            "description": "An admin set the sq ft or the amount."
          },
          "extras": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/JobPayExtra"
            },
            "description": "Extras added by hand."
          },
          "total": {
            "type": "number",
            "format": "double",
            "description": "`amount` plus the extras."
          },
          "payrollDate": {
            "type": [
              "string",
              "null"
            ],
            "description": "The payroll it is paid with (YYYY-MM-DD); null: not in the salary yet."
          },
          "paidOut": {
            "type": "boolean",
            "description": "Paid out to the person."
          }
        }
      },
      "JobPayRule": {
        "type": "object",
        "description": "A pay rule for templates or installs.",
        "required": [
          "id",
          "name",
          "work",
          "kind",
          "amount",
          "active"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int64",
            "description": "Rule id."
          },
          "name": {
            "type": "string",
            "description": "Name (\"Install\", \"Tear-out\")."
          },
          "work": {
            "type": "string",
            "description": "`template` or `install`."
          },
          "kind": {
            "type": "string",
            "description": "`sqft` (dollars per sq ft of every finished job, by itself) or `extra`\n(a fixed amount an admin adds to a job by hand)."
          },
          "amount": {
            "type": "number",
            "format": "double",
            "description": "Dollars per sq ft, or the extra's dollars."
          },
          "userId": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "`sqft` rules: the one person it pays; null: everyone with the work's\nposition (Template technician, Installer)."
          },
          "person": {
            "type": [
              "string",
              "null"
            ],
            "description": "That person's name."
          },
          "active": {
            "type": "boolean",
            "description": "Off rules pay nothing."
          }
        }
      },
      "JobPayRuleInput": {
        "type": "object",
        "description": "A pay rule as an admin builds it.",
        "required": [
          "name",
          "work",
          "kind",
          "amount"
        ],
        "properties": {
          "name": {
            "type": "string",
            "description": "Name (1 to 120 characters)."
          },
          "work": {
            "type": "string",
            "description": "`template` or `install`."
          },
          "kind": {
            "type": "string",
            "description": "`sqft` or `extra`."
          },
          "amount": {
            "type": "number",
            "format": "double",
            "description": "Dollars per sq ft, or the extra's dollars; not negative."
          },
          "userId": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "`sqft` rules: one person; null: everyone with the work's position."
          },
          "active": {
            "type": "boolean",
            "description": "Off rules pay nothing."
          }
        },
        "additionalProperties": false
      },
      "JobStatus": {
        "type": "object",
        "description": "A status a job can have, in order.",
        "required": [
          "key",
          "stage",
          "name",
          "color"
        ],
        "properties": {
          "key": {
            "type": "string",
            "description": "What `events.status` holds: `not_ready`, `called`, `ready`,\n`confirmed` (the starting ones) or `s<id>`."
          },
          "stage": {
            "$ref": "#/components/schemas/Stage",
            "description": "Its type."
          },
          "name": {
            "type": "string",
            "description": "Its name, as the schedule shows it."
          },
          "color": {
            "type": "string",
            "description": "A palette color name (`red`, `amber`, …)."
          }
        }
      },
      "JobStatusInput": {
        "type": "object",
        "description": "A new status.",
        "required": [
          "stage",
          "name",
          "color"
        ],
        "properties": {
          "stage": {
            "$ref": "#/components/schemas/Stage",
            "description": "Its type."
          },
          "name": {
            "type": "string",
            "description": "Its name (trimmed, not empty)."
          },
          "color": {
            "type": "string",
            "description": "A palette color name (`red`, `amber`, …)."
          }
        }
      },
      "JobStatusPatch": {
        "type": "object",
        "description": "A status's new name, color or type (left out: unchanged).",
        "properties": {
          "name": {
            "type": [
              "string",
              "null"
            ],
            "description": "The new name."
          },
          "color": {
            "type": [
              "string",
              "null"
            ],
            "description": "The new palette color name."
          },
          "stage": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/Stage",
                "description": "The new type."
              },
              {
                "type": "null"
              }
            ]
          }
        }
      },
      "JobStatuses": {
        "type": "object",
        "description": "`GET /v1/schedule/statuses`.",
        "required": [
          "statuses",
          "automations",
          "texts_confirmed_only"
        ],
        "properties": {
          "statuses": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/JobStatus"
            },
            "description": "The company's statuses, in order."
          },
          "automations": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Automation"
            },
            "description": "What moves a job to which status."
          },
          "texts_confirmed_only": {
            "type": "boolean",
            "description": "Automatic customer texts go only to jobs whose status is of the\nConfirmed type."
          }
        }
      },
      "JobTime": {
        "type": "object",
        "description": "`GET /v1/schedule/job-time`.",
        "required": [
          "minutes",
          "sale_id",
          "summary",
          "lines"
        ],
        "properties": {
          "minutes": {
            "type": "integer",
            "format": "int32",
            "description": "The job's length, rounded up to 15 minutes.",
            "minimum": 0
          },
          "sale_id": {
            "type": "integer",
            "format": "int32",
            "description": "The sale it was sized from."
          },
          "summary": {
            "type": "string",
            "description": "What the sale holds, e.g. \"50 sq ft · 1 waterfall · 2 sinks\"."
          },
          "lines": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/JobTimeLine"
            },
            "description": "How the length adds up."
          }
        }
      },
      "JobTimeLine": {
        "type": "object",
        "description": "A part of a job's length.",
        "required": [
          "label",
          "minutes"
        ],
        "properties": {
          "label": {
            "type": "string",
            "description": "What it is for, e.g. \"50 sq ft\"."
          },
          "minutes": {
            "type": "integer",
            "format": "int32",
            "description": "Its minutes.",
            "minimum": 0
          }
        }
      },
      "JoinInput": {
        "type": "object",
        "description": "Body of `POST /v1/auth/invite/{token}`.",
        "required": [
          "name",
          "phone_number",
          "password"
        ],
        "properties": {
          "name": {
            "type": "string",
            "description": "Their name."
          },
          "phone_number": {
            "type": "string",
            "description": "Their phone, at least 10 digits."
          },
          "password": {
            "type": "string",
            "description": "At least 8 characters."
          }
        }
      },
      "Kpis": {
        "type": "object",
        "description": "`GET /v1/sales-playbook/kpis`.",
        "required": [
          "month",
          "total",
          "reps",
          "stages",
          "lost_reasons",
          "objections"
        ],
        "properties": {
          "month": {
            "type": "string",
            "description": "`YYYY-MM`."
          },
          "total": {
            "$ref": "#/components/schemas/RepKpis"
          },
          "reps": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/RepKpis"
            },
            "description": "One row per rep with numbers in the month (`user_id` null: deals with no rep)."
          },
          "stages": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/StageDays"
            },
            "description": "Average days in each stage."
          },
          "lost_reasons": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Count"
            },
            "description": "Why deals were lost in the month, the most common first."
          },
          "objections": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Count"
            },
            "description": "Objections of the deals worked on in the month."
          }
        }
      },
      "LayoutInvoice": {
        "type": "object",
        "description": "One invoice of the company's usual split.",
        "required": [
          "shares"
        ],
        "properties": {
          "label": {
            "type": [
              "string",
              "null"
            ],
            "description": "Its message."
          },
          "shares": {
            "type": "object",
            "description": "The percent it charges of each part (`stone`, `area`, ...).",
            "additionalProperties": {
              "type": "number",
              "format": "double"
            },
            "propertyNames": {
              "type": "string"
            }
          }
        }
      },
      "LeadAnswers": {
        "type": "object",
        "description": "What a lead answered on the ad or web form; every field free text, null\nwhen not asked.",
        "properties": {
          "remodal_type": {
            "type": [
              "string",
              "null"
            ],
            "description": "Kind of remodel (kitchen, bath...)."
          },
          "project_size": {
            "type": [
              "string",
              "null"
            ],
            "description": "Project size."
          },
          "contact_time": {
            "type": [
              "string",
              "null"
            ],
            "description": "Best time to call."
          },
          "remove_and_dispose": {
            "type": [
              "string",
              "null"
            ],
            "description": "Whether old countertops must be torn out and disposed of."
          },
          "improve_offer": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Asked for a better offer (1 yes, 0 no)."
          },
          "sink": {
            "type": [
              "string",
              "null"
            ],
            "description": "Sink wanted."
          },
          "when_start": {
            "type": [
              "string",
              "null"
            ],
            "description": "When the project should start."
          },
          "details": {
            "type": [
              "string",
              "null"
            ],
            "description": "Project details."
          },
          "compaign_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "Ad campaign name."
          },
          "adset_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "Ad set name."
          },
          "ad_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "Ad name."
          },
          "backsplash": {
            "type": [
              "string",
              "null"
            ],
            "description": "Backsplash wanted."
          },
          "kitchen_stove": {
            "type": [
              "string",
              "null"
            ],
            "description": "Stove type."
          }
        }
      },
      "LeadAutomation": {
        "type": "object",
        "description": "The caller's automation choice; also the body of `PUT /v1/me/lead-automation`.",
        "required": [
          "mode"
        ],
        "properties": {
          "mode": {
            "$ref": "#/components/schemas/LeadAutomationMode",
            "description": "`company` or `own`."
          }
        },
        "additionalProperties": false
      },
      "LeadAutomationItems": {
        "type": "object",
        "description": "`GET /v1/me/lead-automation/items`: the caller's automations on each side.",
        "required": [
          "company",
          "own"
        ],
        "properties": {
          "company": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/AutomationItem"
            },
            "description": "The company's automations that go to the caller's deals while they\nuse the company's (mode `company`): those naming no sales reps, or\nnaming the caller."
          },
          "own": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/AutomationItem"
            },
            "description": "The caller's own automations, used while their mode is `own`."
          }
        }
      },
      "LeadAutomationMode": {
        "type": "string",
        "description": "Whose automated templates a sales rep's deals get.",
        "enum": [
          "company",
          "own"
        ]
      },
      "LeadCard": {
        "type": "object",
        "description": "A lead's card.",
        "required": [
          "customer",
          "history",
          "has_projects"
        ],
        "properties": {
          "customer": {
            "$ref": "#/components/schemas/CustomerDetail",
            "description": "Contact details and the web form's answers."
          },
          "history": {
            "$ref": "#/components/schemas/CustomerHistory",
            "description": "Deals, reassignments and when it reached a sales rep (no emails,\nactivities or notes)."
          },
          "has_projects": {
            "type": "boolean",
            "description": "The lead is a business or has projects (show the projects tab)."
          }
        }
      },
      "LeadInbox": {
        "type": "object",
        "description": "`GET /v1/customers/lead-inbox`.",
        "required": [
          "is_manager",
          "unassigned",
          "assigned",
          "reps",
          "team",
          "groups"
        ],
        "properties": {
          "is_manager": {
            "type": "boolean",
            "description": "A sales manager or an admin: `unassigned` and `reps` are filled in."
          },
          "unassigned": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/InboxLead"
            },
            "description": "Leads of the last 14 days without a rep, newest first (managers)."
          },
          "assigned": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/InboxLead"
            },
            "description": "Leads given a rep in the last 14 days, newest first: mine, or the\ncompany's for a manager."
          },
          "reps": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/InboxRep"
            },
            "description": "The company's sales reps to assign a lead to (managers only; empty\nfor a sales rep)."
          },
          "team": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/InboxRep"
            },
            "description": "Every sales rep of the company with the leads given to them this\nmonth (since the 1st, server time), sorted by name. Filled in for\neveryone, a sales rep too, so they can compare their count with the\nteam's; the same numbers as `reps`."
          },
          "groups": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/InboxGroup"
            },
            "description": "The company's live pipelines, oldest first (managers only; empty for\na sales rep). When none is the default, the Leads page asks which\nlist a lead goes to."
          }
        }
      },
      "LeadInput": {
        "type": "object",
        "description": "Body of `POST` and `PUT` on a lead.",
        "required": [
          "name"
        ],
        "properties": {
          "name": {
            "type": "string",
            "description": "Name; required."
          },
          "emails": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Email addresses, the first one primary."
          },
          "phone": {
            "type": [
              "string",
              "null"
            ],
            "description": "Phone."
          },
          "phone_2": {
            "type": [
              "string",
              "null"
            ],
            "description": "Second phone."
          },
          "address": {
            "type": [
              "string",
              "null"
            ],
            "description": "Address."
          },
          "your_message": {
            "type": [
              "string",
              "null"
            ],
            "description": "What the customer wrote."
          },
          "referral_source": {
            "type": [
              "string",
              "null"
            ],
            "description": "Creating only: one of the company's referral sources; required."
          },
          "file_url": {
            "type": [
              "string",
              "null"
            ],
            "description": "Creating only: a picture uploaded with `POST /v1/marketing/{company_id}/uploads`."
          }
        },
        "additionalProperties": false
      },
      "LeadKind": {
        "type": "string",
        "description": "What a lead push is about.",
        "enum": [
          "new",
          "repeat",
          "assigned",
          "taken",
          "quote"
        ]
      },
      "LeadProject": {
        "type": "object",
        "description": "A project (the lead's business or one of its jobs).",
        "required": [
          "id",
          "emails",
          "sales"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "Customer id."
          },
          "name": {
            "type": [
              "string",
              "null"
            ],
            "description": "Name."
          },
          "email": {
            "type": [
              "string",
              "null"
            ],
            "description": "Primary email."
          },
          "phone": {
            "type": [
              "string",
              "null"
            ],
            "description": "Phone."
          },
          "address": {
            "type": [
              "string",
              "null"
            ],
            "description": "Address."
          },
          "source": {
            "type": [
              "string",
              "null"
            ],
            "description": "Source."
          },
          "city": {
            "type": [
              "string",
              "null"
            ],
            "description": "City."
          },
          "state": {
            "type": [
              "string",
              "null"
            ],
            "description": "State."
          },
          "postal_code": {
            "type": [
              "string",
              "null"
            ],
            "description": "ZIP code."
          },
          "company_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "Business name."
          },
          "notes": {
            "type": [
              "string",
              "null"
            ],
            "description": "Notes."
          },
          "sales_rep_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "Assigned sales rep's name."
          },
          "deal_stage": {
            "type": [
              "string",
              "null"
            ],
            "description": "Stage of its newest live deal."
          },
          "emails": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Every email address, primary first."
          },
          "sales": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ProjectSale"
            },
            "description": "Its sales."
          }
        }
      },
      "LeadPush": {
        "type": "object",
        "description": "Body of `POST /v1/phone/pushes/lead`.",
        "required": [
          "company_id",
          "customer_id",
          "kind"
        ],
        "properties": {
          "company_id": {
            "type": "integer",
            "format": "int32",
            "description": "The lead's company."
          },
          "customer_id": {
            "type": "integer",
            "format": "int32",
            "description": "The lead (a customer of `company_id`)."
          },
          "deal_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int64",
            "description": "Its deal; else the customer's newest live deal, if any."
          },
          "kind": {
            "$ref": "#/components/schemas/LeadKind"
          },
          "user_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Who is told: this user (the sales rep); the company's sales managers\nwhen left out."
          },
          "except_user_ids": {
            "type": "array",
            "items": {
              "type": "integer",
              "format": "int32"
            },
            "description": "Sales managers not told (no `user_id` only): for `taken`, the rep\nand the manager who assigned the lead."
          }
        }
      },
      "LeadUploadRequest": {
        "type": "object",
        "description": "Body of `POST /v1/marketing/{company_id}/uploads`.",
        "required": [
          "file_name",
          "content_type"
        ],
        "properties": {
          "file_name": {
            "type": "string",
            "description": "Original file name; only its extension is kept."
          },
          "content_type": {
            "type": "string",
            "description": "An image type (`image/jpeg`, `image/png`...): the `Content-Type` of the `PUT`."
          }
        },
        "additionalProperties": false
      },
      "LeaderboardActivity": {
        "type": "object",
        "description": "Counts behind the call, text and email points, after the daily caps.",
        "required": [
          "conversations",
          "voicemails",
          "attempts",
          "sms",
          "emails"
        ],
        "properties": {
          "conversations": {
            "type": "integer",
            "format": "int64",
            "description": "Calls that were a real conversation (over 30 s)."
          },
          "voicemails": {
            "type": "integer",
            "format": "int64",
            "description": "Calls that left a voicemail (at most one per number per day scores)."
          },
          "attempts": {
            "type": "integer",
            "format": "int64",
            "description": "Short calls (at most one per number per day scores)."
          },
          "sms": {
            "type": "integer",
            "format": "int64",
            "description": "Texts sent by hand (at most three per number per day score)."
          },
          "emails": {
            "type": "integer",
            "format": "int64",
            "description": "Emails sent by hand."
          }
        }
      },
      "LeaderboardEntry": {
        "type": "object",
        "description": "One person's points.",
        "required": [
          "user_id",
          "name",
          "points",
          "breakdown",
          "activity"
        ],
        "properties": {
          "user_id": {
            "type": "integer",
            "format": "int32",
            "description": "User id."
          },
          "name": {
            "type": "string",
            "description": "Display name: the user's name, else their email, else \"Colleague\"."
          },
          "points": {
            "type": "number",
            "format": "double",
            "description": "Total points (emails score half a point, so it can end in .5)."
          },
          "rank": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int64",
            "description": "Rank among the reps (ties share a rank, 1 is the top); null for the\n`viewer` row."
          },
          "breakdown": {
            "$ref": "#/components/schemas/PointsBreakdown",
            "description": "Points per source."
          },
          "activity": {
            "$ref": "#/components/schemas/LeaderboardActivity",
            "description": "What the call, text and email points were earned with."
          }
        }
      },
      "LeaderboardPeriod": {
        "type": "string",
        "description": "Which points count.",
        "enum": [
          "all",
          "month"
        ]
      },
      "LeadsPage": {
        "type": "object",
        "description": "The leads page.",
        "required": [
          "leads",
          "deals",
          "stages",
          "invalid_stats",
          "invalid_reasons"
        ],
        "properties": {
          "from": {
            "type": [
              "string",
              "null"
            ],
            "description": "The range used, `YYYY-MM-DD`; null when open."
          },
          "to": {
            "type": [
              "string",
              "null"
            ],
            "description": "The range used."
          },
          "leads": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/MarketingLead"
            },
            "description": "Leads, newest first."
          },
          "deals": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/MarketingDeal"
            },
            "description": "Their live deals created in the range, newest first."
          },
          "stages": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/MarketingStage"
            },
            "description": "The company's stages."
          },
          "invalid_stats": {
            "$ref": "#/components/schemas/InvalidStats",
            "description": "Invalid leads by channel."
          },
          "invalid_reasons": {
            "$ref": "#/components/schemas/InvalidReasons",
            "description": "Lost or invalid leads by reason."
          }
        }
      },
      "LearnInput": {
        "type": "object",
        "description": "Body of `POST /v1/qbo/invoice-style`.",
        "properties": {
          "force": {
            "type": "boolean",
            "description": "Learn now even when it was learned today (admins only; ignored for\nothers)."
          },
          "lines": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "The lines of the draft that is open, as the quote makes them: the\nkinds of line the rules are about."
          }
        }
      },
      "LearnRequest": {
        "allOf": [
          {
            "$ref": "#/components/schemas/ComposeTarget"
          },
          {
            "type": "object",
            "required": [
              "suggested",
              "sent"
            ],
            "properties": {
              "suggested": {
                "type": "string",
                "description": "The whole message the AI proposed."
              },
              "sent": {
                "type": "string",
                "description": "What the rep sent instead."
              }
            }
          }
        ],
        "description": "`POST /v1/ai/compose/learn`."
      },
      "Learned": {
        "type": "object",
        "description": "Whether the notes changed.",
        "required": [
          "learned"
        ],
        "properties": {
          "learned": {
            "type": "boolean",
            "description": "The edit taught something (the notes were rewritten)."
          }
        }
      },
      "LeftHorus": {
        "type": "object",
        "description": "A slab that left Horus (cut, used or removed there).",
        "required": [
          "slab_id",
          "left_at",
          "outcome",
          "was_on_hold"
        ],
        "properties": {
          "slab_id": {
            "type": "integer",
            "format": "int64",
            "description": "The slab in Granite."
          },
          "stone_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "Its stone."
          },
          "bundle": {
            "type": [
              "string",
              "null"
            ],
            "description": "Its number."
          },
          "length": {
            "type": [
              "string",
              "null"
            ],
            "description": "Inches."
          },
          "width": {
            "type": [
              "string",
              "null"
            ],
            "description": "Inches."
          },
          "left_at": {
            "type": "string",
            "format": "date-time",
            "description": "When the sync saw it gone."
          },
          "outcome": {
            "type": "string",
            "description": "`marked_cut`: sold, marked cut then; `sold`: sold and already cut in\nGranite; `hidden`: not sold in Granite, so it left the list."
          },
          "customer": {
            "type": [
              "string",
              "null"
            ],
            "description": "The customer it was sold to or held for."
          },
          "was_on_hold": {
            "type": "boolean",
            "description": "It was on hold (not sold) when it left Horus."
          }
        }
      },
      "LensHint": {
        "type": "object",
        "description": "Whether the customer stones page should highlight its magnifier button.",
        "required": [
          "show"
        ],
        "properties": {
          "show": {
            "type": "boolean",
            "description": "True only the first time this visitor's IP address asks."
          }
        }
      },
      "Letterhead": {
        "type": "object",
        "description": "The company header a form prints (`loadFormCompany`).",
        "properties": {
          "name": {
            "type": [
              "string",
              "null"
            ],
            "description": "Company name."
          },
          "address": {
            "type": [
              "string",
              "null"
            ],
            "description": "Address."
          },
          "domain": {
            "type": [
              "string",
              "null"
            ],
            "description": "Website."
          },
          "logoUrl": {
            "type": [
              "string",
              "null"
            ],
            "description": "Logo."
          }
        }
      },
      "LevelInUse": {
        "type": "object",
        "description": "409 body of `DELETE /v1/stone-levels/{number}`: stones or materials have\nthe level.",
        "required": [
          "error",
          "stones",
          "materials"
        ],
        "properties": {
          "error": {
            "type": "string",
            "description": "\"Stones or materials have this level, so it cannot be deleted.\""
          },
          "stones": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/StoneUsingType"
            },
            "description": "Live stones (bundles) of that level, by name; change their level first."
          },
          "materials": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/StoneUsingType"
            },
            "description": "Materials of that level, by name; change their level first."
          }
        }
      },
      "LevelInput": {
        "type": "object",
        "description": "Body of `POST /v1/stone-levels` and `PATCH /v1/stone-levels/{number}`.",
        "properties": {
          "name": {
            "type": [
              "string",
              "null"
            ],
            "description": "The level's name shown next to its number (\"Standard\", \"Exotic\"), at\nmost 60 characters. Null or blank: just the number (\"Level 8\")."
          }
        },
        "additionalProperties": false
      },
      "LibraryFile": {
        "type": "object",
        "description": "An image or document of the company.",
        "required": [
          "id"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "The file."
          },
          "name": {
            "type": [
              "string",
              "null"
            ],
            "description": "Its name."
          },
          "url": {
            "type": [
              "string",
              "null"
            ],
            "description": "Where it is stored."
          }
        }
      },
      "LibraryImage": {
        "type": "object",
        "description": "An image of the library.",
        "required": [
          "id",
          "name"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "Image id."
          },
          "name": {
            "type": "string",
            "description": "Its name."
          },
          "url": {
            "type": [
              "string",
              "null"
            ],
            "description": "Where it is stored (its thumbnail has `-icon` before the extension)."
          },
          "folder_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Folder it is in; null at the top level."
          }
        }
      },
      "Line": {
        "type": "object",
        "description": "One line of an invoice.",
        "required": [
          "detail_type",
          "editable"
        ],
        "properties": {
          "id": {
            "type": [
              "string",
              "null"
            ],
            "description": "`QuickBooks` line id; `new:<anything>` for a line the editor added."
          },
          "line_num": {
            "type": [
              "number",
              "null"
            ],
            "format": "double",
            "description": "Position."
          },
          "detail_type": {
            "type": "string",
            "description": "`SalesItemLineDetail`, `DescriptionOnly`, `SubTotalLineDetail`, ..."
          },
          "description": {
            "type": [
              "string",
              "null"
            ],
            "description": "Line text."
          },
          "amount": {
            "type": [
              "number",
              "null"
            ],
            "format": "double",
            "description": "Line amount."
          },
          "qty": {
            "type": [
              "number",
              "null"
            ],
            "format": "double",
            "description": "Quantity (sales lines)."
          },
          "unit_price": {
            "type": [
              "number",
              "null"
            ],
            "format": "double",
            "description": "Unit price (sales lines)."
          },
          "item_ref_value": {
            "type": [
              "string",
              "null"
            ],
            "description": "The product or service id (sales lines)."
          },
          "item_ref_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "The product or service name."
          },
          "editable": {
            "type": "boolean",
            "description": "Sales and description lines can be edited."
          },
          "class_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "The sales line's own `QuickBooks` class (full name) on a company\nthat sets classes per line, e.g. cabinets apart from countertops;\nnone takes the invoice's class."
          }
        }
      },
      "LinkEvent": {
        "type": "object",
        "description": "One of the customer's events.",
        "required": [
          "id",
          "title",
          "all_day",
          "calendar_name"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "The event."
          },
          "title": {
            "type": "string",
            "description": "Its title."
          },
          "start_date": {
            "type": [
              "string",
              "null"
            ],
            "description": "UTC, `YYYY-MM-DDTHH:MM:SSZ`; null for an unscheduled event."
          },
          "all_day": {
            "type": "boolean",
            "description": "An all-day event."
          },
          "calendar_name": {
            "type": "string",
            "description": "Its calendar's name."
          },
          "project_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "The project it is linked to."
          }
        }
      },
      "LinkInput": {
        "type": "object",
        "description": "Body of the link routes.",
        "required": [
          "source_stone_id"
        ],
        "properties": {
          "source_stone_id": {
            "type": "integer",
            "format": "int32",
            "description": "The other stone of the company."
          }
        },
        "additionalProperties": false
      },
      "LinkProject": {
        "type": "object",
        "description": "A project the event can be linked to.",
        "required": [
          "id",
          "title",
          "stage_code"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "The project."
          },
          "title": {
            "type": "string",
            "description": "Its title."
          },
          "stage_code": {
            "type": "string",
            "description": "Its stage code (`new`, `templated`, …)."
          }
        }
      },
      "LinkableSale": {
        "type": "object",
        "description": "A transaction of the customer the project may link to.",
        "required": [
          "id"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "Its id."
          },
          "price": {
            "type": [
              "number",
              "null"
            ],
            "format": "double",
            "description": "The transaction price."
          },
          "project_address": {
            "type": [
              "string",
              "null"
            ],
            "description": "The job address."
          },
          "installed_date": {
            "type": [
              "string",
              "null"
            ],
            "description": "When it was installed, UTC ISO."
          },
          "paid_date": {
            "type": [
              "string",
              "null"
            ],
            "description": "When it was paid, UTC ISO."
          },
          "sale_date": {
            "type": [
              "string",
              "null"
            ],
            "description": "When it was made, UTC ISO."
          }
        }
      },
      "ListItem": {
        "type": "object",
        "description": "One item of a company list or a step's own list.",
        "required": [
          "id",
          "label"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "Its id."
          },
          "label": {
            "type": "string",
            "description": "What to do."
          }
        }
      },
      "ListResponse": {
        "oneOf": [
          {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CustomerRow"
            }
          },
          {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CompanyRow"
            }
          }
        ],
        "description": "`GET /v1/customers` returns `CustomerRow`s, or `CompanyRow`s when `view=companies`."
      },
      "LiveAck": {
        "type": "object",
        "description": "Answer to the gateway.",
        "required": [
          "ok"
        ],
        "properties": {
          "ok": {
            "type": "boolean",
            "description": "Always true."
          }
        }
      },
      "LiveRecording": {
        "type": "object",
        "description": "`PUT /v1/phone/calls/recording`.",
        "required": [
          "callId",
          "recording"
        ],
        "properties": {
          "callId": {
            "type": "integer",
            "format": "int64",
            "description": "Our call id."
          },
          "recording": {
            "type": "boolean",
            "description": "The call is being recorded now."
          }
        }
      },
      "LiveTicket": {
        "type": "object",
        "description": "Where a tab connects for live updates.",
        "properties": {
          "url": {
            "type": [
              "string",
              "null"
            ],
            "description": "The WebSocket address to open (`wss://…?ticket=…`), good for one\nminute and one user; null when the API has no live line (keep\npolling)."
          }
        }
      },
      "LoaBox": {
        "type": "object",
        "description": "Where the signature or the date goes on the LOA: points from the page's\ntop-left corner, as the signing editor finds them.",
        "required": [
          "type",
          "page",
          "x",
          "y",
          "width",
          "height"
        ],
        "properties": {
          "type": {
            "$ref": "#/components/schemas/LoaBoxKind",
            "description": "`signature`, `name` (the signer's printed name) or `date`."
          },
          "page": {
            "type": "integer",
            "format": "int64",
            "description": "From 1."
          },
          "x": {
            "type": "number",
            "format": "double",
            "description": "Left edge."
          },
          "y": {
            "type": "number",
            "format": "double",
            "description": "Top edge."
          },
          "width": {
            "type": "number",
            "format": "double",
            "description": "Width."
          },
          "height": {
            "type": "number",
            "format": "double",
            "description": "Height."
          }
        }
      },
      "LoaBoxKind": {
        "type": "string",
        "description": "What a box holds.",
        "enum": [
          "signature",
          "name",
          "date"
        ]
      },
      "LoaInviteInput": {
        "type": "object",
        "description": "Body of `POST /v1/phone/admin/ports/{id}/loa/invite`.",
        "required": [
          "signerName",
          "email"
        ],
        "properties": {
          "signerName": {
            "type": "string",
            "description": "The authorized person."
          },
          "email": {
            "type": "string",
            "description": "Where the link goes."
          }
        }
      },
      "LoaInviteSent": {
        "type": "object",
        "description": "The link was emailed.",
        "required": [
          "email",
          "expiresAt"
        ],
        "properties": {
          "email": {
            "type": "string",
            "description": "Who it went to."
          },
          "expiresAt": {
            "type": "string",
            "format": "date-time",
            "description": "When the link stops working."
          }
        }
      },
      "LoaInviteStatus": {
        "type": "string",
        "description": "Where a link is.",
        "enum": [
          "open",
          "signed",
          "expired"
        ]
      },
      "LoaInviteView": {
        "type": "object",
        "description": "What the link's page shows.",
        "required": [
          "status",
          "signerName",
          "companyName",
          "numbers"
        ],
        "properties": {
          "status": {
            "$ref": "#/components/schemas/LoaInviteStatus",
            "description": "Where the link is."
          },
          "signerName": {
            "type": "string",
            "description": "The authorized person asked to sign."
          },
          "companyName": {
            "type": "string",
            "description": "The company moving its numbers."
          },
          "numbers": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "The numbers moving (E.164)."
          }
        }
      },
      "LoaLinkSignInput": {
        "type": "object",
        "description": "Body of `POST /v1/public/port-loa/{token}/sign`.",
        "required": [
          "fields",
          "signature"
        ],
        "properties": {
          "fields": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/LoaBox"
            },
            "description": "Where to print the signature and the date."
          },
          "signature": {
            "type": "string",
            "description": "The drawn signature: a PNG data URL."
          }
        }
      },
      "LoaSignInput": {
        "type": "object",
        "description": "Body of `POST /v1/phone/admin/ports/{id}/loa/sign`.",
        "required": [
          "fields",
          "signature",
          "signerName"
        ],
        "properties": {
          "fields": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/LoaBox"
            },
            "description": "Where to print the signature and the date."
          },
          "signature": {
            "type": "string",
            "description": "The drawn signature: a PNG data URL."
          },
          "signerName": {
            "type": "string",
            "description": "The authorized person the admin confirms they are."
          }
        }
      },
      "LocationInput": {
        "type": "object",
        "description": "Body of `POST /v1/me/location`.",
        "required": [
          "latitude",
          "longitude"
        ],
        "properties": {
          "latitude": {
            "type": "number",
            "format": "double",
            "description": "Degrees."
          },
          "longitude": {
            "type": "number",
            "format": "double",
            "description": "Degrees."
          },
          "accuracy_m": {
            "type": [
              "number",
              "null"
            ],
            "format": "double",
            "description": "How far off the position may be, in meters; worse than 200 is ignored."
          }
        }
      },
      "LocationResult": {
        "type": "object",
        "description": "`POST /v1/me/location`: the jobs whose status changed.",
        "properties": {
          "arrived": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "The job the crew just arrived at."
          },
          "on_my_way": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "The job they just set off for."
          }
        }
      },
      "LoginChallenge": {
        "type": "object",
        "description": "A sign-in that needs another step (HTTP 202).",
        "required": [
          "step",
          "token"
        ],
        "properties": {
          "step": {
            "$ref": "#/components/schemas/LoginStep",
            "description": "The step to do now."
          },
          "token": {
            "type": "string",
            "description": "Send it as `token` with the step. It works for 10 minutes and stays\nthe same through every step of this sign-in."
          }
        }
      },
      "LoginEmail": {
        "type": "object",
        "description": "An address to sign in with.",
        "properties": {
          "email": {
            "type": "string",
            "description": "The email on the customer's account; empty (with no `phone`) resends\nto the pending one."
          },
          "phone": {
            "type": "string",
            "description": "The phone on the customer's account (any format; US or Canada) to\ntext the code to, instead of an email."
          }
        }
      },
      "LoginInput": {
        "type": "object",
        "description": "Body of `POST /v1/auth/login`.",
        "required": [
          "email",
          "password"
        ],
        "properties": {
          "email": {
            "type": "string",
            "description": "Login email (any case)."
          },
          "password": {
            "type": "string",
            "description": "Password."
          },
          "turnstile_token": {
            "type": [
              "string",
              "null"
            ],
            "description": "The Cloudflare Turnstile token of the page's robot check. Logged\nonly: the check never refuses anyone."
          },
          "turnstile_error": {
            "type": [
              "string",
              "null"
            ],
            "description": "Why the page has no Turnstile token (Cloudflare's error code,\n`timeout`, `script` or `unsupported`). Logged only."
          }
        }
      },
      "LoginStep": {
        "type": "string",
        "description": "What the sign-in needs next.",
        "enum": [
          "code",
          "new_password",
          "setup_authenticator"
        ]
      },
      "LookupInput": {
        "type": "object",
        "description": "Body of `POST /v1/phone/contacts/lookup`.",
        "required": [
          "numbers"
        ],
        "properties": {
          "numbers": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Up to 20 numbers, in any format (matched by their last 10 digits)."
          }
        }
      },
      "LookupMatch": {
        "type": "object",
        "description": "Who one number is.",
        "required": [
          "number"
        ],
        "properties": {
          "number": {
            "type": "string",
            "description": "The number as sent."
          },
          "contact": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/IndexContact",
                "description": "The newest customer with that phone or phone 2; null when none."
              },
              {
                "type": "null"
              }
            ]
          },
          "coworker": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/Coworker",
                "description": "The coworker with this number (any of theirs); null when none."
              },
              {
                "type": "null"
              }
            ]
          }
        }
      },
      "LostReason": {
        "type": "object",
        "description": "How often a rep lost for a reason.",
        "required": [
          "count"
        ],
        "properties": {
          "rep_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "The rep's name."
          },
          "lost_reason": {
            "type": [
              "string",
              "null"
            ],
            "description": "Why it was lost."
          },
          "count": {
            "type": "integer",
            "format": "int64",
            "description": "How many."
          }
        }
      },
      "MailboxPage": {
        "type": "object",
        "description": "One page of a folder.",
        "required": [
          "emails",
          "total_count",
          "page",
          "page_size"
        ],
        "properties": {
          "emails": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/MailboxRow"
            },
            "description": "Every message of the page's threads, threads newest first."
          },
          "total_count": {
            "type": "integer",
            "format": "int64",
            "description": "Threads in the folder (with the search)."
          },
          "page": {
            "type": "integer",
            "format": "int64",
            "description": "This page."
          },
          "page_size": {
            "type": "integer",
            "format": "int64",
            "description": "Threads per page."
          }
        }
      },
      "MailboxRow": {
        "type": "object",
        "description": "A message of a listed thread (every message of the page's threads).",
        "required": [
          "id",
          "body",
          "is_draft",
          "has_attachments",
          "thread_has_attachments",
          "thread_unread"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "Message id."
          },
          "thread_id": {
            "type": [
              "string",
              "null"
            ],
            "description": "Conversation id (UUID)."
          },
          "subject": {
            "type": [
              "string",
              "null"
            ],
            "description": "Subject."
          },
          "body": {
            "type": "string",
            "description": "Plain text body."
          },
          "sent_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When it was sent."
          },
          "sender_email": {
            "type": [
              "string",
              "null"
            ],
            "description": "From header (`Name <address>` or an address)."
          },
          "receiver_email": {
            "type": [
              "string",
              "null"
            ],
            "description": "First To header."
          },
          "sender_user_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Sending user, null for mail from outside."
          },
          "employee_read_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When an employee opened it; null while unread."
          },
          "is_draft": {
            "type": "boolean",
            "description": "Unsent draft."
          },
          "client_read_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When the recipient last opened it (sent mail only)."
          },
          "has_attachments": {
            "type": "boolean",
            "description": "The message has attachments."
          },
          "thread_has_attachments": {
            "type": "boolean",
            "description": "Some message of the conversation has attachments."
          },
          "sender_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "Sender's name: user, customer, or the name in a header."
          },
          "receiver_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "Receiver's name, the same way."
          },
          "inbox_sort_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "Inbox only: the time the thread is ranked by (its latest message to the caller)."
          },
          "thread_unread": {
            "type": "boolean",
            "description": "The conversation is unread for the caller: it is one of the threads\n`GET /v1/emails/folder-counts` (`inbox_unread`) and `GET /v1/emails/unread`\ncount and `unread=true` lists. The same on every message of the thread;\nalways false outside the caller's own inbox (sent, trash, drafts, `scope=admin`)."
          }
        }
      },
      "Maintenance": {
        "type": "object",
        "description": "Everything the maintenance page shows.",
        "required": [
          "can_edit",
          "items",
          "checks",
          "conditions",
          "completions"
        ],
        "properties": {
          "can_edit": {
            "type": "boolean",
            "description": "The caller may manage equipment and checks (a shop manager)."
          },
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Equipment"
            },
            "description": "Equipment by name."
          },
          "checks": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Check"
            },
            "description": "Checks by name."
          },
          "conditions": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Condition"
            },
            "description": "Conditions of the checks."
          },
          "completions": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Completion"
            },
            "description": "Completions, newest first."
          }
        }
      },
      "ManagedUser": {
        "type": "object",
        "description": "A user in the list.",
        "required": [
          "id",
          "is_protected",
          "invite_pending"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "User id."
          },
          "name": {
            "type": [
              "string",
              "null"
            ],
            "description": "Name."
          },
          "email": {
            "type": [
              "string",
              "null"
            ],
            "description": "Email."
          },
          "phone_number": {
            "type": [
              "string",
              "null"
            ],
            "description": "Phone."
          },
          "cloudtalk_agent_id": {
            "type": [
              "string",
              "null"
            ],
            "description": "`CloudTalk` agent id."
          },
          "cloudtalk_phone_number": {
            "type": [
              "string",
              "null"
            ],
            "description": "`CloudTalk` outbound number."
          },
          "ringcentral_extension_id": {
            "type": [
              "string",
              "null"
            ],
            "description": "`RingCentral` extension id."
          },
          "ringcentral_phone_number": {
            "type": [
              "string",
              "null"
            ],
            "description": "`RingCentral` outbound number."
          },
          "is_protected": {
            "type": "boolean",
            "description": "The caller may not change them: a superuser, or a Super Admin when the\ncaller is neither a superuser nor a Super Admin of this company."
          },
          "invite_pending": {
            "type": "boolean",
            "description": "Has not set up their account from the invite yet (no password)."
          }
        }
      },
      "MapsApp": {
        "type": "string",
        "description": "The maps app a user's addresses and directions open in.",
        "enum": [
          "google",
          "apple"
        ]
      },
      "MarketingCompany": {
        "type": "object",
        "description": "A company the user does marketing for.",
        "required": [
          "id",
          "name"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "The company."
          },
          "name": {
            "type": "string",
            "description": "Its name."
          }
        }
      },
      "MarketingDeal": {
        "type": "object",
        "description": "A live deal of a listed lead.",
        "required": [
          "id",
          "customer_id"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int64",
            "description": "Deal id."
          },
          "customer_id": {
            "type": "integer",
            "format": "int32",
            "description": "The lead."
          },
          "list_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Its stage."
          },
          "amount": {
            "type": [
              "string",
              "null"
            ],
            "description": "Amount, decimal string."
          },
          "status": {
            "type": [
              "string",
              "null"
            ],
            "description": "Status text."
          },
          "lost_reason": {
            "type": [
              "string",
              "null"
            ],
            "description": "Why it was lost."
          },
          "is_won": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "1 won, 0 lost, null open."
          }
        }
      },
      "MarketingLead": {
        "type": "object",
        "description": "A lead in the list.",
        "required": [
          "id"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "Customer id."
          },
          "name": {
            "type": [
              "string",
              "null"
            ],
            "description": "Name."
          },
          "email": {
            "type": [
              "string",
              "null"
            ],
            "description": "Primary email."
          },
          "phone": {
            "type": [
              "string",
              "null"
            ],
            "description": "Phone."
          },
          "created_date": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When the lead came in."
          },
          "source": {
            "type": [
              "string",
              "null"
            ],
            "description": "`leads` or `check-in`."
          },
          "referral_source": {
            "type": [
              "string",
              "null"
            ],
            "description": "Where it came from, e.g. `facebook`."
          },
          "form_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "The web form it came through."
          },
          "sales_rep": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Assigned sales rep."
          },
          "sales_rep_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "Their name."
          },
          "invalid_lead": {
            "type": [
              "string",
              "null"
            ],
            "description": "Why it is invalid; null when valid."
          }
        }
      },
      "MarketingStage": {
        "type": "object",
        "description": "A deal stage of the company's displayed pipelines.",
        "required": [
          "id"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "Stage id."
          },
          "name": {
            "type": [
              "string",
              "null"
            ],
            "description": "Name."
          },
          "position": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Order in the board."
          }
        }
      },
      "MatchName": {
        "type": "object",
        "description": "Body of `PUT /v1/horus/names`.",
        "required": [
          "name"
        ],
        "properties": {
          "name": {
            "type": "string",
            "description": "The stone name as Horus spells it (`names[].name`)."
          },
          "stone_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "The company's stone its slabs go under; null keeps them out of Granite."
          }
        },
        "additionalProperties": false
      },
      "MaterialDetail": {
        "type": "object",
        "description": "One material with its stones and installed photos.",
        "required": [
          "id",
          "name",
          "color_ids",
          "stones",
          "images"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "Material id."
          },
          "name": {
            "type": "string",
            "description": "Name, e.g. \"Fantasy Brown\"."
          },
          "type": {
            "type": [
              "string",
              "null"
            ],
            "description": "Stone type."
          },
          "level": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "The material's level (a number of `GET /v1/stone-levels`). With materials first, every bundle\nof the material has it; null: each bundle keeps its own."
          },
          "finishing": {
            "type": [
              "string",
              "null"
            ],
            "description": "The material's finish, e.g. `polished`. With materials first, every\nbundle of the material has it; null: each bundle keeps its own."
          },
          "color_ids": {
            "type": "array",
            "items": {
              "type": "integer",
              "format": "int32"
            },
            "description": "The material's colors (`GET /v1/colors`); its bundles take them."
          },
          "url": {
            "type": [
              "string",
              "null"
            ],
            "description": "Photo: the material's own, else the first stone photo."
          },
          "stones": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Stone"
            },
            "description": "Its stones by bundle number; hidden ones only for admins."
          },
          "images": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/MaterialImage"
            },
            "description": "Installed project photos of all its stones."
          }
        }
      },
      "MaterialImage": {
        "type": "object",
        "description": "An installed project photo of one of the material's stones.",
        "required": [
          "id",
          "stone_id"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "Photo id (`installed_stones`)."
          },
          "url": {
            "type": [
              "string",
              "null"
            ],
            "description": "Photo URL."
          },
          "stone_id": {
            "type": "integer",
            "format": "int32",
            "description": "Stone the photo was added to."
          },
          "bundle_number": {
            "type": [
              "string",
              "null"
            ],
            "description": "That stone's bundle number."
          }
        }
      },
      "MaterialSqft": {
        "type": "object",
        "description": "Square feet of one material.",
        "required": [
          "stone_type",
          "sqft"
        ],
        "properties": {
          "stone_type": {
            "type": "string",
            "description": "Stone type, e.g. `granite`; `Unknown` when the stone has none."
          },
          "sqft": {
            "type": "number",
            "format": "double",
            "description": "Square feet."
          }
        }
      },
      "MediaLink": {
        "type": "object",
        "description": "`GET /v1/phone/texts/media/{id}`.",
        "required": [
          "url",
          "expiresAt"
        ],
        "properties": {
          "url": {
            "type": "string",
            "description": "A link to the file (works 5 minutes)."
          },
          "expiresAt": {
            "type": "string",
            "format": "date-time",
            "description": "When the link stops working (RFC 3339)."
          }
        }
      },
      "Message": {
        "type": "object",
        "description": "One message.",
        "required": [
          "id",
          "provider",
          "direction",
          "text",
          "created_at",
          "status",
          "attachments"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "The SMS row id (page back with `before_id`); unique per provider."
          },
          "provider": {
            "$ref": "#/components/schemas/SmsProvider",
            "description": "The provider that carried it."
          },
          "direction": {
            "$ref": "#/components/schemas/Direction"
          },
          "text": {
            "type": "string",
            "description": "The text; empty for a photo or file alone."
          },
          "agent": {
            "type": [
              "string",
              "null"
            ],
            "description": "Agent id stored on the row."
          },
          "agent_id": {
            "type": [
              "string",
              "null"
            ],
            "description": "The rep who sent it, or whose number received it."
          },
          "agent_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "That rep's name."
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "description": "When it was sent (`CloudTalk`: placed among its neighbours when the\nwebhook arrived late)."
          },
          "status": {
            "$ref": "#/components/schemas/MessageStatus"
          },
          "error_message": {
            "type": [
              "string",
              "null"
            ],
            "description": "Why a failed text failed (`ringcentral_spam`, ...)."
          },
          "attachments": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Attachment"
            },
            "description": "Photos and files, in order."
          }
        }
      },
      "MessageEdit": {
        "type": "object",
        "description": "Body of `PATCH /v1/support/agent/conversations/{id}/messages/{message_id}`.",
        "required": [
          "body"
        ],
        "properties": {
          "body": {
            "type": "string",
            "description": "The new text (at most 5000 characters)."
          }
        },
        "additionalProperties": false
      },
      "MessageStatus": {
        "type": "string",
        "description": "Delivery state.",
        "enum": [
          "sent",
          "sending",
          "failed"
        ]
      },
      "MetricInfo": {
        "type": "object",
        "description": "A usage count the API knows how to compute.",
        "required": [
          "key",
          "label"
        ],
        "properties": {
          "key": {
            "type": "string",
            "description": "The value a feature's `usage_metric` takes to show this count."
          },
          "label": {
            "type": "string",
            "description": "What is counted, e.g. \"texts sent\"."
          }
        }
      },
      "MfaCode": {
        "type": "object",
        "description": "Body of `POST /v1/me/mfa/confirm` and `POST /v1/me/mfa/disable`.",
        "required": [
          "code"
        ],
        "properties": {
          "code": {
            "type": "string",
            "description": "The 6-digit code the authenticator app shows now (spaces ignored)."
          }
        }
      },
      "MfaStatus": {
        "type": "object",
        "description": "`GET /v1/me/mfa`.",
        "required": [
          "enabled",
          "required"
        ],
        "properties": {
          "enabled": {
            "type": "boolean",
            "description": "Two-step sign-in is on: every sign-in asks for the authenticator\napp's code after the password."
          },
          "enabled_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When it was turned on (ISO 8601, UTC); null while off."
          },
          "required": {
            "type": "boolean",
            "description": "The user must keep it on (superusers): it cannot be turned off, and\na sign-in without it set up asks to set it up first."
          }
        }
      },
      "ModelPick": {
        "type": "object",
        "description": "A model picked for a step.",
        "required": [
          "model"
        ],
        "properties": {
          "model": {
            "type": "string",
            "description": "The model the step uses instead of its default."
          },
          "reasoning_effort": {
            "type": [
              "string",
              "null"
            ],
            "description": "The reasoning effort picked with it; null keeps the code's."
          },
          "changed_by": {
            "type": [
              "string",
              "null"
            ],
            "description": "Who picked it; null when the user is gone."
          },
          "changed_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When it was picked (UTC)."
          }
        }
      },
      "ModelUse": {
        "type": "object",
        "description": "A feature's calls of one model.",
        "required": [
          "model",
          "calls",
          "failed"
        ],
        "properties": {
          "model": {
            "type": "string",
            "description": "The model as the log names it."
          },
          "calls": {
            "type": "integer",
            "format": "int64",
            "description": "Calls of the feature on it in the last 7 days."
          },
          "failed": {
            "type": "integer",
            "format": "int64",
            "description": "Calls that failed (a refused pick shows here before its retry)."
          },
          "last_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "The newest of these calls (UTC)."
          }
        }
      },
      "MonthCount": {
        "type": "object",
        "description": "A month's count (`YYYY-MM`); months without any are left out.",
        "required": [
          "month",
          "count"
        ],
        "properties": {
          "month": {
            "type": "string",
            "description": "`YYYY-MM`."
          },
          "count": {
            "type": "integer",
            "format": "int64",
            "description": "How many."
          }
        }
      },
      "MonthlyCount": {
        "type": "object",
        "description": "How many messages were sent in one calendar month.",
        "required": [
          "month",
          "count"
        ],
        "properties": {
          "month": {
            "type": "string",
            "description": "Month, `YYYY-MM`."
          },
          "count": {
            "type": "integer",
            "format": "int64",
            "description": "Messages sent that month."
          }
        }
      },
      "MovedExtras": {
        "type": "object",
        "description": "How many catalog extras the move made.",
        "required": [
          "created"
        ],
        "properties": {
          "created": {
            "type": "integer",
            "description": "New catalog extras.",
            "minimum": 0
          }
        }
      },
      "MyConversation": {
        "type": "object",
        "description": "One of the user's support conversations, as their list shows it.",
        "required": [
          "id",
          "subject",
          "status",
          "last_from_support",
          "last_message_at",
          "created_at",
          "unread"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "Conversation id (send it as `conversation_id` to write in it)."
          },
          "subject": {
            "type": "string",
            "description": "What it is about: written by the AI from the first message."
          },
          "status": {
            "type": "string",
            "description": "`open` (support owes an answer), `waiting` (support answered),\n`resolved` (done; writing in it opens it again)."
          },
          "last_message": {
            "type": [
              "string",
              "null"
            ],
            "description": "The start of the latest message (the team's notes left out)."
          },
          "last_from_support": {
            "type": "boolean",
            "description": "The latest message is support's answer."
          },
          "last_message_at": {
            "type": "string",
            "format": "date-time",
            "description": "When the latest message was written (ISO 8601, UTC)."
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "description": "When it began."
          },
          "unread": {
            "type": "boolean",
            "description": "Support answered since the user last read it."
          }
        }
      },
      "MyConversationDetail": {
        "type": "object",
        "description": "`GET /v1/support/conversations/{id}`.",
        "required": [
          "conversation",
          "messages",
          "reactions"
        ],
        "properties": {
          "conversation": {
            "$ref": "#/components/schemas/MyConversation",
            "description": "The conversation."
          },
          "messages": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SupportMessage"
            },
            "description": "Its messages, oldest first (the team's internal notes left out)."
          },
          "reactions": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SupportReaction"
            },
            "description": "Every reaction in it (also on messages older than `after`), oldest first."
          }
        }
      },
      "MyConversations": {
        "type": "object",
        "description": "`GET /v1/support/conversations`.",
        "required": [
          "conversations",
          "active",
          "unread"
        ],
        "properties": {
          "conversations": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/MyConversation"
            },
            "description": "The user's conversations, latest message first (at most 100)."
          },
          "active": {
            "type": "boolean",
            "description": "One of them is open or waiting: answers may still come."
          },
          "unread": {
            "type": "integer",
            "format": "int64",
            "description": "Conversations with an answer not read yet."
          }
        }
      },
      "MyEmailTemplates": {
        "type": "object",
        "description": "The Email dialog's templates.",
        "required": [
          "templates",
          "ordering_mode"
        ],
        "properties": {
          "templates": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/EmailTemplate"
            },
            "description": "The company's and the caller's own, in the caller's order."
          },
          "ordering_mode": {
            "type": "string",
            "description": "`automatic` (most used first) or `custom` (the caller's drag order)."
          },
          "default_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "The one the dialog starts with: what the caller sends most, else the\ncompany's most used, else the first."
          }
        }
      },
      "MyGmail": {
        "type": "object",
        "description": "`GET /v1/me/gmail`.",
        "required": [
          "available"
        ],
        "properties": {
          "available": {
            "type": "boolean",
            "description": "Granite Manager's Google app is set up and the company does not send\nthrough its own Amazon SES domain, so Connect Gmail works. Stays true\nwhile the caller is connected, so they can disconnect."
          },
          "email": {
            "type": [
              "string",
              "null"
            ],
            "description": "The connected Gmail address; null when not connected."
          }
        }
      },
      "MyLine": {
        "type": "object",
        "description": "A company number that rings me or that I may call from.",
        "required": [
          "numberId",
          "e164",
          "label",
          "kind",
          "rings",
          "mineAlone",
          "noAnswer"
        ],
        "properties": {
          "numberId": {
            "type": "integer",
            "format": "int32",
            "description": "The number's id (for a rule's `numberIds`)."
          },
          "e164": {
            "type": "string",
            "description": "The number, E.164."
          },
          "label": {
            "type": "string",
            "description": "Its name, e.g. \"Sales\"; may be empty."
          },
          "kind": {
            "$ref": "#/components/schemas/NumberKind",
            "description": "`direct`, `shared` or `main`."
          },
          "rings": {
            "type": "boolean",
            "description": "Calls to it ring my phones (else I only call from it)."
          },
          "mineAlone": {
            "type": "boolean",
            "description": "It rings nobody but me: my rules and \"Forward all calls\" decide its\ncalls whole."
          },
          "noAnswer": {
            "type": "string",
            "description": "What its calls do when nobody answers, as it works now: `ai` (the\nAI Assistant), `voicemail` or `forward`."
          }
        }
      },
      "MyLines": {
        "type": "object",
        "description": "`GET /v1/phone/lines`.",
        "required": [
          "lines"
        ],
        "properties": {
          "lines": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/MyLine"
            },
            "description": "My lines: direct first, then shared, then the main line."
          }
        }
      },
      "MyPayJob": {
        "type": "object",
        "description": "A job on the caller's schedule with what its customer still owes.",
        "required": [
          "event_id",
          "title",
          "start",
          "customer_id",
          "open_cents"
        ],
        "properties": {
          "event_id": {
            "type": "integer",
            "format": "int32",
            "description": "The event's id."
          },
          "title": {
            "type": "string",
            "description": "The event's name; its customer's when it has none."
          },
          "location": {
            "type": [
              "string",
              "null"
            ],
            "description": "The event's address."
          },
          "start": {
            "type": "string",
            "description": "When it starts (ISO 8601, UTC)."
          },
          "customer_id": {
            "type": "integer",
            "format": "int32",
            "description": "The customer."
          },
          "customer_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "Their name."
          },
          "project_key": {
            "type": [
              "string",
              "null"
            ],
            "description": "The job to pay for, when the event's sale names one or the customer\nhas a single job; null when the app must ask which."
          },
          "open_cents": {
            "type": "integer",
            "format": "int64",
            "description": "What is still owed: on that job, else on all the customer's jobs."
          }
        }
      },
      "MyPayJobs": {
        "type": "object",
        "description": "What `GET /v1/payments/my-jobs` answers.",
        "required": [
          "can_take",
          "jobs"
        ],
        "properties": {
          "can_take": {
            "type": "boolean",
            "description": "A payment can be taken now (see [`AppPayments::can_take`])."
          },
          "jobs": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/MyPayJob"
            },
            "description": "The caller's events of the range that have a customer, by start."
          }
        }
      },
      "MyPhoto": {
        "type": "object",
        "description": "My picture now.",
        "properties": {
          "photo_url": {
            "type": [
              "string",
              "null"
            ],
            "description": "Public URL of my picture; null when I have none."
          }
        }
      },
      "MyScheduleSettingsInput": {
        "type": "object",
        "description": "`PUT /v1/schedule/settings/me`: only the fields sent change.",
        "properties": {
          "week_starts_on": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/WeekStart",
                "description": "The day the caller's week and month views start their weeks on."
              },
              {
                "type": "null"
              }
            ]
          },
          "time_24h": {
            "type": [
              "boolean",
              "null"
            ],
            "description": "Show times as 13:00 rather than 1:00 PM."
          },
          "maps_app": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/MapsApp",
                "description": "The maps app the caller's addresses and directions open in."
              },
              {
                "type": "null"
              }
            ]
          },
          "prefs_asked": {
            "type": [
              "boolean",
              "null"
            ],
            "description": "`true`: the Schedule asked the caller for their times and maps app\n(answered or closed), so it does not ask again. `false` is ignored."
          }
        }
      },
      "MyTemplateInput": {
        "type": "object",
        "description": "One of the caller's own templates.",
        "required": [
          "name",
          "subject"
        ],
        "properties": {
          "name": {
            "type": "string",
            "description": "Name (required, up to 120 characters)."
          },
          "subject": {
            "type": "string",
            "description": "Subject (required, up to 255 characters)."
          },
          "body": {
            "type": "string",
            "description": "Body; `[PDFLink]` is added when it has no link."
          }
        },
        "additionalProperties": false
      },
      "MyTouches": {
        "type": "object",
        "description": "`GET /v1/me/touches`.",
        "required": [
          "sync",
          "items"
        ],
        "properties": {
          "sync": {
            "type": "boolean",
            "description": "The caller keeps \"Sync to my Todo List\" on."
          },
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Touch"
            },
            "description": "Open touches due today or earlier; empty while `sync` is off."
          }
        }
      },
      "NameInput": {
        "type": "object",
        "description": "Body of `POST /v1/deal-pipelines` and `POST /v1/deal-pipelines/{id}/stages`.",
        "required": [
          "name"
        ],
        "properties": {
          "name": {
            "type": "string",
            "description": "Name (1–255 characters)."
          }
        },
        "additionalProperties": false
      },
      "NamedRow": {
        "type": "object",
        "description": "A type or supplier of the catalog filters.",
        "required": [
          "id",
          "name"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int64",
            "description": "Id."
          },
          "name": {
            "type": "string",
            "description": "Name."
          }
        }
      },
      "NewAgentAction": {
        "type": "object",
        "description": "Body of `POST /v1/ai/agent-actions`.",
        "required": [
          "operation_id",
          "summary"
        ],
        "properties": {
          "operation_id": {
            "type": "string",
            "description": "The endpoint: `send_email`, `send_sms`, `create_deal_note`,\n`add_event_comment`, `create_customer`, `update_customer`,\n`update_deal` or `create_project_task`."
          },
          "summary": {
            "type": "string",
            "description": "What it does, for the user, in a few words (\"Email Dima a thank-you\")."
          },
          "path_params": {
            "type": "object",
            "description": "Values for the `{placeholders}` of the route, by name."
          },
          "query": {
            "type": "object",
            "description": "Query parameters by name."
          },
          "body": {
            "type": "object",
            "description": "The JSON request body, exactly as the endpoint takes it."
          }
        },
        "additionalProperties": false
      },
      "NewAgenticQuestion": {
        "type": "object",
        "description": "Body of `POST /v1/ai/agentic-questions`.",
        "required": [
          "query"
        ],
        "properties": {
          "query": {
            "type": "string",
            "description": "The question (1 to 8000 characters once trimmed)."
          },
          "new_chat": {
            "type": "boolean",
            "description": "Start a new chat instead of continuing the latest one."
          },
          "chat_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int64",
            "description": "Continue this chat of the caller's (the Agent page); wins over\n`new_chat`."
          }
        },
        "additionalProperties": false
      },
      "NewBugReport": {
        "type": "object",
        "description": "Body of `POST /v1/bug-reports`.",
        "required": [
          "description"
        ],
        "properties": {
          "description": {
            "type": "string",
            "description": "What happened, 1 to 16,000 characters; its first line is the title."
          },
          "file_urls": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Files uploaded to the `bug-reports` folder (`POST /v1/uploads`) and\nalready sent to their upload address: 20 at most."
          }
        },
        "additionalProperties": false
      },
      "NewChecklist": {
        "type": "object",
        "description": "Body of `POST /v1/checklists`: the customer's post-installation sign-off.",
        "required": [
          "customer_name",
          "installation_address",
          "signature"
        ],
        "properties": {
          "customer_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "The customer, when known. One that is not the company's (deleted\nsince, for example) is left out: the checklist is saved without it."
          },
          "customer_name": {
            "type": "string",
            "description": "Customer name; required, 255 characters at most. Spaces around it\nare dropped."
          },
          "installation_address": {
            "type": "string",
            "description": "Where the job was; required, 255 characters at most. Spaces around\nit are dropped."
          },
          "email": {
            "type": [
              "string",
              "null"
            ],
            "description": "Where to send the copy; 255 characters at most."
          },
          "material_correct": {
            "type": [
              "string",
              "null"
            ],
            "description": "Each check is `on` when ticked."
          },
          "seams_satisfaction": {
            "type": [
              "string",
              "null"
            ],
            "description": "See `material_correct`."
          },
          "appliances_fit": {
            "type": [
              "string",
              "null"
            ],
            "description": "See `material_correct`."
          },
          "backsplashes_correct": {
            "type": [
              "string",
              "null"
            ],
            "description": "See `material_correct`."
          },
          "edges_correct": {
            "type": [
              "string",
              "null"
            ],
            "description": "See `material_correct`."
          },
          "holes_drilled": {
            "type": [
              "string",
              "null"
            ],
            "description": "See `material_correct`."
          },
          "cleanup_completed": {
            "type": [
              "string",
              "null"
            ],
            "description": "See `material_correct`."
          },
          "comments": {
            "type": [
              "string",
              "null"
            ],
            "description": "Customer comments; 16,000 characters at most."
          },
          "signature": {
            "type": "string",
            "description": "The customer's signature (image data URL); required, 65,535 bytes\nat most."
          }
        }
      },
      "NewContact": {
        "type": "object",
        "description": "Body of `POST /v1/phone/contacts`.",
        "required": [
          "name",
          "phone"
        ],
        "properties": {
          "name": {
            "type": "string",
            "description": "The customer's name (1 to 255 characters)."
          },
          "phone": {
            "type": "string",
            "description": "Their phone: E.164 or 10 digits (US or Canada)."
          },
          "company": {
            "type": [
              "string",
              "null"
            ],
            "description": "Their company name; null or empty for none."
          },
          "email": {
            "type": [
              "string",
              "null"
            ],
            "description": "Their email (becomes the customer's primary address); null or empty\nfor none."
          },
          "address": {
            "type": [
              "string",
              "null"
            ],
            "description": "Their street address, as typed; null or empty for none."
          },
          "phone2": {
            "type": [
              "string",
              "null"
            ],
            "description": "Their second phone (E.164 or 10 digits, US or Canada); null or empty\nfor none. The same number as `phone` is ignored."
          },
          "moreEmails": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "More email addresses after `email`, in order; empty ones are skipped."
          },
          "source": {
            "type": [
              "string",
              "null"
            ],
            "description": "Lead source: a built-in key (`call-in`, `check-in`, `leads`, `other`)\nor a `sourceKey` of `GET /v1/customer-sources`. Null or empty for\n`call-in`."
          },
          "salesRep": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "The sales rep (a live user id of the caller's company, as listed by\n`GET /v1/users/sales-reps`); null for the caller. They get the open\ndeal."
          },
          "notes": {
            "type": [
              "string",
              "null"
            ],
            "description": "Notes about the customer (the CRM's customer Notes); null or empty for\nnone. At most 5000 characters are kept."
          }
        }
      },
      "NewDocument": {
        "type": "object",
        "description": "Body of `POST /v1/documents`.",
        "required": [
          "name",
          "url"
        ],
        "properties": {
          "name": {
            "type": "string",
            "description": "Name in the library (1–100 characters)."
          },
          "url": {
            "type": "string",
            "description": "URL of the file uploaded to the `documents` folder."
          }
        },
        "additionalProperties": false
      },
      "NewExtra": {
        "type": "object",
        "description": "A new extra.",
        "required": [
          "item"
        ],
        "properties": {
          "item": {
            "type": "object",
            "description": "The extra (`OtherItem`)."
          },
          "off_list_ids": {
            "type": "array",
            "items": {
              "type": "integer",
              "format": "int32"
            },
            "description": "Price lists that do not offer it."
          }
        },
        "additionalProperties": false
      },
      "NewFile": {
        "type": "object",
        "description": "One uploaded file to attach.",
        "required": [
          "url"
        ],
        "properties": {
          "url": {
            "type": "string",
            "description": "Public URL from `POST /v1/uploads` (folder `deals`)."
          },
          "name": {
            "type": [
              "string",
              "null"
            ],
            "description": "Original file name; documents keep it as their name."
          }
        }
      },
      "NewFiles": {
        "type": "object",
        "description": "Body of `POST /v1/deals/{id}/files`.",
        "required": [
          "files"
        ],
        "properties": {
          "files": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/NewFile"
            },
            "description": "Files already uploaded with `POST /v1/uploads`."
          }
        }
      },
      "NewFlow": {
        "type": "object",
        "description": "Body of `POST /v1/sms-flows`.",
        "required": [
          "name",
          "scope",
          "steps"
        ],
        "properties": {
          "name": {
            "type": "string",
            "description": "Up to 255 characters."
          },
          "scope": {
            "$ref": "#/components/schemas/TemplateScope",
            "description": "`company` (admins only) or `personal`."
          },
          "steps": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/StepInput"
            },
            "description": "1 to 20 steps."
          }
        }
      },
      "NewGroup": {
        "type": "object",
        "description": "Body of `POST /v1/phone/contact-groups`.",
        "required": [
          "name"
        ],
        "properties": {
          "name": {
            "type": "string",
            "description": "Its name, 1 to 60 characters (trimmed); unique in the company,\nignoring case (400 `name_taken`)."
          },
          "customerIds": {
            "type": "array",
            "items": {
              "type": "integer",
              "format": "int32"
            },
            "description": "Customer ids to put in it at once (as `PUT .../members`)."
          },
          "userIds": {
            "type": "array",
            "items": {
              "type": "integer",
              "format": "int32"
            },
            "description": "Coworkers' user ids to put in it at once (as `PUT .../members`)."
          }
        }
      },
      "NewImage": {
        "type": "object",
        "description": "Body of `POST /v1/images`.",
        "required": [
          "name",
          "url"
        ],
        "properties": {
          "name": {
            "type": "string",
            "description": "Name (1–100 characters)."
          },
          "url": {
            "type": "string",
            "description": "URL of the file uploaded to the `images` folder."
          },
          "folder_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Folder to put it in; an unknown folder means none."
          }
        },
        "additionalProperties": false
      },
      "NewMaterial": {
        "type": "object",
        "description": "Body of `POST /v1/stones/materials`.",
        "required": [
          "name",
          "type"
        ],
        "properties": {
          "name": {
            "type": "string",
            "description": "Name, e.g. \"Taj Mahal\"; required, 100 characters at most. Stones\nadded later with this name (any case) go into it."
          },
          "type": {
            "type": "string",
            "description": "One of the company's stone types (`GET /v1/stone-types`)."
          },
          "image_url": {
            "type": [
              "string",
              "null"
            ],
            "description": "Photo: the `url` of an upload to the `stones` folder\n(`POST /v1/uploads`), placed on the company's slab picture background.\nNull: the material shows its first stone's photo."
          },
          "level": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Level, one of the company's levels (`GET /v1/stone-levels`; 1 to 7\nuntil it adds more); with materials first every bundle of the\nmaterial has it. Null for none."
          },
          "finishing": {
            "type": [
              "string",
              "null"
            ],
            "description": "One of the company's finishes (`GET /v1/stone-finishes`); with\nmaterials first every bundle of the material has it. Null for none."
          },
          "color_ids": {
            "type": [
              "array",
              "null"
            ],
            "items": {
              "type": "integer",
              "format": "int32"
            },
            "description": "The material's colors (`GET /v1/colors`); bundles added to it take them."
          }
        },
        "additionalProperties": false
      },
      "NewOrderChange": {
        "type": "object",
        "description": "A change order to save.",
        "required": [
          "doc",
          "changes"
        ],
        "properties": {
          "doc": {
            "type": "object",
            "description": "The Order's drawing after the change (`QuoteDoc`)."
          },
          "changes": {
            "type": "object",
            "description": "What changed, as the CRM worked it out (`lines` and `rooms`)."
          },
          "note": {
            "type": [
              "string",
              "null"
            ],
            "description": "A note (up to 500 characters)."
          },
          "invoice_action": {
            "type": [
              "string",
              "null"
            ],
            "description": "`update`, `new` or `none` (default)."
          },
          "sign": {
            "type": "boolean",
            "description": "The customer is asked to sign it."
          },
          "tax_pct": {
            "type": [
              "number",
              "null"
            ],
            "format": "double",
            "description": "The Order's tax percent, when the change order changes it."
          },
          "discount_pct": {
            "type": [
              "number",
              "null"
            ],
            "format": "double",
            "description": "Its discount percent, when changed."
          },
          "discount_amount": {
            "type": [
              "number",
              "null"
            ],
            "format": "double",
            "description": "Its discount in dollars, when changed."
          }
        },
        "additionalProperties": false
      },
      "NewPassword": {
        "type": "object",
        "description": "Body of `POST /v1/auth/password-reset/{token}`.",
        "required": [
          "password"
        ],
        "properties": {
          "password": {
            "type": "string",
            "description": "At least 8 characters."
          }
        }
      },
      "NewPayment": {
        "type": "object",
        "description": "Body of `POST /v1/customers/{id}/payments`.",
        "required": [
          "project_key",
          "method",
          "amount_cents"
        ],
        "properties": {
          "project_key": {
            "type": "string",
            "description": "The job to pay for, from `GET /v1/customers/{id}/projects`:\n`deal-<deal id>`, or `sale-<sale id>` for a sale that is not part of\na deal; or `invoice-<QuickBooks invoice id>` for one of the\ncustomer's open `QuickBooks` invoices (`GET /v1/payments/jobs`)."
          },
          "method": {
            "$ref": "#/components/schemas/PaymentMethod",
            "description": "How the customer will pay."
          },
          "amount_cents": {
            "type": "integer",
            "format": "int64",
            "description": "What goes toward the job, in US cents: 100 ($1) to 99999999\n($999,999.99); a card payment at least 1000 ($10). The customer's part\nof the fee is added on top."
          }
        },
        "additionalProperties": false
      },
      "NewPhoneCustomer": {
        "type": "object",
        "description": "Body of `POST /v1/customers/from-phone`.",
        "required": [
          "phone_digits",
          "name"
        ],
        "properties": {
          "phone_digits": {
            "type": "string",
            "description": "10 to 15 digits."
          },
          "name": {
            "type": "string",
            "description": "The customer's name (at most 200 characters are kept)."
          }
        }
      },
      "NewPriceList": {
        "type": "object",
        "description": "A new price list.",
        "required": [
          "name"
        ],
        "properties": {
          "name": {
            "type": "string",
            "description": "Name, unique in the company."
          }
        },
        "additionalProperties": false
      },
      "NewProjectFile": {
        "type": "object",
        "description": "One file uploaded with `POST /v1/uploads` (folder `deals`).",
        "required": [
          "url",
          "name"
        ],
        "properties": {
          "url": {
            "type": "string",
            "description": "Where it was uploaded."
          },
          "name": {
            "type": "string",
            "description": "Its name."
          },
          "contentType": {
            "type": [
              "string",
              "null"
            ],
            "description": "MIME type."
          }
        }
      },
      "NewProjectFiles": {
        "type": "object",
        "description": "Body of `POST /v1/projects/{id}/files`.",
        "required": [
          "files"
        ],
        "properties": {
          "files": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/NewProjectFile"
            },
            "description": "Its files."
          },
          "step_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Added on this step of the project (they still show with its files)."
          },
          "part_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "The part of that step, on a project with parts; left out: its least\nfinished part."
          }
        }
      },
      "NewQuestion": {
        "type": "object",
        "description": "Body of `POST /v1/teach-mode/questions`.",
        "required": [
          "instruction_id",
          "text",
          "choices"
        ],
        "properties": {
          "instruction_id": {
            "type": "integer",
            "format": "int32",
            "description": "The instruction it tests."
          },
          "text": {
            "type": "string",
            "description": "The question."
          },
          "choices": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ChoiceInput"
            },
            "description": "At least two answers, exactly one right."
          }
        }
      },
      "NewQuestionnaire": {
        "type": "object",
        "description": "Body of `POST /v1/questionnaires`.",
        "required": [
          "name",
          "questions"
        ],
        "properties": {
          "name": {
            "type": "string",
            "description": "Name, 1 to 255 characters."
          },
          "questions": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "At least one question, each 1 to 5000 characters."
          }
        }
      },
      "NewQuote": {
        "type": "object",
        "description": "Body of `POST /v1/quotes`.",
        "required": [
          "customer_id"
        ],
        "properties": {
          "customer_id": {
            "type": "integer",
            "format": "int32",
            "description": "The customer."
          },
          "quote_name": {
            "type": "string",
            "description": "Name; blank takes the customer's."
          },
          "price_list_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Price list; none takes the company's default."
          }
        },
        "additionalProperties": false
      },
      "NewQuoteForm": {
        "type": "object",
        "description": "A new form.",
        "required": [
          "name",
          "config"
        ],
        "properties": {
          "name": {
            "type": "string",
            "description": "Name (up to 160 characters)."
          },
          "config": {
            "type": "object",
            "description": "The starting layout (`emptyQuoteFormConfig(kind)`)."
          }
        },
        "additionalProperties": false
      },
      "NewSlab": {
        "type": "object",
        "description": "Body of `POST /v1/stones/{id}/slabs`.",
        "required": [
          "bundle"
        ],
        "properties": {
          "bundle": {
            "type": "string",
            "description": "Bundle label, e.g. \"B-12-7\"; required."
          },
          "length": {
            "type": [
              "number",
              "null"
            ],
            "format": "double",
            "description": "Length in inches; with width 0 or missing, the stone's size is used."
          },
          "width": {
            "type": [
              "number",
              "null"
            ],
            "format": "double",
            "description": "Width in inches."
          },
          "image_url": {
            "type": [
              "string",
              "null"
            ],
            "description": "Photo of the slab: an upload to the `stones` folder; null for none\n(the stone image is shown)."
          }
        },
        "additionalProperties": false
      },
      "NewSmsTemplate": {
        "type": "object",
        "description": "Body of `POST /v1/sms-templates`.",
        "required": [
          "name",
          "body"
        ],
        "properties": {
          "name": {
            "type": "string",
            "description": "Shown in the picker."
          },
          "body": {
            "type": "string",
            "description": "The text, with `{{variables}}`, up to 1600 characters."
          },
          "scope": {
            "$ref": "#/components/schemas/TemplateScope",
            "description": "`company` (admins only) or `personal` (default)."
          },
          "drip": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/Drip",
                "description": "When it sends itself; left out: never."
              },
              {
                "type": "null"
              }
            ]
          },
          "attachments": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SmsFile"
            },
            "description": "Up to ten files (`POST /v1/sms/attachments`) sent with the text."
          }
        }
      },
      "NewSupplierFile": {
        "type": "object",
        "description": "Body of `POST /v1/suppliers/{id}/files`.",
        "required": [
          "name",
          "url"
        ],
        "properties": {
          "name": {
            "type": "string",
            "description": "Name to show for the file (required, at most 255 characters)."
          },
          "url": {
            "type": "string",
            "description": "URL from `POST /v1/uploads` with folder `supplier-files`, after the\nfile was uploaded. PDF, JPEG, PNG, WebP, CSV, TSV or TXT."
          }
        },
        "additionalProperties": false
      },
      "NewSupport": {
        "type": "object",
        "description": "Body of `POST /v1/supports`.",
        "required": [
          "name",
          "url"
        ],
        "properties": {
          "name": {
            "type": "string",
            "description": "Name (1–100 characters)."
          },
          "url": {
            "type": "string",
            "description": "URL of the picture uploaded to the `supports` folder."
          }
        },
        "additionalProperties": false
      },
      "NewSupportMessage": {
        "type": "object",
        "description": "Body of `POST /v1/support/messages`.",
        "required": [
          "body"
        ],
        "properties": {
          "body": {
            "type": "string",
            "description": "The message (at most 5000 characters)."
          },
          "images": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Pictures and videos uploaded to the `chats` folder (`POST /v1/uploads`; the\n`url` it returns), at most 4. Older clients' `bug-reports` uploads\nare still taken and moved into the private chat bucket."
          },
          "page_path": {
            "type": [
              "string",
              "null"
            ],
            "description": "The CRM page the user is on (path and query)."
          },
          "posthog_session_id": {
            "type": [
              "string",
              "null"
            ],
            "description": "The user's PostHog session id (`posthog.get_session_id()`), so the\nteam can watch the recording."
          },
          "replay_seconds": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "How many seconds into that session's recording the user wrote."
          },
          "screen": {
            "type": [
              "string",
              "null"
            ],
            "description": "The browser window size, `WIDTHxHEIGHT`."
          },
          "conversation_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "The conversation to write in: one of the user's\n(`GET /v1/support/conversations`). A resolved one opens again."
          },
          "new_conversation": {
            "type": "boolean",
            "description": "Start a new conversation (a separate request) with this message.\nWith neither field the message joins the user's open request, or\nstarts one."
          },
          "reply_to": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int64",
            "description": "The message this one answers (like a Telegram reply): one of this\nconversation's that the user sees."
          }
        },
        "additionalProperties": false
      },
      "NewUser": {
        "type": "object",
        "description": "Body of `POST /v1/admin/users`.",
        "required": [
          "email"
        ],
        "properties": {
          "email": {
            "type": "string",
            "description": "Email: the invite goes there, and they sign in with it."
          },
          "company_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Superusers: the company (others add to their own)."
          },
          "positions": {
            "type": "array",
            "items": {
              "type": "integer",
              "format": "int32"
            },
            "description": "Position ids."
          },
          "is_admin": {
            "type": "boolean",
            "description": "Admin access."
          }
        },
        "additionalProperties": false
      },
      "NextActivity": {
        "type": "object",
        "description": "The unfinished activity due first on a deal.",
        "required": [
          "id",
          "name",
          "priority"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "Activity id."
          },
          "name": {
            "type": "string",
            "description": "What to do."
          },
          "deadline": {
            "type": [
              "string",
              "null"
            ],
            "description": "Store wall time `YYYY-MM-DDTHH:MM:SS` (midnight means a whole day), or null."
          },
          "priority": {
            "type": "string",
            "description": "`low`, `medium` or `high`."
          }
        }
      },
      "NextCharge": {
        "type": "object",
        "description": "What `PUT /v1/superuser/companies/{id}/billing-day` set.",
        "required": [
          "next_payment_at"
        ],
        "properties": {
          "next_payment_at": {
            "type": "string",
            "format": "date-time",
            "description": "The subscription's next charge."
          }
        }
      },
      "NoAnswerAction": {
        "type": "string",
        "description": "What a call nobody answers does: `ai` (the AI Assistant),\n`voicemail` or `forward` (to another number).",
        "enum": [
          "Ai",
          "Voicemail",
          "Forward"
        ]
      },
      "Note": {
        "type": "object",
        "description": "A note on a deal with its comments, oldest comment first.",
        "required": [
          "id",
          "deal_id",
          "content",
          "is_pinned",
          "comments"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int64",
            "description": "Note id."
          },
          "deal_id": {
            "type": "integer",
            "format": "int64",
            "description": "Deal it belongs to."
          },
          "content": {
            "type": "string",
            "description": "Text."
          },
          "is_pinned": {
            "type": "boolean",
            "description": "Pinned to the top."
          },
          "created_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When it was written."
          },
          "created_by": {
            "type": [
              "string",
              "null"
            ],
            "description": "Author name."
          },
          "comments": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/NoteComment"
            },
            "description": "Comments, oldest first."
          }
        }
      },
      "NoteComment": {
        "type": "object",
        "description": "A comment under a note.",
        "required": [
          "id",
          "note_id",
          "content"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int64",
            "description": "Comment id."
          },
          "note_id": {
            "type": "integer",
            "format": "int64",
            "description": "Note it belongs to."
          },
          "content": {
            "type": "string",
            "description": "Text."
          },
          "created_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When it was written."
          },
          "created_by": {
            "type": [
              "string",
              "null"
            ],
            "description": "Author name; null for comments by non-admins."
          }
        }
      },
      "NoteInput": {
        "type": "object",
        "description": "Body of `POST /v1/projects/{id}/notes`.",
        "required": [
          "content"
        ],
        "properties": {
          "content": {
            "type": "string",
            "description": "The text."
          }
        }
      },
      "NotePatch": {
        "type": "object",
        "description": "Body of `PATCH /v1/deals/{id}/notes/{note_id}`.",
        "properties": {
          "content": {
            "type": [
              "string",
              "null"
            ],
            "description": "New text, up to 5000 characters."
          },
          "is_pinned": {
            "type": [
              "boolean",
              "null"
            ],
            "description": "Pin or unpin."
          }
        }
      },
      "NotePreview": {
        "type": "object",
        "description": "A note preview on a customer's deal.",
        "required": [
          "id",
          "content"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int64",
            "description": "Note id."
          },
          "content": {
            "type": "string",
            "description": "Text."
          },
          "created_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When it was written."
          }
        }
      },
      "NoticeAcceptance": {
        "type": "object",
        "description": "Body of `POST /v1/phone/notices/accept`.",
        "required": [
          "notice",
          "version"
        ],
        "properties": {
          "notice": {
            "$ref": "#/components/schemas/NoticeKind",
            "description": "`recording` or `e911`."
          },
          "version": {
            "type": "integer",
            "format": "int64",
            "description": "The version shown (from `GET /v1/phone/bootstrap` `notices`)."
          }
        }
      },
      "NoticeKind": {
        "type": "string",
        "description": "A notice the app shows once per version: `recording` (calls may be\nrecorded) or `e911` (911 goes through the phone's own dialer).",
        "enum": [
          "Recording",
          "E911"
        ]
      },
      "Notices": {
        "type": "object",
        "description": "The notices the app shows once per version, and what the user accepted.",
        "required": [
          "recordingVersion",
          "e911Version"
        ],
        "properties": {
          "recordingVersion": {
            "type": "integer",
            "format": "int64",
            "description": "The recording notice's current version."
          },
          "e911Version": {
            "type": "integer",
            "format": "int64",
            "description": "The 911 notice's current version."
          },
          "acceptedRecordingVersion": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int64",
            "description": "The newest recording notice the user accepted; null when none (show\nit, then `POST /v1/phone/notices/accept`)."
          },
          "acceptedE911Version": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int64",
            "description": "The newest 911 notice the user accepted; null when none."
          }
        }
      },
      "NotificationFlow": {
        "type": "object",
        "description": "Templates in a sequence for each appointment on a calendar.",
        "required": [
          "id",
          "calendar_id",
          "name",
          "is_default",
          "is_active",
          "steps"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "Flow id."
          },
          "calendar_id": {
            "type": "integer",
            "format": "int32",
            "description": "The calendar whose appointments it is for."
          },
          "name": {
            "type": "string",
            "description": "What admins and the event form call it."
          },
          "is_default": {
            "type": "boolean",
            "description": "Goes on every event of the calendar; else only on events that pick it."
          },
          "is_active": {
            "type": "boolean",
            "description": "Off: kept, but nothing is sent."
          },
          "steps": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/FlowStep"
            },
            "description": "In the order they go out. Text steps are left out while texting is\nnot set up."
          }
        }
      },
      "NotificationFlowInput": {
        "type": "object",
        "description": "Body of `POST /v1/schedule/notifications/flows` and `PUT …/flows/{id}`.",
        "required": [
          "calendar_id",
          "name",
          "steps"
        ],
        "properties": {
          "calendar_id": {
            "type": "integer",
            "format": "int32",
            "description": "A calendar of the company."
          },
          "name": {
            "type": "string",
            "description": "At most 100 characters."
          },
          "is_default": {
            "type": "boolean",
            "description": "The calendar's one default: setting it unsets the calendar's others."
          },
          "is_active": {
            "type": "boolean",
            "description": "Default on."
          },
          "steps": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/FlowStepInput"
            },
            "description": "1 to 10 steps. On edit, steps left out are deleted."
          }
        }
      },
      "NotificationItem": {
        "type": "object",
        "description": "A notification of the bell.",
        "required": [
          "id",
          "title",
          "message",
          "href",
          "sent_at",
          "kind"
        ],
        "properties": {
          "id": {
            "type": "string",
            "description": "`notif-<id>`, `billing-<id>`, `call-<id>` (`CloudTalk`), `rc-call-<id>`\n(`RingCentral`), `telnyx-call-<id>` (Granite Manager), or the email\nthread id."
          },
          "title": {
            "type": "string",
            "description": "Usually the customer's name."
          },
          "message": {
            "type": "string",
            "description": "What happened."
          },
          "href": {
            "type": "string",
            "description": "Where it opens."
          },
          "sent_at": {
            "type": "string",
            "description": "When (ISO 8601, UTC)."
          },
          "kind": {
            "$ref": "#/components/schemas/NotificationKind"
          },
          "notification_type": {
            "type": [
              "string",
              "null"
            ],
            "description": "The activity notification's type (`note_added`, ...)."
          },
          "actor_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "Who did it."
          },
          "customer_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "The customer."
          },
          "type_title": {
            "type": [
              "string",
              "null"
            ],
            "description": "A heading for the type (`Added a Note`)."
          },
          "action_label": {
            "type": [
              "string",
              "null"
            ],
            "description": "Billing: the button text."
          },
          "deal_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int64",
            "description": "The deal an activity notification is about (the phone app opens it)."
          },
          "customer_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "The customer an activity notification is about (the phone app opens\ntheir card when there is no deal)."
          },
          "project_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "The project a project task or step notification is about (the phone\napp opens it)."
          },
          "event_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "The schedule event an `event_issue` notification is about (the phone\napp opens its Issue tab)."
          },
          "issue_status": {
            "type": [
              "string",
              "null"
            ],
            "description": "Where the issue of an `event_issue` notification is: `open`,\n`in_progress` or `solved` (the bell's triangle is yellow in progress)."
          },
          "company_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "The company an activity notification happened in: the app of an\ninstaller or template guy working for several switches to it to open\nit."
          }
        }
      },
      "NotificationKind": {
        "type": "string",
        "description": "What a notification is about.",
        "enum": [
          "activity",
          "email",
          "call",
          "billing"
        ]
      },
      "NotificationList": {
        "type": "object",
        "description": "One of the company's own lists under Customer messages (e.g.\n\"Reminders\"): it groups reminders and scheduling texts; it sends nothing\nitself.",
        "required": [
          "id",
          "name",
          "position"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "List id."
          },
          "name": {
            "type": "string",
            "description": "What admins call it, e.g. \"Reminders\"."
          },
          "position": {
            "type": "integer",
            "format": "int32",
            "description": "Place in the order: lower first (oldest first)."
          }
        }
      },
      "NotificationListInput": {
        "type": "object",
        "description": "Body of `POST /v1/schedule/notifications/lists` and `PUT …/lists/{id}`.",
        "required": [
          "name"
        ],
        "properties": {
          "name": {
            "type": "string",
            "description": "1 to 100 characters."
          }
        }
      },
      "NotificationPreferences": {
        "type": "object",
        "description": "Which Telegram alerts the user wants from the notifications bot.",
        "required": [
          "notifications_telegram_connected",
          "telegram_sms_notifications",
          "telegram_email_notifications",
          "telegram_activity_notifications"
        ],
        "properties": {
          "notifications_telegram_connected": {
            "type": "boolean",
            "description": "The notifications bot is linked."
          },
          "telegram_sms_notifications": {
            "type": "boolean",
            "description": "New texts."
          },
          "telegram_email_notifications": {
            "type": "boolean",
            "description": "New emails."
          },
          "telegram_activity_notifications": {
            "type": "boolean",
            "description": "Deal activities and other CRM alerts."
          }
        }
      },
      "NotificationPreferencesInput": {
        "type": "object",
        "description": "Body of `PUT /v1/me/notification-preferences`.",
        "required": [
          "telegram_sms_notifications",
          "telegram_email_notifications",
          "telegram_activity_notifications"
        ],
        "properties": {
          "telegram_sms_notifications": {
            "type": "boolean",
            "description": "New texts."
          },
          "telegram_email_notifications": {
            "type": "boolean",
            "description": "New emails."
          },
          "telegram_activity_notifications": {
            "type": "boolean",
            "description": "Deal activities and other CRM alerts."
          }
        }
      },
      "NotificationPush": {
        "type": "object",
        "description": "Body of `POST /v1/phone/pushes/notification`.",
        "required": [
          "notification_id"
        ],
        "properties": {
          "notification_id": {
            "type": "integer",
            "format": "int64",
            "description": "The `notifications` row (`notif-<id>` in `GET /v1/notifications`)."
          }
        }
      },
      "NotificationRef": {
        "type": "object",
        "description": "One notification of the bell.",
        "required": [
          "id",
          "kind"
        ],
        "properties": {
          "id": {
            "type": "string",
            "description": "`notif-<id>` for activities, `billing-<id>` for billing, the thread\nid for email, `telnyx-call-<id>` for a Granite Manager call (marked\nseen, as the phone app's Recents shows it). `CloudTalk` and\n`RingCentral` calls are dismissed in the browser only."
          },
          "kind": {
            "$ref": "#/components/schemas/NotificationKind"
          }
        }
      },
      "NotificationSettings": {
        "type": "object",
        "description": "`GET /v1/schedule/notifications`.",
        "required": [
          "templates",
          "flows",
          "lists",
          "sms_enabled",
          "on_my_way",
          "on_my_way_technician",
          "scheduling",
          "auto_confirm_replies"
        ],
        "properties": {
          "templates": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/NotificationTemplate"
            },
            "description": "Templates, oldest first. Texts are left out while texting is not set up."
          },
          "flows": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/NotificationFlow"
            },
            "description": "Flows, oldest first."
          },
          "lists": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/NotificationList"
            },
            "description": "The company's own lists of Customer messages, in order."
          },
          "sms_enabled": {
            "type": "boolean",
            "description": "The company texts through `CloudTalk` or `RingCentral`."
          },
          "on_my_way": {
            "$ref": "#/components/schemas/OnMyWayMessage",
            "description": "What the customer gets when the installer (any job not on the\nTemplates calendar) taps On my way."
          },
          "on_my_way_technician": {
            "$ref": "#/components/schemas/OnMyWayMessage",
            "description": "What the customer gets when the template technician (a Templates\ncalendar job) taps On my way."
          },
          "scheduling": {
            "$ref": "#/components/schemas/SchedulingSettings",
            "description": "The AI texts tab's switch and texting hours."
          },
          "auto_confirm_replies": {
            "$ref": "#/components/schemas/AutoConfirmReplies",
            "description": "What the customer gets back after a YES or a NO to an auto-confirm text."
          }
        }
      },
      "NotificationTemplate": {
        "type": "object",
        "description": "A text or email to customers.",
        "required": [
          "id",
          "name",
          "kind",
          "channel",
          "body",
          "position",
          "calendar_ids"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "Template id."
          },
          "name": {
            "type": "string",
            "description": "What admins call it, e.g. \"Disconnect the sink\"."
          },
          "kind": {
            "$ref": "#/components/schemas/TemplateKind",
            "description": "`reminder` (flows send it), `confirmation` (a scheduling text, sent by\nhand) or `question` (an AI text, sent by hand; AI reads the answer)."
          },
          "channel": {
            "$ref": "#/components/schemas/Channel",
            "description": "`sms` or `email`."
          },
          "subject": {
            "type": [
              "string",
              "null"
            ],
            "description": "Email subject (null for texts); may hold `{{variables}}`."
          },
          "body": {
            "type": "string",
            "description": "The text, plain; may hold `{{variables}}`."
          },
          "position": {
            "type": "integer",
            "format": "int32",
            "description": "Place in the admin's order: lower first."
          },
          "calendar_ids": {
            "type": "array",
            "items": {
              "type": "integer",
              "format": "int32"
            },
            "description": "Scheduling and AI texts: the calendars it is for; empty for every\ncalendar."
          },
          "followup": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/Followup",
                "description": "AI texts: what the customer gets when they have not replied; null for\nnothing."
              },
              {
                "type": "null"
              }
            ]
          },
          "list_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "The company's list (`lists` of `GET /v1/schedule/notifications`) it is\nshown in under Customer messages; null when it is in none."
          }
        }
      },
      "NotificationTemplateInput": {
        "type": "object",
        "description": "Body of `POST /v1/schedule/notifications/templates` and `PUT …/templates/{id}`.",
        "required": [
          "name",
          "channel",
          "body"
        ],
        "properties": {
          "name": {
            "type": "string",
            "description": "At most 100 characters."
          },
          "kind": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/TemplateKind",
                "description": "`reminder`, `confirmation` or `question`. Left out: `reminder` for a new template,\nunchanged on edit. A template a flow uses stays a reminder."
              },
              {
                "type": "null"
              }
            ]
          },
          "channel": {
            "$ref": "#/components/schemas/Channel",
            "description": "`sms` needs `CloudTalk` or `RingCentral`."
          },
          "subject": {
            "type": [
              "string",
              "null"
            ],
            "description": "Required for email (at most 255 characters)."
          },
          "body": {
            "type": "string",
            "description": "Up to 1600 characters for a text."
          },
          "calendar_ids": {
            "type": [
              "array",
              "null"
            ],
            "items": {
              "type": "integer",
              "format": "int32"
            },
            "description": "Scheduling and AI texts: the calendars it is for (empty for every calendar).\nLeft out: every calendar for a new template, unchanged on edit."
          },
          "followup": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/Followup",
                "description": "Scheduling texts sent by text: the follow-up, or null for none. Left\nout: none for a new template, unchanged on edit."
              },
              {
                "type": "null"
              }
            ]
          },
          "list_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "The company's list it goes in (Customer messages), or null for none.\nLeft out: none for a new template, unchanged on edit."
          }
        }
      },
      "Notifications": {
        "type": "object",
        "description": "`GET /v1/notifications`.",
        "required": [
          "notifications"
        ],
        "properties": {
          "notifications": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/NotificationItem"
            },
            "description": "Newest first."
          }
        }
      },
      "NotifyPosition": {
        "type": "object",
        "description": "A position a step's Notify can pick people from.",
        "required": [
          "id",
          "name",
          "people"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "`positions.id`."
          },
          "name": {
            "type": "string",
            "description": "Its name, e.g. \"Shop Manager\"."
          },
          "people": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Person"
            },
            "description": "The company's people in it, by name."
          }
        }
      },
      "NumberAssignment": {
        "type": "object",
        "description": "Who a number rings and who may call from it.",
        "required": [
          "userId",
          "rings",
          "canCallFrom"
        ],
        "properties": {
          "userId": {
            "type": "integer",
            "format": "int32",
            "description": "A user of the company."
          },
          "rings": {
            "type": "boolean",
            "description": "Calls to the number ring this user's phones."
          },
          "canCallFrom": {
            "type": "boolean",
            "description": "The user may call from the number (it is one of their caller IDs)."
          }
        }
      },
      "NumberInput": {
        "type": "object",
        "description": "Body of `PUT /v1/phone/admin/numbers/{id}`: the whole number.",
        "required": [
          "label",
          "kind",
          "noAnswerAction",
          "active"
        ],
        "properties": {
          "label": {
            "type": "string",
            "description": "Its label, up to 100 characters; may be empty."
          },
          "kind": {
            "$ref": "#/components/schemas/NumberKind",
            "description": "`direct`, `shared` or `main`."
          },
          "noAnswerAction": {
            "$ref": "#/components/schemas/NoAnswerAction",
            "description": "`ai`, `voicemail` or `forward`."
          },
          "forwardTo": {
            "type": [
              "string",
              "null"
            ],
            "description": "Where `forward` sends calls: a US or Canada number (E.164 or 10\ndigits); needed for `forward`, null otherwise."
          },
          "greeting": {
            "type": [
              "string",
              "null"
            ],
            "description": "The voicemail greeting, up to 500 characters; null or empty = the\nstandard greeting."
          },
          "active": {
            "type": "boolean",
            "description": "In use."
          },
          "forwardOnly": {
            "type": "boolean",
            "description": "Forward only: it rings nobody and every call goes to `forwardTo`\n(needed then). Left out = false."
          },
          "forwardTextsTo": {
            "type": [
              "string",
              "null"
            ],
            "description": "Where texts to the number are sent on: a US or Canada number (E.164\nor 10 digits); null or empty = nowhere."
          },
          "assignments": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/NumberAssignment"
            },
            "description": "Who it rings and who may call from it: replaces the current list.\nEvery user must be a live user of the company, once each; users with\nneither flag on are left out."
          },
          "schedulingManagers": {
            "type": [
              "boolean",
              "null"
            ],
            "description": "True: this becomes the company's one Scheduling Manager number (a\ndirect line turns shared); false: it stops being it; left out: no\nchange."
          },
          "notifications": {
            "type": [
              "boolean",
              "null"
            ],
            "description": "True: this becomes the company's one Notification number (a direct\nline turns shared; it can't also be the Scheduling Manager number);\nfalse: it stops being it; left out: no change."
          }
        }
      },
      "NumberKind": {
        "type": "string",
        "description": "What a company number is for: `direct` (one person's line), `shared`\n(a team line) or `main` (the company's main line).",
        "enum": [
          "Direct",
          "Shared",
          "Main"
        ]
      },
      "ObjectionInput": {
        "type": "object",
        "description": "Body of `PUT /v1/deals/{id}/objection`.",
        "properties": {
          "objection": {
            "type": [
              "string",
              "null"
            ],
            "description": "`price`, `timing`, `spouse`, `competitor` or `trust`; null: none."
          }
        },
        "additionalProperties": false
      },
      "OddsConfidence": {
        "type": "object",
        "description": "How far to trust the odds: how often, in past deals like this one (same\nstore, same things already happened), the model ranked a buyer above a\nnon-buyer (holdout AUC).",
        "required": [
          "deals"
        ],
        "properties": {
          "percent": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "The AUC as a whole percent, e.g. 78; null when the odds are not to be\ntrusted (fewer than 50 such deals or under 70%), `reason` says why.",
            "minimum": 0
          },
          "level": {
            "type": [
              "string",
              "null"
            ],
            "description": "What has already happened with the deal: `replied` (the customer\nwrote or called, or a call was answered), `worked` (the store wrote,\ncalled or moved the stage, no answer yet) or `untouched`."
          },
          "group": {
            "type": [
              "string",
              "null"
            ],
            "description": "The store group the accuracy was measured on, e.g. \"Indianapolis\"."
          },
          "auc": {
            "type": [
              "number",
              "null"
            ],
            "format": "double",
            "description": "The holdout AUC and its 90% interval, 0..1."
          },
          "auc_low": {
            "type": [
              "number",
              "null"
            ],
            "format": "double"
          },
          "auc_high": {
            "type": [
              "number",
              "null"
            ],
            "format": "double"
          },
          "deals": {
            "type": "integer",
            "format": "int32",
            "description": "Past deals the accuracy was measured on.",
            "minimum": 0
          },
          "reason": {
            "type": [
              "string",
              "null"
            ],
            "description": "Why there is no percent."
          }
        }
      },
      "OddsReason": {
        "type": "object",
        "description": "One thing about the deal that moved its odds.",
        "required": [
          "feature",
          "label",
          "value",
          "raises",
          "effect"
        ],
        "properties": {
          "feature": {
            "type": "string",
            "description": "Model input name, e.g. `lead_source`, `stage_days_in`."
          },
          "label": {
            "type": "string",
            "description": "What it is, for people, e.g. \"Lead source\"."
          },
          "value": {
            "type": "string",
            "description": "The deal's value of it, as text (\"leads\", \"12.5\"); \"unknown\" when missing."
          },
          "raises": {
            "type": "boolean",
            "description": "True when it raises the odds, false when it lowers them."
          },
          "effect": {
            "type": "number",
            "format": "double",
            "description": "Size of the push in log-odds (about 0.1 is small, 1 is large)."
          }
        }
      },
      "OddsVerdict": {
        "type": "string",
        "description": "How likely the deal is to end in a sale, in words.",
        "enum": [
          "likely",
          "maybe",
          "unlikely"
        ]
      },
      "OffsetUnit": {
        "type": "string",
        "description": "What `offset_value` counts.",
        "enum": [
          "minutes",
          "hours",
          "days"
        ]
      },
      "OnMyWayMessage": {
        "type": "object",
        "description": "The On my way message: a text, or an email (with `subject`) when the\ncompany cannot text. Nothing goes out while `message` is null.",
        "properties": {
          "subject": {
            "type": [
              "string",
              "null"
            ],
            "description": "Email subject (at most 255 characters); null uses \"On the way\"."
          },
          "message": {
            "type": [
              "string",
              "null"
            ],
            "description": "Up to 1600 characters for a text."
          }
        }
      },
      "OnboardingFeedback": {
        "type": "object",
        "description": "Body of `POST /v1/me/onboarding-feedback`.",
        "required": [
          "rating"
        ],
        "properties": {
          "rating": {
            "type": "integer",
            "format": "int32",
            "description": "1 to 5 stars."
          },
          "feedback_text": {
            "type": [
              "string",
              "null"
            ],
            "description": "Up to 2000 characters."
          }
        }
      },
      "OnboardingProfile": {
        "type": "object",
        "description": "What the onboarding widget knows about the user.",
        "required": [
          "user_id",
          "is_admin",
          "can_manage_users",
          "has_cloudtalk_api",
          "has_ringcentral_api",
          "has_inbound_email",
          "has_cloudtalk_agent",
          "is_shop_worker",
          "is_shop_manager"
        ],
        "properties": {
          "user_id": {
            "type": "integer",
            "format": "int32",
            "description": "The user."
          },
          "is_admin": {
            "type": "boolean",
            "description": "Admin or super user."
          },
          "can_manage_users": {
            "type": "boolean",
            "description": "May manage users (super user, or Manager)."
          },
          "has_cloudtalk_api": {
            "type": "boolean",
            "description": "The company has CloudTalk."
          },
          "has_ringcentral_api": {
            "type": "boolean",
            "description": "The company has RingCentral."
          },
          "has_inbound_email": {
            "type": "boolean",
            "description": "The company receives email."
          },
          "has_cloudtalk_agent": {
            "type": "boolean",
            "description": "The user has a CloudTalk agent."
          },
          "is_shop_worker": {
            "type": "boolean",
            "description": "Holds the Shop Worker position."
          },
          "is_shop_manager": {
            "type": "boolean",
            "description": "Holds the Shop Manager position."
          },
          "onboarding_completed_at": {
            "type": [
              "string",
              "null"
            ],
            "description": "When the first-run journey was completed."
          },
          "saved_progress": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/OnboardingState",
                "description": "The saved progress; null before any."
              },
              {
                "type": "null"
              }
            ]
          }
        }
      },
      "OnboardingRecord": {
        "type": "object",
        "description": "A user's onboarding record.",
        "required": [
          "state",
          "has_row",
          "usage"
        ],
        "properties": {
          "state": {
            "$ref": "#/components/schemas/OnboardingState",
            "description": "The saved state."
          },
          "completed_at": {
            "type": [
              "string",
              "null"
            ],
            "description": "When the first-run journey was completed."
          },
          "has_row": {
            "type": "boolean",
            "description": "A journey row exists (an empty but dated one counts)."
          },
          "usage": {
            "type": "object",
            "description": "Features the user already uses: usage check id -> when they first used\nit (UTC, ISO 8601). Filled only by `GET /v1/me/onboarding`, and only\nwhile the company's guided tours are on; empty elsewhere.",
            "additionalProperties": {
              "type": "string"
            },
            "propertyNames": {
              "type": "string"
            }
          },
          "account_created_at": {
            "type": [
              "string",
              "null"
            ],
            "description": "When the user's account was created (UTC, ISO 8601). Filled only by\n`GET /v1/me/onboarding`; null elsewhere."
          }
        }
      },
      "OnboardingState": {
        "type": "object",
        "description": "A user's saved onboarding.",
        "required": [
          "dismissed",
          "feedback_dismissed",
          "completed_module_ids",
          "module_step_keys",
          "tasks",
          "sightings",
          "points"
        ],
        "properties": {
          "current_module_id": {
            "type": [
              "string",
              "null"
            ],
            "description": "The first-run module the user is in."
          },
          "current_step_key": {
            "type": [
              "string",
              "null"
            ],
            "description": "Its step."
          },
          "dismissed": {
            "type": "boolean",
            "description": "The first-run journey was put away."
          },
          "feedback_dismissed": {
            "type": "boolean",
            "description": "The feedback prompt was put away."
          },
          "completed_module_ids": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Finished first-run modules, by id."
          },
          "module_step_keys": {
            "type": "object",
            "description": "Each started module's step key.",
            "additionalProperties": {
              "type": "string"
            },
            "propertyNames": {
              "type": "string"
            }
          },
          "tasks": {
            "type": "object",
            "description": "Feature tours, by task id.",
            "additionalProperties": {
              "$ref": "#/components/schemas/TaskProgress"
            },
            "propertyNames": {
              "type": "string"
            }
          },
          "sightings": {
            "type": "object",
            "description": "Sightings of feature tours, by task id: when the user first met the\ntour's opening control on the tour's own page (UTC, ISO 8601), before\nthe tour ever ran. A sighting at or before the user's feature-tour\nreset is left out. The app starts such a tour by itself only on a\nlater local day than its sighting. A sighting is not tour progress:\nit adds no entry to `tasks`.",
            "additionalProperties": {
              "type": "string"
            },
            "propertyNames": {
              "type": "string"
            }
          },
          "points": {
            "type": "integer",
            "format": "int64",
            "description": "Points of completed tours."
          },
          "updated_at": {
            "type": [
              "string",
              "null"
            ],
            "description": "Latest change (UTC, ISO 8601)."
          }
        }
      },
      "OnlineColor": {
        "type": "object",
        "description": "A color the customer can pick: a stone in stock with a photo that the\nprice list prices.",
        "required": [
          "product",
          "color",
          "url",
          "icon",
          "stone_id"
        ],
        "properties": {
          "product": {
            "type": "string",
            "description": "Material, e.g. `Quartz`; send it back as `product`."
          },
          "color": {
            "type": "string",
            "description": "Color, e.g. `Calacatta Laza`; send it back as `color`."
          },
          "url": {
            "type": "string",
            "description": "Photo of the stone."
          },
          "icon": {
            "type": "string",
            "description": "Small copy of the photo."
          },
          "stone_id": {
            "type": "integer",
            "format": "int32",
            "description": "A stone of this color: its installed photos are at\n`GET /v1/public/companies/{company_id}/stones/{stone_id}/images`."
          }
        }
      },
      "OnlineColorPick": {
        "type": "object",
        "description": "A color to price: one of the builder's `colors`.",
        "required": [
          "product",
          "color"
        ],
        "properties": {
          "product": {
            "type": "string",
            "description": "Its `product`."
          },
          "color": {
            "type": "string",
            "description": "Its `color`."
          }
        },
        "additionalProperties": false
      },
      "OnlineContactBy": {
        "type": "string",
        "description": "How the customer wants to hear from the team: `call`, `text` or `email`.",
        "enum": [
          "call",
          "text",
          "email"
        ]
      },
      "OnlineCooktop": {
        "type": "object",
        "description": "The cutout every cooktop gets: the price list's default cooktop cutout.",
        "required": [
          "width",
          "depth",
          "burners"
        ],
        "properties": {
          "width": {
            "type": "number",
            "format": "double",
            "description": "Width, inches."
          },
          "depth": {
            "type": "number",
            "format": "double",
            "description": "Depth, inches."
          },
          "burners": {
            "type": "integer",
            "format": "int64",
            "description": "Burners drawn on it."
          }
        }
      },
      "OnlineCutout": {
        "type": "object",
        "description": "A sink or cooktop cutout in a run.",
        "required": [
          "id",
          "kind",
          "anchorCorner",
          "along",
          "across"
        ],
        "properties": {
          "id": {
            "type": "string",
            "description": "Cutout id: letters, digits, `-` and `_`, up to 40, unique in the drawing."
          },
          "kind": {
            "$ref": "#/components/schemas/OnlineCutoutKind",
            "description": "What it is cut for."
          },
          "anchorCorner": {
            "type": "integer",
            "format": "int64",
            "description": "Run corner its position is measured from: 0 start-left, 1 end-left,\n2 end-right, 3 start-right."
          },
          "along": {
            "type": "number",
            "format": "double",
            "description": "Inches along the run from that corner to the cutout's center."
          },
          "across": {
            "type": "number",
            "format": "double",
            "description": "Inches across the run from that corner to the cutout's center."
          },
          "sinkModel": {
            "type": [
              "string",
              "null"
            ],
            "description": "A sink from the builder's `sinks` (its name); its size, type, shape\nand faucet holes are the model's. Null for the customer's own sink:\na `sink_type` cutout of `width` × `depth`. Ignored for cooktops,\nwhich are always the builder's `cooktop`."
          },
          "sinkType": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/OnlineSinkType",
                "description": "Own sink: how it is mounted; null = undermount. Ignored otherwise."
              },
              {
                "type": "null"
              }
            ]
          },
          "width": {
            "type": "number",
            "format": "double",
            "description": "Own sink: cutout width, 10 to 60 inches."
          },
          "depth": {
            "type": "number",
            "format": "double",
            "description": "Own sink: cutout depth, 10 to 30 inches."
          }
        },
        "additionalProperties": false
      },
      "OnlineCutoutKind": {
        "type": "string",
        "description": "`sink` or `cooktop`.",
        "enum": [
          "sink",
          "cooktop"
        ]
      },
      "OnlineDrawing": {
        "type": "object",
        "description": "Body of `POST /v1/public/companies/{company_id}/online-quote/prices`.",
        "required": [
          "pieces",
          "colors"
        ],
        "properties": {
          "pieces": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/OnlinePiece"
            },
            "description": "1 to 8 countertops."
          },
          "colors": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/OnlineColorPick"
            },
            "description": "1 to 10 colors to compare."
          },
          "extras": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "The builder's `extras` the customer wants, by name."
          }
        },
        "additionalProperties": false
      },
      "OnlineEdge": {
        "type": "object",
        "description": "One edge of a piece.",
        "required": [
          "type"
        ],
        "properties": {
          "type": {
            "$ref": "#/components/schemas/OnlineEdgeType",
            "description": "`finished` (polished with the color's first edge profile),\n`unfinished` (against a wall) or `splash` (a backsplash on it)."
          },
          "splashHeight": {
            "type": "number",
            "format": "double",
            "description": "Backsplash height, inches: 1 to 96 for `splash`; ignored otherwise."
          }
        },
        "additionalProperties": false
      },
      "OnlineEdgeType": {
        "type": "string",
        "description": "An edge: polished, plain against a wall, or with a backsplash on it.",
        "enum": [
          "finished",
          "unfinished",
          "splash"
        ]
      },
      "OnlinePiece": {
        "type": "object",
        "description": "A countertop: 1 run (straight or an island), 2 (an L) or 3 (a U), as the\nquote drawing stores counters.",
        "required": [
          "id",
          "x",
          "y",
          "runs",
          "edges"
        ],
        "properties": {
          "id": {
            "type": "string",
            "description": "Piece id: letters, digits, `-` and `_`, up to 40, unique in the drawing."
          },
          "x": {
            "type": "number",
            "format": "double",
            "description": "Where the first run starts on the drawing, inches."
          },
          "y": {
            "type": "number",
            "format": "double",
            "description": "Where the first run starts on the drawing, inches (down is positive)."
          },
          "angle": {
            "type": "integer",
            "format": "int64",
            "description": "Direction of the first run in 22.5° steps (0 right, 4 down, -4 up)."
          },
          "runs": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/OnlineRun"
            },
            "description": "1 to 3 runs."
          },
          "edges": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/OnlineEdge"
            },
            "description": "2 × runs + 2 edges in drawing order: the left side of each run, the\nend, the right side of each run (last run first), then the start."
          }
        },
        "additionalProperties": false
      },
      "OnlinePrice": {
        "type": "object",
        "description": "One color's price.",
        "required": [
          "product",
          "color"
        ],
        "properties": {
          "product": {
            "type": "string",
            "description": "Material."
          },
          "color": {
            "type": "string",
            "description": "Color."
          },
          "total": {
            "type": [
              "number",
              "null"
            ],
            "format": "double",
            "description": "Total with tax, dollars; null when the price list cannot price all of\nit (the company gives that price itself)."
          }
        }
      },
      "OnlinePrices": {
        "type": "object",
        "description": "Each color's total.",
        "required": [
          "prices"
        ],
        "properties": {
          "prices": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/OnlinePrice"
            },
            "description": "In the order the colors were sent."
          }
        }
      },
      "OnlineQuoteInput": {
        "type": "object",
        "description": "Body of `POST /v1/public/companies/{company_id}/online-quotes`.",
        "required": [
          "name",
          "email",
          "phone",
          "pieces",
          "colors"
        ],
        "properties": {
          "name": {
            "type": "string",
            "description": "The customer's name, 1 to 100 characters."
          },
          "email": {
            "type": "string",
            "description": "Where the quote is emailed."
          },
          "phone": {
            "type": "string",
            "description": "US phone with its area code: 10 digits, or 11 starting with 1."
          },
          "pieces": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/OnlinePiece"
            },
            "description": "1 to 8 countertops."
          },
          "colors": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/OnlineColorPick"
            },
            "description": "1 to 10 colors, one quote option each."
          },
          "extras": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "The builder's `extras` the customer wants, by name; each goes on the\nquote as an extra."
          },
          "website": {
            "type": [
              "string",
              "null"
            ],
            "description": "A hidden form field people leave empty. When it is filled, the request\nis answered as sent and nothing is saved or sent."
          },
          "contact_by": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/OnlineContactBy",
                "description": "How the customer wants to hear from the team about the quote; the\nteam's notice says so. Null: no preference."
              },
              {
                "type": "null"
              }
            ]
          },
          "notes": {
            "type": [
              "string",
              "null"
            ],
            "description": "Anything the customer wants to tell the team, up to 2000 characters;\nsaved as the quote's notes and put in the team's notice. Optional."
          }
        },
        "additionalProperties": false
      },
      "OnlineQuoteNotice": {
        "type": "object",
        "description": "What the team was told about a customer's newest online quote, one line\neach, as the Telegram lead message has them.",
        "required": [
          "quote_id",
          "lines"
        ],
        "properties": {
          "quote_id": {
            "type": "integer",
            "format": "int32",
            "description": "The quote's id."
          },
          "lines": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "`Name: …`, `Phone: …`, `Email: …`, then each color's price\n(`Granite Absolute Black Leathered: $5,482.00`) and `Notes: …`."
          }
        }
      },
      "OnlineQuoteOption": {
        "type": "object",
        "description": "An extra the online quote can offer the customer: one of the company's\nextras (Admin > Quotes > Extras).",
        "required": [
          "id",
          "extra_id",
          "name",
          "sequence",
          "enabled"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "Option id."
          },
          "extra_id": {
            "type": "integer",
            "format": "int32",
            "description": "The extra (`quote_extras.id`) the customer can add."
          },
          "name": {
            "type": "string",
            "description": "The extra's name, e.g. \"Stone/Tile Countertop Tear Out\"."
          },
          "sequence": {
            "type": "integer",
            "format": "int32",
            "description": "Order on the customer's Extras step."
          },
          "enabled": {
            "type": "boolean",
            "description": "Offered to customers. When any is on, the online quote has an Extras step."
          }
        }
      },
      "OnlineQuoteOptionInput": {
        "type": "object",
        "description": "Body of creating or saving an online quote option.",
        "properties": {
          "extra_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "The extra (`quote_extras.id`). Unset: the extra named `name`."
          },
          "name": {
            "type": "string",
            "description": "The extra's name; only used when `extra_id` is unset."
          },
          "sequence": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Order; 1 or more (default 1)."
          },
          "enabled": {
            "type": "boolean",
            "description": "Offered to customers (default false)."
          }
        },
        "additionalProperties": false
      },
      "OnlineQuoteSent": {
        "type": "object",
        "description": "The saved quote.",
        "required": [
          "email",
          "emailed",
          "prices"
        ],
        "properties": {
          "email": {
            "type": "string",
            "description": "Where the quote was emailed."
          },
          "emailed": {
            "type": "boolean",
            "description": "False when the quote was saved but the email could not be sent; the\nteam is told and sends it."
          },
          "prices": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/OnlinePrice"
            },
            "description": "Each color's total, as on the quote."
          }
        }
      },
      "OnlineQuoteSetup": {
        "type": "object",
        "description": "What the online quote offers.",
        "required": [
          "company_name",
          "available",
          "default_depth",
          "colors",
          "sinks",
          "cooktop",
          "extras"
        ],
        "properties": {
          "company_name": {
            "type": "string",
            "description": "Company name."
          },
          "logo_url": {
            "type": [
              "string",
              "null"
            ],
            "description": "Company logo; null when it has none."
          },
          "available": {
            "type": "boolean",
            "description": "The company prices quotes online: it has a price list with prices and\nat least one color to offer. When false, show \"call us\" instead."
          },
          "default_depth": {
            "type": "number",
            "format": "double",
            "description": "Counter depth (front to back) to start with, inches."
          },
          "colors": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/OnlineColor"
            },
            "description": "Colors to pick from, by material then name. Prices are never listed."
          },
          "sinks": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/OnlineSink"
            },
            "description": "Sinks to pick from."
          },
          "cooktop": {
            "$ref": "#/components/schemas/OnlineCooktop",
            "description": "The cooktop cutout."
          },
          "extras": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Extras the customer can add (Admin > Quotes > Customer Quote), in\norder. Empty: the builder has no Extras step."
          }
        }
      },
      "OnlineRun": {
        "type": "object",
        "description": "A straight run of a piece.",
        "required": [
          "length",
          "depth"
        ],
        "properties": {
          "length": {
            "type": "number",
            "format": "double",
            "description": "Length, 6 to 600 inches, measured on the outside of its turns."
          },
          "depth": {
            "type": "number",
            "format": "double",
            "description": "Depth (front to back), 6 to 600 inches."
          },
          "turn": {
            "type": "integer",
            "format": "int64",
            "description": "Turn from the run before, in 22.5° steps: 0 for the first run, 4 or\n-4 (a right angle) for the others."
          },
          "cutouts": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/OnlineCutout"
            },
            "description": "Its sink and cooktop cutouts."
          }
        },
        "additionalProperties": false
      },
      "OnlineSink": {
        "type": "object",
        "description": "A sink the customer can pick: one of the company's sinks on display, with\na photo.",
        "required": [
          "name",
          "sink_type",
          "sink_shape",
          "width",
          "depth",
          "faucet_holes",
          "url",
          "icon"
        ],
        "properties": {
          "name": {
            "type": "string",
            "description": "Model name; send it back as the cutout's `sinkModel`."
          },
          "sink_type": {
            "type": "string",
            "description": "`undermount`, `dropIn` or `farmer`."
          },
          "sink_shape": {
            "type": "string",
            "description": "Cutout shape, e.g. `rectangle` or `60/40`."
          },
          "width": {
            "type": "number",
            "format": "double",
            "description": "Cutout width, inches."
          },
          "depth": {
            "type": "number",
            "format": "double",
            "description": "Cutout depth, inches."
          },
          "faucet_holes": {
            "type": "integer",
            "format": "int64",
            "description": "Faucet holes drilled for it."
          },
          "url": {
            "type": "string",
            "description": "Photo of the sink."
          },
          "icon": {
            "type": "string",
            "description": "Small copy of the photo."
          }
        }
      },
      "OnlineSinkType": {
        "type": "string",
        "description": "How the customer's own sink is mounted: `undermount`, `dropIn` (top-mount)\nor `farmer` (farmhouse).",
        "enum": [
          "undermount",
          "dropIn",
          "farmer"
        ]
      },
      "OpenDay": {
        "type": "object",
        "description": "One day with open times.",
        "required": [
          "date",
          "times",
          "people"
        ],
        "properties": {
          "date": {
            "type": "string",
            "description": "The local day, `YYYY-MM-DD` (in `time_zone`)."
          },
          "times": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "The starts a customer can take that day, ISO 8601 UTC, earliest\nfirst."
          },
          "people": {
            "type": "array",
            "items": {
              "type": "array",
              "items": {
                "type": "integer",
                "format": "int32"
              }
            },
            "description": "For each of `times`, the salespeople free then (ids of\n`salespeople`): pick one to book with them."
          }
        }
      },
      "OpenDeal": {
        "type": "object",
        "description": "A customer's oldest open deal.",
        "required": [
          "id",
          "stage"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int64",
            "description": "The deal."
          },
          "stage": {
            "type": "string",
            "description": "Its stage, e.g. \"Got a Quote\"."
          }
        }
      },
      "OpenedView": {
        "type": "object",
        "description": "The page a verified sign-in opens.",
        "required": [
          "view_id"
        ],
        "properties": {
          "view_id": {
            "type": "string",
            "description": "The customer's page id: open `/customer/{company_id}/{view_id}`."
          }
        }
      },
      "OptimizedRoute": {
        "type": "object",
        "description": "`POST /v1/schedule/optimize-route`.",
        "required": [
          "order",
          "changed",
          "stops"
        ],
        "properties": {
          "order": {
            "type": "array",
            "items": {
              "type": "integer",
              "format": "int32"
            },
            "description": "Event ids in driving order, farthest first."
          },
          "changed": {
            "type": "integer",
            "description": "Events that got a new time.",
            "minimum": 0
          },
          "stops": {
            "type": "integer",
            "description": "Events on the route.",
            "minimum": 0
          }
        }
      },
      "Order": {
        "type": "object",
        "description": "A sold quote's Order.",
        "required": [
          "id",
          "number",
          "quote_id",
          "option_index",
          "sold_revision_id",
          "sold_total",
          "sold_tax_pct",
          "sold_discount_pct",
          "sold_discount_amount",
          "total",
          "signed",
          "changes"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "Order id."
          },
          "number": {
            "type": "integer",
            "format": "int32",
            "description": "Its number in the company (\"Order 1042\")."
          },
          "quote_id": {
            "type": "integer",
            "format": "int32",
            "description": "The quote it was made from."
          },
          "option_index": {
            "type": "integer",
            "format": "int32",
            "description": "The option sold."
          },
          "sold_revision_id": {
            "type": "integer",
            "format": "int32",
            "description": "The quote as sold: `GET /v1/quotes/{id}?revision=` shows it."
          },
          "sold_total": {
            "type": "number",
            "format": "double",
            "description": "The sold option's total."
          },
          "sold_tax_pct": {
            "type": "number",
            "format": "double",
            "description": "Tax percent it was sold with."
          },
          "sold_discount_pct": {
            "type": "number",
            "format": "double",
            "description": "Discount percent it was sold with."
          },
          "sold_discount_amount": {
            "type": "number",
            "format": "double",
            "description": "Discount in dollars it was sold with."
          },
          "total": {
            "type": "number",
            "format": "double",
            "description": "The Order's total now: after its last change order."
          },
          "created_at": {
            "type": [
              "string",
              "null"
            ],
            "description": "When the Order was made (ISO 8601): the sale, or the first Change\norder of a quote sold before Orders."
          },
          "created_by": {
            "type": [
              "string",
              "null"
            ],
            "description": "Who sold it."
          },
          "signed": {
            "type": "boolean",
            "description": "The customer signed the sold quote (its contract, or the quote)."
          },
          "changes": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/OrderChange"
            },
            "description": "Its change orders, newest first."
          }
        }
      },
      "OrderChange": {
        "type": "object",
        "description": "One change order.",
        "required": [
          "id",
          "number",
          "from_revision_id",
          "to_revision_id",
          "changes",
          "total_before",
          "total_after",
          "invoice_action",
          "sign_requested"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "Change order id."
          },
          "number": {
            "type": "integer",
            "format": "int32",
            "description": "Change order 1, 2, ... of its Order."
          },
          "from_revision_id": {
            "type": "integer",
            "format": "int32",
            "description": "The Order before it (a revision of the quote)."
          },
          "to_revision_id": {
            "type": "integer",
            "format": "int32",
            "description": "The Order after it."
          },
          "changes": {
            "type": "object",
            "description": "What changed: `lines` (`kind` new, changed or removed, `text`,\n`amount`) and `rooms` (`id`, `name`, `kind`, `fields`, `sq_ft`)."
          },
          "total_before": {
            "type": "number",
            "format": "double",
            "description": "The Order's total before."
          },
          "total_after": {
            "type": "number",
            "format": "double",
            "description": "The Order's total after."
          },
          "note": {
            "type": [
              "string",
              "null"
            ],
            "description": "The note saved with it."
          },
          "invoice_action": {
            "type": "string",
            "description": "`update` (the quote's invoice follows the Order), `new` (an invoice\nfor the difference) or `none`."
          },
          "invoice_ref": {
            "type": [
              "string",
              "null"
            ],
            "description": "The invoice made for the difference."
          },
          "sign_requested": {
            "type": "boolean",
            "description": "The customer is asked to sign it."
          },
          "contract_status": {
            "type": [
              "string",
              "null"
            ],
            "description": "Its contract: `sent`, `viewed`, `signed`, `declined` or `expired`;\nnone while no contract was sent after it."
          },
          "signed_at": {
            "type": [
              "string",
              "null"
            ],
            "description": "When the customer signed it (ISO 8601)."
          },
          "created_by": {
            "type": [
              "string",
              "null"
            ],
            "description": "Who saved it."
          },
          "created_at": {
            "type": [
              "string",
              "null"
            ],
            "description": "When (ISO 8601)."
          }
        }
      },
      "OrderChangeInvoice": {
        "type": "object",
        "description": "What a change order's invoice turned out to be.",
        "required": [
          "invoice_action"
        ],
        "properties": {
          "invoice_action": {
            "type": "string",
            "description": "`update`, `new` or `none`."
          },
          "invoice_ref": {
            "type": [
              "string",
              "null"
            ],
            "description": "The invoice made for the difference (its number), for `new`."
          }
        },
        "additionalProperties": false
      },
      "OrderInput": {
        "type": "object",
        "description": "Body of `PUT /v1/sales-playbook/stages/{id}/sub-stage-order`.",
        "required": [
          "ids"
        ],
        "properties": {
          "ids": {
            "type": "array",
            "items": {
              "type": "integer",
              "format": "int32"
            },
            "description": "Every sub-stage of the stage, in the new order."
          }
        },
        "additionalProperties": false
      },
      "OrderSlab": {
        "allOf": [
          {
            "$ref": "#/components/schemas/SlabChoice",
            "description": "The slab."
          },
          {
            "type": "object",
            "required": [
              "is_full"
            ],
            "properties": {
              "is_full": {
                "type": "boolean",
                "description": "`false`: only part of it is used."
              }
            }
          }
        ],
        "description": "A slab set on an order."
      },
      "OrderingMode": {
        "type": "string",
        "description": "How a picker sorts.",
        "enum": [
          "automatic",
          "custom"
        ]
      },
      "OurNumber": {
        "type": "object",
        "description": "The company number of a call.",
        "required": [
          "e164",
          "label"
        ],
        "properties": {
          "e164": {
            "type": "string",
            "description": "E.164."
          },
          "label": {
            "type": "string",
            "description": "Its label; may be empty."
          }
        }
      },
      "Outcome": {
        "type": "string",
        "description": "What the agent concluded about the issue.",
        "enum": [
          "fixed_with_test",
          "fixed_without_test",
          "not_a_code_bug",
          "not_reproducible",
          "duplicate",
          "needs_human"
        ]
      },
      "OutcomeBody": {
        "type": "object",
        "description": "Body of `PUT /v1/deals/{id}/outcome`.",
        "required": [
          "outcome"
        ],
        "properties": {
          "outcome": {
            "$ref": "#/components/schemas/DealStatus",
            "description": "`won`, `lost`, or `open` to reopen a closed deal."
          },
          "lost_reason": {
            "type": [
              "string",
              "null"
            ],
            "description": "Why it was lost, at most 255 characters; only with `lost`."
          }
        }
      },
      "OutcomesRequest": {
        "allOf": [
          {
            "$ref": "#/components/schemas/ComposeTarget"
          },
          {
            "type": "object",
            "required": [
              "sent",
              "suggestions"
            ],
            "properties": {
              "source": {
                "$ref": "#/components/schemas/SuggestionSource"
              },
              "sent": {
                "type": "boolean",
                "description": "The message they were shown for was sent (false: the rep left it)."
              },
              "suggestions": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/ShownSuggestion"
                },
                "description": "The suggestions shown while that message was written (at most 40 are kept)."
              }
            }
          }
        ],
        "description": "`POST /v1/ai/compose/outcomes`."
      },
      "OutcomesSaved": {
        "type": "object",
        "description": "How many suggestions were written down.",
        "required": [
          "saved"
        ],
        "properties": {
          "saved": {
            "type": "integer",
            "minimum": 0
          }
        }
      },
      "Outreach": {
        "type": "object",
        "description": "Today's outreach of the signed-in user.",
        "required": [
          "calls",
          "sms",
          "emails",
          "goals"
        ],
        "properties": {
          "calls": {
            "type": "integer",
            "format": "int64",
            "description": "Outbound calls started today, on every phone provider."
          },
          "sms": {
            "type": "integer",
            "format": "int64",
            "description": "Texts sent today through the user's SMS provider."
          },
          "emails": {
            "type": "integer",
            "format": "int64",
            "description": "Emails the user sent today; automated emails left out."
          },
          "goals": {
            "$ref": "#/components/schemas/OutreachGoals"
          }
        }
      },
      "OutreachGoals": {
        "type": "object",
        "description": "The user's own daily minimums; null when not set.",
        "properties": {
          "calls": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Outbound calls a day (0 to 9999); null when not set.",
            "minimum": 0
          },
          "sms": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Texts a day (0 to 9999); null when not set.",
            "minimum": 0
          },
          "emails": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Emails a day (0 to 9999); null when not set.",
            "minimum": 0
          }
        }
      },
      "OverLimitDeal": {
        "type": "object",
        "description": "A deal idle past its stage limit.",
        "required": [
          "deal_id",
          "stage_name",
          "limit_days",
          "idle_days",
          "idle_since"
        ],
        "properties": {
          "deal_id": {
            "type": "integer",
            "format": "int64",
            "description": "The idle deal."
          },
          "customer_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "The deal's customer; null when the customer has no name."
          },
          "stage_name": {
            "type": "string",
            "description": "The stage the deal is idle in."
          },
          "sub_stage_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "Its sub-stage; null when the stage has none."
          },
          "limit_days": {
            "type": "integer",
            "format": "int32",
            "description": "The stage's time limit, in days."
          },
          "idle_days": {
            "type": "integer",
            "format": "int32",
            "description": "Whole days since anything happened (entered the stage or sub-stage,\nor finished an activity)."
          },
          "idle_since": {
            "type": "string",
            "description": "When something last happened, `YYYY-MM-DD`."
          }
        }
      },
      "Overview": {
        "type": "object",
        "description": "`GET /v1/stats/overview`.",
        "required": [
          "deals_by_rep",
          "deals_by_stage",
          "lists",
          "customers_totals",
          "customers_by_source",
          "customers_by_rep",
          "customers_table",
          "customers_deals",
          "conversion_metrics_by_rep",
          "lost_reasons_by_rep",
          "customers_by_campaign",
          "sales_rep_ratings",
          "top_sold_colors",
          "emails_per_month"
        ],
        "properties": {
          "from_date": {
            "type": [
              "string",
              "null"
            ],
            "description": "The days counted, in order."
          },
          "to_date": {
            "type": [
              "string",
              "null"
            ],
            "description": "Last day counted."
          },
          "deals_by_rep": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/DealsByRep"
            },
            "description": "Deals by rep."
          },
          "deals_by_stage": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/DealsByStage"
            },
            "description": "Open deals by stage."
          },
          "lists": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/DealsList"
            },
            "description": "Stages of the shown pipelines."
          },
          "customers_totals": {
            "$ref": "#/components/schemas/CustomersTotals",
            "description": "Customer totals."
          },
          "customers_by_source": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CustomersBySource"
            },
            "description": "Valid customers by source."
          },
          "customers_by_rep": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CustomersByRep"
            },
            "description": "Valid customers by rep."
          },
          "customers_table": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TableCustomer"
            },
            "description": "Customers, newest first."
          },
          "customers_deals": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TableDeal"
            },
            "description": "Those customers' deals."
          },
          "conversion_metrics_by_rep": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ConversionMetrics"
            },
            "description": "Deals made and won by rep."
          },
          "lost_reasons_by_rep": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/LostReason"
            },
            "description": "Lost reasons by rep."
          },
          "customers_by_campaign": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Campaign"
            },
            "description": "Top 8 campaigns."
          },
          "sales_rep_ratings": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/RepRating"
            },
            "description": "Survey ratings by rep."
          },
          "top_sold_colors": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TopSoldColor"
            },
            "description": "Top 10 stones by slabs sold."
          },
          "emails_per_month": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/MonthCount"
            },
            "description": "Emails sent per month."
          },
          "sms_per_month": {
            "type": [
              "array",
              "null"
            ],
            "items": {
              "$ref": "#/components/schemas/MonthCount"
            },
            "description": "Null when the company has no SMS provider."
          }
        }
      },
      "OverviewCall": {
        "type": "object",
        "description": "A logged AI call.",
        "required": [
          "id",
          "feature",
          "model",
          "api_kind",
          "cost_usd",
          "success",
          "created_at"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int64",
            "description": "The log row."
          },
          "feature": {
            "type": "string",
            "description": "Feature key."
          },
          "model": {
            "type": "string",
            "description": "Model used."
          },
          "api_kind": {
            "type": "string",
            "description": "`chat`, `image` or `transcription`."
          },
          "user_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "Who made it; null for background jobs."
          },
          "company_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "Their company."
          },
          "input_tokens": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int64",
            "description": "Input tokens."
          },
          "output_tokens": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int64",
            "description": "Output tokens."
          },
          "cost_usd": {
            "type": "number",
            "format": "double",
            "description": "Cost (USD)."
          },
          "success": {
            "type": "boolean",
            "description": "It succeeded."
          },
          "duration_ms": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int64",
            "description": "How long it took."
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "description": "When."
          }
        }
      },
      "OverviewCompany": {
        "type": "object",
        "description": "A company to filter by.",
        "required": [
          "id"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "Company id."
          },
          "name": {
            "type": [
              "string",
              "null"
            ],
            "description": "Name."
          }
        }
      },
      "OverviewFeature": {
        "type": "object",
        "description": "A feature's usage in the range.",
        "required": [
          "feature",
          "requests",
          "cost_usd",
          "models"
        ],
        "properties": {
          "feature": {
            "type": "string",
            "description": "Feature key."
          },
          "requests": {
            "type": "integer",
            "format": "int64",
            "description": "Calls."
          },
          "cost_usd": {
            "type": "number",
            "format": "double",
            "description": "Cost (USD)."
          },
          "success_rate": {
            "type": [
              "number",
              "null"
            ],
            "format": "double",
            "description": "Share that succeeded."
          },
          "models": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Models it used, by name."
          }
        }
      },
      "OverviewKpis": {
        "type": "object",
        "description": "Spend totals (USD).",
        "required": [
          "mtd_usd",
          "prev_mtd_usd",
          "all_time_usd",
          "range_usd",
          "range_requests"
        ],
        "properties": {
          "mtd_usd": {
            "type": "number",
            "format": "double",
            "description": "This month so far."
          },
          "prev_mtd_usd": {
            "type": "number",
            "format": "double",
            "description": "Last month up to the same day."
          },
          "all_time_usd": {
            "type": "number",
            "format": "double",
            "description": "Ever."
          },
          "range_usd": {
            "type": "number",
            "format": "double",
            "description": "In the range."
          },
          "range_requests": {
            "type": "integer",
            "format": "int64",
            "description": "Calls in the range."
          },
          "range_success_rate": {
            "type": [
              "number",
              "null"
            ],
            "format": "double",
            "description": "Share of range calls that succeeded; null without calls."
          }
        }
      },
      "OwnQuestionnaire": {
        "type": "object",
        "description": "A questionnaire the caller made.",
        "required": [
          "id",
          "name",
          "questions"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "Questionnaire id."
          },
          "name": {
            "type": "string",
            "description": "Name."
          },
          "created_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When it was made."
          },
          "questions": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Question"
            },
            "description": "Questions in creation order."
          }
        }
      },
      "PageInput": {
        "type": "object",
        "description": "The page the user is looking at.",
        "required": [
          "path",
          "text"
        ],
        "properties": {
          "path": {
            "type": "string",
            "description": "The page's address (path and query)."
          },
          "title": {
            "type": "string",
            "description": "The page's title."
          },
          "text": {
            "type": "string",
            "description": "The text the page shows."
          }
        },
        "additionalProperties": false
      },
      "PaidFeatures": {
        "type": "object",
        "description": "`GET /v1/superuser/paid-features`.",
        "required": [
          "features",
          "metrics",
          "paid",
          "chosen",
          "usage",
          "usage_days"
        ],
        "properties": {
          "features": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Feature"
            },
            "description": "Every feature, by name."
          },
          "metrics": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/MetricInfo"
            },
            "description": "Every usage count a feature can show."
          },
          "paid": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PaidMark"
            },
            "description": "Which company paid for which feature (deleted companies left out)."
          },
          "chosen": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PaidMark"
            },
            "description": "Which feature a self-signed-up company picked and pays for through\nits subscription (deleted companies left out)."
          },
          "usage": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Usage"
            },
            "description": "Usage of the metrics the features show, per company; no row: not used."
          },
          "usage_days": {
            "type": "integer",
            "format": "int64",
            "description": "The days the usage covers, back from now."
          }
        }
      },
      "PaidMark": {
        "type": "object",
        "description": "A company that has paid for a feature.",
        "required": [
          "company_id",
          "feature_id"
        ],
        "properties": {
          "company_id": {
            "type": "integer",
            "format": "int32",
            "description": "The company."
          },
          "feature_id": {
            "type": "integer",
            "format": "int32",
            "description": "The feature it has paid for."
          }
        }
      },
      "PaidThroughUs": {
        "type": "object",
        "description": "How many of a company's sold jobs were paid through Granite Manager.\n\nA job is a won deal, or a sale that is not part of a live deal (the jobs\nof a customer's Projects tab). A won deal counts as sold when it was\nmarked won; a sale on its sale date (cancelled sales are left out). A job\nis paid through us when at least one payment link of it was paid (or is\ndisputed and not decided yet) and not wholly refunded, whatever the\namount: a $2,000 deposit on a $10,000 job counts. Two payments on one job\ncount once, so `paid_jobs` is never more than `sold_jobs`.",
        "required": [
          "sold_jobs",
          "paid_jobs",
          "days"
        ],
        "properties": {
          "sold_jobs": {
            "type": "integer",
            "format": "int64",
            "description": "Jobs it sold in the last `days` days."
          },
          "paid_jobs": {
            "type": "integer",
            "format": "int64",
            "description": "How many of them have a payment through us."
          },
          "days": {
            "type": "integer",
            "format": "int32",
            "description": "The window, in days (90)."
          }
        }
      },
      "ParentInput": {
        "type": "object",
        "description": "Body of `PUT /v1/customers/{id}/parent`.",
        "required": [
          "parent_id"
        ],
        "properties": {
          "parent_id": {
            "type": "integer",
            "format": "int32",
            "description": "The customer this one becomes a project of."
          }
        },
        "additionalProperties": false
      },
      "ParsedAddress": {
        "type": "object",
        "description": "Address parts read from a suggestion.",
        "required": [
          "street"
        ],
        "properties": {
          "street": {
            "type": "string",
            "description": "First part, e.g. `11378 Gammel Pl`."
          },
          "city": {
            "type": [
              "string",
              "null"
            ],
            "description": "Second-to-last part when there are three or more."
          },
          "state": {
            "type": [
              "string",
              "null"
            ],
            "description": "Two-letter US state."
          },
          "zip": {
            "type": [
              "string",
              "null"
            ],
            "description": "ZIP code: from the text, else one kept from an earlier pick of the\nplace. Without it, `GET /v1/places/{place_id}` has the ZIP."
          }
        }
      },
      "Part": {
        "type": "object",
        "description": "A line's part of the quote, which a split's shares and classes are\nkept by: `stone` (countertops), `area` (cabinets and other areas\nwithout stone), `other`, `discount`, or `added` (a line the rep added).",
        "required": [
          "line_id",
          "key"
        ],
        "properties": {
          "line_id": {
            "type": "string",
            "description": "The line's `id`."
          },
          "key": {
            "type": "string",
            "description": "Its part."
          }
        }
      },
      "PartInput": {
        "type": "object",
        "description": "Body of `POST /v1/projects/{id}/parts`.",
        "required": [
          "type_id"
        ],
        "properties": {
          "type_id": {
            "type": "integer",
            "format": "int32",
            "description": "The new part's type."
          },
          "name": {
            "type": [
              "string",
              "null"
            ],
            "description": "Its name; the type's name when left out."
          },
          "first_type_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "The first time a project gets parts: the type of the work it already\nhas. Left out: the company's first type."
          }
        }
      },
      "PartType": {
        "type": "object",
        "description": "A kind of part a company's projects are made of, and the stages it uses.",
        "required": [
          "id",
          "name",
          "uses_template",
          "uses_fabrication",
          "position"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "Its id."
          },
          "name": {
            "type": "string",
            "description": "Its name, e.g. \"Cabinets\"."
          },
          "uses_template": {
            "type": "boolean",
            "description": "It is templated (Awaiting Template, Templated)."
          },
          "uses_fabrication": {
            "type": "boolean",
            "description": "It is fabricated (In Fabrication)."
          },
          "position": {
            "type": "integer",
            "format": "int32",
            "description": "Its place in the list."
          }
        }
      },
      "PartTypeInput": {
        "type": "object",
        "description": "A part type to add, or its new values.",
        "required": [
          "name",
          "uses_template",
          "uses_fabrication"
        ],
        "properties": {
          "name": {
            "type": "string",
            "description": "Its name."
          },
          "uses_template": {
            "type": "boolean",
            "description": "It is templated."
          },
          "uses_fabrication": {
            "type": "boolean",
            "description": "It is fabricated."
          }
        }
      },
      "PartUpdate": {
        "type": "object",
        "description": "Body of `PATCH /v1/projects/{id}/parts/{part_id}`.",
        "properties": {
          "name": {
            "type": [
              "string",
              "null"
            ],
            "description": "Its new name."
          },
          "type_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Its new type."
          }
        }
      },
      "PartialCut": {
        "type": "object",
        "description": "Body of `POST /v1/transactions/{id}/slabs/{slab_id}/partial-cut`.",
        "required": [
          "length",
          "width"
        ],
        "properties": {
          "length": {
            "type": "number",
            "format": "double",
            "description": "Length of the piece."
          },
          "width": {
            "type": "number",
            "format": "double",
            "description": "Width of the piece."
          },
          "add_another": {
            "type": "boolean",
            "description": "More pieces follow: the slab is not marked cut yet."
          },
          "replace_first": {
            "type": "boolean",
            "description": "Resize the first piece instead of adding one."
          }
        },
        "additionalProperties": false
      },
      "Participant": {
        "type": "object",
        "description": "An address on a message (no BCC).",
        "required": [
          "email_id",
          "type",
          "email"
        ],
        "properties": {
          "email_id": {
            "type": "integer",
            "format": "int32",
            "description": "Message."
          },
          "type": {
            "type": "string",
            "description": "`from`, `to` or `cc`."
          },
          "email": {
            "type": "string",
            "description": "Address, lowercased."
          },
          "display_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "Name from the header."
          },
          "user_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "The user it belongs to."
          },
          "customer_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "The customer it belongs to."
          },
          "user_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "That user's name."
          },
          "customer_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "That customer's name."
          }
        }
      },
      "PasswordInput": {
        "type": "object",
        "description": "Body of `POST /v1/auth/login/password`.",
        "required": [
          "token",
          "password"
        ],
        "properties": {
          "token": {
            "type": "string",
            "description": "The sign-in's token (`LoginChallenge.token`)."
          },
          "password": {
            "type": "string",
            "description": "The new password: 8 characters or more (spaces around it are\ndropped, as sign-in drops them)."
          }
        }
      },
      "PayCheckout": {
        "type": "object",
        "description": "Where the customer pays.",
        "properties": {
          "url": {
            "type": [
              "string",
              "null"
            ],
            "description": "Stripe's Checkout page to send the customer to; it comes back to the\npayment link with `?checkout=success` or `?checkout=cancel`. Null in\ndemo mode."
          }
        }
      },
      "PayJob": {
        "type": "object",
        "description": "One job, or one open `QuickBooks` invoice, of a customer with what is\nleft to pay on it.",
        "required": [
          "project_key",
          "kind",
          "price_cents",
          "paid_cents",
          "pending_cents",
          "open_cents",
          "free_cents"
        ],
        "properties": {
          "project_key": {
            "type": "string",
            "description": "`deal-<deal id>`, `sale-<sale id>` or `invoice-<QuickBooks invoice\nid>`: what `POST /v1/payments` takes as `project_key`."
          },
          "name": {
            "type": [
              "string",
              "null"
            ],
            "description": "The deal's title, else the address of the work; null without either.\nAn invoice: \"Invoice #3357\", with its job's name when it is on one."
          },
          "kind": {
            "$ref": "#/components/schemas/PayKind",
            "description": "A job or an invoice."
          },
          "number": {
            "type": [
              "string",
              "null"
            ],
            "description": "The invoice's number; null for a job."
          },
          "date": {
            "type": [
              "string",
              "null"
            ],
            "description": "The invoice's date, or the day the job was made (`YYYY-MM-DD`)."
          },
          "price_cents": {
            "type": "integer",
            "format": "int64",
            "description": "What it costs, in US cents: its invoices' total, its price before\nit has an invoice."
          },
          "paid_cents": {
            "type": "integer",
            "format": "int64",
            "description": "Paid toward it, counted once: on its invoices (`QuickBooks` or our\nown, whoever recorded it), deposits and payment links, less refunds."
          },
          "pending_cents": {
            "type": "integer",
            "format": "int64",
            "description": "ACH transfers on their way."
          },
          "open_cents": {
            "type": "integer",
            "format": "int64",
            "description": "What the customer still owes: what its invoices still owe (the price\nwhen it has none) less `pending_cents`, never below zero."
          },
          "free_cents": {
            "type": "integer",
            "format": "int64",
            "description": "The most a new payment can be for: `open_cents` less the links\nnobody paid yet."
          }
        }
      },
      "PayKind": {
        "type": "string",
        "description": "What a [`PayJob`] is.",
        "enum": [
          "job",
          "invoice"
        ]
      },
      "PayPage": {
        "type": "object",
        "description": "What the payment page (`/pay/<payment id>`) shows.",
        "required": [
          "company_name",
          "method",
          "status",
          "amount_cents",
          "customer_fee_cents",
          "customer_fee_bps",
          "total_cents",
          "demo",
          "bank_app"
        ],
        "properties": {
          "company_name": {
            "type": "string",
            "description": "The company being paid."
          },
          "project_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "The job: the deal's title, else the sale's address; null without\neither."
          },
          "method": {
            "$ref": "#/components/schemas/PaymentMethod",
            "description": "How the customer pays."
          },
          "status": {
            "$ref": "#/components/schemas/CustomerPaymentStatus",
            "description": "Where the payment is: only `created` can be paid."
          },
          "amount_cents": {
            "type": "integer",
            "format": "int32",
            "description": "What goes toward the job, in US cents."
          },
          "customer_fee_cents": {
            "type": "integer",
            "format": "int32",
            "description": "The customer's part of the fee, added on top."
          },
          "customer_fee_bps": {
            "type": "integer",
            "format": "int32",
            "description": "That part as a share of the amount, in basis points (50 = 0.5%)."
          },
          "total_cents": {
            "type": "integer",
            "format": "int32",
            "description": "What the customer is charged: the two above together."
          },
          "demo": {
            "type": "boolean",
            "description": "Demo mode: nothing is charged, and the page reports the outcome\nitself with `POST /v1/public/pay/{payment_id}/demo`."
          },
          "confirm_bank": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/ConfirmBank",
                "description": "A bank transfer whose customer typed the routing and account numbers\nand has yet to confirm the account with the small deposit Stripe\nsent: the transfer starts once they do. Left out otherwise."
              },
              {
                "type": "null"
              }
            ]
          },
          "bank_app": {
            "type": "boolean",
            "description": "The customer can send the payment from their own bank app instead of\nsigning in to their bank (`POST\n/v1/public/pay/{payment_id}/bank-transfer`): an unpaid ACH link of a\ncompany whose Stripe account takes US bank transfers."
          }
        }
      },
      "PaymentFeeSetting": {
        "type": "object",
        "description": "How one payment method's fee is split.",
        "required": [
          "rate_bps",
          "customer_share_bps",
          "min_fee_cents",
          "locked"
        ],
        "properties": {
          "rate_bps": {
            "type": "integer",
            "format": "int32",
            "description": "The fee on a payment, in basis points (300 = 3%)."
          },
          "customer_share_bps": {
            "type": "integer",
            "format": "int32",
            "description": "The customer's part of it, `0..=rate_bps`; the company pays the rest."
          },
          "min_fee_cents": {
            "type": "integer",
            "format": "int64",
            "description": "The least the fee on one payment can be, in US cents (900 = $9 for\ncards, 0 for ACH): a small payment's fee is this, not the rate."
          },
          "max_fee_cents": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int64",
            "description": "The most the fee on one payment can be, in US cents (2000 = $20 for\nACH); null has no maximum (cards)."
          },
          "locked": {
            "type": "boolean",
            "description": "The split cannot be changed: the company pays the whole fee. True for\ncards for now."
          }
        }
      },
      "PaymentFees": {
        "type": "object",
        "description": "Each method's fee.",
        "required": [
          "card",
          "ach",
          "card_extra"
        ],
        "properties": {
          "card": {
            "$ref": "#/components/schemas/PaymentFeeSetting",
            "description": "Card payments."
          },
          "ach": {
            "$ref": "#/components/schemas/PaymentFeeSetting",
            "description": "ACH bank transfers."
          },
          "card_extra": {
            "type": "boolean",
            "description": "\"Add 3% on top of card payments\" is on (Admin → Company → Payments):\na card payment offers \"Add 3% on top\", already ticked. Off, it is not\noffered and `add_card_fee` is refused."
          }
        }
      },
      "PaymentFeesInput": {
        "type": "object",
        "description": "Body of `PUT /v1/company/payment-settings`.",
        "required": [
          "card_customer_share_bps",
          "ach_customer_share_bps"
        ],
        "properties": {
          "card_customer_share_bps": {
            "type": "integer",
            "format": "int32",
            "description": "The customer's part of the 3% card fee, in basis points. Must be 0:\nthe card fee cannot be passed on yet."
          },
          "ach_customer_share_bps": {
            "type": "integer",
            "format": "int32",
            "description": "The customer's part of the 1% ACH fee, in basis points: 0 to 100 in\nsteps of 10 (0.1%). The company pays the rest."
          },
          "card_extra": {
            "type": [
              "boolean",
              "null"
            ],
            "description": "\"Add 3% on top of card payments\" (see `PaymentFees::card_extra`).\nLeft out: unchanged."
          }
        },
        "additionalProperties": false
      },
      "PaymentInput": {
        "type": "object",
        "description": "What the Record payment dialog sends.",
        "required": [
          "amount",
          "payment_date"
        ],
        "properties": {
          "amount": {
            "type": "number",
            "format": "double",
            "description": "The amount received, in dollars; above 0 and, on an invoice, no more\nthan its open balance."
          },
          "payment_date": {
            "type": "string",
            "description": "When it was received, `YYYY-MM-DD`."
          },
          "method_id": {
            "type": [
              "string",
              "null"
            ],
            "description": "The `QuickBooks` payment method's id (`GET /v1/payment-options`), for\na company connected to `QuickBooks`."
          },
          "method": {
            "type": [
              "string",
              "null"
            ],
            "description": "The payment method's name, for a company without `QuickBooks`."
          },
          "deposit_account_id": {
            "type": [
              "string",
              "null"
            ],
            "description": "The `QuickBooks` account the money goes to; `QuickBooks` companies\nonly. Left out, `QuickBooks` uses Undeposited Funds."
          },
          "reference": {
            "type": [
              "string",
              "null"
            ],
            "description": "A check number or other reference; at most 21 characters for a\n`QuickBooks` payment, 64 otherwise."
          },
          "memo": {
            "type": [
              "string",
              "null"
            ],
            "description": "A note for the office; never shown to the customer."
          }
        }
      },
      "PaymentLinks": {
        "type": "object",
        "description": "What a payment is for, to open it.",
        "required": [
          "quotes"
        ],
        "properties": {
          "deal_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int64",
            "description": "The deal; null when the payment is for none."
          },
          "project_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "The deal's or the sale's project; null without one."
          },
          "quotes": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PaymentQuote"
            },
            "description": "The quotes: those on the paid `QuickBooks` invoice, else the deal's\nsold ones (all of the deal's while none is sold), else those on the\nsale's events."
          }
        }
      },
      "PaymentMethod": {
        "type": "string",
        "description": "How a customer pays.",
        "enum": [
          "card",
          "ach"
        ]
      },
      "PaymentMethodInput": {
        "type": "object",
        "description": "Body of `POST /v1/payment-options/methods`.",
        "required": [
          "name"
        ],
        "properties": {
          "name": {
            "type": "string",
            "description": "The new method's name, at most 60 characters."
          }
        }
      },
      "PaymentMethodOption": {
        "type": "object",
        "description": "A payment method to pick.",
        "required": [
          "name"
        ],
        "properties": {
          "id": {
            "type": [
              "string",
              "null"
            ],
            "description": "Null in the company's own list (send its `name`); the `QuickBooks`\nid in lists read from `QuickBooks`."
          },
          "name": {
            "type": "string",
            "description": "The name shown in the list, e.g. Check."
          }
        }
      },
      "PaymentMethodsInput": {
        "type": "object",
        "description": "Body of `PUT /v1/payment-options/methods`.",
        "required": [
          "names"
        ],
        "properties": {
          "names": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "The whole list, in the order shown; at most 30 names."
          }
        }
      },
      "PaymentOptions": {
        "type": "object",
        "description": "`GET /v1/payment-options`.",
        "required": [
          "quickbooks",
          "methods",
          "accounts"
        ],
        "properties": {
          "quickbooks": {
            "type": "boolean",
            "description": "The company is connected to `QuickBooks`: the deposit accounts are\nread from it."
          },
          "methods": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PaymentMethodOption"
            },
            "description": "The company's own payment methods, by name."
          },
          "accounts": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/DepositAccount"
            },
            "description": "Bank accounts and Undeposited Funds; empty without `QuickBooks`."
          },
          "default_account_id": {
            "type": [
              "string",
              "null"
            ],
            "description": "The account Record payment starts with; null when none is chosen."
          }
        }
      },
      "PaymentPage": {
        "type": "object",
        "description": "What the payments page shows for a company.",
        "required": [
          "company_name",
          "price_cents"
        ],
        "properties": {
          "company_name": {
            "type": "string",
            "description": "The company's name."
          },
          "price_cents": {
            "type": "integer",
            "format": "int32",
            "description": "The monthly price a new subscription starts at, in US cents."
          },
          "first_payment_on": {
            "type": [
              "string",
              "null"
            ],
            "format": "date",
            "description": "The day a new subscription is first charged (the card is saved at\ncheckout); null when it is charged at checkout."
          },
          "subscription": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/SubscriptionSummary",
                "description": "The company's live subscription (active, trialing, past due, unpaid,\npaused or incomplete, possibly set to cancel); null when it has none\nand can subscribe."
              },
              {
                "type": "null"
              }
            ]
          }
        }
      },
      "PaymentQuote": {
        "type": "object",
        "description": "A quote the payment is for.",
        "required": [
          "id"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "The quote's id."
          },
          "name": {
            "type": [
              "string",
              "null"
            ],
            "description": "Its name; null without one."
          }
        }
      },
      "PaymentStatus": {
        "type": "string",
        "description": "How much of a job's invoices is paid.",
        "enum": [
          "none",
          "unpaid",
          "partial",
          "paid"
        ]
      },
      "PaymentsBadge": {
        "type": "object",
        "description": "Whether the company takes customer payments now.",
        "required": [
          "enabled",
          "connected"
        ],
        "properties": {
          "enabled": {
            "type": "boolean",
            "description": "Customer payments are turned on for the company (by the platform)."
          },
          "connected": {
            "type": "boolean",
            "description": "Its bank account is connected and approved by Stripe, as last kept\n(`bank.status` `connected` of `GET /v1/company/payment-settings`;\nthis part never asks Stripe)."
          }
        }
      },
      "Payout": {
        "type": "object",
        "description": "Commissions paid to the rep, or not after all.",
        "required": [
          "ids"
        ],
        "properties": {
          "ids": {
            "type": "array",
            "items": {
              "type": "integer",
              "format": "int32"
            },
            "description": "Commission row ids."
          },
          "paid": {
            "type": "boolean",
            "description": "Paid to the rep (default), or false to take that back."
          }
        },
        "additionalProperties": false
      },
      "PayrollRep": {
        "type": "object",
        "description": "One rep's paycheck on a payroll date.",
        "required": [
          "rep",
          "commission",
          "bonus",
          "base",
          "jobPay",
          "extras",
          "total"
        ],
        "properties": {
          "userId": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "The rep."
          },
          "rep": {
            "type": "string",
            "description": "Their name."
          },
          "commission": {
            "type": "number",
            "format": "double",
            "description": "Paid commissions."
          },
          "bonus": {
            "type": "number",
            "format": "double",
            "description": "Monthly goal bonuses."
          },
          "base": {
            "type": "number",
            "format": "double",
            "description": "Base pay due that day."
          },
          "jobPay": {
            "type": "number",
            "format": "double",
            "description": "Template and install pay (see `routes::job_pay`)."
          },
          "extras": {
            "type": "number",
            "format": "double",
            "description": "Extras an admin added by hand: reviews, gas, unused vacation days, and\ndeductions (negative)."
          },
          "total": {
            "type": "number",
            "format": "double",
            "description": "All of it."
          }
        }
      },
      "PayrollWeek": {
        "type": "object",
        "description": "A payroll date's paychecks.",
        "required": [
          "payrollDate",
          "reps"
        ],
        "properties": {
          "payrollDate": {
            "type": "string",
            "description": "The payroll date (YYYY-MM-DD)."
          },
          "reps": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PayrollRep"
            },
            "description": "Per rep."
          }
        }
      },
      "Pending": {
        "type": "object",
        "description": "A scheduled message.",
        "required": [
          "id",
          "send_at",
          "text",
          "message",
          "cancel_if_customer_messages"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int64",
            "description": "The row."
          },
          "send_at": {
            "type": "string",
            "format": "date-time",
            "description": "When it goes out (UTC)."
          },
          "text": {
            "type": "string",
            "description": "The text; for an email the subject and body, shortened."
          },
          "message": {
            "type": "string",
            "description": "The full text or email body."
          },
          "cancel_if_customer_messages": {
            "type": "boolean",
            "description": "Dropped if the customer writes first."
          }
        }
      },
      "PendingLogin": {
        "type": "object",
        "description": "A sign-in by email or text in progress.",
        "required": [
          "code_sent",
          "can_text"
        ],
        "properties": {
          "code_sent": {
            "type": "boolean",
            "description": "A code was sent (or would have been) and has not expired."
          },
          "masked_email": {
            "type": [
              "string",
              "null"
            ],
            "description": "Where it went, masked: the email (`a***@example.com`), or the phone\n(`***-***-0188`) for a texted code."
          },
          "code_channel": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/CodeChannel",
                "description": "How it went; null without one."
              },
              {
                "type": "null"
              }
            ]
          },
          "can_text": {
            "type": "boolean",
            "description": "The company can text codes (offer \"Text me a code\")."
          }
        }
      },
      "PendingPictures": {
        "type": "object",
        "description": "How many stone pictures still show an older background.",
        "required": [
          "pending"
        ],
        "properties": {
          "pending": {
            "type": "integer",
            "format": "int64",
            "description": "Stone pictures `POST /v1/stones/settings/slab-background/apply` has\nyet to remake."
          }
        }
      },
      "Permissions": {
        "type": "object",
        "description": "What the caller may do with projects.",
        "required": [
          "viewAll",
          "convert",
          "production",
          "markPaid",
          "manage",
          "delete"
        ],
        "properties": {
          "viewAll": {
            "type": "boolean",
            "description": "Sees every project."
          },
          "convert": {
            "type": "boolean",
            "description": "Turns deals into projects (their own, or any for managers)."
          },
          "production": {
            "type": "boolean",
            "description": "Moves projects forward, links transactions, books appointments."
          },
          "markPaid": {
            "type": "boolean",
            "description": "Confirms payment."
          },
          "manage": {
            "type": "boolean",
            "description": "Cancels, puts on hold, archives, corrects stages, picks the owner."
          },
          "delete": {
            "type": "boolean",
            "description": "Deletes a project for good (admins, Managers, Sales Managers)."
          }
        }
      },
      "Person": {
        "type": "object",
        "description": "Someone in the company.",
        "required": [
          "id",
          "name"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "Its id."
          },
          "name": {
            "type": "string",
            "description": "Its name."
          }
        }
      },
      "PersonColor": {
        "type": "object",
        "description": "Body of `PUT /v1/schedule/people/{user_id}/color`.",
        "required": [
          "color"
        ],
        "properties": {
          "color": {
            "type": "string",
            "description": "One of the schedule colors (`blue`, `red`, ...)."
          }
        }
      },
      "Phone2Taken": {
        "type": "object",
        "description": "`409` when phone 2 would be replaced.",
        "required": [
          "error",
          "phone2"
        ],
        "properties": {
          "error": {
            "type": "string",
            "description": "`phone_2_taken`."
          },
          "phone2": {
            "type": "string",
            "description": "The phone 2 that would be replaced (its last 10 digits)."
          }
        }
      },
      "PhoneActiveCompany": {
        "type": "object",
        "description": "Body of `PUT /v1/phone/active-company`.",
        "required": [
          "companyId"
        ],
        "properties": {
          "companyId": {
            "type": "integer",
            "format": "int32",
            "description": "One of `PhoneUser.companies`."
          }
        }
      },
      "PhoneAdminStatus": {
        "type": "object",
        "description": "The company's calling status.",
        "required": [
          "enabled",
          "recordingMode",
          "configured"
        ],
        "properties": {
          "enabled": {
            "type": "boolean",
            "description": "Calling is switched on for the company (the superuser's kill switch)."
          },
          "recordingMode": {
            "$ref": "#/components/schemas/RecordingMode",
            "description": "Which calls are recorded: `off`, `inbound` or `both`."
          },
          "configured": {
            "type": "boolean",
            "description": "Telnyx is set up for the company (its TeXML app and credential\nconnection are saved): numbers can be imported, phones can call."
          }
        }
      },
      "PhoneAdminUser": {
        "type": "object",
        "description": "A user of the company who may be given a number.",
        "required": [
          "id",
          "name",
          "recordingVoice",
          "hasNumber"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "User id."
          },
          "name": {
            "type": "string",
            "description": "Their name, else their email."
          },
          "recordingVoice": {
            "type": "boolean",
            "description": "Their calls say the recording notice (`recording_voice`; on by default)."
          },
          "hasNumber": {
            "type": "boolean",
            "description": "They have a number: one assigned to them or one their position gives."
          }
        }
      },
      "PhoneAppBadge": {
        "type": "object",
        "description": "Whether the caller uses the phone app.",
        "required": [
          "signed_in"
        ],
        "properties": {
          "signed_in": {
            "type": "boolean",
            "description": "The caller is signed in to the Granite Manager app on an Android\nphone or iPhone in this company (not signed out). The app brings\nleads and alerts itself, so the CRM hides Telegram for them."
          }
        }
      },
      "PhoneCompany": {
        "type": "object",
        "description": "A company the app may switch to.",
        "required": [
          "id",
          "name"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "Company id."
          },
          "name": {
            "type": "string",
            "description": "Its name."
          }
        }
      },
      "PhoneCustomer": {
        "type": "object",
        "description": "The customer a phone now belongs to.",
        "required": [
          "customer_id",
          "customer_name"
        ],
        "properties": {
          "customer_id": {
            "type": "integer",
            "format": "int32",
            "description": "The customer."
          },
          "customer_name": {
            "type": "string",
            "description": "Their name."
          }
        }
      },
      "PhoneDevice": {
        "type": "object",
        "description": "This session's phone, as the app sees it.",
        "required": [
          "id",
          "pushTokenSet",
          "createdAt"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int64",
            "description": "The phone device: use it in `/v1/phone/devices/{id}/...`."
          },
          "sipUsername": {
            "type": [
              "string",
              "null"
            ],
            "description": "The phone's SIP user on Telnyx (`gencred...`); null while calling is\noff for the company or its credential is not made yet."
          },
          "pushTokenSet": {
            "type": "boolean",
            "description": "We have the phone's FCM token (for missed-call and other pushes)."
          },
          "createdAt": {
            "type": "string",
            "format": "date-time",
            "description": "When the phone was registered."
          }
        }
      },
      "PhoneDigits": {
        "oneOf": [
          {
            "type": "integer",
            "format": "int64",
            "minimum": 0
          },
          {
            "type": "string"
          }
        ],
        "description": "The customer's phone, as digits or a number."
      },
      "PhoneInput": {
        "type": "object",
        "description": "Body of the phone routes.",
        "required": [
          "phone_digits"
        ],
        "properties": {
          "phone_digits": {
            "type": "string",
            "description": "10 to 15 digits."
          }
        }
      },
      "PhoneJobRun": {
        "type": "object",
        "description": "What a run did.",
        "required": [
          "processed",
          "phones_signed_out",
          "sessions_expired",
          "credentials_deleted",
          "events_purged",
          "calls_closed",
          "phone_index_refreshed",
          "phone_index_filled",
          "recordings_copied",
          "recordings_failed",
          "telnyx_recordings_deleted",
          "notes_written",
          "notes_skipped",
          "notes_failed",
          "call_points"
        ],
        "properties": {
          "processed": {
            "type": "integer",
            "description": "The work done: the counts below together (old callbacks and the\ncustomer phone index not counted).",
            "minimum": 0
          },
          "phones_signed_out": {
            "type": "integer",
            "description": "Phones signed out because their user may no longer use Granite\nPhone (or their company was deleted).",
            "minimum": 0
          },
          "sessions_expired": {
            "type": "integer",
            "description": "Browser phones signed out because their CRM sign-in ended.",
            "minimum": 0
          },
          "credentials_deleted": {
            "type": "integer",
            "description": "Telnyx credentials of signed-out phones deleted (left over from a\nfailed delete).",
            "minimum": 0
          },
          "events_purged": {
            "type": "integer",
            "format": "int64",
            "description": "Telnyx callbacks older than 30 days deleted.",
            "minimum": 0
          },
          "ai_chat_counts_purged": {
            "type": "integer",
            "format": "int64",
            "description": "AI chat question counts older than an hour deleted (the hourly\nquestion limit's); left out when none.",
            "minimum": 0
          },
          "calls_closed": {
            "type": "integer",
            "format": "int64",
            "description": "Calls closed because Telnyx never reported their end.",
            "minimum": 0
          },
          "phone_index_refreshed": {
            "type": "integer",
            "description": "Customers whose rows in the customer phone index (which matches\ncalls to customers) were rewritten because they changed, were added\nor were deleted since the last run. One that changed in the last 2\nminutes is read again by the next run and counted again.",
            "minimum": 0
          },
          "phone_index_filled": {
            "type": "integer",
            "description": "Customers read by the first fill of a company's phone index (each\ncompany's index is filled once, at most 5,000 customers a run).",
            "minimum": 0
          },
          "recordings_copied": {
            "type": "integer",
            "description": "Recordings copied to our bucket on a retry.",
            "minimum": 0
          },
          "recordings_failed": {
            "type": "integer",
            "description": "Recordings given up (5 copies failed, or not the call's).",
            "minimum": 0
          },
          "telnyx_recordings_deleted": {
            "type": "integer",
            "description": "Telnyx's copies of copied recordings deleted on a retry.",
            "minimum": 0
          },
          "notes_written": {
            "type": "integer",
            "description": "AI notes written (added to the call, and to its deal when it has one).",
            "minimum": 0
          },
          "notes_skipped": {
            "type": "integer",
            "description": "Calls with nothing to note (no speech, a mailbox greeting only, or\nnothing about the job).",
            "minimum": 0
          },
          "notes_failed": {
            "type": "integer",
            "description": "AI notes given up (5 attempts failed).",
            "minimum": 0
          },
          "call_points": {
            "type": "integer",
            "description": "Answered outbound calls written to the call points.",
            "minimum": 0
          },
          "port_orders_refreshed": {
            "type": "integer",
            "description": "Port-in orders read again from Telnyx (`phone::porting`); left out\nwhen none.",
            "minimum": 0
          },
          "port_orders_completed": {
            "type": "integer",
            "description": "Ported orders whose numbers were added to the company and set up\non Telnyx; left out when none.",
            "minimum": 0
          },
          "text_statuses_checked": {
            "type": "integer",
            "description": "Texts sent through Telnyx whose status was read again from Telnyx;\nleft out when none.",
            "minimum": 0
          },
          "tendlc_refreshed": {
            "type": "integer",
            "description": "10DLC texting registrations read again from Telnyx\n(`phone::tendlc_registry`); left out when none.",
            "minimum": 0
          },
          "tendlc_numbers_refreshed": {
            "type": "integer",
            "description": "10DLC number assignments read again from Telnyx; left out when none.",
            "minimum": 0
          },
          "tendlc_numbers_assigned": {
            "type": "integer",
            "description": "Numbers assigned to their company's approved 10DLC campaign by themselves; left out when none.",
            "minimum": 0
          }
        }
      },
      "PhoneOwner": {
        "type": "object",
        "description": "`GET /v1/customers/by-phone`: the customer, if any.",
        "properties": {
          "customer_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "The customer with this phone (or second phone); null when none."
          },
          "customer_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "Their name."
          }
        }
      },
      "PhoneSettings": {
        "type": "object",
        "description": "The user's phone settings, as the app shows them.",
        "required": [
          "aiNotes",
          "cellVerified",
          "cellFallback",
          "ringTimeoutSecs",
          "forwardAll",
          "forwardAllTo",
          "displayNumber",
          "unknownShowMine",
          "announceDirect",
          "announceShared",
          "announceLineName",
          "requirePin",
          "holdMusic"
        ],
        "properties": {
          "defaultCallerNumberId": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "The caller ID the user chose as their default (one of\n`GET /v1/phone/caller-ids`); null when they chose none or it is no\nlonger theirs."
          },
          "aiNotes": {
            "type": "boolean",
            "description": "Transcribe my recorded calls and add an AI note to the deal."
          },
          "workingHours": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/WorkingHours",
                "description": "When the user takes calls; null = always."
              },
              {
                "type": "null"
              }
            ]
          },
          "cellNumber": {
            "type": [
              "string",
              "null"
            ],
            "description": "The user's verified cell, E.164; null until one is verified\n(`POST /v1/phone/cell/verify`, then `/confirm`)."
          },
          "cellVerified": {
            "type": "boolean",
            "description": "A cell number is verified."
          },
          "cellFallback": {
            "type": "boolean",
            "description": "Ring the verified cell after about 15 seconds, and when the app has\nno data connection."
          },
          "ringTimeoutSecs": {
            "type": "integer",
            "format": "int64",
            "description": "How long calls ring the user's phones, in seconds (15 to 60, default\n25)."
          },
          "forwardAll": {
            "type": "boolean",
            "description": "\"Forward all calls\" is on: calls to my own direct line go to\n`forwardAllTo`; on shared and main lines my phones just don't ring.\nDo not disturb wins over it."
          },
          "forwardAllTo": {
            "$ref": "#/components/schemas/ForwardAllTo",
            "description": "Where \"Forward all calls\" sends them: `voicemail` or `number`."
          },
          "forwardAllNumber": {
            "type": [
              "string",
              "null"
            ],
            "description": "With `number`: where to, E.164 (US or Canada); null when none was\nset."
          },
          "displayNumber": {
            "$ref": "#/components/schemas/DisplayNumber",
            "description": "What my phones show for an incoming call: `caller` (their number) or\n`called` (the company number they called)."
          },
          "unknownShowMine": {
            "type": "boolean",
            "description": "When the caller hides their number, show the number they called."
          },
          "announceDirect": {
            "type": "boolean",
            "description": "Hear an announcement (\"Call for <line> from <caller>\") before calls\nto my direct lines connect."
          },
          "announceShared": {
            "type": "boolean",
            "description": "The same for calls to shared lines and the main line."
          },
          "announceLineName": {
            "type": "boolean",
            "description": "The announcement names the line called."
          },
          "requirePin": {
            "type": "boolean",
            "description": "My fallback cell asks for my 4-digit PIN instead of \"press 1\"\nbefore it takes a call."
          },
          "holdMusic": {
            "type": "string",
            "description": "What callers hear while I have them on hold: a built-in track id\n(`GET /v1/phone/hold-music`), `custom` (my upload) or `none`\n(silence)."
          },
          "holdMusicUrl": {
            "type": [
              "string",
              "null"
            ],
            "description": "My uploaded track's URL (MP3 or WAV), kept while another choice is\nmade so it can be chosen again; null until I upload one. It plays\nonly with `custom`."
          },
          "holdMusicName": {
            "type": [
              "string",
              "null"
            ],
            "description": "The uploaded file's name, as shown; null without an upload."
          }
        }
      },
      "PhoneUser": {
        "type": "object",
        "description": "The signed-in user, as the phone app shows them.",
        "required": [
          "id",
          "name",
          "email",
          "companyId",
          "companyName",
          "isAdmin",
          "hasProjectsBoard",
          "customerPayments",
          "isShopManager",
          "isSchedulingManager",
          "isInstaller",
          "isSuperuser",
          "companies"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "User id."
          },
          "name": {
            "type": "string",
            "description": "Display name; empty when the user has none."
          },
          "email": {
            "type": "string",
            "description": "Login email."
          },
          "companyId": {
            "type": "integer",
            "format": "int32",
            "description": "The user's company (every phone request acts in it)."
          },
          "companyName": {
            "type": "string",
            "description": "That company's name."
          },
          "isAdmin": {
            "type": "boolean",
            "description": "Company admin (or superuser / super admin): sees the admin screens."
          },
          "portal": {
            "type": [
              "string",
              "null"
            ],
            "description": "The portal a position locks the user into on the web, if any.\n\nThe same rule as `GET /v1/app/shell` `portal` (`installer`,\n`check-in`, `marketing`, `shop_worker`, `template`); null for everyone\nelse. For `installer` and `template` the app shows only the user's own\nschedule (`GET /v1/me/schedule`) and does not set the phone up for\ncalls."
          },
          "skills": {
            "type": [
              "array",
              "null"
            ],
            "items": {
              "type": "string"
            },
            "description": "The skills the user's positions give them (Position access), as\n`GET /v1/app/shell` `skills` has them: e.g. without `edit_quotes` the\napp shows quotes read-only. Null: every skill (admins, superusers and\npeople without a configurable position)."
          },
          "hasProjectsBoard": {
            "type": "boolean",
            "description": "The user has a Projects board, as `GET /v1/app/shell`\n`has_projects_board` has it: the app shows its Projects tab (`GET\n/v1/projects` with the device token) only then."
          },
          "customerPayments": {
            "type": "boolean",
            "description": "Customer payments are turned on for the company: the app shows its\nPayments tab (`GET /v1/payments`) only then."
          },
          "sections": {
            "type": [
              "array",
              "null"
            ],
            "items": {
              "type": "string"
            },
            "description": "The tabs the user's positions open when the company limits them\n(Position access), as `GET /v1/app/shell` `sections` has them (e.g.\n`transactions`, `samples`, `schedule`, `stones`): the app hides the\nothers. Null: nothing is limited."
          },
          "isShopManager": {
            "type": "boolean",
            "description": "The user is a Shop Manager (`GET /v1/app/shell` `is_shop_manager`):\nthe app shows Maintenance, as a shop worker's does."
          },
          "isSchedulingManager": {
            "type": "boolean",
            "description": "The user is a Scheduling Manager (`GET /v1/app/shell`\n`is_scheduling_manager`): the app shows an event's Scheduling text\nand Scheduling call."
          },
          "isInstaller": {
            "type": "boolean",
            "description": "The user is an Installer (`GET /v1/app/shell` `is_installer`): beside\nShop Worker, Schedule switches between their own jobs and the shop's."
          },
          "isSuperuser": {
            "type": "boolean",
            "description": "A superuser of Granite Manager: the app shows its Support inbox\n(`/v1/support/agent`; usable once signed in with two-step sign-in)."
          },
          "photoUrl": {
            "type": [
              "string",
              "null"
            ],
            "description": "The user's own picture (`PUT /v1/me/photo`); null when they have\nnone (the app shows their initials)."
          },
          "companies": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PhoneCompany"
            },
            "description": "The companies an installer or template guy may switch the app\nbetween (`PUT /v1/phone/active-company`): their own first, then those\na super admin gave them the position in. Empty when there is only one."
          }
        }
      },
      "PhotoInput": {
        "type": "object",
        "description": "Body of `PUT /v1/me/photo`.",
        "required": [
          "url"
        ],
        "properties": {
          "url": {
            "type": "string",
            "description": "The `url` that `POST /v1/uploads` (folder `user-photos`) returned,\nafter the picture was `PUT` to its `upload_url`."
          }
        },
        "additionalProperties": false
      },
      "PhotoStage": {
        "type": "string",
        "description": "Which photos of the job a file is, on the crew's job page.",
        "enum": [
          "before",
          "installed"
        ]
      },
      "PhotosInput": {
        "type": "object",
        "description": "Body of `POST /v1/events/{id}/photos`.",
        "required": [
          "urls"
        ],
        "properties": {
          "urls": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Files uploaded to the `events` folder (`POST /v1/uploads`)."
          },
          "for_customer": {
            "type": "boolean",
            "description": "Job photos the customer sees on their own page (the job card's\nPhotos button). Default: only inside the event."
          },
          "stage": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/PhotoStage",
                "description": "On the crew's job page: `before` or `installed` photos. Default: none."
              },
              {
                "type": "null"
              }
            ]
          }
        }
      },
      "PickedFile": {
        "type": "object",
        "description": "A file uploaded to `sms-uploads/`.",
        "required": [
          "url"
        ],
        "properties": {
          "url": {
            "type": "string",
            "description": "Public URL `POST /v1/uploads` gave for it."
          },
          "filename": {
            "type": "string",
            "description": "The name it was picked with (shown to the customer for documents)."
          }
        }
      },
      "PictureLink": {
        "type": "object",
        "description": "Where a picture is (`link=true`).",
        "required": [
          "url"
        ],
        "properties": {
          "url": {
            "type": "string",
            "description": "The picture, valid an hour."
          }
        }
      },
      "Pipeline": {
        "type": "object",
        "description": "A pipeline with its stages, as the admin settings page shows it.",
        "required": [
          "id",
          "name",
          "is_displayed",
          "is_default",
          "lists"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "Group id."
          },
          "name": {
            "type": "string",
            "description": "Name."
          },
          "is_displayed": {
            "type": "boolean",
            "description": "Shown on the boards."
          },
          "is_default": {
            "type": "boolean",
            "description": "New deals start in it."
          },
          "lists": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PipelineStage"
            },
            "description": "Live stages, in board order."
          }
        }
      },
      "PipelinePatch": {
        "type": "object",
        "description": "Body of `PATCH /v1/deal-pipelines/{id}`.",
        "properties": {
          "name": {
            "type": [
              "string",
              "null"
            ],
            "description": "New name (1–255 characters)."
          },
          "is_displayed": {
            "type": [
              "boolean",
              "null"
            ],
            "description": "Show or hide it on the boards."
          },
          "is_default": {
            "type": [
              "boolean",
              "null"
            ],
            "description": "`true` makes it the company's default (\"Assign leads here\");\n`false` turns that off, leaving the company with no default: its\nsales managers then pick the pipeline of each lead on the website's\nLeads page (Telegram and phone assignments use the oldest pipeline)."
          }
        },
        "additionalProperties": false
      },
      "PipelineStage": {
        "type": "object",
        "description": "A stage of a pipeline.",
        "required": [
          "id",
          "name",
          "position",
          "deal_count",
          "open_deal_count"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "List id."
          },
          "name": {
            "type": "string",
            "description": "Name."
          },
          "position": {
            "type": "integer",
            "format": "int32",
            "description": "Order on the board."
          },
          "deal_count": {
            "type": "integer",
            "format": "int64",
            "description": "Live (not deleted) deals in the stage, open, won and lost. Deleting\nthe stage or its pipeline takes them off every board: the admin page\nwarns with this number."
          },
          "open_deal_count": {
            "type": "integer",
            "format": "int64",
            "description": "Of `deal_count`, the open ones (neither won nor lost)."
          }
        }
      },
      "PlaceDetails": {
        "type": "object",
        "description": "`GET /v1/places/{place_id}`.",
        "properties": {
          "place_id": {
            "type": [
              "string",
              "null"
            ],
            "description": "Google place id."
          },
          "formatted_address": {
            "type": [
              "string",
              "null"
            ],
            "description": "Full address."
          },
          "zip_code": {
            "type": [
              "string",
              "null"
            ],
            "description": "ZIP code."
          },
          "city": {
            "type": [
              "string",
              "null"
            ],
            "description": "City."
          },
          "state": {
            "type": [
              "string",
              "null"
            ],
            "description": "Two-letter state."
          },
          "country": {
            "type": [
              "string",
              "null"
            ],
            "description": "Two-letter country."
          }
        }
      },
      "Placement": {
        "type": "object",
        "description": "Where a request belongs. An `add` has either `instruction_id` (an\nexisting page) or `new_title` (a page to create); a `change` has\n`instruction_id` and `changes`.",
        "required": [
          "action",
          "text",
          "in_list",
          "changes"
        ],
        "properties": {
          "action": {
            "allOf": [
              {
                "type": "string",
                "description": "What the request does to the instructions.",
                "enum": [
                  "add",
                  "change",
                  "ideas",
                  "no_offers",
                  "ask"
                ]
              },
              {
                "type": "object",
                "description": "`add`, `change`, `ideas`, `no_offers` or `ask`."
              }
            ]
          },
          "text": {
            "type": "string",
            "description": "`add`: the note as it will read on the page: plain lines, a list item\nper line starting with `- ` or `1. `. Only the admin's own words, with\nspelling and punctuation fixed; the text as typed when the AI's\nversion added or dropped anything. Empty for a `change`."
          },
          "instruction_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "The existing page the request is about."
          },
          "block": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "With `instruction_id`: a part of the page, counted from 1 over the\npage's top-level blocks, each list item its own part: the part an\n`add` follows, 0 to put the note first.",
            "minimum": 0
          },
          "block_text": {
            "type": [
              "string",
              "null"
            ],
            "description": "With `block` above 0: how that part's text starts, to find it again\nin the page."
          },
          "in_list": {
            "type": "boolean",
            "description": "`add`: the note joins the list of the part it follows, as new items."
          },
          "changes": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PlacementChange"
            },
            "description": "`change`: the words to replace on the page and what replaces them,\none entry per place; empty for an `add`."
          },
          "new_title": {
            "type": [
              "string",
              "null"
            ],
            "description": "`add` without `instruction_id`: the title of the new page."
          },
          "parent_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "With `new_title`: the page the new one sits under; null at the top\nlevel."
          },
          "question": {
            "type": [
              "string",
              "null"
            ],
            "description": "`ask`: the one short question about the details the note leaves out\n(\"How much is the deposit, and when is it paid?\")."
          }
        }
      },
      "PlacementChange": {
        "type": "object",
        "description": "One replacement of a `change`.",
        "required": [
          "block",
          "find",
          "replace"
        ],
        "properties": {
          "block": {
            "type": "integer",
            "format": "int32",
            "description": "The part that holds `find`, counted like `Placement.block`.",
            "minimum": 0
          },
          "block_text": {
            "type": [
              "string",
              "null"
            ],
            "description": "How that part's text starts, to find it again in the page."
          },
          "find": {
            "type": "string",
            "description": "The words to replace, exactly as the part has them (spaces\ncollapsed), found once in it."
          },
          "replace": {
            "type": "string",
            "description": "The words that take their place: only words of the request or of\n`find`; empty to remove them."
          }
        }
      },
      "PlacementInput": {
        "type": "object",
        "description": "Body of `POST /v1/instructions/ai-placement`.",
        "required": [
          "text"
        ],
        "properties": {
          "text": {
            "type": "string",
            "description": "What the admin wants to add, in their own words (at most 4000\ncharacters)."
          },
          "topic": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/PlacementTopic",
                "description": "The subject the admin is writing about (an idea of\n`POST /v1/instructions/ai-ideas`): additions go there unless the\nrequest is clearly about something else."
              },
              {
                "type": "null"
              }
            ]
          },
          "ask_details": {
            "type": "boolean",
            "description": "The AI may answer `ask` when the note leaves out an amount, number\nor time a rule needs. False (the default) files the note as it is."
          }
        },
        "additionalProperties": false
      },
      "PlacementTopic": {
        "type": "object",
        "description": "The subject a request belongs to.",
        "required": [
          "title"
        ],
        "properties": {
          "title": {
            "type": "string",
            "description": "The subject's title."
          },
          "instruction_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "The page it is written on, once that page exists."
          },
          "parent_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "The page a new page for it sits under."
          }
        },
        "additionalProperties": false
      },
      "PlainEmail": {
        "type": "object",
        "description": "Body of `POST /v1/superuser/emails`.",
        "required": [
          "to",
          "subject",
          "text"
        ],
        "properties": {
          "to": {
            "type": "string",
            "description": "Recipient address."
          },
          "subject": {
            "type": "string",
            "description": "Subject (required)."
          },
          "text": {
            "type": "string",
            "description": "Plain-text body (required)."
          }
        }
      },
      "Plan": {
        "type": "object",
        "description": "A plan the company can subscribe to.",
        "required": [
          "price_id",
          "name"
        ],
        "properties": {
          "price_id": {
            "type": "string",
            "description": "Stripe price id (`price_...`)."
          },
          "name": {
            "type": "string",
            "description": "Plan name to show."
          },
          "monthly_price_cents": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int64",
            "description": "Monthly price in cents, when configured."
          }
        }
      },
      "PlanChoice": {
        "type": "object",
        "description": "Body of `POST /v1/billing/checkout` and `PUT /v1/billing/subscription`.",
        "required": [
          "price_id"
        ],
        "properties": {
          "price_id": {
            "type": "string",
            "description": "A plan's `price_id` from `GET /v1/billing`."
          }
        }
      },
      "PlanItem": {
        "type": "object",
        "description": "A step of the deal's current touch plan.",
        "required": [
          "activity_id",
          "name",
          "kind",
          "is_completed"
        ],
        "properties": {
          "activity_id": {
            "type": "integer",
            "format": "int32",
            "description": "The deal activity it added."
          },
          "name": {
            "type": "string",
            "description": "What to do."
          },
          "kind": {
            "type": "string",
            "description": "`call`, `sms`, `email`, `task` or `move`."
          },
          "deadline": {
            "type": [
              "string",
              "null"
            ],
            "description": "Store wall time `YYYY-MM-DDTHH:MM:SS`."
          },
          "is_completed": {
            "type": "boolean",
            "description": "True once done."
          },
          "assigned_user_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Who does it; null: the deal's sales rep."
          },
          "assigned_user_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "Who does it; null when nobody is set."
          }
        }
      },
      "Platform": {
        "type": "string",
        "description": "The phone's operating system.",
        "enum": [
          "android",
          "ios"
        ]
      },
      "Point": {
        "type": "object",
        "description": "A geocoded point.",
        "required": [
          "lat",
          "lng"
        ],
        "properties": {
          "lat": {
            "type": "number",
            "format": "double",
            "description": "Latitude."
          },
          "lng": {
            "type": "number",
            "format": "double",
            "description": "Longitude."
          }
        }
      },
      "PointsBreakdown": {
        "type": "object",
        "description": "Points per source. Each source counts only from its own start date.",
        "required": [
          "tours",
          "deals",
          "progress",
          "calls",
          "sms",
          "emails"
        ],
        "properties": {
          "tours": {
            "type": "integer",
            "format": "int64",
            "description": "Guided tours finished (each task's points net of resets, never below 0)."
          },
          "deals": {
            "type": "integer",
            "format": "int64",
            "description": "Deals marked won (25 each)."
          },
          "progress": {
            "type": "integer",
            "format": "int64",
            "description": "Deals moved to another stage (3 per stage entered; creating a deal scores nothing)."
          },
          "calls": {
            "type": "integer",
            "format": "int64",
            "description": "Calls: 10 per conversation, 5 per voicemail left, 2 per attempt."
          },
          "sms": {
            "type": "integer",
            "format": "int64",
            "description": "Texts sent by hand (1 each)."
          },
          "emails": {
            "type": "number",
            "format": "double",
            "description": "Emails sent by hand (0.5 each)."
          }
        }
      },
      "PointsLeaderboard": {
        "type": "object",
        "description": "The company's points leaderboard for one period.",
        "required": [
          "period",
          "includes_tours",
          "entries"
        ],
        "properties": {
          "period": {
            "$ref": "#/components/schemas/LeaderboardPeriod",
            "description": "The period counted."
          },
          "includes_tours": {
            "type": "boolean",
            "description": "Whether guided tour points count (only while the company's guided\ntours are on; otherwise `breakdown.tours` is always 0)."
          },
          "entries": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/LeaderboardEntry"
            },
            "description": "The company's Sales Reps, most points first (then by name), ranked\namong themselves; reps with no points are listed with 0."
          },
          "viewer": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/LeaderboardEntry",
                "description": "The signed-in user's own row, scored the same way but not ranked, when\nthey are not one of the Sales Reps (e.g. a manager); null otherwise.\nOnly they see it."
              },
              {
                "type": "null"
              }
            ]
          }
        }
      },
      "PortActions": {
        "type": "object",
        "description": "What the admin may do with a port now.",
        "required": [
          "edit",
          "submit",
          "cancel",
          "delete",
          "comment"
        ],
        "properties": {
          "edit": {
            "type": "boolean",
            "description": "Change its details, documents or date (`PATCH`, documents)."
          },
          "submit": {
            "type": "boolean",
            "description": "Submit it (`POST .../submit`): a draft, or again after an exception."
          },
          "cancel": {
            "type": "boolean",
            "description": "Ask Telnyx to cancel it (`POST .../cancel`); false within 48 hours of\nthe confirmed port date (Telnyx support must do it then)."
          },
          "delete": {
            "type": "boolean",
            "description": "Delete it (`DELETE`): drafts only."
          },
          "comment": {
            "type": "boolean",
            "description": "Write to Telnyx's porting team (`POST .../comments`)."
          }
        }
      },
      "PortAskInput": {
        "type": "object",
        "description": "Body of `POST /v1/ai/port-ask`.",
        "required": [
          "question",
          "details"
        ],
        "properties": {
          "question": {
            "type": "string",
            "description": "What the user asks."
          },
          "step": {
            "type": "string",
            "description": "The step they are on: `business`, `documents`, `date` or `review`."
          },
          "loaAttached": {
            "type": "boolean",
            "description": "Whether the signed LOA and the recent bill are attached."
          },
          "billAttached": {
            "type": "boolean",
            "description": "Whether the recent bill is attached."
          },
          "details": {
            "$ref": "#/components/schemas/PortCheckInput",
            "description": "The Business details as typed (the PIN itself is not sent)."
          }
        }
      },
      "PortAskResult": {
        "type": "object",
        "description": "The AI's answer.",
        "required": [
          "answer"
        ],
        "properties": {
          "answer": {
            "type": "string",
            "description": "The answer, plain text."
          }
        }
      },
      "PortBillDetails": {
        "type": "object",
        "description": "What the AI read off the bill; null where the bill does not show it.",
        "properties": {
          "entityName": {
            "type": [
              "string",
              "null"
            ],
            "description": "The business name on the account."
          },
          "authPersonName": {
            "type": [
              "string",
              "null"
            ],
            "description": "The person the account is billed to."
          },
          "billingPhoneNumber": {
            "type": [
              "string",
              "null"
            ],
            "description": "The account's main (billing) number, as printed."
          },
          "accountNumber": {
            "type": [
              "string",
              "null"
            ],
            "description": "The account number, as printed."
          },
          "streetAddress": {
            "type": [
              "string",
              "null"
            ],
            "description": "The service address's street line."
          },
          "extendedAddress": {
            "type": [
              "string",
              "null"
            ],
            "description": "Suite, floor or unit."
          },
          "locality": {
            "type": [
              "string",
              "null"
            ],
            "description": "The city."
          },
          "administrativeArea": {
            "type": [
              "string",
              "null"
            ],
            "description": "The 2-letter state or province."
          },
          "postalCode": {
            "type": [
              "string",
              "null"
            ],
            "description": "The ZIP or postal code."
          },
          "countryCode": {
            "type": [
              "string",
              "null"
            ],
            "description": "`US` or `CA`."
          }
        }
      },
      "PortBillInput": {
        "type": "object",
        "description": "Body of `POST /v1/ai/port-bill-read`.",
        "required": [
          "filename",
          "contentBase64"
        ],
        "properties": {
          "filename": {
            "type": "string",
            "description": "The file's name, e.g. `bill.pdf`."
          },
          "contentBase64": {
            "type": "string",
            "description": "The bill, base64: a PDF, JPEG or PNG of at most 4 MB."
          }
        }
      },
      "PortCheckInput": {
        "type": "object",
        "description": "Body of `POST /v1/ai/port-details-check`: the form as typed.",
        "properties": {
          "phoneNumbers": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "The numbers being ported."
          },
          "oldCarrier": {
            "type": [
              "string",
              "null"
            ],
            "description": "The losing carrier, when Telnyx named it."
          },
          "entityName": {
            "type": "string",
            "description": "The business name on the current carrier's account."
          },
          "authPersonName": {
            "type": "string",
            "description": "The person allowed to authorize the port."
          },
          "billingPhoneNumber": {
            "type": "string",
            "description": "The account's billing phone number (BTN)."
          },
          "accountNumber": {
            "type": "string",
            "description": "The account number with the current carrier."
          },
          "pinSet": {
            "type": "boolean",
            "description": "Whether a PIN is typed or already saved (the PIN itself is not sent)."
          },
          "streetAddress": {
            "type": "string",
            "description": "Service address: street and number."
          },
          "extendedAddress": {
            "type": "string",
            "description": "Service address: suite, unit or floor."
          },
          "locality": {
            "type": "string",
            "description": "Service address: city."
          },
          "administrativeArea": {
            "type": "string",
            "description": "Service address: state (two letters in the US)."
          },
          "postalCode": {
            "type": "string",
            "description": "Service address: ZIP code."
          },
          "countryCode": {
            "type": "string",
            "description": "Service address: country (two letters, e.g. `US`)."
          },
          "kind": {
            "type": "string",
            "description": "`full` or `partial`."
          },
          "remainingNumbersAction": {
            "type": "string",
            "description": "`keep`, `disconnect` or empty."
          },
          "newBillingPhoneNumber": {
            "type": "string",
            "description": "The billing number the account keeps after a partial port."
          }
        }
      },
      "PortCheckIssue": {
        "type": "object",
        "description": "One problem the AI found.",
        "required": [
          "message"
        ],
        "properties": {
          "field": {
            "type": [
              "string",
              "null"
            ],
            "description": "The form field it is about, or null."
          },
          "message": {
            "type": "string",
            "description": "What to fix."
          }
        }
      },
      "PortCheckResult": {
        "type": "object",
        "description": "What the AI found; empty when everything looks right.",
        "required": [
          "issues"
        ],
        "properties": {
          "issues": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PortCheckIssue"
            },
            "description": "The problems found, in form order."
          }
        }
      },
      "PortComment": {
        "type": "object",
        "description": "A comment on a port.",
        "required": [
          "id",
          "body",
          "author"
        ],
        "properties": {
          "id": {
            "type": "string",
            "description": "Telnyx's id."
          },
          "body": {
            "type": "string",
            "description": "The text."
          },
          "author": {
            "type": "string",
            "description": "`telnyx` (Telnyx's porting team), `us` (written from here) or\n`system`."
          },
          "createdAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When; null when Telnyx did not say."
          }
        }
      },
      "PortCommentInput": {
        "type": "object",
        "description": "Body of `POST /v1/phone/admin/ports/{id}/comments`.",
        "required": [
          "body"
        ],
        "properties": {
          "body": {
            "type": "string",
            "description": "The text for Telnyx's porting team, up to 2000 characters."
          }
        }
      },
      "PortComments": {
        "type": "object",
        "description": "`GET /v1/phone/admin/ports/{id}/comments`.",
        "required": [
          "comments"
        ],
        "properties": {
          "comments": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PortComment"
            },
            "description": "Oldest first."
          }
        }
      },
      "PortCreateInput": {
        "type": "object",
        "description": "Body of `POST /v1/phone/admin/ports`.",
        "required": [
          "phoneNumbers"
        ],
        "properties": {
          "phoneNumbers": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "The numbers to move, as typed (10 digits or E.164; US and Canada\nonly), 1 to 50. None may be a company number already or in an open\nport."
          },
          "label": {
            "type": "string",
            "description": "What the numbers are called once ported, up to 100 characters; may\nbe empty."
          }
        }
      },
      "PortDetails": {
        "type": "object",
        "description": "What Telnyx has on the order now.",
        "required": [
          "endUser",
          "location",
          "portType",
          "documents",
          "numbers"
        ],
        "properties": {
          "endUser": {
            "$ref": "#/components/schemas/PortEndUser",
            "description": "The account holder (business details)."
          },
          "location": {
            "$ref": "#/components/schemas/PortLocation",
            "description": "The service address."
          },
          "portType": {
            "$ref": "#/components/schemas/PortTypeInfo",
            "description": "Full or partial port."
          },
          "documents": {
            "$ref": "#/components/schemas/PortDocuments",
            "description": "Which documents are attached."
          },
          "numbers": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PortNumber"
            },
            "description": "The numbers with Telnyx's statuses; empty in answers to changes\n(the numbers are in `order.phoneNumbers`)."
          },
          "messagingCapable": {
            "type": [
              "boolean",
              "null"
            ],
            "description": "Telnyx can move the numbers' texting too; null when it did not say."
          }
        }
      },
      "PortDocumentInput": {
        "type": "object",
        "description": "Body of `POST /v1/phone/admin/ports/{id}/documents`.",
        "required": [
          "kind",
          "filename",
          "contentBase64"
        ],
        "properties": {
          "kind": {
            "$ref": "#/components/schemas/PortDocumentKind",
            "description": "`loa`, `invoice` or `requirement`."
          },
          "requirementTypeId": {
            "type": [
              "string",
              "null"
            ],
            "description": "For `requirement`: the requirement it fulfils\n(`PortRequirement.requirementTypeId`)."
          },
          "filename": {
            "type": "string",
            "description": "The file's name, e.g. `bill.pdf`."
          },
          "contentBase64": {
            "type": "string",
            "description": "The file, base64: a PDF, JPEG or PNG of at most 4 MB."
          }
        }
      },
      "PortDocumentKind": {
        "type": "string",
        "description": "Which document is uploaded.",
        "enum": [
          "Loa",
          "Invoice",
          "Requirement"
        ]
      },
      "PortDocuments": {
        "type": "object",
        "description": "Which of the two documents every port needs are attached.",
        "required": [
          "loa",
          "invoice"
        ],
        "properties": {
          "loa": {
            "type": "boolean",
            "description": "The signed Letter of Authorization."
          },
          "invoice": {
            "type": "boolean",
            "description": "A recent bill of the current carrier."
          }
        }
      },
      "PortEndUser": {
        "type": "object",
        "description": "The current account holder at the losing carrier, as on its bill.",
        "required": [
          "pinSet"
        ],
        "properties": {
          "entityName": {
            "type": [
              "string",
              "null"
            ],
            "description": "The business (or person) the account is in the name of; null until set."
          },
          "authPersonName": {
            "type": [
              "string",
              "null"
            ],
            "description": "Who authorizes the port (signs the LOA); null until set."
          },
          "billingPhoneNumber": {
            "type": [
              "string",
              "null"
            ],
            "description": "The account's billing telephone number (BTN); null until set."
          },
          "accountNumber": {
            "type": [
              "string",
              "null"
            ],
            "description": "The account number at the losing carrier; null until set."
          },
          "pinSet": {
            "type": "boolean",
            "description": "A port-out PIN or passcode is saved (it is never sent back)."
          }
        }
      },
      "PortEndUserInput": {
        "type": "object",
        "description": "The account holder, as on the current carrier's bill.",
        "required": [
          "entityName",
          "authPersonName",
          "billingPhoneNumber",
          "accountNumber"
        ],
        "properties": {
          "entityName": {
            "type": "string",
            "description": "The business (or person) the account is in the name of, as on the\nbill; up to 100 characters."
          },
          "authPersonName": {
            "type": "string",
            "description": "Who authorizes the port and signs the LOA; up to 100 characters."
          },
          "billingPhoneNumber": {
            "type": "string",
            "description": "The account's billing telephone number (BTN), a US or Canada number."
          },
          "accountNumber": {
            "type": "string",
            "description": "The account number at the current carrier, as on the bill; up to\n100 characters."
          },
          "pinPasscode": {
            "type": [
              "string",
              "null"
            ],
            "description": "The port-out PIN or passcode, when the carrier has one (RingCentral\nand most wireless carriers do); up to 20 characters. Null or empty\nkeeps the saved one."
          }
        }
      },
      "PortFocWindow": {
        "type": "object",
        "description": "A range of times a port date may be asked for.",
        "required": [
          "startAt",
          "endAt"
        ],
        "properties": {
          "startAt": {
            "type": "string",
            "format": "date-time",
            "description": "Its start (UTC)."
          },
          "endAt": {
            "type": "string",
            "format": "date-time",
            "description": "Its end (UTC)."
          }
        }
      },
      "PortFocWindows": {
        "type": "object",
        "description": "`GET /v1/phone/admin/ports/{id}/foc-windows`.",
        "required": [
          "windows"
        ],
        "properties": {
          "windows": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PortFocWindow"
            },
            "description": "Earliest first."
          }
        }
      },
      "PortKind": {
        "type": "string",
        "description": "Whether every number of the account moves.",
        "enum": [
          "Full",
          "Partial"
        ]
      },
      "PortLocation": {
        "type": "object",
        "description": "The service address on the account.",
        "properties": {
          "streetAddress": {
            "type": [
              "string",
              "null"
            ],
            "description": "Street and number; null until set."
          },
          "extendedAddress": {
            "type": [
              "string",
              "null"
            ],
            "description": "Suite, floor; null when none."
          },
          "locality": {
            "type": [
              "string",
              "null"
            ],
            "description": "City; null until set."
          },
          "administrativeArea": {
            "type": [
              "string",
              "null"
            ],
            "description": "State or province, 2 letters; null until set."
          },
          "postalCode": {
            "type": [
              "string",
              "null"
            ],
            "description": "ZIP or postal code; null until set."
          },
          "countryCode": {
            "type": [
              "string",
              "null"
            ],
            "description": "`US` or `CA`; null until set."
          }
        }
      },
      "PortLocationInput": {
        "type": "object",
        "description": "The service address on the account.",
        "required": [
          "streetAddress",
          "locality",
          "administrativeArea",
          "postalCode",
          "countryCode"
        ],
        "properties": {
          "streetAddress": {
            "type": "string",
            "description": "Street and number; up to 100 characters."
          },
          "extendedAddress": {
            "type": [
              "string",
              "null"
            ],
            "description": "Suite, floor; null or empty when none."
          },
          "locality": {
            "type": "string",
            "description": "City; up to 100 characters."
          },
          "administrativeArea": {
            "type": "string",
            "description": "State or province, 2 letters (`IN`, `ON`)."
          },
          "postalCode": {
            "type": "string",
            "description": "ZIP code (`46204`, `46204-1234`) or Canadian postal code (`K1A 0B1`)."
          },
          "countryCode": {
            "type": "string",
            "description": "`US` or `CA`."
          }
        }
      },
      "PortNumber": {
        "type": "object",
        "description": "A number of the order, with Telnyx's view of it.",
        "required": [
          "e164"
        ],
        "properties": {
          "e164": {
            "type": "string",
            "description": "The number, E.164."
          },
          "activationStatus": {
            "type": [
              "string",
              "null"
            ],
            "description": "Telnyx's activation status (`New`, `Pending`, `Conflict`, `Active`,\n...); null when not given."
          },
          "portabilityStatus": {
            "type": [
              "string",
              "null"
            ],
            "description": "`pending`, `confirmed` or `provisional`; null when not given."
          }
        }
      },
      "PortOrder": {
        "type": "object",
        "description": "A port order: our copy, as the Phone page lists it.",
        "required": [
          "id",
          "requestId",
          "status",
          "statusDetails",
          "phoneNumbers",
          "label",
          "fastPort",
          "requirementsMet",
          "createdAt",
          "updatedAt",
          "actions"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int64",
            "description": "Our id (`/v1/phone/admin/ports/{id}`)."
          },
          "requestId": {
            "type": "string",
            "description": "The request it came from: orders Telnyx split from one request\nshare it."
          },
          "status": {
            "$ref": "#/components/schemas/PortStatus",
            "description": "Where the port is."
          },
          "statusDetails": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PortStatusDetail"
            },
            "description": "Telnyx's reasons for the status (an exception's problems); may be\nempty."
          },
          "phoneNumbers": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "The numbers it moves, E.164."
          },
          "label": {
            "type": "string",
            "description": "What the numbers are called once ported; may be empty."
          },
          "supportKey": {
            "type": [
              "string",
              "null"
            ],
            "description": "What to quote to Telnyx support; null while a draft."
          },
          "oldCarrier": {
            "type": [
              "string",
              "null"
            ],
            "description": "The current (losing) carrier, as Telnyx names it; null until known."
          },
          "numberType": {
            "type": [
              "string",
              "null"
            ],
            "description": "`local`, `toll_free`, `mobile`, ...; null until known."
          },
          "fastPort": {
            "type": "boolean",
            "description": "FastPort: it can port within the day of the date."
          },
          "focRequestedAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "The port date asked for (UTC); null until picked."
          },
          "focAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "The port date the current carrier confirmed (UTC); null until then."
          },
          "requirementsMet": {
            "type": "boolean",
            "description": "Telnyx approved every requirement (documents, details)."
          },
          "messagingStatus": {
            "type": [
              "string",
              "null"
            ],
            "description": "Texting's own port: `not_applicable`, `pending`, `activating`,\n`exception`, `ported`, ...; null when Telnyx did not say."
          },
          "createdByName": {
            "type": [
              "string",
              "null"
            ],
            "description": "Who started it (name, else email); null when unknown."
          },
          "createdAt": {
            "type": "string",
            "format": "date-time",
            "description": "When it was started."
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time",
            "description": "When our copy last changed."
          },
          "submittedAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When it was submitted; null before."
          },
          "portedAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When Telnyx said it ported; null before."
          },
          "completedAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When the ported numbers were added to the company and set up for\ncalls; null until then."
          },
          "lastError": {
            "type": [
              "string",
              "null"
            ],
            "description": "What went wrong last on our side (setting up ported numbers), for\nthe admin; null when nothing."
          },
          "refreshedAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When it was last read from Telnyx; null when never."
          },
          "actions": {
            "$ref": "#/components/schemas/PortActions",
            "description": "What the admin may do now."
          }
        }
      },
      "PortOrderDetail": {
        "type": "object",
        "description": "One port, with what Telnyx has on it.",
        "required": [
          "order"
        ],
        "properties": {
          "order": {
            "$ref": "#/components/schemas/PortOrder",
            "description": "Our copy, brought up to date."
          },
          "details": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/PortDetails",
                "description": "Telnyx's details; null when Telnyx could not be read (`refreshError`)."
              },
              {
                "type": "null"
              }
            ]
          },
          "refreshError": {
            "type": [
              "string",
              "null"
            ],
            "description": "Why the order could not be read from Telnyx just now; null when it was."
          }
        }
      },
      "PortOrders": {
        "type": "object",
        "description": "`GET /v1/phone/admin/ports`, and the answer of `POST /v1/phone/admin/ports`.",
        "required": [
          "orders"
        ],
        "properties": {
          "orders": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PortOrder"
            },
            "description": "Newest first (a new request's orders, in Telnyx's order)."
          }
        }
      },
      "PortRequirement": {
        "type": "object",
        "description": "One requirement of a port.",
        "required": [
          "requirementTypeId",
          "fulfilled",
          "acceptableValues"
        ],
        "properties": {
          "requirementTypeId": {
            "type": "string",
            "description": "Its id: send it with a value (`PATCH`, `requirements`) or a document\n(`POST .../documents`, kind `requirement`)."
          },
          "name": {
            "type": [
              "string",
              "null"
            ],
            "description": "E.g. \"Latest Invoice\"; null when Telnyx gave none."
          },
          "description": {
            "type": [
              "string",
              "null"
            ],
            "description": "What it asks for; null when Telnyx gave none."
          },
          "example": {
            "type": [
              "string",
              "null"
            ],
            "description": "An example of what satisfies it; null when none."
          },
          "fieldType": {
            "type": [
              "string",
              "null"
            ],
            "description": "`document` or `textual`; null when Telnyx did not say."
          },
          "value": {
            "type": [
              "string",
              "null"
            ],
            "description": "The text value given so far (textual ones); null otherwise."
          },
          "fulfilled": {
            "type": "boolean",
            "description": "Something was given for it."
          },
          "status": {
            "type": [
              "string",
              "null"
            ],
            "description": "`requirement-info-pending` (to do), `requirement-info-under-review`,\n`requirement-info-exception` (redo) or `approved`; null when none."
          },
          "acceptableValues": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "The values Telnyx accepts, when it lists them."
          }
        }
      },
      "PortRequirementInput": {
        "type": "object",
        "description": "A text value for one of the order's requirements.",
        "required": [
          "requirementTypeId",
          "fieldValue"
        ],
        "properties": {
          "requirementTypeId": {
            "type": "string",
            "description": "The requirement (`PortRequirement.requirementTypeId`)."
          },
          "fieldValue": {
            "type": "string",
            "description": "Its value, up to 500 characters."
          }
        }
      },
      "PortRequirements": {
        "type": "object",
        "description": "`GET /v1/phone/admin/ports/{id}/requirements`.",
        "required": [
          "requirements"
        ],
        "properties": {
          "requirements": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PortRequirement"
            },
            "description": "In Telnyx's order."
          }
        }
      },
      "PortStatus": {
        "type": "string",
        "description": "Where a port-in order is: Telnyx's status, or `deleted` for a draft\nthat is gone (deleted by an admin, or by Telnyx after 30 days).",
        "enum": [
          "Draft",
          "InProcess",
          "Submitted",
          "Exception",
          "FocDateConfirmed",
          "Ported",
          "CancelPending",
          "Cancelled",
          "Deleted"
        ]
      },
      "PortStatusDetail": {
        "type": "object",
        "description": "One of Telnyx's reasons for an order's status.",
        "required": [
          "code"
        ],
        "properties": {
          "code": {
            "type": "string",
            "description": "Telnyx's code, e.g. `ACCOUNT_NUMBER_MISMATCH`, `LOA_ILLEGIBLE`,\n`FOC_REJECTED`."
          },
          "description": {
            "type": [
              "string",
              "null"
            ],
            "description": "What it means, in Telnyx's words; null when Telnyx gave none."
          }
        }
      },
      "PortTimeline": {
        "type": "object",
        "description": "`GET /v1/phone/admin/ports/{id}/timeline`.",
        "required": [
          "entries"
        ],
        "properties": {
          "entries": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PortTimelineEntry"
            },
            "description": "Oldest first."
          }
        }
      },
      "PortTimelineEntry": {
        "type": "object",
        "description": "One entry of a port's timeline.",
        "required": [
          "kind",
          "at"
        ],
        "properties": {
          "kind": {
            "type": "string",
            "description": "`created`, `details` (sections saved), `document` (its kind),\n`submitted`, `status` (a status change), `foc` (the port date moved),\n`comment`, `split`, `cancel_requested`, `messaging` (texting's port),\n`completed` (the numbers added; `detail` = how many)."
          },
          "status": {
            "type": [
              "string",
              "null"
            ],
            "description": "The status after a status change; null otherwise."
          },
          "detail": {
            "type": [
              "string",
              "null"
            ],
            "description": "A short fact: exception codes, the sections saved, the document\nkind, a count; null when none."
          },
          "actorName": {
            "type": [
              "string",
              "null"
            ],
            "description": "The admin who did it; null for Telnyx and our system."
          },
          "at": {
            "type": "string",
            "format": "date-time",
            "description": "When."
          }
        }
      },
      "PortTypeInfo": {
        "type": "object",
        "description": "Whether every number of the account moves.",
        "properties": {
          "kind": {
            "type": [
              "string",
              "null"
            ],
            "description": "`full` (every number of the account) or `partial`; null until set."
          },
          "remainingNumbersAction": {
            "type": [
              "string",
              "null"
            ],
            "description": "For a partial port, what happens to the numbers left behind: `keep`\nor `disconnect`; null otherwise."
          },
          "newBillingPhoneNumber": {
            "type": [
              "string",
              "null"
            ],
            "description": "For a partial port moving the billing number: the account's new one;\nnull otherwise."
          }
        }
      },
      "PortTypeInput": {
        "type": "object",
        "description": "Full or partial port.",
        "required": [
          "kind"
        ],
        "properties": {
          "kind": {
            "$ref": "#/components/schemas/PortKind",
            "description": "`full` or `partial`."
          },
          "remainingNumbersAction": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/RemainingNumbers",
                "description": "For `partial`: what happens to the numbers that stay; required then."
              },
              {
                "type": "null"
              }
            ]
          },
          "newBillingPhoneNumber": {
            "type": [
              "string",
              "null"
            ],
            "description": "For `partial` with `keep` when the billing number is one of those\nmoving: the account's new billing number (one that stays), a US or\nCanada number; required then."
          }
        }
      },
      "PortUpdateInput": {
        "type": "object",
        "description": "Body of `PATCH /v1/phone/admin/ports/{id}`: the sections to change; the\nones left out (or null) stay as they are.",
        "properties": {
          "label": {
            "type": [
              "string",
              "null"
            ],
            "description": "What the numbers are called once ported (ours only), up to 100\ncharacters."
          },
          "endUser": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/PortEndUserInput",
                "description": "The account holder, every field."
              },
              {
                "type": "null"
              }
            ]
          },
          "location": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/PortLocationInput",
                "description": "The service address, every field."
              },
              {
                "type": "null"
              }
            ]
          },
          "portType": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/PortTypeInput",
                "description": "Full or partial port."
              },
              {
                "type": "null"
              }
            ]
          },
          "focDatetimeRequested": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "The port date to ask for (RFC 3339): inside one of the windows of\n`GET .../foc-windows`."
          },
          "requirements": {
            "type": [
              "array",
              "null"
            ],
            "items": {
              "$ref": "#/components/schemas/PortRequirementInput"
            },
            "description": "Text values for the order's textual requirements, at most 20."
          }
        }
      },
      "PortabilityInput": {
        "type": "object",
        "description": "Body of `POST /v1/phone/admin/ports/portability`.",
        "required": [
          "phoneNumbers"
        ],
        "properties": {
          "phoneNumbers": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "The numbers to check, as typed (10 digits or E.164; US and Canada\nonly), 1 to 50."
          }
        }
      },
      "PortabilityResult": {
        "type": "object",
        "description": "One number's portability.",
        "required": [
          "e164",
          "portable",
          "fastPortable",
          "onTelnyx",
          "inOpenPort"
        ],
        "properties": {
          "e164": {
            "type": "string",
            "description": "The number, E.164."
          },
          "portable": {
            "type": "boolean",
            "description": "It can move to Telnyx."
          },
          "fastPortable": {
            "type": "boolean",
            "description": "FastPort: it can move within the day."
          },
          "messagingCapable": {
            "type": [
              "boolean",
              "null"
            ],
            "description": "Its texting can move too; null when Telnyx did not say."
          },
          "reason": {
            "type": [
              "string",
              "null"
            ],
            "description": "Why it cannot move (Telnyx's words); null when it can."
          },
          "onTelnyx": {
            "type": "boolean",
            "description": "It is a company number on Telnyx already (nothing to port)."
          },
          "inOpenPort": {
            "type": "boolean",
            "description": "It is in an open port already."
          }
        }
      },
      "PortabilityResults": {
        "type": "object",
        "description": "`POST /v1/phone/admin/ports/portability`.",
        "required": [
          "results"
        ],
        "properties": {
          "results": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PortabilityResult"
            },
            "description": "One per distinct number, in the order typed."
          }
        }
      },
      "PortalChoice": {
        "type": "object",
        "description": "Body of `POST /v1/billing/portal`.",
        "properties": {
          "flow": {
            "type": [
              "string",
              "null"
            ],
            "description": "`payment_method` (the card form, the default) or `manage` (the whole\nsubscription)."
          }
        }
      },
      "PortalQuote": {
        "type": "object",
        "description": "A quote as the customer sees it.",
        "required": [
          "inactive",
          "doc",
          "prices",
          "sold_out",
          "stone_images",
          "signing"
        ],
        "properties": {
          "inactive": {
            "type": "boolean",
            "description": "The link was switched off: only this is set."
          },
          "quote": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/PortalQuoteInfo",
                "description": "The quote."
              },
              {
                "type": "null"
              }
            ]
          },
          "inventory_url": {
            "type": [
              "string",
              "null"
            ],
            "description": "The company's public stone catalog."
          },
          "doc": {
            "type": "object",
            "description": "The drawing, without supplier costs."
          },
          "prices": {
            "type": "array",
            "items": {
              "type": "object"
            },
            "description": "Each option priced."
          },
          "sold_out": {
            "type": "array",
            "items": {
              "type": "boolean"
            },
            "description": "Per option: it has a sold-out color and cannot be accepted."
          },
          "form_view": {
            "type": [
              "object",
              "null"
            ],
            "description": "The company form to show the quote in (`{config, data}`), if any."
          },
          "stone_images": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/StoneImage"
            },
            "description": "Photos of the quote's colors."
          },
          "signing": {
            "type": "boolean",
            "description": "The company lets customers accept and sign on the link (Admin ›\nQuotes › Automation \"Sign on the quote link\")."
          }
        }
      },
      "PortalQuoteInfo": {
        "type": "object",
        "description": "The quote's own fields the customer sees.",
        "required": [
          "id",
          "name",
          "expired"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "Quote id."
          },
          "name": {
            "type": "string",
            "description": "Its name."
          },
          "signed_at": {
            "type": [
              "string",
              "null"
            ],
            "description": "When the customer signed (ISO 8601)."
          },
          "accepted": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "The option accepted."
          },
          "signature_data": {
            "type": [
              "string",
              "null"
            ],
            "description": "The signature (a PNG data URL)."
          },
          "expiration_date": {
            "type": [
              "string",
              "null"
            ],
            "description": "Expires on (YYYY-MM-DD)."
          },
          "expired": {
            "type": "boolean",
            "description": "It has expired."
          }
        }
      },
      "PortalToken": {
        "type": "object",
        "description": "The customer link's token.",
        "required": [
          "token"
        ],
        "properties": {
          "token": {
            "type": "string",
            "description": "Open `/quote-portal/{token}`."
          }
        }
      },
      "PortingNotification": {
        "type": "object",
        "description": "A Telnyx porting notification. Most come as `{\"data\": <event>, \"meta\":\n{...}}`, some as the event itself.",
        "required": [
          "data"
        ],
        "properties": {
          "data": {
            "type": "object",
            "description": "The event: `id`, `event_type` (`porting_order.status_changed`,\n`porting_order.new_comment`, `porting_order.split`,\n`porting_order.messaging_changed`, `porting_order.deleted`, ...),\n`occurred_at` and `payload` (the order's `id`, or `porting_order_id`\nand the `comment` with its `user_type`; a split's `from.id` and\n`to.id`)."
          }
        }
      },
      "PositionAccess": {
        "type": "object",
        "description": "`GET /v1/company/position-sections`.",
        "required": [
          "sections",
          "skills",
          "positions"
        ],
        "properties": {
          "sections": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SectionInfo"
            },
            "description": "Every tab, in the order to show them: the main app, then admin pages."
          },
          "skills": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SkillInfo"
            },
            "description": "Every skill, in the order to show them."
          },
          "positions": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PositionSections"
            },
            "description": "Each position whose tabs the company may change. My Account and\nReport a Bug always stay open."
          }
        }
      },
      "PositionRow": {
        "type": "object",
        "description": "A position the user holds in the current company.",
        "required": [
          "position_id"
        ],
        "properties": {
          "position_id": {
            "type": "integer",
            "format": "int32",
            "description": "`positions.id`, e.g. 1 = sales rep, 9 = super admin."
          }
        }
      },
      "PositionSections": {
        "type": "object",
        "description": "One position whose tabs the company may change.",
        "required": [
          "position_id",
          "sections",
          "default_sections",
          "skills",
          "default_skills",
          "customized"
        ],
        "properties": {
          "position_id": {
            "type": "integer",
            "format": "int32",
            "description": "`positions.id`: 1 Sales Rep, 2 Sales Manager, 5 Manager, 3 Shop\nManager, 4 Shop Worker (only the Shop app's tabs: Transactions,\nSamples, Schedule), 12 Inventory Manager, 13 Scheduling Manager."
          },
          "sections": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "The tabs it opens in this company, in [`SectionInfo`] order."
          },
          "default_sections": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "The tabs it opens in a company that has not changed it."
          },
          "skills": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Its skills in this company, in [`SkillInfo`] order."
          },
          "default_skills": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Its skills in a company that has not changed them."
          },
          "customized": {
            "type": "boolean",
            "description": "The company changed it (false: it uses the defaults)."
          }
        }
      },
      "PositionSectionsInput": {
        "type": "object",
        "description": "Body of `PUT /v1/company/position-sections/{position_id}`.",
        "required": [
          "sections"
        ],
        "properties": {
          "sections": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Tab keys the position opens (may be empty: then only My Account)."
          },
          "skills": {
            "type": [
              "array",
              "null"
            ],
            "items": {
              "type": "string"
            },
            "description": "Skill keys it has (may be empty); null or left out: the default\nskills, which follow later changes to the defaults."
          }
        },
        "additionalProperties": false
      },
      "PrepareAttachments": {
        "type": "object",
        "description": "Body of `POST /v1/sms/attachments`.",
        "required": [
          "files"
        ],
        "properties": {
          "files": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PickedFile"
            },
            "description": "One to ten uploaded files."
          }
        }
      },
      "PreparedAttachment": {
        "type": "object",
        "description": "A file ready to send; pass it in `attachments` of the send call.",
        "required": [
          "s3_key",
          "url",
          "content_type",
          "filename",
          "size"
        ],
        "properties": {
          "s3_key": {
            "type": "string",
            "description": "Its key, under `sms-attachments/<company id>/`."
          },
          "url": {
            "type": "string",
            "description": "Its public URL (shown in the composer and the conversation)."
          },
          "content_type": {
            "type": "string",
            "description": "JPEG, PNG or GIF for pictures; the document's type otherwise."
          },
          "filename": {
            "type": "string",
            "description": "The name it was picked with."
          },
          "width": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Pixel width of a picture; null for documents.",
            "minimum": 0
          },
          "height": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Pixel height of a picture; null for documents.",
            "minimum": 0
          },
          "size": {
            "type": "integer",
            "description": "Bytes as stored.",
            "minimum": 0
          }
        }
      },
      "PreparedAttachments": {
        "type": "object",
        "description": "Body of the answer: each file is prepared or failed, in order.",
        "required": [
          "uploaded",
          "failed"
        ],
        "properties": {
          "uploaded": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PreparedAttachment"
            },
            "description": "Files ready to send."
          },
          "failed": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/FailedAttachment"
            },
            "description": "Files that could not be used."
          }
        }
      },
      "PreviewMessage": {
        "type": "object",
        "description": "One message of the follow-up, as written and maybe edited by the rep.",
        "required": [
          "delay_minutes",
          "delay_label",
          "goal",
          "channel",
          "skip",
          "body"
        ],
        "properties": {
          "delay_minutes": {
            "type": "integer",
            "format": "int64",
            "description": "Minutes after the previous message (the first: after now)."
          },
          "delay_label": {
            "type": "string",
            "description": "\"Immediately\", \"+2 days\", ..."
          },
          "goal": {
            "type": "string",
            "description": "What the message is for."
          },
          "channel": {
            "$ref": "#/components/schemas/CadenceChannel"
          },
          "skip": {
            "type": "boolean",
            "description": "Left out of the flow."
          },
          "skip_reason": {
            "type": [
              "string",
              "null"
            ],
            "description": "Why it is left out."
          },
          "body": {
            "type": "string",
            "description": "The text that will be sent."
          },
          "subject": {
            "type": [
              "string",
              "null"
            ],
            "description": "Email messages: the subject."
          },
          "generated_body": {
            "type": [
              "string",
              "null"
            ],
            "description": "What the model wrote (the rep's edits are learned from)."
          },
          "generated_subject": {
            "type": [
              "string",
              "null"
            ],
            "description": "What the model wrote as the subject."
          },
          "angle": {
            "type": [
              "string",
              "null"
            ],
            "description": "The message's angle (e.g. `quote_status`)."
          },
          "phase": {
            "type": [
              "string",
              "null"
            ],
            "description": "Where in the follow-up it falls (e.g. `EARLY_FOLLOWUP`)."
          }
        }
      },
      "PreviewRequest": {
        "allOf": [
          {
            "$ref": "#/components/schemas/Target"
          },
          {
            "type": "object",
            "properties": {
              "force_generate": {
                "type": "boolean",
                "description": "Write it even though the customer should not be followed up now."
              }
            }
          }
        ],
        "description": "`POST /v1/followups/ai-cadence/preview`."
      },
      "PreviewResult": {
        "type": "object",
        "description": "The written follow-up.",
        "required": [
          "channel",
          "remaining_step_count",
          "cadence_mode",
          "preview"
        ],
        "properties": {
          "channel": {
            "$ref": "#/components/schemas/CadenceChannel"
          },
          "last_contact_at": {
            "type": [
              "string",
              "null"
            ],
            "description": "The last message sent to the customer."
          },
          "remaining_step_count": {
            "type": "integer",
            "description": "Messages in the preview.",
            "minimum": 0
          },
          "cadence_mode": {
            "type": "string",
            "description": "`new`, `unanswered` or `monthly`."
          },
          "preview": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PreviewMessage"
            },
            "description": "The messages, in sending order."
          }
        }
      },
      "PriceListEditor": {
        "type": "object",
        "description": "A list in the editor.",
        "required": [
          "price_list",
          "info",
          "synced_info",
          "stock",
          "revisions"
        ],
        "properties": {
          "price_list": {
            "$ref": "#/components/schemas/PriceListRow",
            "description": "The list."
          },
          "info": {
            "type": "object",
            "description": "Its current prices, as saved."
          },
          "synced_info": {
            "type": "object",
            "description": "The prices matched to today's inventory (what the editor starts from)."
          },
          "stock": {
            "type": "object",
            "description": "Stones in stock and sinks in stock."
          },
          "revisions": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PriceListRevision"
            },
            "description": "Every revision, newest first."
          }
        }
      },
      "PriceListMeta": {
        "type": "object",
        "description": "Name or status of a list.",
        "properties": {
          "name": {
            "type": [
              "string",
              "null"
            ],
            "description": "New name."
          },
          "status": {
            "type": [
              "string",
              "null"
            ],
            "description": "`active` or `inactive`."
          }
        },
        "additionalProperties": false
      },
      "PriceListOrder": {
        "type": "object",
        "description": "Body of `PUT /v1/quote-price-lists/order`.",
        "required": [
          "ids"
        ],
        "properties": {
          "ids": {
            "type": "array",
            "items": {
              "type": "integer",
              "format": "int32"
            },
            "description": "The company's list ids in their new order."
          }
        },
        "additionalProperties": false
      },
      "PriceListProblems": {
        "type": "object",
        "description": "Why the prices were not saved.",
        "required": [
          "error",
          "errors"
        ],
        "properties": {
          "error": {
            "type": "string",
            "description": "The first problem."
          },
          "errors": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Every problem."
          }
        }
      },
      "PriceListRevision": {
        "type": "object",
        "description": "A revision of a list.",
        "required": [
          "id",
          "revision_number"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "Revision id."
          },
          "revision_number": {
            "type": "integer",
            "format": "int32",
            "description": "Its number in the list."
          },
          "created_at": {
            "type": [
              "string",
              "null"
            ],
            "description": "When it was saved (ISO 8601)."
          },
          "created_by": {
            "type": [
              "string",
              "null"
            ],
            "description": "Who saved it."
          },
          "notes": {
            "type": [
              "string",
              "null"
            ],
            "description": "What changed."
          }
        }
      },
      "PriceListRow": {
        "type": "object",
        "description": "A price list (`PriceListRow`).",
        "required": [
          "id",
          "company_id",
          "name",
          "status",
          "sequence"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "Price list id."
          },
          "company_id": {
            "type": "integer",
            "format": "int32",
            "description": "Company."
          },
          "name": {
            "type": "string",
            "description": "Name, unique in the company."
          },
          "status": {
            "type": "string",
            "description": "`active` or `inactive`."
          },
          "sequence": {
            "type": "integer",
            "format": "int32",
            "description": "Order in the lists."
          },
          "current_revision_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "The revision quotes price with now."
          },
          "revision_number": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Its number."
          },
          "revision_created_at": {
            "type": [
              "string",
              "null"
            ],
            "description": "When it was saved (ISO 8601)."
          },
          "revision_created_by": {
            "type": [
              "string",
              "null"
            ],
            "description": "Who saved it."
          },
          "created_at": {
            "type": [
              "string",
              "null"
            ],
            "description": "When the list was made (ISO 8601)."
          },
          "created_by_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "Who made it."
          },
          "units": {
            "type": [
              "string",
              "null"
            ],
            "description": "`in` or `mm`, from the current revision."
          },
          "expiration_days": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int64",
            "description": "Days a quote stays valid, from the current revision."
          }
        }
      },
      "PriceLists": {
        "type": "object",
        "description": "The company's price lists.",
        "required": [
          "price_lists"
        ],
        "properties": {
          "price_lists": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PriceListRow"
            },
            "description": "Active first, then by sequence and name."
          },
          "default_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "The list new quotes get."
          }
        }
      },
      "PriceOffers": {
        "type": "object",
        "description": "Body of `GET /v1/suppliers/price-offers`.",
        "required": [
          "offers",
          "incomplete",
          "tax_pct"
        ],
        "properties": {
          "offers": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SupplierOffer"
            },
            "description": "Up to 12 matching prices, closest name first, without repeats."
          },
          "incomplete": {
            "type": "boolean",
            "description": "Some price files in the searched scope are still processing or\nfailed, so the list may be incomplete."
          },
          "tax_pct": {
            "type": "number",
            "format": "double",
            "description": "The company's sales tax in percent (7.25 = 7.25%); 0 when not set."
          }
        }
      },
      "PriceUnit": {
        "type": "string",
        "description": "What a price is for.",
        "enum": [
          "sqft",
          "slab"
        ]
      },
      "PrintPreview": {
        "type": "object",
        "description": "Where the printed PDF goes, and where to open it.",
        "required": [
          "upload_url",
          "url"
        ],
        "properties": {
          "upload_url": {
            "type": "string",
            "description": "`PUT` the PDF here (valid 15 minutes) with `Content-Type: application/pdf`."
          },
          "url": {
            "type": "string",
            "description": "Open this (valid an hour) to show the PDF; the viewer saves it under\nthe file name."
          }
        }
      },
      "PrintPreviewInput": {
        "type": "object",
        "description": "Body of `POST /v1/quotes/print-previews`.",
        "required": [
          "filename"
        ],
        "properties": {
          "filename": {
            "type": "string",
            "description": "What the PDF is saved as, e.g. `Smith Kitchen.pdf` (ends with `.pdf`,\nat most 180 characters, none of `\\ / : * ? \" < > |`)."
          }
        }
      },
      "Priority": {
        "type": "string",
        "description": "Activity priority.",
        "enum": [
          "low",
          "medium",
          "high"
        ]
      },
      "ProcessStage": {
        "type": "object",
        "description": "Who is told when a project moves on from a stage (the stage's built-in step).",
        "required": [
          "stage_code",
          "notify",
          "notify_sales_rep",
          "event_rules"
        ],
        "properties": {
          "stage_code": {
            "$ref": "#/components/schemas/Stage",
            "description": "The stage a project moves on from."
          },
          "notify": {
            "type": "array",
            "items": {
              "type": "integer",
              "format": "int32"
            },
            "description": "Who is told (user ids)."
          },
          "notify_sales_rep": {
            "type": "boolean",
            "description": "Also tells the sales rep assigned to the project."
          },
          "event_rules": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/StepEventRule"
            },
            "description": "What moving on from the stage does to the project's schedule events."
          },
          "auto": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/StepAuto",
                "description": "What moves the project on by itself, if anything."
              },
              {
                "type": "null"
              }
            ]
          }
        }
      },
      "ProcessStep": {
        "type": "object",
        "description": "A step a company added to a stage of its process.",
        "required": [
          "id",
          "stage_code",
          "name",
          "position",
          "notify",
          "notify_sales_rep",
          "event_rules",
          "responsible_sales_rep",
          "items",
          "ends_stage"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "Its id."
          },
          "stage_code": {
            "$ref": "#/components/schemas/Stage",
            "description": "The stage it belongs to."
          },
          "column_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "The company's own board column of the stage it is in; null: the\nstage's built-in column. Steps come in column order."
          },
          "name": {
            "type": "string",
            "description": "What to do, e.g. \"Confirm a file\"."
          },
          "position": {
            "type": "integer",
            "format": "int32",
            "description": "Its place in the stage."
          },
          "notify": {
            "type": "array",
            "items": {
              "type": "integer",
              "format": "int32"
            },
            "description": "Who is told when a project checks it off (user ids)."
          },
          "notify_sales_rep": {
            "type": "boolean",
            "description": "Also tells the sales rep assigned to the project."
          },
          "auto": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/StepAuto",
                "description": "What checks it off by itself, if anything."
              },
              {
                "type": "null"
              }
            ]
          },
          "event_rules": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/StepEventRule"
            },
            "description": "What checking it off does to the project's schedule events."
          },
          "responsible_user_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "The person responsible on every project; null for none."
          },
          "responsible_sales_rep": {
            "type": "boolean",
            "description": "The project's sales rep is responsible."
          },
          "due_days": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Due this many days after the project reaches the stage; null for no due date."
          },
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ListItem"
            },
            "description": "Its own to-do list, in order."
          },
          "ask_question": {
            "type": [
              "string",
              "null"
            ],
            "description": "Asked (Yes or No) when a project checks it off, e.g. \"Does this job need a layout?\"."
          },
          "only_if_step_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Happens only if the answer to this step's question is Yes; a No marks it Not needed."
          },
          "ends_stage": {
            "type": "boolean",
            "description": "Deprecated, for older apps: true when its Auto waits for the project to\nmove on (`stage_moved`) or moves it on (`moves`). The project's Next\nshows its template or installation date while it is the step to do."
          }
        }
      },
      "ProcessStepAuto": {
        "type": "object",
        "description": "A step's new rule; `null` turns it off.",
        "properties": {
          "auto": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/StepAuto",
                "description": "The rule, or none."
              },
              {
                "type": "null"
              }
            ]
          }
        }
      },
      "ProcessStepCondition": {
        "type": "object",
        "description": "A process step's question, and the question it depends on.",
        "properties": {
          "ask_question": {
            "type": [
              "string",
              "null"
            ],
            "description": "Asked when a project checks the step off; empty or null asks nothing."
          },
          "only_if_step_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Another step with a question: this one happens only if its answer is Yes."
          }
        }
      },
      "ProcessStepEvents": {
        "type": "object",
        "description": "A step's new event rules; empty turns them off.",
        "required": [
          "rules"
        ],
        "properties": {
          "rules": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/StepEventRule"
            },
            "description": "The rules, one per target."
          }
        }
      },
      "ProcessStepInput": {
        "type": "object",
        "description": "A new process step.",
        "required": [
          "stage",
          "name"
        ],
        "properties": {
          "stage": {
            "$ref": "#/components/schemas/Stage",
            "description": "The stage to add it to."
          },
          "name": {
            "type": "string",
            "description": "What to do."
          },
          "column_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "The company's own column of that stage to add it to; left out: the\nstage's built-in column."
          }
        }
      },
      "ProcessStepName": {
        "type": "object",
        "description": "A process step's new name.",
        "required": [
          "name"
        ],
        "properties": {
          "name": {
            "type": "string",
            "description": "What to do."
          }
        }
      },
      "ProcessStepNotify": {
        "type": "object",
        "description": "Who to tell when a project checks a step off.",
        "required": [
          "user_ids"
        ],
        "properties": {
          "user_ids": {
            "type": "array",
            "items": {
              "type": "integer",
              "format": "int32"
            },
            "description": "Users of the company; empty tells nobody."
          },
          "sales_rep": {
            "type": "boolean",
            "description": "Also tell the sales rep assigned to the project."
          }
        }
      },
      "ProcessStepOrder": {
        "type": "object",
        "description": "A stage's steps, in their new order.",
        "required": [
          "ids"
        ],
        "properties": {
          "ids": {
            "type": "array",
            "items": {
              "type": "integer",
              "format": "int32"
            },
            "description": "Step ids, first to last."
          }
        }
      },
      "ProgressUser": {
        "type": "object",
        "description": "A sales rep of the company.",
        "required": [
          "id",
          "email"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "User id."
          },
          "email": {
            "type": "string",
            "description": "Email."
          },
          "name": {
            "type": [
              "string",
              "null"
            ],
            "description": "Name."
          }
        }
      },
      "Project": {
        "type": "object",
        "description": "One job of a customer: a deal and its sales, or a sale on its own.",
        "required": [
          "sale_ids",
          "cancelled"
        ],
        "properties": {
          "deal_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int64",
            "description": "The deal; null for a sale that is not part of a deal."
          },
          "title": {
            "type": [
              "string",
              "null"
            ],
            "description": "The deal's title."
          },
          "price": {
            "type": [
              "string",
              "null"
            ],
            "description": "The deal's amount, else the total of its sales that were not\ncancelled, a decimal string."
          },
          "address": {
            "type": [
              "string",
              "null"
            ],
            "description": "Address of the job: its first sale's, else its newest quote's."
          },
          "date": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "The first sale's date, else when the deal was made."
          },
          "sale_ids": {
            "type": "array",
            "items": {
              "type": "integer",
              "format": "int32"
            },
            "description": "The sales of the job."
          },
          "cancelled": {
            "type": "boolean",
            "description": "A sale on its own that was cancelled: nothing is owed for it, and it\ntakes no payment link. Always false for a deal."
          }
        }
      },
      "ProjectAction": {
        "oneOf": [
          {
            "type": "object",
            "description": "Move forward (production).",
            "required": [
              "version",
              "stage",
              "intent"
            ],
            "properties": {
              "version": {
                "type": "integer",
                "format": "int32",
                "description": "The project's version as the page has it; a stale page gets a 409."
              },
              "stage": {
                "$ref": "#/components/schemas/Stage",
                "description": "The stage."
              },
              "partId": {
                "type": [
                  "integer",
                  "null"
                ],
                "format": "int32",
                "description": "The part, on a project with parts; left out: its least finished part."
              },
              "columnId": {
                "type": [
                  "integer",
                  "null"
                ],
                "format": "int32",
                "description": "The company's own column of that stage to put it in; left out: the\nstage's built-in column."
              },
              "intent": {
                "type": "string",
                "enum": [
                  "stage"
                ]
              }
            }
          },
          {
            "type": "object",
            "description": "Link the customer's transaction.",
            "required": [
              "version",
              "saleId",
              "intent"
            ],
            "properties": {
              "version": {
                "type": "integer",
                "format": "int32",
                "description": "The project's version as the page has it; a stale page gets a 409."
              },
              "saleId": {
                "type": "integer",
                "format": "int32",
                "description": "The transaction."
              },
              "intent": {
                "type": "string",
                "enum": [
                  "link-sale"
                ]
              }
            }
          },
          {
            "type": "object",
            "description": "Confirm full payment on this date (ISO).",
            "required": [
              "version",
              "date",
              "intent"
            ],
            "properties": {
              "version": {
                "type": "integer",
                "format": "int32",
                "description": "The project's version as the page has it; a stale page gets a 409."
              },
              "date": {
                "type": "string",
                "description": "The date, ISO."
              },
              "intent": {
                "type": "string",
                "enum": [
                  "paid"
                ]
              }
            }
          },
          {
            "type": "object",
            "description": "Pick the owner (null: nobody).",
            "required": [
              "version",
              "intent"
            ],
            "properties": {
              "version": {
                "type": "integer",
                "format": "int32",
                "description": "The project's version as the page has it; a stale page gets a 409."
              },
              "ownerId": {
                "type": [
                  "integer",
                  "null"
                ],
                "format": "int32",
                "description": "The owner; null for nobody."
              },
              "intent": {
                "type": "string",
                "enum": [
                  "assign"
                ]
              }
            }
          },
          {
            "type": "object",
            "description": "Put on hold or take off hold (managers).",
            "required": [
              "version",
              "onHold",
              "intent"
            ],
            "properties": {
              "version": {
                "type": "integer",
                "format": "int32",
                "description": "The project's version as the page has it; a stale page gets a 409."
              },
              "onHold": {
                "type": "boolean",
                "description": "On hold (true) or not."
              },
              "intent": {
                "type": "string",
                "enum": [
                  "hold"
                ]
              }
            }
          },
          {
            "type": "object",
            "description": "Cancel, with a reason (managers).",
            "required": [
              "version",
              "reason",
              "intent"
            ],
            "properties": {
              "version": {
                "type": "integer",
                "format": "int32",
                "description": "The project's version as the page has it; a stale page gets a 409."
              },
              "reason": {
                "type": "string",
                "description": "Why, for a correction or cancel."
              },
              "intent": {
                "type": "string",
                "enum": [
                  "cancel"
                ]
              }
            }
          },
          {
            "type": "object",
            "description": "Archive a finished or cancelled project, or bring it back (managers).",
            "required": [
              "version",
              "archived",
              "intent"
            ],
            "properties": {
              "version": {
                "type": "integer",
                "format": "int32",
                "description": "The project's version as the page has it; a stale page gets a 409."
              },
              "archived": {
                "type": "boolean",
                "description": "Archived (true) or back on the board."
              },
              "intent": {
                "type": "string",
                "enum": [
                  "archive"
                ]
              }
            }
          },
          {
            "type": "object",
            "description": "Change or clear the payment date, with a reason.",
            "required": [
              "version",
              "reason",
              "intent"
            ],
            "properties": {
              "version": {
                "type": "integer",
                "format": "int32",
                "description": "The project's version as the page has it; a stale page gets a 409."
              },
              "date": {
                "type": [
                  "string",
                  "null"
                ],
                "description": "The date, ISO."
              },
              "reason": {
                "type": "string",
                "description": "Why, for a correction or cancel."
              },
              "intent": {
                "type": "string",
                "enum": [
                  "correct-payment"
                ]
              }
            }
          },
          {
            "type": "object",
            "description": "The shop finished fabricating it (production).",
            "required": [
              "version",
              "intent"
            ],
            "properties": {
              "version": {
                "type": "integer",
                "format": "int32",
                "description": "The project's version as the page has it; a stale page gets a 409."
              },
              "partId": {
                "type": [
                  "integer",
                  "null"
                ],
                "format": "int32",
                "description": "The part, on a project with parts; left out: its least finished part."
              },
              "intent": {
                "type": "string",
                "enum": [
                  "fabricated"
                ]
              }
            }
          },
          {
            "type": "object",
            "description": "Move back, with a reason (managers).",
            "required": [
              "version",
              "stage",
              "reason",
              "intent"
            ],
            "properties": {
              "version": {
                "type": "integer",
                "format": "int32",
                "description": "The project's version as the page has it; a stale page gets a 409."
              },
              "stage": {
                "$ref": "#/components/schemas/Stage",
                "description": "The stage."
              },
              "reason": {
                "type": "string",
                "description": "Why, for a correction or cancel."
              },
              "partId": {
                "type": [
                  "integer",
                  "null"
                ],
                "format": "int32",
                "description": "The part, on a project with parts; left out: its least finished part."
              },
              "intent": {
                "type": "string",
                "enum": [
                  "correct"
                ]
              }
            }
          }
        ],
        "description": "Body of `POST /v1/projects/{id}/actions`. `version` is the project's as\nthe page has it: a stale page gets a 409."
      },
      "ProjectAppointment": {
        "type": "object",
        "description": "The next template or installation appointment.",
        "required": [
          "id",
          "project_id",
          "kind",
          "title",
          "start_date",
          "unscheduled"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "Its id."
          },
          "project_id": {
            "type": "integer",
            "format": "int32",
            "description": "The project it belongs to."
          },
          "kind": {
            "type": "string",
            "description": "`templates` or `installations` (the calendar)."
          },
          "title": {
            "type": "string",
            "description": "The event title."
          },
          "start_date": {
            "type": "string",
            "description": "When it starts, UTC ISO."
          },
          "unscheduled": {
            "type": "boolean",
            "description": "Waiting for a date on the schedule (`start_date` means nothing yet)."
          },
          "part_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "The part it is for; null for the project's first part."
          },
          "assignee_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "Who is assigned to it (the templater or the installer)."
          }
        }
      },
      "ProjectCustomer": {
        "type": "object",
        "description": "One customer of the family.",
        "required": [
          "id",
          "emails",
          "sales",
          "projects"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "Customer id."
          },
          "name": {
            "type": [
              "string",
              "null"
            ],
            "description": "Name."
          },
          "email": {
            "type": [
              "string",
              "null"
            ],
            "description": "Primary email address."
          },
          "emails": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Every address, primary first."
          },
          "phone": {
            "type": [
              "string",
              "null"
            ],
            "description": "Phone."
          },
          "address": {
            "type": [
              "string",
              "null"
            ],
            "description": "Address."
          },
          "sales_rep_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "Sales rep's name."
          },
          "deal_stage": {
            "type": [
              "string",
              "null"
            ],
            "description": "Stage of the newest live deal."
          },
          "source": {
            "type": [
              "string",
              "null"
            ],
            "description": "Lead source."
          },
          "city": {
            "type": [
              "string",
              "null"
            ],
            "description": "City."
          },
          "state": {
            "type": [
              "string",
              "null"
            ],
            "description": "State."
          },
          "postal_code": {
            "type": [
              "string",
              "null"
            ],
            "description": "ZIP code."
          },
          "company_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "Company name."
          },
          "notes": {
            "type": [
              "string",
              "null"
            ],
            "description": "Notes."
          },
          "sales": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ProjectSale"
            },
            "description": "Sales to the customer."
          },
          "projects": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Project"
            },
            "description": "The customer's jobs, oldest first: each won deal (or deal with a sale)\nwith its sales, then each sale that is not part of such a deal."
          }
        }
      },
      "ProjectEventLinks": {
        "type": "object",
        "description": "`GET /v1/projects/{id}/event-links`.",
        "required": [
          "projects",
          "events"
        ],
        "properties": {
          "projects": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/LinkProject"
            },
            "description": "The customer's open projects the caller can see (this one included),\nto name the project an event is on now."
          },
          "events": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/LinkEvent"
            },
            "description": "The customer's events and the ones linked to this project, soonest\nfirst."
          }
        }
      },
      "ProjectEventLinksInput": {
        "type": "object",
        "description": "`PUT /v1/projects/{id}/event-links`.",
        "properties": {
          "event_ids": {
            "type": "array",
            "items": {
              "type": "integer",
              "format": "int32"
            },
            "description": "The events that are this project's: each is linked to it (leaving its\nold project); this project's other events are unlinked."
          }
        }
      },
      "ProjectFile": {
        "type": "object",
        "description": "A file on a project.",
        "required": [
          "id",
          "name",
          "url",
          "content_type",
          "created_by",
          "created_at"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "Its id."
          },
          "name": {
            "type": "string",
            "description": "Its name."
          },
          "url": {
            "type": "string",
            "description": "A URL the browser can open."
          },
          "content_type": {
            "type": "string",
            "description": "MIME type."
          },
          "created_by": {
            "type": "integer",
            "format": "int32",
            "description": "Who made it."
          },
          "created_at": {
            "type": "string",
            "description": "When it was made, UTC ISO."
          },
          "step_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "The step it was added on; null for one added to the project itself."
          },
          "part_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "The part of that step, on a project with parts."
          }
        }
      },
      "ProjectIssue": {
        "type": "object",
        "description": "A problem the crew reported on one of the project's jobs (the job card's\nIssues).",
        "required": [
          "id",
          "description",
          "created_at",
          "photos",
          "comments"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "Its id."
          },
          "event_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "The job it was reported on; null for one reported on the project itself."
          },
          "part_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "The part it is for, on a project with parts."
          },
          "kind": {
            "type": [
              "string",
              "null"
            ],
            "description": "`templates` or `installations`; null for another calendar."
          },
          "job_date": {
            "type": [
              "string",
              "null"
            ],
            "description": "When the job is (UTC ISO); null while it waits for a date."
          },
          "description": {
            "type": "string",
            "description": "What is wrong."
          },
          "author": {
            "type": [
              "string",
              "null"
            ],
            "description": "Who reported it."
          },
          "created_at": {
            "type": "string",
            "description": "When, UTC ISO."
          },
          "solved_at": {
            "type": [
              "string",
              "null"
            ],
            "description": "When it was marked solved (UTC ISO); null while it is open."
          },
          "solved_by": {
            "type": [
              "string",
              "null"
            ],
            "description": "Who marked it solved."
          },
          "in_progress_at": {
            "type": [
              "string",
              "null"
            ],
            "description": "When someone marked it in progress (UTC ISO); null while nobody has."
          },
          "in_progress_by": {
            "type": [
              "string",
              "null"
            ],
            "description": "Who marked it in progress."
          },
          "author_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Who reported it (user id), so they can delete one of the project's own."
          },
          "photos": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Its pictures (URLs the browser can open)."
          },
          "comments": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/IssueComment"
            },
            "description": "Comments under it, oldest first."
          }
        }
      },
      "ProjectIssueCount": {
        "type": "object",
        "description": "How many open issues a project has (its jobs' and its own); with parts, one\nrow for each part that has any.",
        "required": [
          "project_id",
          "count",
          "in_progress"
        ],
        "properties": {
          "project_id": {
            "type": "integer",
            "format": "int32",
            "description": "The project."
          },
          "part_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "The part, on a project with parts."
          },
          "count": {
            "type": "integer",
            "format": "int64",
            "description": "Its open issues."
          },
          "in_progress": {
            "type": "integer",
            "format": "int64",
            "description": "Of those, the ones someone marked In progress (the card's triangle is\nyellow when all are)."
          }
        }
      },
      "ProjectIssueInput": {
        "type": "object",
        "description": "Body of `POST /v1/projects/{id}/issues`.",
        "required": [
          "description"
        ],
        "properties": {
          "description": {
            "type": "string",
            "description": "What is wrong: 1 to 2000 characters (trimmed)."
          },
          "urls": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Pictures: `url`s that `POST /v1/uploads` (folder `events`) returned.\nAt most 20; may be empty."
          },
          "part_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "The part it is for, on a project with parts; left out: the first part."
          }
        }
      },
      "ProjectJobPhoto": {
        "type": "object",
        "description": "A job photo the crew took on one of the project's appointments (the job\ncard's Job photos, which the customer also sees on their page).",
        "required": [
          "id",
          "event_id",
          "url",
          "created_at"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "Its id."
          },
          "event_id": {
            "type": "integer",
            "format": "int32",
            "description": "The appointment it was taken on."
          },
          "kind": {
            "type": [
              "string",
              "null"
            ],
            "description": "`templates` or `installations`; null for another calendar."
          },
          "url": {
            "type": "string",
            "description": "A URL the browser can open."
          },
          "author": {
            "type": [
              "string",
              "null"
            ],
            "description": "Who took it."
          },
          "created_at": {
            "type": "string",
            "description": "When it was added, UTC ISO."
          }
        }
      },
      "ProjectList": {
        "type": "object",
        "description": "A company's own to-do list, to fill a to-do list task (Admin › Projects).",
        "required": [
          "id",
          "name",
          "items"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "Its id."
          },
          "name": {
            "type": "string",
            "description": "Its name, e.g. \"After sale\"."
          },
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ListItem"
            },
            "description": "Its items, in order."
          }
        }
      },
      "ProjectListInput": {
        "type": "object",
        "description": "Body of `POST /v1/projects/lists` and `PUT /v1/projects/lists/{list_id}`.",
        "required": [
          "name"
        ],
        "properties": {
          "name": {
            "type": "string",
            "description": "1 to 120 characters."
          },
          "items": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "The items, in order: 1 to 200 characters each (blank ones dropped), at most 60."
          }
        }
      },
      "ProjectNote": {
        "type": "object",
        "description": "A note on a project.",
        "required": [
          "id",
          "content",
          "created_by",
          "created_at"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "Its id."
          },
          "content": {
            "type": "string",
            "description": "The text."
          },
          "created_by": {
            "type": "integer",
            "format": "int32",
            "description": "Who made it."
          },
          "author": {
            "type": [
              "string",
              "null"
            ],
            "description": "Its author's name."
          },
          "created_at": {
            "type": "string",
            "description": "When it was made, UTC ISO."
          }
        }
      },
      "ProjectNoteInput": {
        "type": "object",
        "description": "Body of `POST /v1/events/{id}/project-notes`.",
        "required": [
          "content"
        ],
        "properties": {
          "content": {
            "type": "string",
            "description": "1 to 2000 characters (trimmed)."
          },
          "audience": {
            "type": [
              "string",
              "null"
            ],
            "description": "`installers`, `sales_rep` or `everyone` (the default)."
          }
        }
      },
      "ProjectPart": {
        "type": "object",
        "description": "A part of a project: it goes through the stages on its own.",
        "required": [
          "id",
          "project_id",
          "type_id",
          "type_name",
          "name",
          "uses_template",
          "uses_fabrication",
          "stage_code",
          "position"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "Its id."
          },
          "project_id": {
            "type": "integer",
            "format": "int32",
            "description": "The project it belongs to."
          },
          "type_id": {
            "type": "integer",
            "format": "int32",
            "description": "Its type."
          },
          "type_name": {
            "type": "string",
            "description": "The type's name."
          },
          "name": {
            "type": "string",
            "description": "Its name, e.g. \"Backsplash\"."
          },
          "uses_template": {
            "type": "boolean",
            "description": "Its type is templated."
          },
          "uses_fabrication": {
            "type": "boolean",
            "description": "Its type is fabricated."
          },
          "stage_code": {
            "$ref": "#/components/schemas/Stage",
            "description": "Where it is (never Paid & Completed: that is the whole project's)."
          },
          "fabricated_at": {
            "type": [
              "string",
              "null"
            ],
            "description": "The shop marked it fabricated."
          },
          "template_date": {
            "type": [
              "string",
              "null"
            ],
            "description": "Its template is on the calendar for this time (UTC ISO), not done yet."
          },
          "install_date": {
            "type": [
              "string",
              "null"
            ],
            "description": "Its installation is on the calendar for this time (UTC ISO), not done yet\n(a pickup is not one)."
          },
          "pickup_date": {
            "type": [
              "string",
              "null"
            ],
            "description": "Its pickup (an event marked \"Pickup: no install\") is on the calendar for\nthis time (UTC ISO), not done yet. A pickup stands in for the\ninstallation: completing it finishes the job."
          },
          "position": {
            "type": "integer",
            "format": "int32",
            "description": "Its place in the project."
          },
          "column_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "The company's own board column it was put in; counts only while that\ncolumn's stage is `stage_code`."
          }
        }
      },
      "ProjectPayment": {
        "type": "object",
        "description": "One project's payment.",
        "required": [
          "project_id",
          "status",
          "balance",
          "total",
          "paid",
          "invoice_ids"
        ],
        "properties": {
          "project_id": {
            "type": "integer",
            "format": "int32",
            "description": "The project it belongs to."
          },
          "status": {
            "$ref": "#/components/schemas/PaymentStatus",
            "description": "Paid in full, partly, not at all, or no invoice."
          },
          "balance": {
            "type": "number",
            "format": "double",
            "description": "What is still owed: the invoices' balance less deposits waiting for\nan invoice and payment links not recorded on one."
          },
          "total": {
            "type": "number",
            "format": "double",
            "description": "The invoices' total."
          },
          "paid": {
            "type": "number",
            "format": "double",
            "description": "Everything paid toward it, counted once: on its invoices, deposits\nwaiting for an invoice, and payment links not recorded on one. The\ncustomer's Projects tab shows the same amount."
          },
          "invoice_ids": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "The ids of the invoices it counts (`QuickBooks` ids for a company\nconnected to `QuickBooks`), so the project page can open them."
          }
        }
      },
      "ProjectPayments": {
        "type": "object",
        "description": "`GET /v1/projects/payments`.",
        "required": [
          "connected",
          "payments",
          "moved"
        ],
        "properties": {
          "connected": {
            "type": "boolean",
            "description": "False when `QuickBooks` is the company's books and did not answer:\nthen no project has an answer."
          },
          "payments": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ProjectPayment"
            },
            "description": "The asked projects the caller sees."
          },
          "moved": {
            "type": "boolean",
            "description": "A project became paid or unpaid just now: its stage may have moved,\nso the board is worth reading again."
          }
        }
      },
      "ProjectQuoteLink": {
        "type": "object",
        "description": "A sold quote of the project's deal.",
        "required": [
          "id"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "Its id."
          },
          "name": {
            "type": [
              "string",
              "null"
            ],
            "description": "Its name; none when it has no name."
          }
        }
      },
      "ProjectSale": {
        "type": "object",
        "description": "A sale to a customer of the family.",
        "required": [
          "id",
          "customer_id",
          "cancelled"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "Sale id."
          },
          "customer_id": {
            "type": "integer",
            "format": "int32",
            "description": "Customer."
          },
          "deal_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int64",
            "description": "The deal the sale is part of."
          },
          "price": {
            "type": [
              "string",
              "null"
            ],
            "description": "Price, a decimal string."
          },
          "project_address": {
            "type": [
              "string",
              "null"
            ],
            "description": "Address of the job."
          },
          "sale_date": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When it was sold."
          },
          "cancelled": {
            "type": "boolean",
            "description": "The sale was cancelled: its price is not part of its deal's total."
          }
        }
      },
      "ProjectTask": {
        "type": "object",
        "description": "A task on a project, for anyone in the company.",
        "required": [
          "id",
          "project_id",
          "name",
          "priority",
          "created_by",
          "created_at",
          "photos",
          "kind",
          "items"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "Its id."
          },
          "project_id": {
            "type": "integer",
            "format": "int32",
            "description": "The project it belongs to."
          },
          "name": {
            "type": "string",
            "description": "Its name."
          },
          "assigned_user_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Who does it; null for nobody."
          },
          "assigned_user_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "That person's name."
          },
          "deadline": {
            "type": [
              "string",
              "null"
            ],
            "description": "Store wall time `YYYY-MM-DDTHH:MM:SS`; `T00:00:00` is a date with no time."
          },
          "priority": {
            "type": "string",
            "description": "`low`, `medium` or `high` (no longer shown; new tasks are `medium`)."
          },
          "completed_at": {
            "type": [
              "string",
              "null"
            ],
            "description": "When it was done, UTC ISO; null while open."
          },
          "response": {
            "type": [
              "string",
              "null"
            ],
            "description": "The reply left when it was done; null with none."
          },
          "created_by": {
            "type": "integer",
            "format": "int32",
            "description": "Who made it."
          },
          "created_by_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "Its maker's name."
          },
          "created_at": {
            "type": "string",
            "description": "When it was made, UTC ISO."
          },
          "photos": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Its pictures' URLs, oldest first; empty with none (and on board cards)."
          },
          "kind": {
            "type": "string",
            "description": "`text` (a plain task) or `list` (a to-do list of `items`)."
          },
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TaskItem"
            },
            "description": "A to-do list's items, in order; empty on a plain task (and on board cards)."
          }
        }
      },
      "ProjectWorkspace": {
        "type": "object",
        "description": "`GET /v1/projects/{id}`: a project's page.",
        "required": [
          "project",
          "tasks",
          "task_times",
          "notes",
          "files",
          "job_photos",
          "customer_todos",
          "issues",
          "history",
          "sales",
          "quotes",
          "people",
          "task_people",
          "calendars",
          "appointments",
          "process_steps",
          "done_steps",
          "parts",
          "part_types",
          "permissions",
          "user_id",
          "step_owners",
          "step_items_done",
          "step_notes",
          "lists",
          "questions",
          "involved",
          "crew",
          "chat_regulars"
        ],
        "properties": {
          "project": {
            "$ref": "#/components/schemas/Project",
            "description": "The project."
          },
          "tasks": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ProjectTask"
            },
            "description": "Its tasks, open and done."
          },
          "task_times": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TaskTime"
            },
            "description": "The company's remembered task times, to fill in the due date."
          },
          "notes": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ProjectNote"
            },
            "description": "Its notes, newest first."
          },
          "files": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ProjectFile"
            },
            "description": "Its files."
          },
          "job_photos": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ProjectJobPhoto"
            },
            "description": "The crew's job photos from its appointments, newest first."
          },
          "customer_todos": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CustomerTodo"
            },
            "description": "What the customer must do before install, from its template\nappointments: open ones first. Tick one off with `PUT /v1/customer-todos/{id}`."
          },
          "issues": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ProjectIssue"
            },
            "description": "The problems the crew reported on its jobs, newest first."
          },
          "history": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/StageChange"
            },
            "description": "What happened, newest first."
          },
          "sales": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/LinkableSale"
            },
            "description": "Transactions to link (empty once one is linked)."
          },
          "quotes": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ProjectQuoteLink"
            },
            "description": "Every sold quote of its deal, oldest first (a deal can hold more\nthan one job)."
          },
          "people": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Person"
            },
            "description": "Everyone in the company."
          },
          "task_people": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Person"
            },
            "description": "Who a task can be given to: `people` less the marketing team."
          },
          "calendars": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Calendar"
            },
            "description": "The Templates and Installations calendars."
          },
          "appointments": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ProjectAppointment"
            },
            "description": "Every appointment of the project, newest first."
          },
          "process_steps": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ProcessStep"
            },
            "description": "The company's own steps in the process."
          },
          "done_steps": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/DoneStep"
            },
            "description": "Which of those steps this project has done."
          },
          "parts": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ProjectPart"
            },
            "description": "Its parts, when it has several."
          },
          "part_types": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PartType"
            },
            "description": "The company's part types, to add a part."
          },
          "permissions": {
            "$ref": "#/components/schemas/Permissions",
            "description": "What the caller may do."
          },
          "user_id": {
            "type": "integer",
            "format": "int32",
            "description": "The caller's user id (to show which tasks and notes are theirs)."
          },
          "step_owners": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/StepOwner"
            },
            "description": "Who is responsible for each step on this project, and when it is due."
          },
          "step_items_done": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/StepItemDone"
            },
            "description": "Ticks of the steps' own to-do lists on this project."
          },
          "step_notes": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/StepNote"
            },
            "description": "The steps' notes on this project."
          },
          "lists": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ProjectList"
            },
            "description": "The company's lists, to fill a new to-do list task."
          },
          "questions": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/QuestionSummary"
            },
            "description": "Its questions the caller can see: theirs first."
          },
          "involved": {
            "type": "array",
            "items": {
              "type": "integer",
              "format": "int32"
            },
            "description": "The people involved in the project (sales rep, owner, step and task\npeople, the crew on its appointments), to ask a question or give work."
          },
          "crew": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CrewMember"
            },
            "description": "Who templates and who installs it (its appointments' crew)."
          },
          "chat_regulars": {
            "type": "array",
            "items": {
              "type": "integer",
              "format": "int32"
            },
            "description": "The company's people most often in project chats lately, most first:\nthe chat's people picker puts them before the rest."
          }
        }
      },
      "ProjectsBoard": {
        "type": "object",
        "description": "`GET /v1/projects`: the caller's board.",
        "required": [
          "projects",
          "stages",
          "owners",
          "appointments",
          "tasks",
          "process_steps",
          "done_steps",
          "parts",
          "issue_counts",
          "permissions",
          "page",
          "has_next"
        ],
        "properties": {
          "projects": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Project"
            },
            "description": "The projects, in board order."
          },
          "stages": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Stage"
            },
            "description": "The columns the caller has, in order."
          },
          "owners": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Person"
            },
            "description": "People who may own a project (the owner filter)."
          },
          "appointments": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ProjectAppointment"
            },
            "description": "The next appointments of these projects."
          },
          "tasks": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ProjectTask"
            },
            "description": "Their open tasks, the most urgent first."
          },
          "process_steps": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ProcessStep"
            },
            "description": "The company's own steps in the process."
          },
          "done_steps": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/DoneStep"
            },
            "description": "Which of those steps these projects have done."
          },
          "parts": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ProjectPart"
            },
            "description": "The parts of the projects that have several (none for the others)."
          },
          "issue_counts": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ProjectIssueCount"
            },
            "description": "How many issues the crew reported on these projects' jobs (only those with any)."
          },
          "permissions": {
            "$ref": "#/components/schemas/Permissions",
            "description": "What the caller may do."
          },
          "page": {
            "type": "integer",
            "format": "int32",
            "description": "This page, from 1.",
            "minimum": 0
          },
          "has_next": {
            "type": "boolean",
            "description": "Another page follows."
          }
        }
      },
      "PromiseEvent": {
        "type": "object",
        "description": "Something on the schedule at a time.",
        "required": [
          "title",
          "start"
        ],
        "properties": {
          "title": {
            "type": "string",
            "description": "The event's name."
          },
          "start": {
            "type": "string",
            "format": "date-time",
            "description": "When it starts."
          }
        }
      },
      "PromiseUpdate": {
        "type": "object",
        "description": "Body of `PATCH /v1/ai/promises/{id}`.",
        "required": [
          "status"
        ],
        "properties": {
          "status": {
            "type": "string",
            "description": "`done` (kept), `dismissed` (not a promise, or not wanted) or `open`."
          }
        }
      },
      "PromisesRun": {
        "type": "object",
        "description": "What a run did.",
        "required": [
          "processed",
          "queued",
          "promises",
          "reminded"
        ],
        "properties": {
          "processed": {
            "type": "integer",
            "description": "Calls, texts and emails read.",
            "minimum": 0
          },
          "queued": {
            "type": "integer",
            "format": "int64",
            "description": "Calls, texts and emails newly queued to read.",
            "minimum": 0
          },
          "promises": {
            "type": "integer",
            "description": "Promises, quote tasks and approvals saved.",
            "minimum": 0
          },
          "reminded": {
            "type": "integer",
            "description": "Due promises the reps were reminded of.",
            "minimum": 0
          }
        }
      },
      "PublicBookVisitInput": {
        "type": "object",
        "description": "`POST /v1/public/companies/{company_id}/visits`: a visitor of the\ncompany's stones page books without an account.",
        "required": [
          "kind",
          "start",
          "name",
          "email",
          "phone"
        ],
        "properties": {
          "kind": {
            "$ref": "#/components/schemas/VisitKind",
            "description": "The kind of visit."
          },
          "start": {
            "type": "string",
            "description": "One of the `times` of `GET /v1/public/companies/{company_id}/visits/options`\n(ISO 8601, UTC)."
          },
          "name": {
            "type": "string",
            "description": "Their name, up to 100 characters."
          },
          "email": {
            "type": "string",
            "description": "Their email: the confirmation goes there."
          },
          "phone": {
            "type": "string",
            "description": "Their phone, a US number with its area code."
          },
          "address": {
            "type": [
              "string",
              "null"
            ],
            "description": "Where an in-home estimate happens; required for one, ignored for a\nshowroom visit. Up to 500 characters."
          },
          "notes": {
            "type": [
              "string",
              "null"
            ],
            "description": "Anything they want the salesperson to know, up to 1000 characters."
          },
          "website": {
            "type": [
              "string",
              "null"
            ],
            "description": "Left empty by people: a hidden field only bots fill in."
          },
          "salesperson_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "The salesperson to book with (`salespeople` of the options); they\nmust be free then. Omitted: anyone free then."
          }
        }
      },
      "PublicCompany": {
        "type": "object",
        "description": "A company of the showroom.",
        "required": [
          "id"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "Company id; use it in the other public routes."
          }
        }
      },
      "PublicCompanyCard": {
        "type": "object",
        "description": "A company's name and logo for a showroom chooser.",
        "required": [
          "id"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "Company id."
          },
          "name": {
            "type": [
              "string",
              "null"
            ],
            "description": "Name."
          },
          "logo_url": {
            "type": [
              "string",
              "null"
            ],
            "description": "Logo URL; null when it has none."
          }
        }
      },
      "PublicFixture": {
        "type": "object",
        "description": "A sink or faucet model of the showroom.",
        "required": [
          "id",
          "name",
          "type",
          "url",
          "regular_stock",
          "available"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "Model id."
          },
          "name": {
            "type": "string",
            "description": "Model name."
          },
          "type": {
            "type": "string",
            "description": "Model type."
          },
          "url": {
            "type": "string",
            "description": "Image URL; may be empty."
          },
          "length": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Length in inches (sinks); null for faucets."
          },
          "width": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Width in inches (sinks); null for faucets."
          },
          "regular_stock": {
            "type": "boolean",
            "description": "Always orderable."
          },
          "available": {
            "type": "integer",
            "format": "int64",
            "description": "Units free to sell."
          },
          "retail_price": {
            "type": [
              "string",
              "null"
            ],
            "description": "Retail price, decimal string; null if not set."
          }
        }
      },
      "PublicMaterial": {
        "type": "object",
        "description": "A material of the showroom (the stones of one name, e.g. \"Fantasy\nBrown\"): its stones in stock, each one bundle, and the installed photos\nof its stones. Prices are never sent: `retail_price` and\n`slab_price_per_sqft` of its stones are always null.",
        "required": [
          "id",
          "name",
          "stones",
          "images"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "Material id."
          },
          "name": {
            "type": "string",
            "description": "Name, e.g. \"Fantasy Brown\"."
          },
          "type": {
            "type": [
              "string",
              "null"
            ],
            "description": "Stone type, e.g. `granite`."
          },
          "url": {
            "type": [
              "string",
              "null"
            ],
            "description": "Photo: the material's own, else the first stone photo."
          },
          "stones": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PublicStone"
            },
            "description": "Its displayed stones in stock, by bundle number."
          },
          "images": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PublicPhoto"
            },
            "description": "Installed project photos of its displayed stones, newest first."
          }
        }
      },
      "PublicPhoto": {
        "type": "object",
        "description": "A photo of a stone installed in a project.",
        "required": [
          "id"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "Photo id."
          },
          "url": {
            "type": [
              "string",
              "null"
            ],
            "description": "Photo URL."
          }
        }
      },
      "PublicSlab": {
        "type": "object",
        "description": "An available slab of a showroom stone.",
        "required": [
          "id"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int64",
            "description": "Slab id."
          },
          "bundle": {
            "type": [
              "string",
              "null"
            ],
            "description": "Bundle label."
          },
          "url": {
            "type": [
              "string",
              "null"
            ],
            "description": "Photo of the slab; null when none (show the stone image)."
          },
          "length": {
            "type": [
              "string",
              "null"
            ],
            "description": "Length in inches as entered."
          },
          "width": {
            "type": [
              "string",
              "null"
            ],
            "description": "Width in inches as entered."
          }
        }
      },
      "PublicStone": {
        "type": "object",
        "description": "A stone of the showroom: no costs, only what customers may see.",
        "required": [
          "id",
          "on_sale",
          "regular_stock",
          "slabs"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "Stone id."
          },
          "name": {
            "type": [
              "string",
              "null"
            ],
            "description": "Stone name."
          },
          "type": {
            "type": [
              "string",
              "null"
            ],
            "description": "Material type, e.g. `granite`."
          },
          "url": {
            "type": [
              "string",
              "null"
            ],
            "description": "Image URL; null when none. Thumbnails are at `<name>-icon.<ext>`."
          },
          "material_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Material (the stones of one name) it belongs to; null until linked."
          },
          "length": {
            "type": [
              "number",
              "null"
            ],
            "format": "float",
            "description": "Typical slab length in inches."
          },
          "width": {
            "type": [
              "number",
              "null"
            ],
            "format": "float",
            "description": "Typical slab width in inches."
          },
          "on_sale": {
            "type": "boolean",
            "description": "Marked as on sale."
          },
          "regular_stock": {
            "type": "boolean",
            "description": "Always orderable."
          },
          "retail_price": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Retail price per square foot in dollars; 0 means priced by slab\n(see `slab_price_per_sqft`)."
          },
          "slab_price_per_sqft": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Price per square foot of a slab, set only for stones priced by slab\n(`retail_price` 0); null otherwise."
          },
          "level": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Price level, a number of the frame's `stone_levels` (1 = cheapest); contractor discounts depend on it."
          },
          "finishing": {
            "type": [
              "string",
              "null"
            ],
            "description": "Surface finish."
          },
          "bundle_number": {
            "type": [
              "string",
              "null"
            ],
            "description": "Supplier bundle number."
          },
          "block_number": {
            "type": [
              "string",
              "null"
            ],
            "description": "Quarry block number; a block gives several bundles."
          },
          "created_date": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When the stone was added."
          },
          "slabs": {
            "$ref": "#/components/schemas/SlabCounts",
            "description": "Slabs in the yard (own and linked stones)."
          }
        }
      },
      "Purged": {
        "type": "object",
        "description": "Result of `POST /v1/emails/threads/purge`.",
        "required": [
          "purged"
        ],
        "properties": {
          "purged": {
            "type": "integer",
            "description": "Messages erased.",
            "minimum": 0
          }
        }
      },
      "PushSent": {
        "type": "object",
        "description": "How many phones were told.",
        "required": [
          "pushed"
        ],
        "properties": {
          "pushed": {
            "type": "integer",
            "description": "Phones FCM accepted the push for; 0 when there was nothing to push or\nno signed-in phone.",
            "minimum": 0
          }
        }
      },
      "PushSetting": {
        "type": "object",
        "description": "One push switch.",
        "required": [
          "key",
          "on"
        ],
        "properties": {
          "key": {
            "type": "string",
            "description": "What the push is (`missed_call`, `text`, `lead_new`, `task_due`...)."
          },
          "on": {
            "type": "boolean",
            "description": "The push is sent to my phones."
          }
        }
      },
      "PushSettingInput": {
        "type": "object",
        "description": "Body of `PUT /v1/phone/push-settings`.",
        "required": [
          "key",
          "on"
        ],
        "properties": {
          "key": {
            "type": "string",
            "description": "A key from `GET /v1/phone/push-settings`."
          },
          "on": {
            "type": "boolean",
            "description": "`true`: send these pushes; `false`: mute them."
          }
        }
      },
      "PushSettings": {
        "type": "object",
        "description": "`GET /v1/phone/push-settings`.",
        "required": [
          "settings"
        ],
        "properties": {
          "settings": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PushSetting"
            },
            "description": "The switches I get, in order: the lead switches only sales managers\nget are left out for others, as are maintenance (the shop's) and\npromise reminders (only for those who have them). The 911 alert has\nnone: it always goes out."
          }
        }
      },
      "PushTokenInput": {
        "type": "object",
        "description": "Body of `PUT /v1/phone/devices/{id}/push-token`.",
        "required": [
          "pushToken"
        ],
        "properties": {
          "pushToken": {
            "type": "string",
            "description": "The phone's current FCM registration token (at most 512 characters)."
          }
        }
      },
      "QboCopyInput": {
        "type": "object",
        "description": "Body of `PUT /v1/invoices/{id}/qbo-copy`.",
        "properties": {
          "qbo_invoice_id": {
            "type": [
              "string",
              "null"
            ],
            "description": "The `QuickBooks` invoice that copies this one; null when there is\nnone any more (deleted in `QuickBooks`)."
          }
        },
        "additionalProperties": false
      },
      "QboCustomer": {
        "type": "object",
        "description": "A `QuickBooks` customer.",
        "required": [
          "id",
          "display_name"
        ],
        "properties": {
          "id": {
            "type": "string",
            "description": "`QuickBooks` customer id."
          },
          "display_name": {
            "type": "string",
            "description": "Display name."
          },
          "email": {
            "type": [
              "string",
              "null"
            ],
            "description": "Primary email."
          }
        }
      },
      "QboCustomers": {
        "type": "object",
        "description": "`GET /v1/qbo/customers`.",
        "required": [
          "connected",
          "customers"
        ],
        "properties": {
          "connected": {
            "type": "boolean",
            "description": "False when the company has not connected `QuickBooks`."
          },
          "customers": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/QboCustomer"
            },
            "description": "Matches."
          }
        }
      },
      "QboInvoiceCopiesRun": {
        "type": "object",
        "description": "What a run did.",
        "required": [
          "filling",
          "checked",
          "changed",
          "failed"
        ],
        "properties": {
          "filling": {
            "type": "integer",
            "description": "Companies whose copy took pages of its first fill.",
            "minimum": 0
          },
          "checked": {
            "type": "integer",
            "description": "Companies whose changes were read.",
            "minimum": 0
          },
          "changed": {
            "type": "integer",
            "description": "Invoices that changed.",
            "minimum": 0
          },
          "failed": {
            "type": "integer",
            "description": "Companies `QuickBooks` could not be asked for (tried again later).",
            "minimum": 0
          }
        }
      },
      "QboItem": {
        "type": "object",
        "description": "A product or service an invoice line can sell.",
        "required": [
          "id",
          "name"
        ],
        "properties": {
          "id": {
            "type": "string",
            "description": "`QuickBooks` item id."
          },
          "name": {
            "type": "string",
            "description": "Its name."
          }
        }
      },
      "QboItems": {
        "type": "object",
        "description": "`GET /v1/qbo/items`.",
        "required": [
          "items",
          "classes",
          "class_per_line"
        ],
        "properties": {
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/QboItem"
            },
            "description": "By name."
          },
          "classes": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "The active classes' full names, by name."
          },
          "class_per_line": {
            "type": "boolean",
            "description": "The company sets classes on each line, so a line can have its own."
          }
        }
      },
      "QboWebhookReceived": {
        "type": "object",
        "description": "What the webhook answers.",
        "required": [
          "companies"
        ],
        "properties": {
          "companies": {
            "type": "integer",
            "description": "`QuickBooks` companies marked changed.",
            "minimum": 0
          }
        }
      },
      "Question": {
        "type": "object",
        "description": "A question of a questionnaire.",
        "required": [
          "id",
          "question"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "Question id."
          },
          "question": {
            "type": "string",
            "description": "The question."
          }
        }
      },
      "QuestionChange": {
        "type": "object",
        "description": "Body of `PUT /v1/projects/{id}/questions/{question_id}`.",
        "properties": {
          "add": {
            "type": "array",
            "items": {
              "type": "integer",
              "format": "int32"
            },
            "description": "People to add (they are told)."
          },
          "join": {
            "type": "boolean",
            "description": "The caller joins it (no one is told)."
          },
          "remove": {
            "type": "array",
            "items": {
              "type": "integer",
              "format": "int32"
            },
            "description": "People to take off it (no one is told; never the person who started\nit). They still read it like anyone on the project, without alerts."
          },
          "resolved": {
            "type": [
              "boolean",
              "null"
            ],
            "description": "Answered (true) or open again (false); left out keeps it."
          }
        }
      },
      "QuestionCount": {
        "type": "object",
        "description": "How many questions a call published or generated.",
        "required": [
          "count"
        ],
        "properties": {
          "count": {
            "type": "integer",
            "format": "int64",
            "description": "Questions.",
            "minimum": 0
          }
        }
      },
      "QuestionInput": {
        "type": "object",
        "description": "Body of `POST /v1/projects/{id}/questions`.",
        "required": [
          "text"
        ],
        "properties": {
          "text": {
            "type": "string",
            "description": "The question: 1 to 5000 characters (may be empty with pictures)."
          },
          "to": {
            "type": "array",
            "items": {
              "type": "integer",
              "format": "int32"
            },
            "description": "Who it is for (user ids in the company); ignored with `everyone`."
          },
          "everyone": {
            "type": "boolean",
            "description": "Ask everyone involved in the project."
          },
          "urls": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Pictures uploaded to the `chats` folder (`POST /v1/uploads`; the\n`url` it returns), at most 10. Older apps' `events` uploads are still\ntaken and moved into the private chat bucket."
          }
        }
      },
      "QuestionMessage": {
        "type": "object",
        "description": "One message of a question.",
        "required": [
          "id",
          "body",
          "created_at",
          "photos"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "Its id."
          },
          "user_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Who wrote it; null once that user is gone."
          },
          "user_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "Their name."
          },
          "body": {
            "type": "string",
            "description": "The text (may be empty when it has pictures)."
          },
          "created_at": {
            "type": "string",
            "description": "When, UTC ISO."
          },
          "photos": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Its pictures, in order: links that work for one to two hours (the\npictures are private; read the chat again for fresh ones)."
          }
        }
      },
      "QuestionReply": {
        "type": "object",
        "description": "Body of `POST /v1/projects/{id}/questions/{question_id}/messages`.",
        "required": [
          "text"
        ],
        "properties": {
          "text": {
            "type": "string",
            "description": "1 to 5000 characters (may be empty with pictures)."
          },
          "urls": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Pictures uploaded to the `chats` folder (`POST /v1/uploads`; the\n`url` it returns), at most 10. Older apps' `events` uploads are still\ntaken and moved into the private chat bucket."
          }
        }
      },
      "QuestionSummary": {
        "type": "object",
        "description": "A question on a project, for its list.",
        "required": [
          "id",
          "title",
          "everyone",
          "created_at",
          "last_message_at",
          "message_count",
          "unread",
          "member",
          "members"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "Its id."
          },
          "title": {
            "type": "string",
            "description": "Its first words."
          },
          "everyone": {
            "type": "boolean",
            "description": "Asked to everyone involved in the project."
          },
          "created_by": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Who asked; null once that user is gone."
          },
          "created_by_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "Their name."
          },
          "created_at": {
            "type": "string",
            "description": "When it was asked, UTC ISO."
          },
          "last_message_at": {
            "type": "string",
            "description": "When its last message was written, UTC ISO."
          },
          "resolved_at": {
            "type": [
              "string",
              "null"
            ],
            "description": "When it was marked answered, UTC ISO; null while open."
          },
          "message_count": {
            "type": "integer",
            "format": "int64",
            "description": "How many messages it has."
          },
          "unread": {
            "type": "integer",
            "format": "int64",
            "description": "Messages the caller has not read (always 0 for someone not in it)."
          },
          "member": {
            "type": "boolean",
            "description": "The caller is in it (asked, or asked to, or joined)."
          },
          "members": {
            "type": "array",
            "items": {
              "type": "integer",
              "format": "int32"
            },
            "description": "The people in it (user ids), the asker first."
          }
        }
      },
      "QuestionThread": {
        "type": "object",
        "description": "`GET /v1/projects/{id}/questions/{question_id}`: a question and its messages.",
        "required": [
          "question",
          "messages"
        ],
        "properties": {
          "question": {
            "$ref": "#/components/schemas/QuestionSummary",
            "description": "The question."
          },
          "messages": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/QuestionMessage"
            },
            "description": "Its messages, oldest first."
          }
        }
      },
      "QuestionUpdate": {
        "type": "object",
        "description": "Body of `PUT /v1/teach-mode/questions/{id}`.",
        "required": [
          "text",
          "choices"
        ],
        "properties": {
          "text": {
            "type": "string",
            "description": "The question."
          },
          "choices": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ChoiceInput"
            },
            "description": "The answers it keeps (others are deleted): at least two, exactly one right."
          }
        }
      },
      "QueuedQuestion": {
        "type": "object",
        "description": "A queued question.",
        "required": [
          "id",
          "status",
          "chat_id",
          "runner"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int64",
            "description": "The question's id, to poll."
          },
          "status": {
            "type": "string",
            "description": "Always `queued`."
          },
          "chat_id": {
            "type": "integer",
            "format": "int64",
            "description": "The chat it was asked in."
          },
          "runner": {
            "$ref": "#/components/schemas/RunnerState",
            "description": "How soon the agent's machine can pick it up."
          }
        }
      },
      "QueuedSale": {
        "type": "object",
        "description": "A sale waiting for its invoice.",
        "required": [
          "id"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "Sale id."
          },
          "sale_date": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When it was sold."
          },
          "customer_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "Customer name."
          },
          "seller_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "Seller name."
          },
          "cancelled_date": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When it was cancelled."
          },
          "installed_date": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When it was installed."
          }
        }
      },
      "QueuedSaleDetail": {
        "allOf": [
          {
            "$ref": "#/components/schemas/QueuedSale"
          },
          {
            "type": "object",
            "properties": {
              "email": {
                "type": [
                  "string",
                  "null"
                ],
                "description": "The customer's primary email."
              },
              "phone": {
                "type": [
                  "string",
                  "null"
                ],
                "description": "The customer's phone."
              },
              "address": {
                "type": [
                  "string",
                  "null"
                ],
                "description": "The customer's address."
              },
              "qbo_id": {
                "type": [
                  "integer",
                  "null"
                ],
                "format": "int32",
                "description": "The customer's QuickBooks id; null until linked."
              }
            }
          }
        ],
        "description": "A queued sale with its customer's contact."
      },
      "QuickStone": {
        "type": "object",
        "description": "Response of `POST /v1/stones/quick`.",
        "required": [
          "id",
          "name",
          "type",
          "retail_price",
          "slab_ids"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "New stone id."
          },
          "name": {
            "type": "string",
            "description": "Stone name."
          },
          "type": {
            "type": "string",
            "description": "Material type."
          },
          "retail_price": {
            "type": "number",
            "format": "double",
            "description": "Retail price per square foot."
          },
          "slab_ids": {
            "type": "array",
            "items": {
              "type": "integer",
              "format": "int64"
            },
            "description": "Ids of the slabs added, in order."
          }
        }
      },
      "QuickStoneInput": {
        "type": "object",
        "description": "Body of `POST /v1/stones/quick`.",
        "required": [
          "name",
          "type",
          "retail_price",
          "leftover"
        ],
        "properties": {
          "name": {
            "type": "string",
            "description": "Stone name."
          },
          "type": {
            "type": "string",
            "description": "Material type; must be one of the company's stone types."
          },
          "retail_price": {
            "type": "number",
            "format": "double",
            "description": "Retail price per square foot in dollars; must be positive."
          },
          "length": {
            "type": [
              "number",
              "null"
            ],
            "format": "double",
            "description": "Slab length in inches; 0 when unknown."
          },
          "width": {
            "type": [
              "number",
              "null"
            ],
            "format": "double",
            "description": "Slab width in inches; 0 when unknown."
          },
          "leftover": {
            "type": "boolean",
            "description": "`true` adds one leftover slab with a generated bundle (`LO-YYYYMMDD-XXXX`);\n`false` adds one slab per entry of `bundles`."
          },
          "bundles": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Bundle labels of the slabs to add when `leftover` is false."
          }
        },
        "additionalProperties": false
      },
      "QuickbooksApp": {
        "type": "object",
        "description": "Body of `PUT /v1/superuser/companies/{id}/quickbooks-app`.",
        "required": [
          "client_id",
          "client_secret"
        ],
        "properties": {
          "client_id": {
            "type": "string",
            "description": "The company's own Intuit app client id (10+ characters)."
          },
          "client_secret": {
            "type": "string",
            "description": "Its client secret (10+ characters)."
          }
        }
      },
      "QuickbooksCallback": {
        "type": "object",
        "description": "Body of `POST /v1/quickbooks/connection`.",
        "required": [
          "state",
          "code",
          "realm_id"
        ],
        "properties": {
          "state": {
            "type": "string",
            "description": "`state` as Intuit returned it."
          },
          "code": {
            "type": "string",
            "description": "`code` as Intuit returned it."
          },
          "realm_id": {
            "type": "string",
            "description": "`realmId` as Intuit returned it (the `QuickBooks` company)."
          }
        }
      },
      "QuickbooksConnection": {
        "type": "object",
        "description": "`GET /v1/quickbooks/connection`.",
        "required": [
          "can_connect",
          "connected"
        ],
        "properties": {
          "can_connect": {
            "type": "boolean",
            "description": "The feature is on and an app is set up: Connect works."
          },
          "connected": {
            "type": "boolean",
            "description": "The company has connected an account (false when it cannot connect)."
          }
        }
      },
      "QuickbooksSettings": {
        "type": "object",
        "description": "`QuickBooks` as company settings show it.",
        "required": [
          "feature_enabled",
          "credentials_source",
          "connected"
        ],
        "properties": {
          "feature_enabled": {
            "type": "boolean",
            "description": "The `QuickBooks` feature is on for the company."
          },
          "credentials_source": {
            "$ref": "#/components/schemas/CredentialsSource",
            "description": "Which app connecting uses: `company-app`, `shared-app`, or `none`\n(connecting is not set up)."
          },
          "connected": {
            "type": "boolean",
            "description": "The company has connected an account."
          }
        }
      },
      "QuoteChanges": {
        "type": "object",
        "description": "Changes to a quote; fields left out stay.",
        "properties": {
          "quote_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "Name (blank keeps it)."
          },
          "notes": {
            "type": [
              "string",
              "null"
            ],
            "description": "Notes (blank clears)."
          },
          "address": {
            "type": [
              "string",
              "null"
            ],
            "description": "Job address (blank clears)."
          },
          "phone": {
            "type": [
              "string",
              "null"
            ],
            "description": "Phone (blank clears)."
          },
          "phone_2": {
            "type": [
              "string",
              "null"
            ],
            "description": "The customer's second phone (saved on the customer; blank clears)."
          },
          "email": {
            "type": [
              "string",
              "null"
            ],
            "description": "Email (blank clears)."
          },
          "email_2": {
            "type": [
              "string",
              "null"
            ],
            "description": "Second email, on the quote only (blank clears)."
          },
          "address_notes": {
            "type": [
              "string",
              "null"
            ],
            "description": "Address notes (blank clears)."
          },
          "terms": {
            "type": [
              "object",
              "null"
            ],
            "description": "Payment terms."
          },
          "salesperson_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "A sales rep of the company."
          },
          "customer_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Another customer of the company."
          },
          "tax_pct": {
            "type": [
              "number",
              "null"
            ],
            "format": "double",
            "description": "Tax percent."
          },
          "discount_pct": {
            "type": [
              "number",
              "null"
            ],
            "format": "double",
            "description": "Discount percent."
          },
          "discount_amount": {
            "type": [
              "number",
              "null"
            ],
            "format": "double",
            "description": "Discount in dollars (not negative)."
          },
          "expiration_date": {
            "type": [
              "string",
              "null"
            ],
            "description": "Expires on (YYYY-MM-DD)."
          },
          "price_list_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "A price list: the quote takes its newest revision (the same list moves to its newest)."
          },
          "bill_to": {
            "type": [
              "object",
              "null"
            ],
            "description": "Bill to (`name`, `company`, `address`, `phone`, `email`); `{}` goes back to the quote's contact."
          },
          "ship_to": {
            "type": [
              "object",
              "null"
            ],
            "description": "Ship to (as `bill_to`, or `{\"same\": true}`); `{}` goes back to the quote's contact."
          },
          "form_hidden": {
            "type": [
              "object",
              "null"
            ],
            "description": "Sections hidden on this quote's printed forms (form id → field ids); replaces the stored set."
          }
        },
        "additionalProperties": false
      },
      "QuoteContract": {
        "type": "object",
        "description": "A contract sent for signature from this quote.",
        "required": [
          "id",
          "filename",
          "status",
          "signer_name",
          "signer_email",
          "url"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int64",
            "description": "Signature request id."
          },
          "filename": {
            "type": "string",
            "description": "File name without `.pdf`."
          },
          "status": {
            "type": "string",
            "description": "Request status."
          },
          "signer_name": {
            "type": "string",
            "description": "Signer."
          },
          "signer_email": {
            "type": "string",
            "description": "Signer's email."
          },
          "sent_to": {
            "type": [
              "string",
              "null"
            ],
            "description": "Who the email carrying it went to."
          },
          "sent_at": {
            "type": [
              "string",
              "null"
            ],
            "description": "When it was sent (ISO 8601)."
          },
          "signed_at": {
            "type": [
              "string",
              "null"
            ],
            "description": "When it was signed (ISO 8601)."
          },
          "url": {
            "type": "string",
            "description": "Where to open it (an API path, or the file's URL)."
          }
        }
      },
      "QuoteCopy": {
        "type": "object",
        "description": "A copy of a quote.",
        "required": [
          "quote_name"
        ],
        "properties": {
          "quote_name": {
            "type": "string",
            "description": "The copy's name (required)."
          },
          "quote_type": {
            "type": [
              "string",
              "null"
            ],
            "description": "Type; blank keeps the quote's."
          },
          "price_list_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Another price list (its newest revision); none keeps the quote's."
          },
          "salesperson_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Another sales rep; none keeps the quote's."
          },
          "copy_address": {
            "type": "boolean",
            "description": "Copy the address, phone, email and address notes."
          },
          "copy_drawing": {
            "type": "boolean",
            "description": "Copy the drawing."
          }
        },
        "additionalProperties": false
      },
      "QuoteDetail": {
        "type": "object",
        "description": "Everything the quote page and the editor show.",
        "required": [
          "quote",
          "doc",
          "price_list",
          "latest_price_list",
          "default_edge_profile_sets",
          "revisions",
          "emails",
          "contracts",
          "salespeople",
          "stone_icons",
          "stone_images",
          "sender"
        ],
        "properties": {
          "quote": {
            "$ref": "#/components/schemas/QuoteInfo",
            "description": "The quote."
          },
          "doc": {
            "type": "object",
            "description": "The drawing (or the revision's), as stored."
          },
          "viewing_revision": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "The revision shown instead of the current drawing."
          },
          "price_list": {
            "type": "object",
            "description": "The quote's prices: its snapshot with today's new choices."
          },
          "latest_price_list": {
            "type": "object",
            "description": "The same list as it prices today."
          },
          "default_edge_profile_sets": {
            "type": "array",
            "items": {
              "type": "object"
            },
            "description": "A quote with no price list (an imported one): the edge profiles of\nthe company's default list, for the Edge choices only (never priced).\nEmpty for a quote with a price list."
          },
          "revisions": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/QuoteRevision"
            },
            "description": "Saved revisions, newest first."
          },
          "emails": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/QuoteEmailRow"
            },
            "description": "Emails that carried the link, newest first."
          },
          "contracts": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/QuoteContract"
            },
            "description": "Contracts sent from the quote."
          },
          "salespeople": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Salesperson"
            },
            "description": "The company's sales reps."
          },
          "stone_icons": {
            "type": "object",
            "description": "Small photo per color: by `name\\0material` and by name.",
            "additionalProperties": {
              "type": "string"
            },
            "propertyNames": {
              "type": "string"
            }
          },
          "stone_images": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/StoneImage"
            },
            "description": "Photos of the quote's colors (the browser builds the previews)."
          },
          "sender": {
            "type": "string",
            "description": "The address the caller's mail leaves from."
          },
          "autosave": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/Autosave",
                "description": "The caller's unsaved drawing."
              },
              {
                "type": "null"
              }
            ]
          },
          "order": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/Order",
                "description": "The Order made when the quote was sold, with its change orders: from\nthen on the drawing is the Order's, and `order.sold_revision_id` is\nthe quote as sold."
              },
              {
                "type": "null"
              }
            ]
          }
        }
      },
      "QuoteEditorPerson": {
        "type": "object",
        "description": "Someone with the quote open in the editor.",
        "required": [
          "id"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "User id."
          },
          "name": {
            "type": [
              "string",
              "null"
            ],
            "description": "Name; null when the user has none."
          }
        }
      },
      "QuoteEditors": {
        "type": "object",
        "description": "The others working on a quote right now.",
        "required": [
          "editors"
        ],
        "properties": {
          "editors": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/QuoteEditorPerson"
            },
            "description": "The other people with the quote open in the editor (never the\ncaller), the one there longest first."
          }
        }
      },
      "QuoteEmail": {
        "type": "object",
        "description": "An email with the quote's link.",
        "required": [
          "to",
          "subject",
          "body"
        ],
        "properties": {
          "to": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Recipients (required)."
          },
          "cc": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Copies."
          },
          "bcc": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Blind copies."
          },
          "subject": {
            "type": "string",
            "description": "Subject (required); `{{variables}}` are filled in like the body's."
          },
          "body": {
            "type": "string",
            "description": "Plain text, or the template editor's rich text (HTML: sizes, colors,\nlists, links, pictures; cleaned before sending). `{{variables}}` are filled in: the `POST /v1/templates/fill`\nones (`user.*`, `customer.*`, `company.*`, `deal.*` when the quote has a\ndeal, `current_date`) plus `{{quote.name}}`, `{{quote.total}}`\n(accepted option, else the first, e.g. `$12,345.00`), `{{quote.color}}`\n(that option's materials and colors), `{{quote.link}}` (the customer's\nlink) and `{{quote.expiration}}` (e.g. `November 5, 2026`). A\n`{{quote.*}}` or `{{deal.*}}` with no value yet is refused (400);\nother unknown variables are left as typed. `[QuoteLink]`/`[PDFLink]` become a \"View\nyour quote\" link; one is added at the end when the link is missing."
          },
          "form_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "A company form the link shows the quote in."
          },
          "template_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "The template used (counts toward the default)."
          },
          "attachments": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SendAttachment"
            },
            "description": "Files sent with the email, each uploaded by the caller\n(`POST /v1/uploads`, folder `emails`, with its `token`)."
          }
        },
        "additionalProperties": false
      },
      "QuoteEmailRow": {
        "type": "object",
        "description": "An email that carried the quote's link.",
        "required": [
          "id",
          "view_count",
          "views"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "Email id."
          },
          "revision_number": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "The revision sent."
          },
          "recipients": {
            "type": [
              "string",
              "null"
            ],
            "description": "To."
          },
          "subject": {
            "type": [
              "string",
              "null"
            ],
            "description": "Subject."
          },
          "sent_at": {
            "type": [
              "string",
              "null"
            ],
            "description": "When (ISO 8601)."
          },
          "sent_by": {
            "type": [
              "string",
              "null"
            ],
            "description": "Who sent it."
          },
          "view_count": {
            "type": "integer",
            "format": "int32",
            "description": "How many times the link was opened."
          },
          "last_viewed_at": {
            "type": [
              "string",
              "null"
            ],
            "description": "Last opened (ISO 8601)."
          },
          "expires_at": {
            "type": [
              "string",
              "null"
            ],
            "description": "The link expires on (YYYY-MM-DD)."
          },
          "body_html": {
            "type": [
              "string",
              "null"
            ],
            "description": "The message as sent."
          },
          "deactivated_at": {
            "type": [
              "string",
              "null"
            ],
            "description": "The link was switched off (ISO 8601)."
          },
          "views": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/QuoteEmailView"
            },
            "description": "Every time the link was opened, newest first. Views from before\nviews were kept one by one are only in `view_count`, so this list\ncan be shorter than the count."
          }
        }
      },
      "QuoteEmailTemplate": {
        "type": "object",
        "description": "A default for emailing quotes.",
        "required": [
          "id",
          "personal",
          "name",
          "subject",
          "body",
          "sequence"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "Template id."
          },
          "personal": {
            "type": "boolean",
            "description": "The caller's own template (only they see it); false for company ones."
          },
          "name": {
            "type": "string",
            "description": "Name."
          },
          "subject": {
            "type": "string",
            "description": "Email subject."
          },
          "body": {
            "type": "string",
            "description": "Email body; links to the quote with `[QuoteLink]` or `[PDFLink]`."
          },
          "sequence": {
            "type": "integer",
            "format": "int32",
            "description": "Order among the company's templates."
          }
        }
      },
      "QuoteEmailTemplateInput": {
        "type": "object",
        "description": "Body of creating or saving a company quote email template.",
        "required": [
          "name",
          "subject",
          "body"
        ],
        "properties": {
          "name": {
            "type": "string",
            "description": "Name; required, at most 120 characters (longer is cut)."
          },
          "subject": {
            "type": "string",
            "description": "Subject; required, at most 255 characters (longer is cut)."
          },
          "body": {
            "type": "string",
            "description": "Body; `[PDFLink]` is added when it has no quote link."
          },
          "sequence": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Position among the company's templates (1 = first)."
          }
        },
        "additionalProperties": false
      },
      "QuoteEmailTemplateOrder": {
        "type": "object",
        "description": "Body of `PUT /v1/quote-email-templates/order`.",
        "required": [
          "ids"
        ],
        "properties": {
          "ids": {
            "type": "array",
            "items": {
              "type": "integer",
              "format": "int32"
            },
            "description": "The company template ids in their new order."
          }
        },
        "additionalProperties": false
      },
      "QuoteEmailView": {
        "type": "object",
        "description": "One opening of an emailed quote link.",
        "required": [
          "viewed_at"
        ],
        "properties": {
          "viewed_at": {
            "type": "string",
            "description": "When (ISO 8601)."
          },
          "ip_address": {
            "type": [
              "string",
              "null"
            ],
            "description": "The viewer's IP address, when known."
          },
          "user_agent": {
            "type": [
              "string",
              "null"
            ],
            "description": "The viewer's browser (`User-Agent`), when known."
          }
        }
      },
      "QuoteForm": {
        "type": "object",
        "description": "A form with its layout.",
        "required": [
          "id",
          "name",
          "status",
          "sequence",
          "kind",
          "config"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "Form id."
          },
          "name": {
            "type": "string",
            "description": "Name."
          },
          "status": {
            "type": "string",
            "description": "`active` or `inactive`."
          },
          "sequence": {
            "type": "integer",
            "format": "int32",
            "description": "Order in the print and send dialogs."
          },
          "kind": {
            "type": "string",
            "description": "`quote` or `contract`."
          },
          "config": {
            "type": "object",
            "description": "The layout (`QuoteFormConfig`), as saved; null when unreadable."
          }
        }
      },
      "QuoteFormSummary": {
        "type": "object",
        "description": "A form without its layout.",
        "required": [
          "id",
          "name",
          "status",
          "sequence",
          "kind",
          "design"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "Form id."
          },
          "name": {
            "type": "string",
            "description": "Name."
          },
          "status": {
            "type": "string",
            "description": "`active` or `inactive`."
          },
          "sequence": {
            "type": "integer",
            "format": "int32",
            "description": "Order in the print and send dialogs."
          },
          "kind": {
            "type": "string",
            "description": "`quote` or `contract` (ends with signature lines)."
          },
          "design": {
            "type": "string",
            "description": "Its look: `classic`, `modern`, `minimal` or `bold`."
          }
        }
      },
      "QuoteInfo": {
        "type": "object",
        "description": "The quote's own fields.",
        "required": [
          "id",
          "name",
          "customer_id",
          "terms",
          "tax_pct",
          "discount_pct",
          "discount_amount",
          "form_hidden"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "Quote id."
          },
          "quote_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "Its own name."
          },
          "name": {
            "type": "string",
            "description": "What it is called (its name, else the customer's)."
          },
          "expiration_date": {
            "type": [
              "string",
              "null"
            ],
            "description": "Expires on (YYYY-MM-DD)."
          },
          "price_list_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "The price list."
          },
          "price_list_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "Its name."
          },
          "price_list_revision_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "The revision the quote prices with."
          },
          "price_list_revision_number": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Its number."
          },
          "sales_rep": {
            "type": [
              "string",
              "null"
            ],
            "description": "Sales rep's name."
          },
          "salesperson_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Sales rep."
          },
          "quote_type": {
            "type": [
              "string",
              "null"
            ],
            "description": "Type."
          },
          "notes": {
            "type": [
              "string",
              "null"
            ],
            "description": "Notes."
          },
          "customer_id": {
            "type": "integer",
            "format": "int32",
            "description": "The customer."
          },
          "customer_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "Their name."
          },
          "address": {
            "type": [
              "string",
              "null"
            ],
            "description": "The job's address."
          },
          "phone": {
            "type": [
              "string",
              "null"
            ],
            "description": "The quote's phone."
          },
          "customer_phone": {
            "type": [
              "string",
              "null"
            ],
            "description": "The customer's phone."
          },
          "phone_2": {
            "type": [
              "string",
              "null"
            ],
            "description": "The customer's second phone."
          },
          "email": {
            "type": [
              "string",
              "null"
            ],
            "description": "The quote's email."
          },
          "email_2": {
            "type": [
              "string",
              "null"
            ],
            "description": "The quote's second email."
          },
          "address_notes": {
            "type": [
              "string",
              "null"
            ],
            "description": "Address notes."
          },
          "current_revision": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Latest saved revision."
          },
          "current_step": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Editor step."
          },
          "portal_token": {
            "type": [
              "string",
              "null"
            ],
            "description": "The customer link's token."
          },
          "terms": {
            "type": "object",
            "description": "Payment terms (`terms`, `mode`, `deposits`, `remaining`)."
          },
          "status": {
            "type": [
              "string",
              "null"
            ],
            "description": "`draft`, `active`, `accepted`, `lost` or `converted`."
          },
          "sold_option": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Index of the option sold or accepted."
          },
          "deal_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int64",
            "description": "The deal."
          },
          "signed_at": {
            "type": [
              "string",
              "null"
            ],
            "description": "When the customer signed (ISO 8601)."
          },
          "tax_pct": {
            "type": "number",
            "format": "double",
            "description": "Tax percent."
          },
          "discount_pct": {
            "type": "number",
            "format": "double",
            "description": "Discount percent."
          },
          "discount_amount": {
            "type": "number",
            "format": "double",
            "description": "Discount in dollars."
          },
          "created_date": {
            "type": [
              "string",
              "null"
            ],
            "description": "Made on (ISO 8601)."
          },
          "created_by_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "Who made it."
          },
          "salesperson_phone": {
            "type": [
              "string",
              "null"
            ],
            "description": "The sales rep's phone."
          },
          "qbo_invoice_id": {
            "type": [
              "string",
              "null"
            ],
            "description": "The `QuickBooks` invoice made from it."
          },
          "bill_to": {
            "type": [
              "object",
              "null"
            ],
            "description": "Who pays (`name`, `company`, `address`, `phone`, `email`); null: the quote's own contact."
          },
          "ship_to": {
            "type": [
              "object",
              "null"
            ],
            "description": "Where it goes (as `bill_to`, or `{\"same\": true}` for the Bill to); null: the quote's own contact."
          },
          "form_hidden": {
            "type": "object",
            "description": "Sections hidden on this quote's printed forms: form id → field ids."
          }
        }
      },
      "QuoteInvoiceSyncInput": {
        "type": "object",
        "description": "Body of `PUT /v1/company/quote-invoice-sync`.",
        "required": [
          "enabled"
        ],
        "properties": {
          "enabled": {
            "type": "boolean",
            "description": "On: a new invoice from a quote starts with \"Keep in sync with the\nquote\" ticked."
          }
        },
        "additionalProperties": false
      },
      "QuoteLinkSigningInput": {
        "type": "object",
        "description": "Body of `PUT /v1/company/quote-link-signing`.",
        "required": [
          "enabled"
        ],
        "properties": {
          "enabled": {
            "type": "boolean",
            "description": "On: the customer's quote link shows Accept & Sign."
          }
        },
        "additionalProperties": false
      },
      "QuoteList": {
        "type": "object",
        "description": "`GET /v1/quotes`.",
        "required": [
          "quotes",
          "default_show"
        ],
        "properties": {
          "quotes": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/QuoteListRow"
            },
            "description": "Not deleted quotes, newest first: the page asked for, or all of them."
          },
          "default_show": {
            "type": "string",
            "description": "`all` for sales reps (they start on every quote), else `mine`."
          },
          "total": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int64",
            "description": "With `page`: how many quotes the search and `show` match on all pages."
          }
        }
      },
      "QuoteListRow": {
        "type": "object",
        "description": "A quote in the quotes list.\nIts text borrows the database row: the list is every quote of the\ncompany (thousands), and a `String` per field was a third of its cost.",
        "required": [
          "id",
          "quote_type",
          "status",
          "current_revision",
          "sales_rep",
          "mine"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "The quote."
          },
          "quote_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "Its name."
          },
          "customer_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "The customer's name."
          },
          "quote_type": {
            "type": "string",
            "description": "Quote type."
          },
          "status": {
            "type": "string",
            "description": "`draft`, `sent`, `converted`, ..."
          },
          "created_date": {
            "type": [
              "string",
              "null"
            ],
            "description": "When it was made (UTC, ISO 8601)."
          },
          "current_revision": {
            "type": "integer",
            "format": "int32",
            "description": "Last sent revision; 0 for a draft."
          },
          "price_list_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "Its price list."
          },
          "sales_rep": {
            "type": "string",
            "description": "The salesperson's name."
          },
          "email_viewed_at": {
            "type": [
              "string",
              "null"
            ],
            "description": "When the customer last opened an emailed revision (UTC, ISO 8601)."
          },
          "address": {
            "type": [
              "string",
              "null"
            ],
            "description": "Address, for the list search."
          },
          "phone": {
            "type": [
              "string",
              "null"
            ],
            "description": "Phone, for the list search."
          },
          "email": {
            "type": [
              "string",
              "null"
            ],
            "description": "Email, for the list search."
          },
          "mine": {
            "type": "boolean",
            "description": "The caller is its salesperson (or made it and it has none)."
          }
        }
      },
      "QuoteMoney": {
        "type": "object",
        "description": "One quote's invoices, added up.",
        "required": [
          "quote_id",
          "invoiced",
          "paid",
          "due"
        ],
        "properties": {
          "quote_id": {
            "type": "integer",
            "format": "int32",
            "description": "The quote."
          },
          "invoiced": {
            "type": "number",
            "format": "double",
            "description": "The total of its invoices."
          },
          "paid": {
            "type": "number",
            "format": "double",
            "description": "What is paid on them."
          },
          "due": {
            "type": "number",
            "format": "double",
            "description": "What they still owe."
          },
          "unpaid_due_date": {
            "type": [
              "string",
              "null"
            ],
            "description": "The earliest due date among its invoices that still owe something\n(`YYYY-MM-DD`); null when none has a due date or nothing is owed.\nPast this day with `due` above 0, the quote is past due."
          }
        }
      },
      "QuotePaymentTerm": {
        "type": "object",
        "description": "Payment terms a quote can show.",
        "required": [
          "id",
          "name",
          "sequence",
          "terms"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "Terms id."
          },
          "name": {
            "type": "string",
            "description": "Name, e.g. \"50% deposit\"."
          },
          "sequence": {
            "type": "integer",
            "format": "int32",
            "description": "Order in the lists; the first one prefills new quotes."
          },
          "terms": {
            "type": "string",
            "description": "The terms text."
          }
        }
      },
      "QuotePaymentTermInput": {
        "type": "object",
        "description": "Body of creating or saving payment terms.",
        "required": [
          "name",
          "terms"
        ],
        "properties": {
          "name": {
            "type": "string",
            "description": "Name; required, at most 120 characters (longer is cut)."
          },
          "sequence": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Order; 1 or more (default 1)."
          },
          "terms": {
            "type": "string",
            "description": "The terms text; required, at most 5000 characters (longer is cut)."
          }
        },
        "additionalProperties": false
      },
      "QuotePrint": {
        "type": "object",
        "description": "A print of the quote.",
        "properties": {
          "form_label": {
            "type": "string",
            "description": "The form printed, as the deal's history names it."
          }
        },
        "additionalProperties": false
      },
      "QuoteRevision": {
        "type": "object",
        "description": "A saved revision.",
        "required": [
          "id",
          "revision_number"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "Revision id."
          },
          "revision_number": {
            "type": "integer",
            "format": "int32",
            "description": "Its number."
          },
          "created_at": {
            "type": [
              "string",
              "null"
            ],
            "description": "When (ISO 8601)."
          },
          "created_by": {
            "type": [
              "string",
              "null"
            ],
            "description": "Who saved it."
          },
          "notes": {
            "type": [
              "string",
              "null"
            ],
            "description": "What changed."
          }
        }
      },
      "QuoteSaleEvent": {
        "type": "object",
        "description": "An extra event a quote's sale can add to the schedule.",
        "required": [
          "id",
          "calendar_id",
          "calendar_name",
          "title_variable",
          "title_before",
          "title_text",
          "trigger_extra_ids",
          "trigger_options",
          "no_install",
          "notify_rep"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "Template id."
          },
          "calendar_id": {
            "type": "integer",
            "format": "int32",
            "description": "The calendar the event goes on."
          },
          "calendar_name": {
            "type": "string",
            "description": "That calendar's name."
          },
          "title_variable": {
            "$ref": "#/components/schemas/TitleVariable",
            "description": "The name the event's title is built around."
          },
          "title_before": {
            "type": "string",
            "description": "What comes before the variable, e.g. \"Rough-in\"; empty: nothing."
          },
          "title_text": {
            "type": "string",
            "description": "What follows the variable, e.g. \"Plumbing\"; empty: the variable alone."
          },
          "trigger_extra_ids": {
            "type": "array",
            "items": {
              "type": "integer",
              "format": "int64"
            },
            "description": "Catalog extras (`GET /v1/quote-extras` ids) that tick this event in\nMark as Sold when the quote has one of them (a line whose `catalogId`\nis one of these, any option). Empty: the seller ticks it by hand."
          },
          "trigger_options": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TriggerOption"
            },
            "description": "Single options of catalog extras that tick this event in Mark as Sold\nwhen the quote has a line of that extra with that option (its\n`catalogId` and `optionId`)."
          },
          "part_type_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "The part type (`GET /v1/projects/part-types`) the event is for: when\nthe sale adds it, the sold job's project gets a part of that type and\nthe event belongs to it. Null: the project's first part."
          },
          "part_type_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "That part type's name; null with `part_type_id`."
          },
          "no_install": {
            "type": "boolean",
            "description": "A pickup: the customer collects the job, so its project needs no\ninstallation; the event stands in for it (Completed finishes the job)."
          },
          "notify_rep": {
            "type": "boolean",
            "description": "Tell the job's sales rep (bell and phone push) when the event is\nmarked Completed."
          }
        }
      },
      "QuoteSaleEventInput": {
        "type": "object",
        "description": "Body of creating or saving an event template.",
        "required": [
          "calendar_id"
        ],
        "properties": {
          "calendar_id": {
            "type": "integer",
            "format": "int32",
            "description": "A calendar of the company (`GET /v1/calendars`)."
          },
          "title_variable": {
            "$ref": "#/components/schemas/TitleVariable",
            "description": "What the title starts with (default `quote_name`)."
          },
          "title_before": {
            "type": "string",
            "description": "What comes before the variable, e.g. \"Rough-in\" (at most 200\ncharacters; blank: nothing)."
          },
          "title_text": {
            "type": "string",
            "description": "What follows the variable, e.g. \"Plumbing\" (at most 200 characters;\nblank: the variable alone)."
          },
          "trigger_extra_ids": {
            "type": "array",
            "items": {
              "type": "integer",
              "format": "int64"
            },
            "description": "Catalog extras (`GET /v1/quote-extras` ids) that tick this event in\nMark as Sold when the quote has one. Ids not in the company's catalog\nare dropped. Default none."
          },
          "trigger_options": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TriggerOption"
            },
            "description": "Single options of catalog extras that tick this event in Mark as Sold\nwhen the quote has one. Options not in the company's catalog are\ndropped. Default none."
          },
          "part_type_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "A part type of the company (`GET /v1/projects/part-types`): the sale's\nevent is for a part of that type on the job's project, added when the\nproject has none. Default none: the project's first part."
          },
          "no_install": {
            "type": "boolean",
            "description": "A pickup (see [`QuoteSaleEvent::no_install`]). Default false."
          },
          "notify_rep": {
            "type": "boolean",
            "description": "Tell the sales rep when the event is completed. Default false."
          }
        },
        "additionalProperties": false
      },
      "QuoteSettings": {
        "type": "object",
        "description": "Company defaults for new quotes.",
        "required": [
          "units",
          "rounding",
          "default_depth"
        ],
        "properties": {
          "units": {
            "type": "string",
            "description": "Always `in`."
          },
          "rounding": {
            "type": "number",
            "format": "double",
            "description": "Measurements round to this many inches: 0.5, 0.25, 0.125 or 0.0625."
          },
          "default_depth": {
            "type": "number",
            "format": "double",
            "description": "Default counter depth in inches."
          }
        }
      },
      "QuoteSettingsInput": {
        "type": "object",
        "description": "Body of `PUT /v1/quote-settings`.",
        "required": [
          "rounding",
          "default_depth"
        ],
        "properties": {
          "rounding": {
            "type": "number",
            "format": "double",
            "description": "0.5, 0.25, 0.125 or 0.0625; anything else reads as 0.0625."
          },
          "default_depth": {
            "type": "number",
            "format": "double",
            "description": "Inches, more than 0 and at most 120 (rounded to hundredths)."
          }
        },
        "additionalProperties": false
      },
      "QuoteSquareFeet": {
        "type": "object",
        "description": "A quote's countertop square feet.",
        "required": [
          "id",
          "square_feet"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "The quote."
          },
          "square_feet": {
            "type": "number",
            "format": "double",
            "description": "Countertop sq ft of its drawing: each area's, rounded as its price\nlist rounds material (to 0.1 sq ft, or up to a whole foot), times how\nmany of that area the quote sells, added up. Not rounded again."
          }
        }
      },
      "QuoteSuggestions": {
        "type": "object",
        "description": "`GET /v1/quotes/suggestions`.",
        "required": [
          "area_names",
          "items",
          "hidden"
        ],
        "properties": {
          "area_names": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/AreaNameSuggestion"
            },
            "description": "Area names, used by most customers first (ties: most recent first).\nDefault names such as `Area #2` and hidden ones are left out."
          },
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ItemSuggestion"
            },
            "description": "Miscellaneous and text items, used by most customers first (ties: most\nrecent first). Hidden ones are left out."
          },
          "hidden": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/HiddenSuggestion"
            },
            "description": "Suggestions the company took out with the x. The editor also leaves\nthese out of its own built-in names (`Kitchen`, `Vanity`, ...) and of\nthe names on the quote being drawn. Compare ignoring case and spaces."
          }
        }
      },
      "QuoteTaxRate": {
        "type": "object",
        "description": "A tax rate a quote can apply.",
        "required": [
          "id",
          "name",
          "sequence",
          "tax_pct"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "Rate id."
          },
          "name": {
            "type": "string",
            "description": "Name, e.g. \"Marion County\"."
          },
          "sequence": {
            "type": "integer",
            "format": "int32",
            "description": "Order in the lists; the first one is the default."
          },
          "tax_pct": {
            "type": "number",
            "format": "double",
            "description": "Percent, e.g. `7.25`."
          }
        }
      },
      "QuoteTaxRateInput": {
        "type": "object",
        "description": "Body of creating or saving a tax rate.",
        "required": [
          "name",
          "tax_pct"
        ],
        "properties": {
          "name": {
            "type": "string",
            "description": "Name; required, at most 120 characters (longer is cut)."
          },
          "sequence": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Order; 1 or more (default 1)."
          },
          "tax_pct": {
            "type": "number",
            "format": "double",
            "description": "Percent, 0 to 100."
          }
        },
        "additionalProperties": false
      },
      "QuoteViewLink": {
        "type": "object",
        "description": "The quote's page to look at, for the app.",
        "required": [
          "url"
        ],
        "properties": {
          "url": {
            "type": "string",
            "description": "The customer's page with `?staff=1`: no Accept & Sign, not counted as a view."
          }
        }
      },
      "QuotesMoney": {
        "type": "object",
        "description": "`GET /v1/quotes/money`.",
        "required": [
          "connected",
          "quotes"
        ],
        "properties": {
          "connected": {
            "type": "boolean",
            "description": "False when `QuickBooks` is the company's books and did not answer:\nthen no quote has an answer."
          },
          "quotes": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/QuoteMoney"
            },
            "description": "The asked quotes that have an invoice; a quote with none is left out."
          }
        }
      },
      "RaptorJobsRun": {
        "type": "object",
        "description": "What a run did.",
        "required": [
          "done",
          "failed"
        ],
        "properties": {
          "done": {
            "type": "integer",
            "format": "int32",
            "description": "Projects whose Raptor jobs were made.",
            "minimum": 0
          },
          "failed": {
            "type": "integer",
            "format": "int32",
            "description": "Projects that failed this time (tried again later, three times in all).",
            "minimum": 0
          }
        }
      },
      "RateLimited": {
        "type": "object",
        "description": "`429`: wait before trying again.",
        "required": [
          "error",
          "retryAfterSecs"
        ],
        "properties": {
          "error": {
            "type": "string",
            "description": "`rate_limited`."
          },
          "retryAfterSecs": {
            "type": "integer",
            "format": "int64",
            "description": "Seconds to wait (also in the `Retry-After` header).",
            "minimum": 0
          }
        }
      },
      "ReactionInput": {
        "type": "object",
        "description": "Body of the reaction routes.",
        "properties": {
          "emoji": {
            "type": [
              "string",
              "null"
            ],
            "description": "The emoji to put on the message; null removes the caller's reaction.\nThe caller's current emoji again also removes it."
          }
        },
        "additionalProperties": false
      },
      "ReactionsOut": {
        "type": "object",
        "description": "Answer of the reaction routes.",
        "required": [
          "reactions"
        ],
        "properties": {
          "reactions": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SupportReaction"
            },
            "description": "Every reaction of the conversation, after the change."
          }
        }
      },
      "ReactivationFinished": {
        "type": "object",
        "description": "Body of the finish answer.",
        "required": [
          "status"
        ],
        "properties": {
          "status": {
            "$ref": "#/components/schemas/ReactivationStatus",
            "description": "`active` or `pending`."
          }
        }
      },
      "ReactivationPlan": {
        "type": "object",
        "description": "What restoring access costs.",
        "required": [
          "price_id",
          "plan_name",
          "quantity"
        ],
        "properties": {
          "price_id": {
            "type": "string",
            "description": "Stripe price id (`price_...`)."
          },
          "plan_name": {
            "type": "string",
            "description": "Plan name to show."
          },
          "quantity": {
            "type": "integer",
            "format": "int64",
            "description": "Units billed (always 1: a flat price per company)."
          },
          "monthly_cents": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int64",
            "description": "Due today and each month, in cents; null when unknown."
          }
        }
      },
      "ReactivationQuote": {
        "type": "object",
        "description": "`GET /v1/billing/reactivation`.",
        "required": [
          "needed",
          "cards"
        ],
        "properties": {
          "needed": {
            "type": "boolean",
            "description": "The company is paused without a running subscription: paying restores\nit. False: go back to `/admin/billing`."
          },
          "cards": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Card"
            },
            "description": "Saved cards, the default first."
          },
          "plan": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/ReactivationPlan",
                "description": "The plan to pay for; null when no plan is configured."
              },
              {
                "type": "null"
              }
            ]
          },
          "publishable_key": {
            "type": [
              "string",
              "null"
            ],
            "description": "Stripe.js publishable key (`pk_...`), or null when not configured."
          }
        }
      },
      "ReactivationStarted": {
        "type": "object",
        "description": "How the payment goes on.",
        "required": [
          "status"
        ],
        "properties": {
          "status": {
            "$ref": "#/components/schemas/StartStatus",
            "description": "`paid`, or `requires_payment`: confirm the payment in the browser\n(`stripe.confirmCardPayment`) with `client_secret`, then call\n`/v1/billing/reactivation/finish` with `subscription_id`."
          },
          "client_secret": {
            "type": [
              "string",
              "null"
            ],
            "description": "The first invoice's payment confirmation secret; absent when paid."
          },
          "subscription_id": {
            "type": [
              "string",
              "null"
            ],
            "description": "The new subscription, for the finish call; absent when paid."
          }
        }
      },
      "ReactivationStatus": {
        "type": "string",
        "description": "Whether access is back.",
        "enum": [
          "active",
          "pending"
        ]
      },
      "ReadinessReply": {
        "type": "object",
        "description": "Body of `GET /v1/suppliers/file-readiness`.",
        "properties": {
          "readiness": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/FileReadiness",
                "description": "Counts over the company's suppliers with that name; null when the\nname is blank or the company has no such supplier."
              },
              {
                "type": "null"
              }
            ]
          }
        }
      },
      "RealmDisconnect": {
        "type": "object",
        "description": "Body of `POST /v1/quickbooks/disconnected`.",
        "properties": {
          "realm_id": {
            "type": "string",
            "description": "`realmId` from Intuit's disconnect link; anything but 1-32 digits is\nignored."
          }
        }
      },
      "Reassignment": {
        "type": "object",
        "description": "A reassignment of the customer.",
        "properties": {
          "reassigned_by": {
            "type": [
              "string",
              "null"
            ],
            "description": "Who reassigned."
          },
          "reassigned_to": {
            "type": [
              "string",
              "null"
            ],
            "description": "To whom."
          },
          "updated_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When."
          }
        }
      },
      "RecentInvoices": {
        "type": "object",
        "description": "`GET /v1/qbo/invoices/recent`.",
        "required": [
          "invoices"
        ],
        "properties": {
          "invoices": {
            "type": "array",
            "items": {
              "type": "object"
            },
            "description": "`QuickBooks`' own invoice objects (class, CC, terms, lines, ...)."
          }
        }
      },
      "Recipient": {
        "type": "object",
        "description": "A suggested address.",
        "required": [
          "id",
          "name",
          "email"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "Customer (or user) id."
          },
          "name": {
            "type": "string",
            "description": "Name."
          },
          "email": {
            "type": "string",
            "description": "Address."
          },
          "company_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "Company of a business customer."
          }
        }
      },
      "Recipients": {
        "type": "object",
        "description": "Result of `GET /v1/customers/email-recipients`.",
        "required": [
          "customers",
          "users"
        ],
        "properties": {
          "customers": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Recipient"
            },
            "description": "Customers' addresses, best match first (at most 15)."
          },
          "users": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Recipient"
            },
            "description": "Coworkers (with `include_users`)."
          }
        }
      },
      "RecordedPayment": {
        "type": "object",
        "description": "A payment as an invoice (or a quote's deposits) lists it.",
        "required": [
          "id",
          "amount",
          "total",
          "from_link",
          "editable"
        ],
        "properties": {
          "id": {
            "type": "string",
            "description": "The `QuickBooks` payment id, or the id of our own payment."
          },
          "payment_date": {
            "type": [
              "string",
              "null"
            ],
            "description": "When it was received, `YYYY-MM-DD`."
          },
          "amount": {
            "type": "number",
            "format": "double",
            "description": "What it put on this invoice, in dollars (a deposit: its whole amount)."
          },
          "total": {
            "type": "number",
            "format": "double",
            "description": "The whole payment, when it also covers other invoices or part of it\nis not applied; else the same as `amount`."
          },
          "method_id": {
            "type": [
              "string",
              "null"
            ],
            "description": "The `QuickBooks` payment method's id; null for an own payment."
          },
          "method": {
            "type": [
              "string",
              "null"
            ],
            "description": "The payment method's name."
          },
          "deposit_account_id": {
            "type": [
              "string",
              "null"
            ],
            "description": "The `QuickBooks` account it went to."
          },
          "deposit_account": {
            "type": [
              "string",
              "null"
            ],
            "description": "That account's name."
          },
          "reference": {
            "type": [
              "string",
              "null"
            ],
            "description": "Check number or other reference."
          },
          "memo": {
            "type": [
              "string",
              "null"
            ],
            "description": "The office's note."
          },
          "recorded_by": {
            "type": [
              "string",
              "null"
            ],
            "description": "Who recorded it in Granite Manager; null for a payment entered in\n`QuickBooks` itself, or recorded automatically from a payment link."
          },
          "from_link": {
            "type": "boolean",
            "description": "It records a payment link (card or ACH paid online)."
          },
          "editable": {
            "type": "boolean",
            "description": "It can be edited here: it is on this invoice alone. A payment that\nalso covers other invoices is changed in `QuickBooks`."
          }
        }
      },
      "RecordingInput": {
        "type": "object",
        "description": "Body of `PUT /v1/phone/calls/recording`.",
        "required": [
          "recording"
        ],
        "properties": {
          "recording": {
            "type": "boolean",
            "description": "True: record (start, or resume after a pause); false: pause."
          },
          "telnyxCallIds": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "The ids Telnyx's SDK knows the caller's call by (its call control\nid, call session id, leg id; at most 4 are read), to pick the call\nwhen the caller has more than one; empty = the newest."
          }
        }
      },
      "RecordingLink": {
        "type": "object",
        "description": "`GET /v1/phone/calls/{id}/recording`.",
        "required": [
          "url",
          "expiresAt",
          "contentType"
        ],
        "properties": {
          "url": {
            "type": "string",
            "description": "A link to the recording (works 5 minutes)."
          },
          "expiresAt": {
            "type": "string",
            "format": "date-time",
            "description": "When the link stops working (RFC 3339)."
          },
          "contentType": {
            "type": "string",
            "description": "The audio's type, e.g. `audio/mpeg`."
          }
        }
      },
      "RecordingMode": {
        "type": "string",
        "description": "Which calls are recorded: `off`, `inbound` (the default) or `both`.",
        "enum": [
          "Off",
          "Inbound",
          "Both"
        ]
      },
      "Redirect": {
        "type": "object",
        "description": "A link to open in the browser.",
        "required": [
          "url"
        ],
        "properties": {
          "url": {
            "type": "string",
            "description": "Stripe's page."
          }
        }
      },
      "ReferralSource": {
        "type": "string",
        "description": "How a customer heard of the company.",
        "enum": [
          "google",
          "facebook",
          "referral",
          "flyer",
          "drive-thru",
          "instagram",
          "other"
        ]
      },
      "ReferralSourceInput": {
        "type": "object",
        "description": "Body of `POST` and `PATCH` on referral sources.",
        "required": [
          "name"
        ],
        "properties": {
          "name": {
            "type": "string",
            "description": "1 to 255 characters; unique per company, ignoring case."
          }
        },
        "additionalProperties": false
      },
      "RefundPayment": {
        "type": "object",
        "description": "Body of `POST /v1/payments/{payment_id}/refund`.",
        "properties": {
          "amount_cents": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int64",
            "description": "What to give back, in US cents of the amount; the card fee the customer\npaid on top is never given back. Left out: all that is left."
          }
        },
        "additionalProperties": false
      },
      "RegenerateRequest": {
        "allOf": [
          {
            "$ref": "#/components/schemas/Target"
          },
          {
            "type": "object",
            "required": [
              "channel",
              "goal",
              "delay_minutes",
              "delay_label",
              "avoid_body"
            ],
            "properties": {
              "channel": {
                "$ref": "#/components/schemas/CadenceChannel"
              },
              "goal": {
                "type": "string",
                "description": "The message's goal."
              },
              "delay_minutes": {
                "type": "integer",
                "format": "int64",
                "description": "Its wait, in minutes."
              },
              "delay_label": {
                "type": "string",
                "description": "Its wait, as shown."
              },
              "avoid_body": {
                "type": "string",
                "description": "The draft being replaced."
              },
              "avoid_subject": {
                "type": [
                  "string",
                  "null"
                ],
                "description": "Its subject (email)."
              },
              "avoid_previous": {
                "type": "array",
                "items": {
                  "type": "string"
                },
                "description": "Earlier drafts of the message already turned down (the last 8 count)."
              },
              "angle": {
                "type": [
                  "string",
                  "null"
                ],
                "description": "The message's angle."
              },
              "phase": {
                "type": [
                  "string",
                  "null"
                ],
                "description": "The message's phase."
              },
              "force_generate": {
                "type": "boolean",
                "description": "Write it even though the customer should not be followed up now."
              }
            }
          }
        ],
        "description": "`POST /v1/followups/ai-cadence/regenerate`."
      },
      "Regenerated": {
        "type": "object",
        "description": "A rewritten message.",
        "required": [
          "body"
        ],
        "properties": {
          "body": {
            "type": "string",
            "description": "The new text."
          },
          "subject": {
            "type": [
              "string",
              "null"
            ],
            "description": "Email messages: the subject."
          }
        }
      },
      "RemainingNumbers": {
        "type": "string",
        "description": "What happens to the numbers that stay at the current carrier.",
        "enum": [
          "Keep",
          "Disconnect"
        ]
      },
      "ReminderRun": {
        "type": "object",
        "description": "What a run did.",
        "required": [
          "processed",
          "sent",
          "failed",
          "rep_processed",
          "rep_sent",
          "rep_failed",
          "rule_processed",
          "rule_sent",
          "rule_failed",
          "answers_read",
          "marked_ready",
          "followups_sent"
        ],
        "properties": {
          "processed": {
            "type": "integer",
            "description": "Customer reminders that were due.",
            "minimum": 0
          },
          "sent": {
            "type": "integer",
            "description": "Customer reminders sent.",
            "minimum": 0
          },
          "failed": {
            "type": "integer",
            "description": "Customer reminders that failed (or came too late).",
            "minimum": 0
          },
          "rep_processed": {
            "type": "integer",
            "description": "Rep reminders that were due.",
            "minimum": 0
          },
          "rep_sent": {
            "type": "integer",
            "description": "Rep reminders sent.",
            "minimum": 0
          },
          "rep_failed": {
            "type": "integer",
            "description": "Rep reminders that failed.",
            "minimum": 0
          },
          "rule_processed": {
            "type": "integer",
            "description": "Notification-rule messages that were due.",
            "minimum": 0
          },
          "rule_sent": {
            "type": "integer",
            "description": "Notification-rule messages sent.",
            "minimum": 0
          },
          "rule_failed": {
            "type": "integer",
            "description": "Notification-rule messages that failed.",
            "minimum": 0
          },
          "answers_read": {
            "type": "integer",
            "description": "Scheduling-text replies the AI read.",
            "minimum": 0
          },
          "marked_ready": {
            "type": "integer",
            "description": "Jobs the AI marked Ready because the customer agreed.",
            "minimum": 0
          },
          "followups_sent": {
            "type": "integer",
            "description": "Scheduling-text follow-ups sent to customers who had not replied.",
            "minimum": 0
          }
        }
      },
      "ReorderBody": {
        "type": "object",
        "description": "Body of `POST /v1/deals/reorder`.",
        "required": [
          "updates"
        ],
        "properties": {
          "updates": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ReorderItem"
            },
            "description": "Every card whose stage or position changed."
          }
        }
      },
      "ReorderItem": {
        "type": "object",
        "description": "One card move of `POST /v1/deals/reorder`.",
        "required": [
          "id",
          "list_id",
          "position"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int64",
            "description": "Deal id."
          },
          "list_id": {
            "type": "integer",
            "format": "int32",
            "description": "Stage it is now in."
          },
          "position": {
            "type": "integer",
            "format": "int32",
            "description": "Order inside that stage."
          }
        }
      },
      "ReorderProjects": {
        "type": "object",
        "description": "Body of `POST /v1/projects/reorder`.",
        "required": [
          "ids"
        ],
        "properties": {
          "ids": {
            "type": "array",
            "items": {
              "type": "integer",
              "format": "int32"
            },
            "description": "One column's projects, in their new order."
          }
        }
      },
      "RepAmount": {
        "type": "object",
        "description": "One sales rep's share of the company's sales this month.",
        "required": [
          "name",
          "amount",
          "is_you"
        ],
        "properties": {
          "user_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "`users.id`; null for the classes no rep's name matches."
          },
          "name": {
            "type": "string",
            "description": "The rep's name, or `Other` for unmatched classes."
          },
          "amount": {
            "type": "number",
            "format": "double",
            "description": "Sales this month."
          },
          "is_you": {
            "type": "boolean",
            "description": "The row is the caller's own."
          }
        }
      },
      "RepCustomers": {
        "type": "object",
        "description": "`GET /v1/me/qbo-sales/customers`.",
        "required": [
          "status",
          "customers",
          "total",
          "currency"
        ],
        "properties": {
          "status": {
            "$ref": "#/components/schemas/CustomersStatus"
          },
          "customers": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CustomerSales"
            },
            "description": "Customers, by their first invoice date."
          },
          "total": {
            "type": "number",
            "format": "double",
            "description": "Sum of the customers' sales."
          },
          "currency": {
            "type": "string",
            "description": "Currency code."
          }
        }
      },
      "RepKpis": {
        "type": "object",
        "description": "A rep's numbers (or the company's).",
        "required": [
          "name",
          "leads",
          "quoted",
          "won",
          "no_next_touch",
          "over_limit"
        ],
        "properties": {
          "user_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Null: deals with no sales rep. Missing on the company's total."
          },
          "name": {
            "type": "string",
            "description": "The rep's name, or \"Everyone\" for the company total."
          },
          "leads": {
            "type": "integer",
            "format": "int64",
            "description": "Deals created in the month."
          },
          "lead_to_quote_hours": {
            "type": [
              "number",
              "null"
            ],
            "format": "double",
            "description": "Average hours from a new deal to its first quote; null: none quoted."
          },
          "quoted": {
            "type": "integer",
            "format": "int64",
            "description": "Deals first quoted in the month."
          },
          "won": {
            "type": "integer",
            "format": "int64",
            "description": "Of those, the ones won."
          },
          "quote_to_contract_pct": {
            "type": [
              "number",
              "null"
            ],
            "format": "double",
            "description": "`won / quoted` in percent; null: none quoted."
          },
          "no_next_touch": {
            "type": "integer",
            "format": "int64",
            "description": "Open deals now without an unfinished activity with a due date."
          },
          "over_limit": {
            "type": "integer",
            "format": "int64",
            "description": "Open deals now idle past their stage limit."
          }
        }
      },
      "RepRating": {
        "type": "object",
        "description": "A rep's post-installation survey score.",
        "required": [
          "rep_id",
          "responses"
        ],
        "properties": {
          "rep_id": {
            "type": "integer",
            "format": "int32",
            "description": "The rep (user id)."
          },
          "rep_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "The rep's name."
          },
          "avg_rating": {
            "type": [
              "number",
              "null"
            ],
            "format": "double",
            "description": "Average rating (1-5)."
          },
          "responses": {
            "type": "integer",
            "format": "int64",
            "description": "Surveys answered."
          }
        }
      },
      "RepSales": {
        "type": "object",
        "description": "`GET /v1/me/qbo-sales`.",
        "required": [
          "status",
          "can_set_company_goal",
          "reps"
        ],
        "properties": {
          "status": {
            "$ref": "#/components/schemas/SalesStatus"
          },
          "amount": {
            "type": [
              "number",
              "null"
            ],
            "format": "double",
            "description": "The rep's classes' sales this month."
          },
          "company_amount": {
            "type": [
              "number",
              "null"
            ],
            "format": "double",
            "description": "The whole company's sales this month (the report's grand total)."
          },
          "company_goal": {
            "type": [
              "number",
              "null"
            ],
            "format": "double",
            "description": "The company's monthly sales goal, when a manager set one."
          },
          "can_set_company_goal": {
            "type": "boolean",
            "description": "The caller may set the company goal (a Manager or Sales Manager)."
          },
          "reps": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/RepAmount"
            },
            "description": "The company's sales this month by sales rep, highest first."
          },
          "currency": {
            "type": [
              "string",
              "null"
            ],
            "description": "Currency code."
          },
          "start_period": {
            "type": [
              "string",
              "null"
            ],
            "description": "First day of the report."
          },
          "end_period": {
            "type": [
              "string",
              "null"
            ],
            "description": "Last day of the report (today)."
          },
          "month_end_period": {
            "type": [
              "string",
              "null"
            ],
            "description": "Last day of the month."
          },
          "week_end_period": {
            "type": [
              "string",
              "null"
            ],
            "description": "Sunday of this week."
          },
          "days_remaining_in_week": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Days left in the week, today included.",
            "minimum": 0
          },
          "days_remaining_in_month": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Days left in the month, today included.",
            "minimum": 0
          }
        }
      },
      "Replacement": {
        "type": "object",
        "description": "Body of `POST /v1/transactions/{id}/slabs/{slab_id}/replace`.",
        "required": [
          "new_slab_id"
        ],
        "properties": {
          "new_slab_id": {
            "type": "integer",
            "format": "int32",
            "description": "The free slab to put on the sale instead."
          }
        },
        "additionalProperties": false
      },
      "ReplyMode": {
        "type": "string",
        "description": "What kind of draft.",
        "enum": [
          "fast_reply",
          "follow_up",
          "custom"
        ]
      },
      "ResetCodeConfirm": {
        "type": "object",
        "description": "Body of `POST /v1/auth/password-reset-code/confirm`.",
        "required": [
          "email",
          "code",
          "password"
        ],
        "properties": {
          "email": {
            "type": "string",
            "description": "The account's email."
          },
          "code": {
            "type": "string",
            "description": "The 6-digit code from the email."
          },
          "password": {
            "type": "string",
            "description": "The new password, at least 8 characters."
          },
          "authenticator_code": {
            "type": [
              "string",
              "null"
            ],
            "description": "The 6-digit code of the authenticator app; needed only when the\nuser has two-step sign-in on (else ignored). Leave it out at first:\na 409 `authenticator_code_required` says it is needed."
          }
        }
      },
      "ResetCodeRequest": {
        "type": "object",
        "description": "Body of `POST /v1/auth/password-reset-code`.",
        "required": [
          "email"
        ],
        "properties": {
          "email": {
            "type": "string",
            "description": "The account's email."
          }
        }
      },
      "ResetRequest": {
        "type": "object",
        "description": "Body of `POST /v1/auth/password-reset`.",
        "required": [
          "email"
        ],
        "properties": {
          "email": {
            "type": "string",
            "description": "The account's email."
          },
          "turnstile_token": {
            "type": [
              "string",
              "null"
            ],
            "description": "The Cloudflare Turnstile token of the page's robot check. Logged\nonly: the check never refuses anyone."
          },
          "turnstile_error": {
            "type": [
              "string",
              "null"
            ],
            "description": "Why the page has no Turnstile token (Cloudflare's error code,\n`timeout`, `script` or `unsupported`). Logged only."
          }
        }
      },
      "Resolve": {
        "type": "object",
        "description": "Body of `POST /v1/superuser/manual-feedback/{id}/resolve`.",
        "required": [
          "apply_manual_change"
        ],
        "properties": {
          "apply_manual_change": {
            "type": "boolean",
            "description": "Write the proposed section text into the manual (when the thread has\none); false only marks it reviewed."
          }
        }
      },
      "RestoredRevision": {
        "type": "object",
        "description": "A restored revision.",
        "required": [
          "revision_number"
        ],
        "properties": {
          "revision_number": {
            "type": "integer",
            "format": "int32",
            "description": "The number of the revision restored."
          }
        }
      },
      "RevisionDrawing": {
        "type": "object",
        "description": "A revision's drawing.",
        "required": [
          "doc"
        ],
        "properties": {
          "doc": {
            "type": "object",
            "description": "The drawing."
          }
        }
      },
      "RingCentralCall": {
        "type": "object",
        "description": "One `RingCentral` call.",
        "required": [
          "id",
          "direction",
          "status",
          "startedAt",
          "durationSecs",
          "otherNumber"
        ],
        "properties": {
          "id": {
            "type": "string",
            "description": "`RingCentral`'s call-log id."
          },
          "direction": {
            "$ref": "#/components/schemas/CallDirection"
          },
          "status": {
            "$ref": "#/components/schemas/CallStatus",
            "description": "`answered`, `missed`, `voicemail`, `busy` or `no_answer`."
          },
          "startedAt": {
            "type": "string",
            "description": "RFC 3339."
          },
          "durationSecs": {
            "type": "integer",
            "format": "int64",
            "description": "Talk time in seconds; 0 when nobody talked."
          },
          "otherNumber": {
            "type": "string",
            "description": "The other party's number, as `RingCentral` gives it (E.164)."
          },
          "customer": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/CallCustomer",
                "description": "Our customer with that number; null when none."
              },
              {
                "type": "null"
              }
            ]
          }
        }
      },
      "RingCentralCalls": {
        "type": "object",
        "description": "The caller's `RingCentral` calls.",
        "required": [
          "calls"
        ],
        "properties": {
          "calls": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/RingCentralCall"
            },
            "description": "Newest first, the last 30 days."
          }
        }
      },
      "RingcentralCallback": {
        "type": "object",
        "description": "Body of `POST /v1/ringcentral/connection`.",
        "required": [
          "state"
        ],
        "properties": {
          "state": {
            "type": "string",
            "description": "`state` as `RingCentral` returned it."
          },
          "code": {
            "type": [
              "string",
              "null"
            ],
            "description": "`code` as `RingCentral` returned it; absent when the user cancelled."
          },
          "error": {
            "type": [
              "string",
              "null"
            ],
            "description": "`error` as `RingCentral` returned it (the user cancelled)."
          }
        }
      },
      "RingcentralConnected": {
        "type": "object",
        "description": "`POST /v1/me/ringcentral`.",
        "properties": {
          "company_subdomain": {
            "type": [
              "string",
              "null"
            ],
            "description": "The company's subdomain, to go back to My Account there; null when it\nhas none."
          },
          "ringcentral_phone_number": {
            "type": [
              "string",
              "null"
            ],
            "description": "The number the user texts from now (10 digits); null when their\n`RingCentral` user has no number that can text."
          }
        }
      },
      "RingcentralDeliveryInput": {
        "type": "object",
        "description": "Which texts to check.",
        "required": [
          "company_id",
          "extension",
          "date_from"
        ],
        "properties": {
          "company_id": {
            "type": "integer",
            "format": "int32",
            "description": "The company whose texts are checked."
          },
          "extension": {
            "type": "string",
            "description": "The rep's `RingCentral` extension id (`ringcentral_sms.agent`)."
          },
          "date_from": {
            "type": "string",
            "description": "Texts sent from then on (ISO 8601, e.g. `2026-06-01T00:00:00Z`)."
          },
          "date_to": {
            "type": [
              "string",
              "null"
            ],
            "description": "And before then, when given."
          },
          "page": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Page of 100 texts, from 1.",
            "minimum": 0
          }
        }
      },
      "RingcentralDeliveryRun": {
        "type": "object",
        "description": "What a run did.",
        "required": [
          "checked",
          "marked"
        ],
        "properties": {
          "checked": {
            "type": "integer",
            "description": "Texts `RingCentral` reported on this page.",
            "minimum": 0
          },
          "marked": {
            "type": "integer",
            "description": "Of them, the CRM texts now marked failed.",
            "minimum": 0
          },
          "next_page": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "The page to ask for next, or null when this was the last.",
            "minimum": 0
          }
        }
      },
      "RingcentralReturn": {
        "type": "object",
        "description": "Body of `POST /v1/me/ringcentral`.",
        "required": [
          "state"
        ],
        "properties": {
          "state": {
            "type": "string",
            "description": "`state` as `RingCentral` returned it."
          },
          "code": {
            "type": [
              "string",
              "null"
            ],
            "description": "`code` as `RingCentral` returned it; absent when the user cancelled."
          },
          "error": {
            "type": [
              "string",
              "null"
            ],
            "description": "`error` as `RingCentral` returned it (the user cancelled)."
          }
        }
      },
      "RingcentralSettings": {
        "type": "object",
        "description": "`RingCentral` as company settings show it.",
        "required": [
          "connect_available"
        ],
        "properties": {
          "connect_available": {
            "type": "boolean",
            "description": "Granite Manager's `RingCentral` app is configured (Connect works)."
          },
          "status": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/ConnectionStatus",
                "description": "For a company that pressed Connect: whether `RingCentral` still\naccepts the connection; null when it never connected."
              },
              {
                "type": "null"
              }
            ]
          }
        }
      },
      "RingcentralSignIn": {
        "type": "object",
        "description": "`POST /v1/me/ringcentral/start`.",
        "required": [
          "url"
        ],
        "properties": {
          "url": {
            "type": "string",
            "description": "`RingCentral`'s sign-in page."
          }
        }
      },
      "RiskLevel": {
        "type": "string",
        "description": "0-20 good, 21-50 review, above high risk.",
        "enum": [
          "GOOD",
          "REVIEW",
          "HIGH_RISK",
          "UNKNOWN"
        ]
      },
      "RoomInput": {
        "type": "object",
        "description": "One room of a sale being saved.",
        "required": [
          "room_id",
          "room",
          "backsplash",
          "tear_out",
          "stove",
          "waterfall",
          "seam",
          "slabs"
        ],
        "properties": {
          "room_id": {
            "type": "string",
            "description": "Room UUID (any version), shared by its slabs; no two rooms of a sale\nhave the same."
          },
          "room": {
            "type": "string",
            "description": "Room name, e.g. `kitchen`; at most 255 characters."
          },
          "backsplash": {
            "type": "string",
            "description": "Backsplash option; at most 255 characters."
          },
          "square_feet": {
            "type": [
              "number",
              "null"
            ],
            "format": "double",
            "description": "Square feet of the room; positive, at most 99,999,999.99."
          },
          "retail_price": {
            "type": "number",
            "format": "double",
            "description": "Price per square foot in dollars, from 0 to 99,999,999.99."
          },
          "tear_out": {
            "type": "string",
            "description": "Tear-out option; at most 255 characters."
          },
          "stove": {
            "type": "string",
            "description": "Stove option; at most 255 characters."
          },
          "waterfall": {
            "type": "string",
            "description": "Waterfall option; at most 255 characters."
          },
          "corbels": {
            "type": "integer",
            "format": "int32",
            "description": "Number of corbels, 0 or more."
          },
          "seam": {
            "type": "string",
            "description": "Seam option; at most 255 characters."
          },
          "ten_year_sealer": {
            "type": "boolean",
            "description": "Ten year sealer included."
          },
          "extras": {
            "type": "object",
            "description": "Room extras, stored as given."
          },
          "slabs": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SaleSlab"
            },
            "description": "Slabs used in the room. The same slab may appear in several rooms:\neach later room gets its own piece cut from it."
          },
          "sinks": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/FixtureInput"
            },
            "description": "Sinks to install: one free unit of each model is taken."
          },
          "faucets": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/FixtureInput"
            },
            "description": "Faucets to install: one free unit of each model is taken."
          }
        },
        "additionalProperties": false
      },
      "RouteInput": {
        "type": "object",
        "description": "Body of `POST /v1/schedule/optimize-route` and `route-preview`.",
        "required": [
          "event_ids"
        ],
        "properties": {
          "event_ids": {
            "type": "array",
            "items": {
              "type": "integer",
              "format": "int32"
            },
            "description": "The day's events with an address, 2 to 20."
          },
          "order": {
            "type": [
              "array",
              "null"
            ],
            "items": {
              "type": "integer",
              "format": "int32"
            },
            "description": "The approved order from `route-preview` (the same ids). Saves exactly\nthat order without asking Google again; omitted, the fastest order is\nworked out."
          }
        }
      },
      "RouteMove": {
        "type": "object",
        "description": "A stop that gets a new time on the route.",
        "required": [
          "id",
          "start",
          "end"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "Event id."
          },
          "start": {
            "type": "string",
            "description": "New start, UTC (`2030-01-15T14:00:00Z`)."
          },
          "end": {
            "type": "string",
            "description": "New end, UTC."
          }
        }
      },
      "RoutePreview": {
        "type": "object",
        "description": "`POST /v1/schedule/route-preview`.",
        "required": [
          "order",
          "moves",
          "stops"
        ],
        "properties": {
          "order": {
            "type": "array",
            "items": {
              "type": "integer",
              "format": "int32"
            },
            "description": "Event ids in driving order, farthest first."
          },
          "moves": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/RouteMove"
            },
            "description": "Timed events whose start would change, with their new times."
          },
          "stops": {
            "type": "integer",
            "description": "Events on the route.",
            "minimum": 0
          }
        }
      },
      "RuleAction": {
        "type": "string",
        "description": "What a matching rule does with the call: `ring` (my phones),\n`forward` (to `forwardTo`), `voicemail`, or `message` (play\n`message`, then hang up).",
        "enum": [
          "Ring",
          "Forward",
          "Voicemail",
          "Message"
        ]
      },
      "RuleCaller": {
        "type": "object",
        "description": "One caller a rule is for: a phone number or a CRM contact (whichever\nof their numbers calls).",
        "properties": {
          "number": {
            "type": [
              "string",
              "null"
            ],
            "description": "A phone number, E.164; null for a contact."
          },
          "customerId": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "A customer of the company (`GET /v1/phone/contacts/{id}`); null for a\nnumber."
          }
        }
      },
      "RuleInput": {
        "type": "object",
        "description": "A rule as an admin builds it (`commissionRuleSchema`).",
        "required": [
          "name",
          "applies",
          "rateType",
          "rate"
        ],
        "properties": {
          "name": {
            "type": "string",
            "description": "Name (1 to 120 characters)."
          },
          "applies": {
            "type": "string",
            "description": "`material`, `quote`, `lines` or `monthly_goal`."
          },
          "rateType": {
            "type": "string",
            "description": "`percent` or `flat`."
          },
          "rate": {
            "type": "number",
            "format": "double",
            "description": "Percent or dollars; not negative."
          },
          "priority": {
            "type": "integer",
            "format": "int64",
            "description": "Higher goes first."
          },
          "stop": {
            "type": "boolean",
            "description": "Material rules: a match keeps lower rules from paying on the area.\nLine rules: their lines are left out of the room's stone percent."
          },
          "materials": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Material rules: only these materials."
          },
          "colors": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Material rules: only these colors."
          },
          "levelMin": {
            "type": [
              "number",
              "null"
            ],
            "format": "double",
            "description": "Material rules: lowest level."
          },
          "levelMax": {
            "type": [
              "number",
              "null"
            ],
            "format": "double",
            "description": "Material rules: highest level."
          },
          "lineMatch": {
            "type": "string",
            "description": "Line rules: text the line contains (up to 120 characters)."
          },
          "threshold": {
            "type": [
              "number",
              "null"
            ],
            "format": "double",
            "description": "Monthly goals: the month's paid sales that earn the bonus."
          },
          "discountMin": {
            "type": [
              "number",
              "null"
            ],
            "format": "double",
            "description": "Only when the quote's discount is over this percent (0 to 100)."
          },
          "discountMax": {
            "type": [
              "number",
              "null"
            ],
            "format": "double",
            "description": "Only when the quote's discount is at most this percent (0 to 100)."
          },
          "madeBy": {
            "type": "string",
            "description": "Who made the quote: `any` (default), `rep` (the rep themself) or\n`other` (someone else made it for them)."
          },
          "paidOnly": {
            "type": "boolean",
            "description": "Line rules: only lines the customer pays for."
          },
          "active": {
            "type": "boolean",
            "description": "Off rules pay nothing."
          }
        },
        "additionalProperties": false
      },
      "RunReport": {
        "type": "object",
        "description": "Body of `POST /v1/posthog-autofix/runs/{id}/result`.",
        "required": [
          "issue_id",
          "conclusion",
          "verification"
        ],
        "properties": {
          "issue_id": {
            "type": "string",
            "description": "The run's PostHog issue id, checked against the ledger row."
          },
          "conclusion": {
            "$ref": "#/components/schemas/Conclusion",
            "description": "How the workflow run ended."
          },
          "agent": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/AgentResult",
                "description": "The agent's result; absent when the run broke before it answered."
              },
              {
                "type": "null"
              }
            ]
          },
          "verification": {
            "$ref": "#/components/schemas/Verification",
            "description": "What the workflow proved about the commits."
          },
          "notes": {
            "type": [
              "string",
              "null"
            ],
            "description": "Why verification failed, or what broke the run."
          },
          "pr_url": {
            "type": [
              "string",
              "null"
            ],
            "description": "The pull request, when one was opened."
          },
          "pr_draft": {
            "type": "boolean",
            "description": "The pull request is a draft (unverified)."
          },
          "cost_usd": {
            "type": [
              "number",
              "null"
            ],
            "format": "double",
            "description": "The agent's cost as Claude Code estimated it, in US dollars."
          },
          "github_run_url": {
            "type": [
              "string",
              "null"
            ],
            "description": "The GitHub Actions run."
          }
        },
        "additionalProperties": false
      },
      "RunnerState": {
        "type": "string",
        "description": "How ready the agent's machine is.",
        "enum": [
          "ready",
          "starting",
          "unknown"
        ]
      },
      "Sale": {
        "type": "object",
        "description": "The option sold.",
        "required": [
          "option"
        ],
        "properties": {
          "option": {
            "type": "integer",
            "format": "int32",
            "description": "Index of the color option sold."
          },
          "deal_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int64",
            "description": "The customer's deal to mark won (none: the quote's own deal, else the\ncustomer's latest open one; never a won or lost one)."
          },
          "new_deal": {
            "type": "boolean",
            "description": "Make a new won deal instead of using an existing one."
          },
          "job_status": {
            "type": [
              "string",
              "null"
            ],
            "description": "Status of the template job it adds to Unscheduled: `ready` (default) or\n`not_ready`."
          },
          "installation_status": {
            "type": [
              "string",
              "null"
            ],
            "description": "Status of the installation job: `ready` or `not_ready` (default)."
          },
          "fh_backsplash_template_status": {
            "type": [
              "string",
              "null"
            ],
            "description": "Status of the FH Backsplash template job: `ready` or `not_ready` (default)."
          },
          "fh_backsplash_installation_status": {
            "type": [
              "string",
              "null"
            ],
            "description": "Status of the FH Backsplash installation job: `ready` or `not_ready` (default)."
          },
          "fh_backsplash_template_notes": {
            "type": [
              "string",
              "null"
            ],
            "description": "Notes on the FH Backsplash template job; left out: the template job's notes."
          },
          "fh_backsplash_installation_notes": {
            "type": [
              "string",
              "null"
            ],
            "description": "Notes on the FH Backsplash installation job; left out: the installation job's notes."
          },
          "template_notes": {
            "type": [
              "string",
              "null"
            ],
            "description": "Notes on the template job it adds to Unscheduled."
          },
          "install_notes": {
            "type": [
              "string",
              "null"
            ],
            "description": "Notes on the installation job it adds to Unscheduled."
          },
          "project_notes": {
            "type": [
              "string",
              "null"
            ],
            "description": "A note for the project the sale starts (Project on a sale)."
          },
          "full_height_backsplash": {
            "type": "boolean",
            "description": "Full Height Backsplash (higher than 15\"): also adds a \"FH Backsplash\"\ntemplate and installation job, both `not_ready`."
          },
          "fh_backsplash_template": {
            "type": "boolean",
            "description": "Only the \"FH Backsplash\" template job, `not_ready` (Mark as Sold ›\nExtra events)."
          },
          "fh_backsplash_installation": {
            "type": "boolean",
            "description": "Only the \"FH Backsplash\" installation job, `not_ready`."
          },
          "skip_template": {
            "type": "boolean",
            "description": "The seller unticked the template event in Mark as Sold: no template\njob (nor its FH Backsplash one) is added."
          },
          "skip_installation": {
            "type": "boolean",
            "description": "The seller unticked the installation event: no installation job (nor\nits FH Backsplash one) is added."
          },
          "extra_events": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SaleExtraEvent"
            },
            "description": "Extra events to add (Mark as Sold › Extra events): the event templates\nticked (`GET /v1/quote-sale-events`), each with optional notes. Each\nadds one unscheduled, `not_ready` event on its template's calendar,\nwhether or not the company adds template and installation jobs. Left\nout or empty: none. Unknown template ids are skipped."
          },
          "template_urgent": {
            "type": "boolean",
            "description": "Red flag on the template job: it must be scheduled fast."
          },
          "installation_urgent": {
            "type": "boolean",
            "description": "Red flag on the installation job."
          },
          "fh_backsplash_template_urgent": {
            "type": "boolean",
            "description": "Red flag on the FH Backsplash template job."
          },
          "fh_backsplash_installation_urgent": {
            "type": "boolean",
            "description": "Red flag on the FH Backsplash installation job."
          }
        },
        "additionalProperties": false
      },
      "SaleBuiltInJobsInput": {
        "type": "object",
        "description": "Body of `PUT /v1/company/sale-built-in-jobs`.",
        "required": [
          "template",
          "installation"
        ],
        "properties": {
          "template": {
            "type": "boolean",
            "description": "A sold quote adds its template event (with Jobs to Unscheduled on)."
          },
          "installation": {
            "type": "boolean",
            "description": "A sold quote adds its installation event (with Jobs to Unscheduled on)."
          }
        },
        "additionalProperties": false
      },
      "SaleContract": {
        "type": "object",
        "description": "A sale as the sell / edit form shows it: who bought, who sold, and the\nrooms with their slabs, sinks and faucets.",
        "required": [
          "id",
          "customer_id",
          "rooms"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "Sale id."
          },
          "customer_id": {
            "type": "integer",
            "format": "int32",
            "description": "Customer who bought."
          },
          "deal_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int64",
            "description": "The customer's deal this sale is part of; null if none."
          },
          "seller_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "User credited with the sale; null if unknown."
          },
          "project_address": {
            "type": [
              "string",
              "null"
            ],
            "description": "Address of the job; null or empty means the customer's address."
          },
          "notes": {
            "type": [
              "string",
              "null"
            ],
            "description": "Notes on the whole sale."
          },
          "price": {
            "type": [
              "string",
              "null"
            ],
            "description": "Total price, decimal string (e.g. \"4200.00\"); null if not set."
          },
          "company_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "The customer's company name; null for private customers."
          },
          "extras": {
            "type": [
              "object",
              "null"
            ],
            "description": "Extra line items of the whole sale (`[{\"adjustment\": \"...\", \"price\": 0}]`),\nas saved; null when none were saved."
          },
          "rooms": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SaleRoom"
            },
            "description": "Rooms in the order their first slab was added."
          }
        }
      },
      "SaleEventName": {
        "type": "object",
        "description": "How a sold quote's built-in template or installation event is named:\nthe text before, the variable, the text after.",
        "properties": {
          "title_variable": {
            "$ref": "#/components/schemas/TitleVariable",
            "description": "The name the title is built around (default `quote_name`)."
          },
          "title_before": {
            "type": "string",
            "description": "What comes before the variable (at most 200 characters; blank: nothing)."
          },
          "title_text": {
            "type": "string",
            "description": "What follows the variable (at most 200 characters; blank: nothing)."
          }
        }
      },
      "SaleExtraEvent": {
        "type": "object",
        "description": "An extra event ticked in Mark as Sold.",
        "required": [
          "template_id"
        ],
        "properties": {
          "urgent": {
            "type": "boolean",
            "description": "Red flag: the event must be scheduled fast."
          },
          "status": {
            "type": [
              "string",
              "null"
            ],
            "description": "Its status: `ready` or `not_ready` (default)."
          },
          "template_id": {
            "type": "integer",
            "format": "int32",
            "description": "The event template (`GET /v1/quote-sale-events`)."
          },
          "notes": {
            "type": [
              "string",
              "null"
            ],
            "description": "Notes on the event (trimmed; blank: none)."
          }
        },
        "additionalProperties": false
      },
      "SaleFixture": {
        "type": "object",
        "description": "A sink or faucet unit on a sale.",
        "required": [
          "id",
          "type_id"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "Unit id (`sinks.id` / `faucets.id`)."
          },
          "type_id": {
            "type": "integer",
            "format": "int32",
            "description": "Model id (`sink_type.id` / `faucet_type.id`)."
          },
          "price": {
            "type": [
              "string",
              "null"
            ],
            "description": "Price charged for the unit, decimal string; null if not set."
          }
        }
      },
      "SaleHeader": {
        "type": "object",
        "description": "The sale's header.",
        "required": [
          "id",
          "customer_id",
          "seller_id"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "Sale id."
          },
          "customer_id": {
            "type": "integer",
            "format": "int32",
            "description": "Customer id."
          },
          "customer_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "Customer name."
          },
          "sale_date": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When it was sold."
          },
          "seller_id": {
            "type": "integer",
            "format": "int32",
            "description": "Seller id."
          },
          "seller_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "Seller name."
          },
          "project_address": {
            "type": [
              "string",
              "null"
            ],
            "description": "Project address."
          }
        }
      },
      "SaleInput": {
        "type": "object",
        "description": "Body of `POST /v1/sales` and `PUT /v1/sales/{id}`.",
        "required": [
          "customer_id",
          "rooms"
        ],
        "properties": {
          "customer_id": {
            "type": "integer",
            "format": "int32",
            "description": "Customer who buys; must be a live customer of the company."
          },
          "deal_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int64",
            "description": "The customer's deal the sale is part of; 0 for none, never negative.\nMissing keeps the edited sale's deal (none when selling, or when the\ncustomer changes)."
          },
          "seller_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "User credited with the sale: a live user of the company (an edit may\nkeep the sale's seller though they left). Defaults to the caller when\nselling; left unchanged when editing."
          },
          "project_address": {
            "type": [
              "string",
              "null"
            ],
            "description": "Address of the job, at most 255 characters. Empty or missing uses\nthe customer's address."
          },
          "notes": {
            "type": [
              "string",
              "null"
            ],
            "description": "Notes on the whole sale, at most 65,535 bytes; empty clears them."
          },
          "price": {
            "type": "number",
            "format": "double",
            "description": "Total price in dollars, from 0 to 99,999,999.99."
          },
          "extras": {
            "type": "object",
            "description": "Extra line items of the whole sale, stored as given."
          },
          "rooms": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/RoomInput"
            },
            "description": "At least one room, each with at least one slab and its own `room_id`."
          }
        },
        "additionalProperties": false
      },
      "SaleResult": {
        "type": "object",
        "description": "What selling did.",
        "properties": {
          "deal_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int64",
            "description": "The deal marked won (none: the quote has no sales rep to make one)."
          }
        }
      },
      "SaleRoom": {
        "type": "object",
        "description": "One room of a sale. Room fields are stored on each of its slabs; these\ncome from the room's first slab. Nulls mean \"not set\" (the form uses its\ndefaults).",
        "required": [
          "ten_year_sealer",
          "slabs",
          "sinks",
          "faucets"
        ],
        "properties": {
          "room_id": {
            "type": [
              "string",
              "null"
            ],
            "description": "Room UUID shared by its slabs; null for old sales saved without one."
          },
          "room": {
            "type": [
              "string",
              "null"
            ],
            "description": "Room name, e.g. `kitchen`, `bathroom`, or free text."
          },
          "backsplash": {
            "type": [
              "string",
              "null"
            ],
            "description": "Backsplash: `no`, `4 inch`, `full height`, or free text."
          },
          "square_feet": {
            "type": [
              "string",
              "null"
            ],
            "description": "Square feet of the room, decimal string."
          },
          "retail_price": {
            "type": [
              "string",
              "null"
            ],
            "description": "Price per square foot, decimal string."
          },
          "tear_out": {
            "type": [
              "string",
              "null"
            ],
            "description": "Tear-out option."
          },
          "stove": {
            "type": [
              "string",
              "null"
            ],
            "description": "Stove option."
          },
          "waterfall": {
            "type": [
              "string",
              "null"
            ],
            "description": "Waterfall option."
          },
          "corbels": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Number of corbels."
          },
          "seam": {
            "type": [
              "string",
              "null"
            ],
            "description": "Seam option."
          },
          "ten_year_sealer": {
            "type": "boolean",
            "description": "Ten year sealer included."
          },
          "extras": {
            "type": [
              "object",
              "null"
            ],
            "description": "Room extras (edge, tear-out, stove... prices) as saved."
          },
          "slabs": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SaleSlab"
            },
            "description": "Slabs used in the room."
          },
          "sinks": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SaleFixture"
            },
            "description": "Sinks installed in the room, on any of its slabs."
          },
          "faucets": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SaleFixture"
            },
            "description": "Faucets installed in the room, on any of its slabs."
          }
        }
      },
      "SaleSinkRow": {
        "type": "object",
        "description": "A sink on the sale.",
        "required": [
          "id",
          "sink_type_id",
          "is_deleted",
          "slab_id"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int64",
            "description": "Sink unit id."
          },
          "sink_type_id": {
            "type": "integer",
            "format": "int32",
            "description": "Sink model id."
          },
          "name": {
            "type": [
              "string",
              "null"
            ],
            "description": "Model name."
          },
          "price": {
            "type": [
              "number",
              "null"
            ],
            "format": "double",
            "description": "Price."
          },
          "is_deleted": {
            "type": "boolean",
            "description": "Always false (deleted units are left out)."
          },
          "slab_id": {
            "type": "integer",
            "format": "int64",
            "description": "Slab it is cut into."
          },
          "room": {
            "type": [
              "string",
              "null"
            ],
            "description": "That slab's room."
          },
          "room_uuid": {
            "type": [
              "string",
              "null"
            ],
            "description": "That slab's room id (hex)."
          }
        }
      },
      "SaleSlab": {
        "type": "object",
        "description": "A slab used in a room.",
        "required": [
          "id",
          "is_full"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int64",
            "description": "Slab id."
          },
          "is_full": {
            "type": "boolean",
            "description": "`true` when the whole slab is sold. `false` when only part of it is:\nselling then leaves a remnant (a child slab) in the yard."
          }
        }
      },
      "SaleSlabRow": {
        "type": "object",
        "description": "A slab on the sale.",
        "required": [
          "id",
          "stone_id",
          "child_count"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int64",
            "description": "Slab id."
          },
          "stone_id": {
            "type": "integer",
            "format": "int32",
            "description": "Stone id."
          },
          "bundle": {
            "type": [
              "string",
              "null"
            ],
            "description": "Bundle."
          },
          "stone_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "Stone name."
          },
          "cut_date": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When it was cut."
          },
          "notes": {
            "type": [
              "string",
              "null"
            ],
            "description": "Notes."
          },
          "square_feet": {
            "type": [
              "number",
              "null"
            ],
            "format": "double",
            "description": "Square feet of its room."
          },
          "length": {
            "type": [
              "string",
              "null"
            ],
            "description": "Length (inches, as entered)."
          },
          "width": {
            "type": [
              "string",
              "null"
            ],
            "description": "Width (inches, as entered)."
          },
          "room_uuid": {
            "type": [
              "string",
              "null"
            ],
            "description": "Room id (hex)."
          },
          "room": {
            "type": [
              "string",
              "null"
            ],
            "description": "Room name."
          },
          "parent_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int64",
            "description": "The slab it was cut from."
          },
          "child_count": {
            "type": "integer",
            "format": "int64",
            "description": "Live pieces cut from it."
          }
        }
      },
      "SalesEmail": {
        "type": "object",
        "description": "The latest message of a thread in the folder.",
        "required": [
          "id",
          "thread_id",
          "has_attachments",
          "thread_has_attachments"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int64",
            "description": "The message."
          },
          "thread_id": {
            "type": "string",
            "description": "Its thread."
          },
          "subject": {
            "type": [
              "string",
              "null"
            ],
            "description": "Subject."
          },
          "body": {
            "type": [
              "string",
              "null"
            ],
            "description": "Text."
          },
          "sent_at": {
            "type": [
              "string",
              "null"
            ],
            "description": "When (UTC, ISO 8601)."
          },
          "sender_email": {
            "type": [
              "string",
              "null"
            ],
            "description": "From."
          },
          "receiver_email": {
            "type": [
              "string",
              "null"
            ],
            "description": "To."
          },
          "sender_user_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int64",
            "description": "The CRM user who sent it."
          },
          "has_attachments": {
            "type": "boolean",
            "description": "It has attachments."
          },
          "thread_has_attachments": {
            "type": "boolean",
            "description": "Any message of the thread has attachments."
          },
          "sender_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "The sender's user or customer name."
          },
          "receiver_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "The receiver's user or customer name."
          }
        }
      },
      "SalesGoal": {
        "type": "object",
        "description": "The signed-in user's monthly sales goal.",
        "properties": {
          "monthly_sales_goal": {
            "type": [
              "string",
              "null"
            ],
            "description": "Goal for each month, decimal string in USD (e.g. \"50000.00\"); null\nwhen the user has not set one (the dashboard then assumes $50,000)."
          }
        }
      },
      "SalesInvoice": {
        "type": "object",
        "description": "An invoice behind a customer's sales.",
        "required": [
          "id"
        ],
        "properties": {
          "id": {
            "type": "string",
            "description": "`QuickBooks` invoice id."
          },
          "doc_number": {
            "type": [
              "string",
              "null"
            ],
            "description": "Invoice number."
          },
          "total_amt": {
            "type": [
              "number",
              "null"
            ],
            "format": "double",
            "description": "Total."
          },
          "txn_date": {
            "type": [
              "string",
              "null"
            ],
            "description": "Invoice date."
          }
        }
      },
      "SalesOrder": {
        "allOf": [
          {
            "$ref": "#/components/schemas/SalesOrderRow"
          },
          {
            "type": "object",
            "required": [
              "option_index",
              "price",
              "items"
            ],
            "properties": {
              "option_index": {
                "type": "integer",
                "format": "int32",
                "description": "The sold option, 0-based."
              },
              "price": {
                "type": "number",
                "format": "double",
                "description": "The option's total, in dollars."
              },
              "sale_id": {
                "type": [
                  "integer",
                  "null"
                ],
                "format": "int32",
                "description": "The sale confirming made."
              },
              "confirmed_by_name": {
                "type": [
                  "string",
                  "null"
                ],
                "description": "Who confirmed it."
              },
              "confirmed_at": {
                "type": [
                  "string",
                  "null"
                ],
                "description": "When it was confirmed (UTC, ISO 8601)."
              },
              "items": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/SalesOrderItem"
                },
                "description": "Its colors, in the quote's order."
              }
            }
          }
        ],
        "description": "One order."
      },
      "SalesOrderInput": {
        "type": "object",
        "description": "The slabs of an order, every color given.",
        "required": [
          "items"
        ],
        "properties": {
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ItemSlabsInput"
            },
            "description": "Every color of the order with its slabs."
          }
        },
        "additionalProperties": false
      },
      "SalesOrderItem": {
        "type": "object",
        "description": "One color of an order.",
        "required": [
          "id",
          "color",
          "product",
          "rooms",
          "square_feet",
          "slabs_asked",
          "slabs",
          "available"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "The color of the order (`ItemSlabsInput.id`)."
          },
          "color": {
            "type": "string",
            "description": "The color, as the quote names it."
          },
          "product": {
            "type": "string",
            "description": "The material (Quartz, Granite, …)."
          },
          "rooms": {
            "type": "string",
            "description": "The rooms using it, comma-separated."
          },
          "square_feet": {
            "type": "number",
            "format": "double",
            "description": "Square feet of it the quote uses."
          },
          "slabs_asked": {
            "type": "integer",
            "format": "int32",
            "description": "Slabs the quote asks for."
          },
          "stone_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "The inventory stone of the color; null when it is not in the inventory."
          },
          "stone_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "The inventory stone's name."
          },
          "stone_url": {
            "type": [
              "string",
              "null"
            ],
            "description": "The inventory stone's picture."
          },
          "slabs": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/OrderSlab"
            },
            "description": "The slabs set."
          },
          "available": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SlabChoice"
            },
            "description": "Free slabs of the stone another pending order does not hold (those\nset here too), for a pending order."
          }
        }
      },
      "SalesOrderRow": {
        "type": "object",
        "description": "One order in the list.",
        "required": [
          "id",
          "status",
          "created_at",
          "customer_id",
          "quote_id",
          "slabs_asked",
          "slabs_set"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "The order."
          },
          "status": {
            "type": "string",
            "description": "`pending` or `confirmed`."
          },
          "created_at": {
            "type": "string",
            "description": "When the quote was sold (UTC, ISO 8601)."
          },
          "customer_id": {
            "type": "integer",
            "format": "int32",
            "description": "Its customer."
          },
          "customer_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "The customer's name."
          },
          "seller_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "Who the sale is credited to."
          },
          "quote_id": {
            "type": "integer",
            "format": "int32",
            "description": "The sold quote."
          },
          "quote_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "The quote's name."
          },
          "colors": {
            "type": [
              "string",
              "null"
            ],
            "description": "Its colors, comma-separated."
          },
          "slabs_asked": {
            "type": "integer",
            "format": "int64",
            "description": "Slabs the quote asks for."
          },
          "slabs_set": {
            "type": "number",
            "format": "double",
            "description": "Slabs set on it (a part counts a half)."
          }
        }
      },
      "SalesPage": {
        "type": "object",
        "description": "`GET /v1/superuser/sales-emails`.",
        "required": [
          "emails",
          "total_count",
          "current_page",
          "page_size",
          "mailbox"
        ],
        "properties": {
          "emails": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SalesEmail"
            },
            "description": "Threads, latest message first."
          },
          "total_count": {
            "type": "integer",
            "format": "int64",
            "description": "Threads in the folder (and search)."
          },
          "current_page": {
            "type": "integer",
            "format": "int64",
            "description": "The page."
          },
          "page_size": {
            "type": "integer",
            "format": "int64",
            "description": "Threads per page."
          },
          "mailbox": {
            "type": "string",
            "description": "The mailbox's address."
          }
        }
      },
      "SalesPlaybookInput": {
        "type": "object",
        "description": "Body of `PUT /v1/company/sales-playbook`.",
        "required": [
          "enabled"
        ],
        "properties": {
          "enabled": {
            "type": "boolean",
            "description": "On: the company's users see sub-stages, touch plans, stage time\nlimits and sales KPIs."
          }
        },
        "additionalProperties": false
      },
      "SalesRep": {
        "type": "object",
        "description": "A rep who texts through the provider.",
        "required": [
          "agent_id",
          "name"
        ],
        "properties": {
          "agent_id": {
            "type": "string",
            "description": "Filter value for `agent_id`."
          },
          "name": {
            "type": "string",
            "description": "The rep's name."
          }
        }
      },
      "SalesRepInput": {
        "type": "object",
        "description": "Body of `PUT /v1/customers/{id}/sales-rep`.",
        "properties": {
          "sales_rep": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "The new sales rep (user id), or null to unassign."
          },
          "group_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "The pipeline (group) whose first stage a new deal starts in; omit\nfor the default pipeline. Used only when the customer has no open\ndeal yet (the website's Leads page)."
          },
          "list_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "The list (stage) a new deal starts in, a live list of one of the\ncompany's pipelines; wins over `group_id`. Omit for the pipeline's\nfirst list. Used only when the customer has no open deal yet."
          }
        },
        "additionalProperties": false
      },
      "SalesReplyRequest": {
        "type": "object",
        "description": "Body of `POST /v1/superuser/sales-emails/{thread_id}/reply`.",
        "required": [
          "body"
        ],
        "properties": {
          "body": {
            "type": "string",
            "description": "The answer, plain text (new lines kept)."
          }
        }
      },
      "SalesReplyResult": {
        "type": "object",
        "description": "`POST /v1/superuser/sales-emails/{thread_id}/reply`.",
        "required": [
          "email_id",
          "to"
        ],
        "properties": {
          "email_id": {
            "type": "integer",
            "format": "int64",
            "description": "The recorded message."
          },
          "to": {
            "type": "string",
            "description": "Who it went to."
          }
        }
      },
      "SalesStats": {
        "type": "object",
        "description": "The signed-in user's deals this month so far, from the 1st through today\n(UTC). Only deals assigned to the user, of live customers of the company,\nin a live deal list, count.",
        "required": [
          "start_date",
          "end_date",
          "won_count",
          "lost_count",
          "won_amount",
          "active_deals_count",
          "pipeline_amount",
          "new_deals_count"
        ],
        "properties": {
          "start_date": {
            "type": "string",
            "description": "First day counted, `YYYY-MM-DD`."
          },
          "end_date": {
            "type": "string",
            "description": "Last day counted (today), `YYYY-MM-DD`."
          },
          "won_count": {
            "type": "integer",
            "format": "int64",
            "description": "Deals marked won this month (dated by their last change)."
          },
          "lost_count": {
            "type": "integer",
            "format": "int64",
            "description": "Deals marked lost this month."
          },
          "won_amount": {
            "type": "string",
            "description": "Total amount of the deals won this month, decimal string in USD\n(e.g. \"2200.00\"); \"0.00\" when none."
          },
          "active_deals_count": {
            "type": "integer",
            "format": "int64",
            "description": "Open deals (neither won nor lost), whenever they were created."
          },
          "pipeline_amount": {
            "type": "string",
            "description": "Total amount of the open deals, decimal string in USD; deals without an\namount add nothing."
          },
          "new_deals_count": {
            "type": "integer",
            "format": "int64",
            "description": "Deals created this month."
          }
        }
      },
      "SalesStatus": {
        "type": "string",
        "description": "`ok`, `error`, or `unavailable` when the company does not use\n`QuickBooks` (or the rep has no name to match).",
        "enum": [
          "ok",
          "error",
          "unavailable"
        ]
      },
      "Salesperson": {
        "type": "object",
        "description": "A sales rep a quote can name.",
        "required": [
          "id"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "User id."
          },
          "name": {
            "type": [
              "string",
              "null"
            ],
            "description": "Name."
          },
          "phone_number": {
            "type": [
              "string",
              "null"
            ],
            "description": "Phone."
          }
        }
      },
      "SamplesInput": {
        "type": "object",
        "description": "Body of `PATCH /v1/stones/{id}/samples`; at least one field.",
        "properties": {
          "amount": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Samples on hand, 0 or more."
          },
          "importance": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "How many samples to keep: 1 (few) to 3 (many), 4 = none needed."
          }
        },
        "additionalProperties": false
      },
      "SaveEventCrewChecksInput": {
        "type": "object",
        "description": "Body of `PUT /v1/events/{id}/crew-checks`.",
        "required": [
          "kind"
        ],
        "properties": {
          "kind": {
            "$ref": "#/components/schemas/CrewChecklistKind",
            "description": "Whose they are."
          },
          "checklist_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "The list they came from (`GET /v1/crew-checklists`), if any."
          },
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/EventCrewCheckInput"
            },
            "description": "Every check of the appointment, in order (replaces what was saved),\nat most 80."
          }
        }
      },
      "SaveMaterial": {
        "type": "object",
        "description": "`PUT /v1/stones/materials/{id}`.",
        "required": [
          "name",
          "type"
        ],
        "properties": {
          "name": {
            "type": "string",
            "description": "Name, e.g. \"Fantasy Brown\"; every stone of the material takes it."
          },
          "type": {
            "type": "string",
            "description": "One of the company's stone types (`GET /v1/stone-types`); every\nstone of the material takes it."
          },
          "image_url": {
            "type": [
              "string",
              "null"
            ],
            "description": "Photo: the `url` of an upload to the `stones` folder\n(`POST /v1/uploads`), placed on the company's slab picture background.\nOmitted: kept; null: removed (the card shows its first stone's photo)."
          },
          "level": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Level, one of the company's levels (`GET /v1/stone-levels`; 1 to 7\nuntil it adds more); with materials first every bundle of the\nmaterial takes it. Omitted: kept; null: none (each bundle keeps its\nown)."
          },
          "finishing": {
            "type": [
              "string",
              "null"
            ],
            "description": "One of the company's finishes (`GET /v1/stone-finishes`); with\nmaterials first every bundle of the material takes it. Omitted: kept;\nnull: none (each bundle keeps its own)."
          },
          "color_ids": {
            "type": [
              "array",
              "null"
            ],
            "items": {
              "type": "integer",
              "format": "int32"
            },
            "description": "The material's colors (`GET /v1/colors`); every stone of the\nmaterial takes them. Omitted: kept."
          },
          "regular_stock": {
            "type": [
              "boolean",
              "null"
            ],
            "description": "Regular Stock: every bundle of the material takes it. Omitted: kept."
          }
        },
        "additionalProperties": false
      },
      "SaveOrder": {
        "type": "object",
        "description": "Body of `PUT /v1/me/template-order/{type}`.",
        "required": [
          "template_ids"
        ],
        "properties": {
          "template_ids": {
            "type": "array",
            "items": {
              "type": "integer",
              "format": "int32"
            },
            "description": "Every template of the picker, in the new order."
          }
        },
        "additionalProperties": false
      },
      "SaveStoneSettings": {
        "type": "object",
        "description": "`PUT /v1/stones/settings`.",
        "required": [
          "stone_view"
        ],
        "properties": {
          "stone_view": {
            "$ref": "#/components/schemas/StoneView",
            "description": "`stones` (default) or `materials`."
          },
          "show_all_locations": {
            "type": [
              "boolean",
              "null"
            ],
            "description": "Show all locations' inventory to the company's staff. Omitted: kept."
          },
          "show_schedule_visit": {
            "type": [
              "boolean",
              "null"
            ],
            "description": "Show Schedule a visit on the public stones page. Omitted: kept."
          },
          "customer_stones_per_row": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Cards per row of the customer stones page on a wide screen: 4, 6 or\n7; any other number is 400. Omitted: kept.",
            "minimum": 0
          },
          "staff_stones_per_row": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Cards per row of the company's own stones pages on a wide screen, for\neveryone who has not picked their own: 4, 6 or 7; any other number is\n400. Omitted: kept.",
            "minimum": 0
          }
        },
        "additionalProperties": false
      },
      "SaveWidgetLayout": {
        "type": "object",
        "description": "Body of `PUT /v1/stats/widget-layout`.",
        "required": [
          "value"
        ],
        "properties": {
          "value": {
            "type": "object",
            "description": "The whole layout as the page serializes it."
          }
        }
      },
      "SavedDraft": {
        "type": "object",
        "description": "A saved draft.",
        "required": [
          "id",
          "thread_id"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "Draft id."
          },
          "thread_id": {
            "type": "string",
            "description": "Conversation it will start."
          }
        }
      },
      "SavedDrawing": {
        "type": "object",
        "description": "A drawing to save.",
        "required": [
          "doc"
        ],
        "properties": {
          "doc": {
            "type": "object",
            "description": "The drawing (`QuoteDoc`)."
          },
          "step": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "The editor step to come back to."
          },
          "notes": {
            "type": [
              "string",
              "null"
            ],
            "description": "What changed (up to 500 characters)."
          }
        },
        "additionalProperties": false
      },
      "SavedFeedback": {
        "type": "object",
        "description": "Saved feedback (`approve`, `escalate`).",
        "required": [
          "feedbackId",
          "message"
        ],
        "properties": {
          "feedbackId": {
            "type": "integer",
            "format": "int64",
            "description": "The `message_feedback` row.",
            "minimum": 0
          },
          "message": {
            "type": "string",
            "description": "What to tell the user."
          },
          "escalate": {
            "type": [
              "boolean",
              "null"
            ],
            "description": "True when escalated."
          }
        }
      },
      "SavedMaterial": {
        "type": "object",
        "description": "`PUT /v1/stones/materials/{id}` answer.",
        "required": [
          "id"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "The material's id; another one's when the new name was already a\nmaterial (the two are now one)."
          }
        }
      },
      "SavedOrderChange": {
        "type": "object",
        "description": "The change order saved.",
        "required": [
          "number",
          "total_before",
          "total_after",
          "sales_order_reopened"
        ],
        "properties": {
          "number": {
            "type": "integer",
            "format": "int64",
            "description": "Its number."
          },
          "total_before": {
            "type": "number",
            "format": "double",
            "description": "The Order's total before."
          },
          "total_after": {
            "type": "number",
            "format": "double",
            "description": "The Order's total after."
          },
          "sales_order_reopened": {
            "type": "boolean",
            "description": "The stone or the slabs changed, so the Inventory Manager got the\nsales order to confirm again."
          }
        }
      },
      "SavedPriceList": {
        "type": "object",
        "description": "Body of saving a list.",
        "required": [
          "name",
          "status"
        ],
        "properties": {
          "name": {
            "type": "string",
            "description": "Name, unique in the company."
          },
          "status": {
            "type": "string",
            "description": "`active` or `inactive`."
          },
          "info": {
            "type": [
              "object",
              "null"
            ],
            "description": "The edited prices; left out when only the name or status changed."
          },
          "notes": {
            "type": [
              "string",
              "null"
            ],
            "description": "What changed (up to 500 characters)."
          }
        },
        "additionalProperties": false
      },
      "SavedQuoteForm": {
        "type": "object",
        "description": "A form as the editor saves it.",
        "required": [
          "name",
          "status",
          "sequence",
          "config"
        ],
        "properties": {
          "name": {
            "type": "string",
            "description": "Name (up to 160 characters)."
          },
          "status": {
            "type": "string",
            "description": "`active` or `inactive`."
          },
          "sequence": {
            "type": "number",
            "format": "double",
            "description": "Order (1 or more)."
          },
          "config": {
            "type": "object",
            "description": "The layout (`QuoteFormConfig`)."
          }
        },
        "additionalProperties": false
      },
      "SavedRevision": {
        "type": "object",
        "description": "The revision saved.",
        "required": [
          "revision"
        ],
        "properties": {
          "revision": {
            "type": "integer",
            "format": "int64",
            "description": "Its number."
          }
        }
      },
      "ScheduleActivity": {
        "type": "object",
        "description": "`GET /v1/schedule/activity`.",
        "required": [
          "events",
          "has_more"
        ],
        "properties": {
          "events": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ActivityEvent"
            },
            "description": "Most recently changed first."
          },
          "has_more": {
            "type": "boolean",
            "description": "More events past this page."
          }
        }
      },
      "ScheduleEvent": {
        "type": "object",
        "description": "An event on the schedule.",
        "required": [
          "id",
          "title",
          "start_date",
          "end_date",
          "all_day",
          "urgent",
          "created_user_id",
          "customer_told",
          "automated",
          "people"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "Event id."
          },
          "title": {
            "type": "string",
            "description": "The event's name."
          },
          "location": {
            "type": [
              "string",
              "null"
            ],
            "description": "Address."
          },
          "start_date": {
            "type": "string",
            "description": "Start (UTC, ISO 8601)."
          },
          "end_date": {
            "type": "string",
            "description": "End (UTC, ISO 8601)."
          },
          "all_day": {
            "type": "boolean",
            "description": "All day."
          },
          "color": {
            "type": [
              "string",
              "null"
            ],
            "description": "Label color."
          },
          "status": {
            "type": [
              "string",
              "null"
            ],
            "description": "Status."
          },
          "urgent": {
            "type": "boolean",
            "description": "Red flag: it must be scheduled fast (Mark as Sold or its edit form)."
          },
          "notes": {
            "type": [
              "string",
              "null"
            ],
            "description": "Notes."
          },
          "calendar_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Calendar."
          },
          "rrule": {
            "type": [
              "string",
              "null"
            ],
            "description": "Repeat rule (RFC 5545), for repeating events."
          },
          "recurrence_until": {
            "type": [
              "string",
              "null"
            ],
            "description": "Last repeat (UTC, ISO 8601)."
          },
          "recurrence_exdates": {
            "type": [
              "string",
              "null"
            ],
            "description": "Days a repeating event skips: comma-separated `YYYY-MM-DD` in the\nshop's time zone. Null when none are skipped."
          },
          "created_user_id": {
            "type": "integer",
            "format": "int32",
            "description": "Who made it."
          },
          "created_user_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "Name of the user who made it (the schedule shows it on the event).\nNull when that user has no name."
          },
          "created_user_photo_url": {
            "type": [
              "string",
              "null"
            ],
            "description": "That user's picture (`PUT /v1/me/photo`); null when they have none."
          },
          "assigned_user_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "The installer or template maker on it."
          },
          "assigned_user_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "The assignee's name; null when no one is assigned or they have no name."
          },
          "assigned_user_photo_url": {
            "type": [
              "string",
              "null"
            ],
            "description": "The assignee's picture (`PUT /v1/me/photo`); null when they have none."
          },
          "sale_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Its sale."
          },
          "customer_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "The customer it is for."
          },
          "customer_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "That customer's name."
          },
          "contact_phone": {
            "type": [
              "string",
              "null"
            ],
            "description": "Phone for this event only; null uses the customer's."
          },
          "contact_email": {
            "type": [
              "string",
              "null"
            ],
            "description": "Email for this event only; null uses the customer's."
          },
          "contact_phone_2": {
            "type": [
              "string",
              "null"
            ],
            "description": "A second phone for this event; automated texts go to both."
          },
          "contact_email_2": {
            "type": [
              "string",
              "null"
            ],
            "description": "A second email for this event; automated emails go to both."
          },
          "crew_status": {
            "type": [
              "string",
              "null"
            ],
            "description": "The crew's progress: `on_my_way`, `arrived` or `completed`."
          },
          "on_my_way_at": {
            "type": [
              "string",
              "null"
            ],
            "description": "When the crew set off (UTC, ISO 8601)."
          },
          "arrived_at": {
            "type": [
              "string",
              "null"
            ],
            "description": "When the crew's phone reached the address (UTC, ISO 8601)."
          },
          "completed_at": {
            "type": [
              "string",
              "null"
            ],
            "description": "When the crew tapped Completed (UTC, ISO 8601)."
          },
          "shop_status": {
            "type": [
              "string",
              "null"
            ],
            "description": "The shop's progress: `cut` or `complete`; null until cut. Everyone\ngets it."
          },
          "customer_told": {
            "type": "boolean",
            "description": "The customer got the On my way message."
          },
          "automated": {
            "type": "boolean",
            "description": "Added by the CRM on its own when a quote was sold (Mark as Sold's\njobs and extra events), not by a person: show it as made by the\nsystem. `created_user_id` is then whoever sold it."
          },
          "quote_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "The sold quote that added it (Mark as Sold); null when a person\nmade it. The calendar adds up these quotes' sq ft per day."
          },
          "qbo_invoice": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/EventInvoice",
                "description": "Its QuickBooks invoice (only when QuickBooks is connected)."
              },
              {
                "type": "null"
              }
            ]
          },
          "people": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/EventPerson"
            },
            "description": "People of the company added to it, by name (empty when none).\nChange them with `people_ids` on `PUT /v1/events/{id}`."
          }
        }
      },
      "ScheduleEvents": {
        "type": "object",
        "description": "`GET /v1/schedule/events`.",
        "required": [
          "events",
          "quickbooks_connected"
        ],
        "properties": {
          "events": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ScheduleEvent"
            },
            "description": "One-off events in the range and repeating events that may fall in it,\nby start; calendars hidden from the caller are left out."
          },
          "quickbooks_connected": {
            "type": "boolean",
            "description": "QuickBooks is on and connected: events show their invoices."
          }
        }
      },
      "SchedulePerson": {
        "type": "object",
        "description": "An installer or template maker.",
        "required": [
          "id",
          "name",
          "role",
          "color"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "User id."
          },
          "name": {
            "type": "string",
            "description": "Name (\"Unnamed\" when blank)."
          },
          "role": {
            "type": "string",
            "description": "`installer` or `template`."
          },
          "color": {
            "type": "string",
            "description": "Their color on the schedule: the saved one, else one picked by id."
          }
        }
      },
      "ScheduleSettings": {
        "type": "object",
        "description": "`GET /v1/schedule/settings`.",
        "required": [
          "week_starts_on",
          "company_week_starts_on",
          "time_24h",
          "prefs_asked",
          "notify_rep_on_install_complete"
        ],
        "properties": {
          "week_starts_on": {
            "$ref": "#/components/schemas/WeekStart",
            "description": "The day the caller's week and month views start their weeks on: their\nown choice, else the company's."
          },
          "company_week_starts_on": {
            "$ref": "#/components/schemas/WeekStart",
            "description": "The day the company's weeks start on (Admin > Schedule)."
          },
          "time_24h": {
            "type": "boolean",
            "description": "The caller shows times as 13:00 rather than 1:00 PM."
          },
          "maps_app": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/MapsApp",
                "description": "The maps app the caller's addresses and directions open in; null when\nthey have not picked one (the device's own: Apple Maps on Apple\ndevices)."
              },
              {
                "type": "null"
              }
            ]
          },
          "prefs_asked": {
            "type": "boolean",
            "description": "The Schedule already asked the caller for their 12/24-hour times and\nmaps app (answered or closed): it does not ask again."
          },
          "estimates_calendar_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "The calendar the deal page's Schedule estimate button books on: the\none an admin picked, else the built-in Estimates calendar (null when\nthere is neither)."
          },
          "favorite_color": {
            "type": [
              "string",
              "null"
            ],
            "description": "The label color of the last event the caller added by hand (null when\nnone): a new event starts with it."
          },
          "notify_rep_on_install_complete": {
            "type": "boolean",
            "description": "The job's sales rep is told when the installer taps Completed on an\ninstallation (Admin > Schedule; on unless an admin turned it off)."
          }
        }
      },
      "ScheduleSettingsInput": {
        "type": "object",
        "description": "`PUT /v1/schedule/settings`: only the fields sent change.",
        "properties": {
          "week_starts_on": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/WeekStart",
                "description": "The day the week and month views start their weeks on."
              },
              {
                "type": "null"
              }
            ]
          },
          "estimates_calendar_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "A calendar of the caller's company."
          },
          "notify_rep_on_install_complete": {
            "type": [
              "boolean",
              "null"
            ],
            "description": "Tell the sales rep when the installer taps Completed on an installation."
          }
        }
      },
      "SchedulingCallerId": {
        "type": "object",
        "description": "`GET` / `PUT /v1/schedule/notifications/caller-id`: the name people see\nwhen the Scheduling call rings.",
        "properties": {
          "line": {
            "type": [
              "string",
              "null"
            ],
            "description": "The Scheduling Manager's line the calls come from, E.164; `None` when\nthe company cannot place Scheduling calls."
          },
          "name": {
            "type": [
              "string",
              "null"
            ],
            "description": "The caller ID name listed for that line; `None` when none is."
          }
        }
      },
      "SchedulingCallerIdInput": {
        "type": "object",
        "description": "Body of `PUT /v1/schedule/notifications/caller-id`.",
        "properties": {
          "name": {
            "type": [
              "string",
              "null"
            ],
            "description": "Up to 15 letters, digits, spaces and `& , . - '`. Empty or left out\nstops listing a name."
          }
        }
      },
      "SchedulingSettings": {
        "type": "object",
        "description": "Admin > Schedule > AI texts: what happens after an AI text.",
        "required": [
          "ai_ready",
          "text_days",
          "text_start",
          "text_end"
        ],
        "properties": {
          "ai_ready": {
            "type": "boolean",
            "description": "AI reads the customer's replies to an AI text and, when it is\ncertain they agreed to the date, marks the job Ready and tells the\nScheduling Managers."
          },
          "text_days": {
            "type": "array",
            "items": {
              "type": "integer",
              "format": "int32",
              "minimum": 0
            },
            "description": "Days follow-ups may go out: 0 Monday ... 6 Sunday."
          },
          "text_start": {
            "type": "string",
            "description": "Store time (`HH:MM`) follow-ups may start going out."
          },
          "text_end": {
            "type": "string",
            "description": "Store time (`HH:MM`) after which they wait for the next texting day."
          }
        }
      },
      "SchedulingTextPreview": {
        "type": "object",
        "description": "A scheduling text the event form's Send SMS lists.",
        "required": [
          "id",
          "name",
          "ai"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "Template id: send it with `POST /v1/events/{id}/confirmation`."
          },
          "name": {
            "type": "string",
            "description": "The template's name."
          },
          "text": {
            "type": [
              "string",
              "null"
            ],
            "description": "The text as the customer would get it; null when it can't be filled."
          },
          "problem": {
            "type": [
              "string",
              "null"
            ],
            "description": "Why it can't go, e.g. the event has no address."
          },
          "followup": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/Followup",
                "description": "What happens when the customer doesn't reply."
              },
              {
                "type": "null"
              }
            ]
          },
          "ai": {
            "type": "boolean",
            "description": "An AI text: AI reads the customer's answer."
          }
        }
      },
      "SchedulingTexts": {
        "type": "object",
        "description": "`GET /v1/events/{id}/scheduling-texts`.",
        "required": [
          "templates",
          "ai_ready",
          "can_call"
        ],
        "properties": {
          "templates": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SchedulingTextPreview"
            },
            "description": "The scheduling texts for the event's calendar, in the admin's order."
          },
          "problem": {
            "type": [
              "string",
              "null"
            ],
            "description": "Why no text can go to this event's customer (no customer, no phone,\nno Scheduling Manager line); null when they can."
          },
          "ai_ready": {
            "type": "boolean",
            "description": "AI marks the job Ready when the customer agrees."
          },
          "can_call": {
            "type": "boolean",
            "description": "The company can place a Scheduling call (`POST\n/v1/events/{id}/confirmation-call`): calling is on and the Scheduling\nManager has a Granite Manager line."
          }
        }
      },
      "SectionInfo": {
        "type": "object",
        "description": "A tab a position may open.",
        "required": [
          "key",
          "label",
          "admin"
        ],
        "properties": {
          "key": {
            "type": "string",
            "description": "Stable key (`stones`, `customers`, `schedule`, `admin_stones`, ...)."
          },
          "label": {
            "type": "string",
            "description": "Its name on the Company page (admin tabs are listed apart)."
          },
          "admin": {
            "type": "boolean",
            "description": "An admin page: it opens for someone without the Admin switch only\nwhen one of their positions has it (the Admin switch opens them all)."
          }
        }
      },
      "SeenInput": {
        "type": "object",
        "description": "Body of `POST /v1/phone/calls/seen`: `ids` or `upTo`.",
        "properties": {
          "ids": {
            "type": [
              "array",
              "null"
            ],
            "items": {
              "type": "integer",
              "format": "int64"
            },
            "description": "These calls (up to 500; other companies' ids are ignored)."
          },
          "upTo": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "Or every call in my Recents that started at or before this\n(RFC 3339)."
          }
        }
      },
      "SelfPayment": {
        "type": "object",
        "description": "Body of `POST /v1/public/customer-view/{company_id}/{view_id}/payments`.",
        "required": [
          "project_key",
          "method",
          "amount_cents"
        ],
        "properties": {
          "project_key": {
            "type": "string",
            "description": "The job to pay for, one of the page's `projects` (`project_key`)."
          },
          "method": {
            "$ref": "#/components/schemas/PaymentMethod",
            "description": "How the customer pays."
          },
          "amount_cents": {
            "type": "integer",
            "format": "int64",
            "description": "What goes toward the job, in US cents: 100 ($1) up to the job's\n`open_cents`; a card payment at least 1000 ($10)."
          }
        },
        "additionalProperties": false
      },
      "SelfPaymentMade": {
        "type": "object",
        "description": "The payment the customer made on their page.",
        "required": [
          "id",
          "url"
        ],
        "properties": {
          "id": {
            "type": "string",
            "description": "The payment's id (`pay_...`): `POST /v1/public/pay/{payment_id}/checkout`\nopens Stripe's page for it."
          },
          "url": {
            "type": "string",
            "description": "The payment's own page."
          }
        }
      },
      "SendAttachment": {
        "type": "object",
        "description": "A file attached to an email being sent.",
        "required": [
          "url",
          "filename",
          "content_type"
        ],
        "properties": {
          "url": {
            "type": "string",
            "description": "URL of the file."
          },
          "filename": {
            "type": "string",
            "description": "File name shown to the recipient (at most 255 characters)."
          },
          "content_type": {
            "type": "string",
            "description": "MIME type, e.g. `application/pdf`."
          },
          "token": {
            "type": [
              "string",
              "null"
            ],
            "description": "The upload's `token`; absent for attachments of a conversation."
          }
        },
        "additionalProperties": false
      },
      "SendCustomerTodosInput": {
        "type": "object",
        "description": "Body of `POST /v1/events/{id}/customer-todos`.",
        "properties": {
          "checklist_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "The list they were picked from (`GET /v1/customer-checklists`), if any."
          },
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CustomerTodoInput"
            },
            "description": "The to-dos that apply to this customer, at most 60. Empty means there\nis nothing to do."
          }
        }
      },
      "SendEmailRequest": {
        "type": "object",
        "description": "Body of `POST /v1/emails`.",
        "required": [
          "to"
        ],
        "properties": {
          "to": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Recipients; at least one. Several without `cc`, `bcc`, `thread_id` or\n`send_together` each get their own message and conversation."
          },
          "cc": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Copy recipients (at most 25)."
          },
          "bcc": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Blind copy recipients (at most 25)."
          },
          "subject": {
            "type": "string",
            "description": "Subject (at most 255 characters)."
          },
          "body": {
            "type": "string",
            "description": "The note: editor HTML or plain text. `{{variables}}` are filled per\nrecipient. Required unless there are attachments. At most 65,535 bytes\nwith its variables filled."
          },
          "thread_id": {
            "type": [
              "string",
              "null"
            ],
            "description": "Reply in this conversation (threads the message after its last one)."
          },
          "deal_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Deal the email is about; its customer gets the recipients' new\naddresses (never a coworker's)."
          },
          "customer_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Customer the email is about, when there is no deal."
          },
          "send_together": {
            "type": "boolean",
            "description": "Send one message to all `to` recipients."
          },
          "attachments": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SendAttachment"
            },
            "description": "Files uploaded with `POST /v1/uploads` (folder `emails`, with their\n`token`), or attachments of a conversation the caller may read."
          },
          "template_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Email template the note came from (orders the template picker)."
          },
          "send_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "Send later instead (within 90 days)."
          },
          "cancel_if_customer_messages": {
            "type": "boolean",
            "description": "With `send_at`: cancel when the customer writes first."
          },
          "signature_requests": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SignatureRequestInput"
            },
            "description": "PDF attachments sent for e-signature: the email carries their signing\nlinks instead of the files (at most 20, one message to everyone)."
          },
          "signature_send_key": {
            "type": [
              "string",
              "null"
            ],
            "description": "The composer's id of this send (a UUID), so a retried send reuses its\nsignature documents."
          }
        },
        "additionalProperties": false
      },
      "SendEmailResult": {
        "type": "object",
        "description": "Result of `POST /v1/emails`.",
        "required": [
          "sent",
          "delayed",
          "thread_ids"
        ],
        "properties": {
          "sent": {
            "type": "integer",
            "description": "Messages sent (0 when scheduled).",
            "minimum": 0
          },
          "delayed": {
            "type": "boolean",
            "description": "The email was scheduled for `send_at`."
          },
          "thread_ids": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Conversations the messages went to."
          }
        }
      },
      "SendSmsRequest": {
        "type": "object",
        "description": "Body of `POST /v1/sms/{provider}/messages`.",
        "required": [
          "phone_digits"
        ],
        "properties": {
          "phone_digits": {
            "type": "string",
            "description": "The customer's phone, 10 to 15 digits."
          },
          "text": {
            "type": "string",
            "description": "The message (up to 1600 characters); may be empty with files."
          },
          "attachments": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SmsFile"
            },
            "description": "Up to ten files."
          },
          "template_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "The SMS template it was written from (counts towards its ordering)."
          },
          "customer_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "The customer it is for (scheduled texts only)."
          },
          "send_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "Send later instead, within 90 days."
          },
          "cancel_if_customer_messages": {
            "type": "boolean",
            "description": "A scheduled text is dropped if the customer writes first."
          },
          "line_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "The caller's Telnyx line to send from (a `number_id` of\n`/v1/sms/mine/lines`); without one, their default line."
          }
        }
      },
      "SendText": {
        "type": "object",
        "description": "Body of `POST /v1/phone/texts`.",
        "required": [
          "ourNumberId",
          "to"
        ],
        "properties": {
          "ourNumberId": {
            "type": "integer",
            "format": "int32",
            "description": "The line to text from: one of mine (`ourNumber.id` of a thread, or a\ncaller ID's `numberId`)."
          },
          "to": {
            "type": "string",
            "description": "The other number: E.164 or 10 digits (US and Canada only)."
          },
          "text": {
            "type": "string",
            "description": "The text, up to 1600 characters; may be empty with files."
          },
          "attachments": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SmsFile"
            },
            "description": "Up to ten files made ready by `POST /v1/sms/attachments` (pictures go\nas MMS, other files as links), as for the CRM's texts."
          }
        }
      },
      "SentInvite": {
        "type": "object",
        "description": "An invite link that was made for a user.",
        "required": [
          "invite_url",
          "email_sent"
        ],
        "properties": {
          "invite_url": {
            "type": "string",
            "description": "The link, to share another way if the email does not arrive."
          },
          "email_sent": {
            "type": "boolean",
            "description": "The link was emailed to the user."
          }
        }
      },
      "SentRequest": {
        "type": "object",
        "description": "A document sent for signature.",
        "required": [
          "id",
          "filename",
          "signer_name",
          "signer_email",
          "status",
          "provider",
          "signed_url"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int64",
            "description": "The request."
          },
          "filename": {
            "type": "string",
            "description": "Document name."
          },
          "signer_name": {
            "type": "string",
            "description": "Who signs."
          },
          "signer_email": {
            "type": "string",
            "description": "Their email."
          },
          "status": {
            "type": "string",
            "description": "`draft`, `sent`, `viewed`, `signed`, `declined` or `expired`."
          },
          "provider": {
            "type": "string",
            "description": "`signwell` or `native`."
          },
          "customer_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "The customer's name, or null."
          },
          "sender_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "Who sent it, or null."
          },
          "created_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When it was sent."
          },
          "updated_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "Last change (when signed, the signing time)."
          },
          "signed_url": {
            "type": "string",
            "description": "Where to open it: an API path (`/v1/...`) to open on the API's host,\nelse the original file's URL."
          }
        }
      },
      "SentReset": {
        "type": "object",
        "description": "A password reset link a manager made for a user.",
        "required": [
          "reset_url",
          "email_sent"
        ],
        "properties": {
          "reset_url": {
            "type": "string",
            "description": "The link, to share another way if the email does not arrive. It\nworks once, for 24 hours."
          },
          "email_sent": {
            "type": "boolean",
            "description": "The link was emailed to the user (false when the email failed or the\nuser has no email address)."
          }
        }
      },
      "SentSms": {
        "type": "object",
        "description": "Texts the signed-in user sent through the company's SMS provider.",
        "required": [
          "months"
        ],
        "properties": {
          "provider": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/SmsProvider",
                "description": "The provider counted; null when the company has none, and then\n`months` is empty."
              },
              {
                "type": "null"
              }
            ]
          },
          "months": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/MonthlyCount"
            },
            "description": "Months with at least one text, oldest first, over the current month and\nthe two before it. Months without texts are left out."
          }
        }
      },
      "SesInbound": {
        "type": "object",
        "description": "Whether a company receives email through SES.",
        "required": [
          "ses_pending",
          "mx_inbound",
          "inbound_ready"
        ],
        "properties": {
          "domain": {
            "type": [
              "string",
              "null"
            ],
            "description": "The domain checked, or null without one."
          },
          "ses_verified": {
            "type": [
              "boolean",
              "null"
            ],
            "description": "SES verified the domain; null when SES could not be asked."
          },
          "ses_pending": {
            "type": "boolean",
            "description": "Verification is pending at SES."
          },
          "mx_inbound": {
            "type": "boolean",
            "description": "The domain's MX points at SES email receiving (`inbound-smtp.`)."
          },
          "inbound_ready": {
            "type": "boolean",
            "description": "Verified and the MX points at SES: inbound email works."
          }
        }
      },
      "SessionUser": {
        "type": "object",
        "description": "The signed-in user, after the super-admin rule is applied.",
        "required": [
          "id",
          "email",
          "is_employee",
          "is_admin",
          "is_superuser",
          "company_id",
          "pined_bar",
          "is_signature_available"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "User id."
          },
          "email": {
            "type": "string",
            "description": "Login email."
          },
          "name": {
            "type": [
              "string",
              "null"
            ],
            "description": "Display name."
          },
          "phone_number": {
            "type": [
              "string",
              "null"
            ],
            "description": "Personal phone number."
          },
          "is_employee": {
            "type": "boolean",
            "description": "Staff member of the company (sees customers, deals, inventory)."
          },
          "is_admin": {
            "type": "boolean",
            "description": "Company admin. Always true for super admins."
          },
          "is_superuser": {
            "type": "boolean",
            "description": "Platform-wide superuser."
          },
          "company_id": {
            "type": "integer",
            "format": "int32",
            "description": "Company every request acts in. For a super admin this is the company\nselected in the session, otherwise the user's own company."
          },
          "pined_bar": {
            "type": "boolean",
            "description": "UI preference: the sidebar is pinned open."
          },
          "cloudtalk_agent_id": {
            "type": [
              "string",
              "null"
            ],
            "description": "CloudTalk telephony agent id, when the user has a CloudTalk seat."
          },
          "cloudtalk_phone_number": {
            "type": [
              "string",
              "null"
            ],
            "description": "Outbound CloudTalk phone number."
          },
          "ringcentral_extension_id": {
            "type": [
              "string",
              "null"
            ],
            "description": "RingCentral extension id, when the user has a RingCentral seat."
          },
          "ringcentral_phone_number": {
            "type": [
              "string",
              "null"
            ],
            "description": "Outbound RingCentral phone number."
          },
          "is_signature_available": {
            "type": "boolean",
            "description": "Feature flag: the user may use e-signatures."
          }
        }
      },
      "SetAiModel": {
        "type": "object",
        "description": "Body of `POST /v1/ai-models/settings`.",
        "required": [
          "feature"
        ],
        "properties": {
          "feature": {
            "type": "string",
            "description": "The step's feature, as `GET /v1/ai-models` lists it (`quick_reply`)."
          },
          "step": {
            "type": "string",
            "description": "The step's name within the feature, as listed; `\"\"` (the default) for\na feature with one step."
          },
          "company_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "One company's own pick; absent or null for every company."
          },
          "model": {
            "type": [
              "string",
              "null"
            ],
            "description": "The model to use, one of `GET /v1/ai-models` `models` of the step's\nkind; null puts the step back on the code's default (for the company,\nor for every company without a company's own pick)."
          },
          "reasoning_effort": {
            "type": [
              "string",
              "null"
            ],
            "description": "`none`, `minimal`, `low`, `medium`, `high` or `xhigh` for a text\nstep; null keeps the effort the code asks for. Only with a model."
          }
        },
        "additionalProperties": false
      },
      "SettingsPatch": {
        "type": "object",
        "description": "Body of `PUT /v1/phone/settings`: only the fields sent change.",
        "properties": {
          "defaultCallerNumberId": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "My default caller ID: one of `GET /v1/phone/caller-ids` (400\n`not_a_caller_id` otherwise); null clears it."
          },
          "aiNotes": {
            "type": [
              "boolean",
              "null"
            ],
            "description": "Transcribe my recorded calls and add AI notes to deals."
          },
          "workingHours": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/WorkingHours",
                "description": "When I take calls; null clears them (always available)."
              },
              {
                "type": "null"
              }
            ]
          },
          "cellFallback": {
            "type": [
              "boolean",
              "null"
            ],
            "description": "Ring my cell when the app does not answer; turning it on needs a\nverified cell (400 `cell_not_verified`)."
          },
          "ringTimeoutSecs": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int64",
            "description": "How long calls ring my phones, 15 to 60 seconds."
          },
          "forwardAll": {
            "type": [
              "boolean",
              "null"
            ],
            "description": "\"Forward all calls\" on or off; on with `number` needs a number\n(400 `invalid_phone`)."
          },
          "forwardAllTo": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/ForwardAllTo",
                "description": "Where \"Forward all calls\" sends calls: `voicemail` or `number`."
              },
              {
                "type": "null"
              }
            ]
          },
          "forwardAllNumber": {
            "type": [
              "string",
              "null"
            ],
            "description": "The number to forward all calls to: a US or Canada number, any\nformat (400 `invalid_phone` otherwise); null clears it."
          },
          "displayNumber": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/DisplayNumber",
                "description": "What my phones show for an incoming call: `caller` or `called`."
              },
              {
                "type": "null"
              }
            ]
          },
          "unknownShowMine": {
            "type": [
              "boolean",
              "null"
            ],
            "description": "When the caller hides their number, show the number they called."
          },
          "announceDirect": {
            "type": [
              "boolean",
              "null"
            ],
            "description": "Announce calls to my direct lines before they connect."
          },
          "announceShared": {
            "type": [
              "boolean",
              "null"
            ],
            "description": "Announce calls to shared lines and the main line."
          },
          "announceLineName": {
            "type": [
              "boolean",
              "null"
            ],
            "description": "The announcement names the line called."
          },
          "answerPin": {
            "type": [
              "string",
              "null"
            ],
            "description": "My answer PIN for my fallback cell: exactly 4 digits (400\n`invalid_pin` otherwise); null clears it (and turns `requirePin`\noff). It is never sent back."
          },
          "requirePin": {
            "type": [
              "boolean",
              "null"
            ],
            "description": "My fallback cell asks for the PIN instead of \"press 1\"; turning it\non needs a PIN, sent now or before (400 `pin_required`)."
          },
          "holdMusic": {
            "type": [
              "string",
              "null"
            ],
            "description": "Hold music: a built-in track id (`GET /v1/phone/hold-music`),\n`custom` (with `holdMusicUrl`) or `none` (400 `invalid_hold_music`\notherwise)."
          },
          "holdMusicUrl": {
            "type": [
              "string",
              "null"
            ],
            "description": "With `custom`: the `url` from `POST /v1/phone/hold-music/upload`,\nonce the file was put there; it must be my upload, an MP3 or WAV of\nat most 5 MB (400 `invalid_hold_music`). Left out with `custom`: my\ncurrent upload stays."
          },
          "holdMusicName": {
            "type": [
              "string",
              "null"
            ],
            "description": "With `custom` and a new `holdMusicUrl`: the file's name to show (at\nmost 100 characters)."
          }
        }
      },
      "Setup": {
        "type": "object",
        "description": "`GET /v1/sales-playbook/setup`.",
        "required": [
          "group_id",
          "stages"
        ],
        "properties": {
          "group_id": {
            "type": "integer",
            "format": "int32",
            "description": "The pipeline shown."
          },
          "stages": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SetupStage"
            },
            "description": "Its stages, in board order."
          }
        }
      },
      "SetupChecklist": {
        "type": "object",
        "description": "`GET /v1/company/setup-checklist`.",
        "required": [
          "items",
          "done_count",
          "total_count",
          "contact_email"
        ],
        "properties": {
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SetupItem"
            },
            "description": "The items, in order."
          },
          "done_count": {
            "type": "integer",
            "description": "Required items done.",
            "minimum": 0
          },
          "total_count": {
            "type": "integer",
            "description": "Required items in all.",
            "minimum": 0
          },
          "contact_email": {
            "type": "string",
            "description": "Granite Manager's address for the `contact` items."
          }
        }
      },
      "SetupHow": {
        "type": "string",
        "description": "Who does an item.",
        "enum": [
          "self",
          "contact"
        ]
      },
      "SetupItem": {
        "type": "object",
        "description": "One thing to configure.",
        "required": [
          "key",
          "title",
          "hint",
          "done",
          "auto_done",
          "ticked",
          "how",
          "optional"
        ],
        "properties": {
          "key": {
            "type": "string",
            "description": "Item key, for `PUT /v1/company/setup-checklist/{key}`."
          },
          "title": {
            "type": "string",
            "description": "What to configure."
          },
          "hint": {
            "type": "string",
            "description": "What it gives, or where it stands."
          },
          "done": {
            "type": "boolean",
            "description": "Done: seen in the company's data, or ticked by hand."
          },
          "auto_done": {
            "type": "boolean",
            "description": "Seen done in the company's data."
          },
          "ticked": {
            "type": "boolean",
            "description": "Ticked by a manager (done, or not needed)."
          },
          "how": {
            "$ref": "#/components/schemas/SetupHow",
            "description": "`self` or `contact`."
          },
          "href": {
            "type": [
              "string",
              "null"
            ],
            "description": "The page to do it on (`self` items), e.g. `/admin/users`; null for\n`contact` items."
          },
          "optional": {
            "type": "boolean",
            "description": "Not every company needs it; it does not count toward `done_count`."
          }
        }
      },
      "SetupPage": {
        "type": "object",
        "description": "`GET /v1/me/onboarding/setup`.",
        "required": [
          "profile",
          "setup"
        ],
        "properties": {
          "profile": {
            "$ref": "#/components/schemas/OnboardingProfile",
            "description": "The onboarding profile."
          },
          "setup": {
            "$ref": "#/components/schemas/SetupStatus",
            "description": "The setup checklist."
          },
          "credit": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/Credit",
                "description": "Null unless something was credited just now."
              },
              {
                "type": "null"
              }
            ]
          }
        }
      },
      "SetupStage": {
        "type": "object",
        "description": "A stage with its playbook.",
        "required": [
          "list_id",
          "name",
          "next_touch_required",
          "sub_stages",
          "steps"
        ],
        "properties": {
          "list_id": {
            "type": "integer",
            "format": "int32",
            "description": "The stage (deal list) id."
          },
          "name": {
            "type": "string",
            "description": "The stage's name."
          },
          "limit_days": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Days a deal may stay without anything happening; null: no limit."
          },
          "next_touch_required": {
            "type": "boolean",
            "description": "A deal can't leave the stage without a next touch."
          },
          "instructions": {
            "type": [
              "string",
              "null"
            ],
            "description": "What the sales rep does on this stage (plain text); null: none."
          },
          "sub_stages": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SubStage"
            },
            "description": "Its live sub-stages, in order."
          },
          "steps": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Step"
            },
            "description": "The stage plan and the plans of its sub-stages."
          }
        }
      },
      "SetupStatus": {
        "type": "object",
        "description": "The setup checklist (`EmployeeSetupChecklistStatus`).",
        "required": [
          "has_email_name",
          "has_email_signature",
          "has_telegram",
          "has_sales_goal",
          "is_admin",
          "is_sales_rep",
          "has_sales_rep",
          "has_installer",
          "has_walk_in_login",
          "has_logo",
          "has_sales_tax",
          "has_quick_books",
          "quickbooks_feature_enabled",
          "has_supplier_price_lists",
          "has_permissions"
        ],
        "properties": {
          "has_email_name": {
            "type": "boolean",
            "description": "An email sender name is set."
          },
          "has_email_signature": {
            "type": "boolean",
            "description": "An email signature is set."
          },
          "has_telegram": {
            "type": "boolean",
            "description": "Linked to both Telegram bots."
          },
          "has_sales_goal": {
            "type": "boolean",
            "description": "A monthly sales goal is set."
          },
          "is_admin": {
            "type": "boolean",
            "description": "Admin checklist rows apply."
          },
          "is_sales_rep": {
            "type": "boolean",
            "description": "Holds the Sales Rep position."
          },
          "has_sales_rep": {
            "type": "boolean",
            "description": "The company has a sales rep."
          },
          "has_installer": {
            "type": "boolean",
            "description": "The company has an installer."
          },
          "has_walk_in_login": {
            "type": "boolean",
            "description": "A walk-in has checked in."
          },
          "has_logo": {
            "type": "boolean",
            "description": "The company has a logo."
          },
          "has_sales_tax": {
            "type": "boolean",
            "description": "The company sales tax is set."
          },
          "has_quick_books": {
            "type": "boolean",
            "description": "QuickBooks is connected."
          },
          "quickbooks_feature_enabled": {
            "type": "boolean",
            "description": "QuickBooks is switched on."
          },
          "has_supplier_price_lists": {
            "type": "boolean",
            "description": "A supplier price list is processed."
          },
          "has_permissions": {
            "type": "boolean",
            "description": "A Manager opened Position access (Company page), or the company\nexisted before the checklist asked."
          }
        }
      },
      "SetupTick": {
        "type": "object",
        "description": "Body of `PUT /v1/company/setup-checklist/{key}`.",
        "required": [
          "ticked"
        ],
        "properties": {
          "ticked": {
            "type": "boolean",
            "description": "True: done (or not needed); false: take the tick off."
          }
        }
      },
      "Share": {
        "type": "object",
        "description": "What one invoice of a split charges of one priced line.",
        "required": [
          "line_id",
          "amount"
        ],
        "properties": {
          "line_id": {
            "type": "string",
            "description": "The line's `id`."
          },
          "amount": {
            "type": "number",
            "format": "double",
            "description": "The amount this invoice charges of it."
          }
        }
      },
      "ShellCompany": {
        "type": "object",
        "description": "The company requests act in, for the header.",
        "required": [
          "id"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "Company id."
          },
          "name": {
            "type": [
              "string",
              "null"
            ],
            "description": "Name."
          },
          "logo_url": {
            "type": [
              "string",
              "null"
            ],
            "description": "Logo URL."
          },
          "logo_height": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Saved logo height in the header, in pixels (the app clamps it)."
          }
        }
      },
      "ShellCompanyRef": {
        "type": "object",
        "description": "A company of the switcher.",
        "required": [
          "id",
          "name"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "Company id."
          },
          "name": {
            "type": "string",
            "description": "Name."
          }
        }
      },
      "ShellFeatures": {
        "type": "object",
        "description": "Company-level switches the frame reads.",
        "required": [
          "quickbooks",
          "signature",
          "onboarding",
          "leaderboard"
        ],
        "properties": {
          "quickbooks": {
            "type": "boolean",
            "description": "QuickBooks is switched on."
          },
          "signature": {
            "type": "boolean",
            "description": "E-signatures are set up."
          },
          "onboarding": {
            "type": "boolean",
            "description": "Guided tours are on."
          },
          "leaderboard": {
            "type": "boolean",
            "description": "The points leaderboard is on."
          }
        }
      },
      "ShopStatus": {
        "type": "string",
        "description": "The shop's progress on a job.",
        "enum": [
          "cut",
          "complete"
        ]
      },
      "ShopStatusInput": {
        "type": "object",
        "description": "Body of `POST /v1/events/{id}/shop-status`.",
        "properties": {
          "status": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/ShopStatus",
                "description": "`cut`, `complete`, or null to clear it."
              },
              {
                "type": "null"
              }
            ]
          }
        }
      },
      "ShopStatusSaved": {
        "type": "object",
        "description": "`POST /v1/events/{id}/shop-status`.",
        "properties": {
          "status": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/ShopStatus",
                "description": "The job's shop status now; null when cleared."
              },
              {
                "type": "null"
              }
            ]
          }
        }
      },
      "ShownSuggestion": {
        "type": "object",
        "description": "One suggestion the composer showed.",
        "required": [
          "suggestion",
          "outcome"
        ],
        "properties": {
          "draft_chars": {
            "type": "integer",
            "format": "int32",
            "description": "How many characters were typed when it was asked for (0: an opener).",
            "minimum": 0
          },
          "draft_tail": {
            "type": "string",
            "description": "The end of what was typed (the server keeps its last 200 characters)."
          },
          "suggestion": {
            "type": "string",
            "description": "The gray words."
          },
          "wait_ms": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Milliseconds from the rep's last key (for an opener: from the empty\nbox) to the gray words.",
            "minimum": 0
          },
          "outcome": {
            "$ref": "#/components/schemas/SuggestionOutcome"
          },
          "kept": {
            "type": [
              "boolean",
              "null"
            ],
            "description": "For taken and typed words: they are still in the message that was sent."
          }
        }
      },
      "SidebarPin": {
        "type": "object",
        "description": "Body of `PUT /v1/me/sidebar-pin`.",
        "required": [
          "pinned"
        ],
        "properties": {
          "pinned": {
            "type": "boolean",
            "description": "Keep the desktop sidebar open instead of expanding on hover."
          }
        }
      },
      "SignatureAccess": {
        "type": "object",
        "description": "Who may send for signature.",
        "required": [
          "companies",
          "users"
        ],
        "properties": {
          "companies": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CompanyOption"
            },
            "description": "Every company, by name."
          },
          "users": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SignatureUser"
            },
            "description": "Their live users, by company then name."
          },
          "company_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "The company the list is narrowed to."
          }
        }
      },
      "SignatureAccessInput": {
        "type": "object",
        "description": "Body of `PUT /v1/superuser/users/{id}/signature-access`.",
        "required": [
          "enabled"
        ],
        "properties": {
          "enabled": {
            "type": "boolean",
            "description": "May send documents for signature."
          }
        },
        "additionalProperties": false
      },
      "SignatureField": {
        "type": "object",
        "description": "A field on the document: one the signer fills in, or one the sender\nfilled (`value`), which is printed before it goes out.",
        "required": [
          "type",
          "page",
          "x",
          "y",
          "width",
          "height",
          "required"
        ],
        "properties": {
          "type": {
            "$ref": "#/components/schemas/FieldKind",
            "description": "`signature`, `date`, `text`, `autofill_date_signed` or `checkmark`."
          },
          "page": {
            "type": "integer",
            "format": "int64",
            "description": "From 1."
          },
          "x": {
            "type": "number",
            "format": "double",
            "description": "Left edge, points from the page's left."
          },
          "y": {
            "type": "number",
            "format": "double",
            "description": "Top edge, points from the page's top."
          },
          "width": {
            "type": "number",
            "format": "double",
            "description": "Points wide."
          },
          "height": {
            "type": "number",
            "format": "double",
            "description": "Points high."
          },
          "required": {
            "type": "boolean",
            "description": "The signer must fill it."
          },
          "value": {
            "type": [
              "string",
              "null"
            ],
            "description": "What the sender filled in (a signature: a PNG data URL)."
          },
          "prefill": {
            "type": [
              "string",
              "null"
            ],
            "description": "Text fields: which customer detail filled the value."
          },
          "label": {
            "type": [
              "string",
              "null"
            ],
            "description": "The editor's name for it."
          },
          "id": {
            "type": [
              "string",
              "null"
            ],
            "description": "Native signing: the field's stable id."
          }
        }
      },
      "SignatureRequest": {
        "type": "object",
        "description": "A document sent for signature.",
        "required": [
          "id",
          "filename",
          "signer_name",
          "signer_email",
          "status",
          "view_url"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int64",
            "description": "The request."
          },
          "filename": {
            "type": "string",
            "description": "Document name."
          },
          "signer_name": {
            "type": "string",
            "description": "Who signs."
          },
          "signer_email": {
            "type": "string",
            "description": "Their email."
          },
          "status": {
            "type": "string",
            "description": "`draft`, `sent`, `viewed`, `signed`, `declined` or `expired`."
          },
          "created_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When it was sent."
          },
          "view_url": {
            "type": "string",
            "description": "Where to open it: an API path (`/v1/...`, the signed PDF or native\ndocument) to open on the API's host, else the original file's URL."
          }
        }
      },
      "SignatureRequestInput": {
        "type": "object",
        "description": "A document to sign.",
        "required": [
          "filename",
          "signer_name",
          "signer_email",
          "fields"
        ],
        "properties": {
          "filename": {
            "type": "string",
            "description": "The attachment's file name."
          },
          "url": {
            "type": [
              "string",
              "null"
            ],
            "description": "The attachment's URL (matched first, then the file name)."
          },
          "signer_name": {
            "type": "string",
            "description": "Who signs."
          },
          "signer_email": {
            "type": "string",
            "description": "Where the signing link goes."
          },
          "fields": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SignatureField"
            },
            "description": "Where to sign and what the sender filled in (1 to 20)."
          },
          "reminders": {
            "type": "boolean",
            "description": "The signer is reminded until they sign."
          }
        }
      },
      "SignatureRun": {
        "type": "object",
        "description": "What one run did.",
        "required": [
          "processed",
          "sent",
          "failed",
          "expired"
        ],
        "properties": {
          "processed": {
            "type": "integer",
            "description": "Reminders and notifications sent (what the scheduler logs).",
            "minimum": 0
          },
          "sent": {
            "type": "integer",
            "description": "Reminders and notifications sent.",
            "minimum": 0
          },
          "failed": {
            "type": "integer",
            "description": "Sends that failed or were blocked.",
            "minimum": 0
          },
          "expired": {
            "type": "integer",
            "description": "Open requests expired.",
            "minimum": 0
          }
        }
      },
      "SignatureUser": {
        "type": "object",
        "description": "A user and whether they may send documents for signature.",
        "required": [
          "id",
          "company_id",
          "is_signature_available"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "User id."
          },
          "name": {
            "type": [
              "string",
              "null"
            ],
            "description": "Name."
          },
          "email": {
            "type": [
              "string",
              "null"
            ],
            "description": "Email."
          },
          "company_id": {
            "type": "integer",
            "format": "int32",
            "description": "Company."
          },
          "company_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "Company name."
          },
          "is_signature_available": {
            "type": "boolean",
            "description": "May send for signature."
          }
        }
      },
      "SignedInDevice": {
        "type": "object",
        "description": "A phone signed in as the caller.",
        "required": [
          "id",
          "deviceName",
          "platform",
          "createdAt",
          "current"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int64",
            "description": "The device session: pass it to `DELETE /v1/me/devices/{id}`."
          },
          "deviceName": {
            "type": "string",
            "description": "The name the phone gave at sign-in (a browser phone: e.g. \"Chrome on\nWindows\")."
          },
          "platform": {
            "$ref": "#/components/schemas/DevicePlatform",
            "description": "`android` or `ios` (the app), or `web` (a browser phone of the CRM)."
          },
          "appVersion": {
            "type": [
              "string",
              "null"
            ],
            "description": "The app version at sign-in; null when it sent none (always for a\nbrowser phone)."
          },
          "createdAt": {
            "type": "string",
            "format": "date-time",
            "description": "When it signed in."
          },
          "lastSeenAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When it was last used (updated at most every 5 minutes); null when\nnever since sign-in."
          },
          "current": {
            "type": "boolean",
            "description": "The caller's own phone (the device token of this request)."
          }
        }
      },
      "SignedInDevices": {
        "type": "object",
        "description": "`GET /v1/me/devices`.",
        "required": [
          "devices"
        ],
        "properties": {
          "devices": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SignedInDevice"
            },
            "description": "The caller's phones that are not signed out, newest first."
          }
        }
      },
      "SignedOrder": {
        "type": "object",
        "description": "A signed contract.",
        "required": [
          "filename",
          "signed_at",
          "view_url"
        ],
        "properties": {
          "filename": {
            "type": "string",
            "description": "The file's name."
          },
          "signed_at": {
            "type": "string",
            "format": "date-time",
            "description": "When it was signed."
          },
          "view_url": {
            "type": "string",
            "description": "Where to open it: an API path (`/v1/...`) to open on the API's host,\nelse the file's URL."
          }
        }
      },
      "SignerErrorBody": {
        "type": "object",
        "description": "A refusal: `{\"error\", \"code\"}`.",
        "required": [
          "error",
          "code"
        ],
        "properties": {
          "error": {
            "type": "string",
            "description": "For the signer."
          },
          "code": {
            "type": "string",
            "description": "`invalid_link`, `expired`, `signed`, `declined`, `csrf`,\n`review_required`, `invalid_submission`, `processing`,\n`retryable_finalization`, `idempotency_conflict`, `no_claim`,\n`version_changed`, `decline_disabled`, `parity_pending`, `unavailable`."
          }
        }
      },
      "SigningAction": {
        "type": "object",
        "description": "Body of `POST /v1/public/signing/{document_id}/actions`.",
        "required": [
          "intent",
          "csrf"
        ],
        "properties": {
          "intent": {
            "type": "string",
            "description": "`start` (the signer reviewed the document), `finish` (sign with\n`submission`), `resume` (complete an interrupted finish) or `decline`."
          },
          "csrf": {
            "type": "string",
            "description": "The view's `csrf`."
          },
          "submission": {
            "type": [
              "object",
              "null"
            ],
            "description": "With `finish`: the answers."
          },
          "reason": {
            "type": [
              "string",
              "null"
            ],
            "description": "With `decline`: why (up to 500 characters)."
          }
        },
        "additionalProperties": false
      },
      "SigningPage": {
        "type": "object",
        "description": "What the signing page shows.",
        "required": [
          "provider"
        ],
        "properties": {
          "provider": {
            "type": "string",
            "description": "`native` (signed here, see `view`) or `signwell` (embed `signing_url`)."
          },
          "view": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/SigningView",
                "description": "A native document and the signer's state."
              },
              {
                "type": "null"
              }
            ]
          },
          "signing_url": {
            "type": [
              "string",
              "null"
            ],
            "description": "`SignWell`'s signing page for the embed."
          }
        }
      },
      "SigningView": {
        "type": "object",
        "description": "A field as the signer sees it.",
        "required": [
          "document_id",
          "document_version",
          "filename",
          "signer_name",
          "status",
          "fields",
          "signature_methods",
          "allow_decline",
          "reviewed",
          "finish_pending",
          "csrf",
          "consent_version",
          "consent_text",
          "prepared_url"
        ],
        "properties": {
          "document_id": {
            "type": "string",
            "description": "The document's id."
          },
          "document_version": {
            "type": "string",
            "description": "The prepared PDF's SHA-256; send it back with the answers."
          },
          "filename": {
            "type": "string",
            "description": "Document name."
          },
          "signer_name": {
            "type": "string",
            "description": "Who signs."
          },
          "status": {
            "type": "string",
            "description": "`sent`, `viewed`, `signed`, `declined` or `expired`."
          },
          "fields": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SignatureField"
            },
            "description": "The fields; those without `value` (and not `autofill_date_signed`)\nare the signer's to fill."
          },
          "signature_methods": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "How the signer may sign: `type` and/or `draw`."
          },
          "allow_decline": {
            "type": "boolean",
            "description": "The signer may decline."
          },
          "reviewed": {
            "type": "boolean",
            "description": "The signer pressed start in this session (required before finishing)."
          },
          "finish_pending": {
            "type": "boolean",
            "description": "A finish was recorded but not completed: resume it."
          },
          "csrf": {
            "type": "string",
            "description": "Send it with every action."
          },
          "consent_version": {
            "type": "string",
            "description": "The consent the signer agrees to."
          },
          "consent_text": {
            "type": "string",
            "description": "Its wording."
          },
          "prepared_url": {
            "type": "string",
            "description": "The document to read (API path, on this host)."
          },
          "completed_url": {
            "type": [
              "string",
              "null"
            ],
            "description": "The signed copy (API path), once signed."
          }
        }
      },
      "SignupInput": {
        "type": "object",
        "description": "Body of `POST /v1/public/signup`.",
        "required": [
          "company_name",
          "subdomain",
          "name",
          "email",
          "phone_number",
          "password",
          "accept_terms"
        ],
        "properties": {
          "company_name": {
            "type": "string",
            "description": "The company's name, 1 to 120 characters."
          },
          "subdomain": {
            "type": "string",
            "description": "The web address it wants (`acme` of `acme.granite-manager.com`); see\n`GET /v1/public/signup/subdomain/{subdomain}`."
          },
          "address": {
            "type": [
              "string",
              "null"
            ],
            "description": "The company's address; optional."
          },
          "name": {
            "type": "string",
            "description": "The person signing up: their name, 1 to 100 characters. They become\nthe company's Manager."
          },
          "email": {
            "type": "string",
            "description": "Their email, which they sign in with. Must not sign in anywhere yet."
          },
          "phone_number": {
            "type": "string",
            "description": "Their phone number, at least 10 digits."
          },
          "password": {
            "type": "string",
            "description": "Their password, 8 to 200 characters."
          },
          "accept_terms": {
            "type": "boolean",
            "description": "They accept the End-User License Agreement and the Privacy Policy."
          },
          "website": {
            "type": [
              "string",
              "null"
            ],
            "description": "Leave empty (a field people do not see; bots fill it in)."
          },
          "turnstile_token": {
            "type": [
              "string",
              "null"
            ],
            "description": "The Cloudflare Turnstile token of the page's robot check. Logged\nonly: the check never refuses anyone."
          },
          "turnstile_error": {
            "type": [
              "string",
              "null"
            ],
            "description": "Why the page has no Turnstile token (Cloudflare's error code,\n`timeout`, `script` or `unsupported`). Logged only."
          }
        }
      },
      "SignupOptions": {
        "type": "object",
        "description": "`GET /v1/public/signup`.",
        "required": [
          "monthly_price_cents",
          "contact_email",
          "base_domain"
        ],
        "properties": {
          "monthly_price_cents": {
            "type": "integer",
            "format": "int32",
            "description": "What the company pays a month, in USD cents (80000: $800)."
          },
          "contact_email": {
            "type": "string",
            "description": "Who to write to for a free month and a demo instead of paying now."
          },
          "base_domain": {
            "type": "string",
            "description": "The base domain of company web addresses (`granite-manager.com`)."
          }
        }
      },
      "Sink": {
        "type": "object",
        "description": "A sink model the company sells, with how many units are free to sell.",
        "required": [
          "id",
          "name",
          "type",
          "url",
          "is_display",
          "regular_stock",
          "length",
          "width",
          "available"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "Sink model id."
          },
          "name": {
            "type": "string",
            "description": "Model name, e.g. \"Undermount 3219\"."
          },
          "type": {
            "type": "string",
            "description": "Sink type, e.g. `stainless 18 gauge` or `farm house`."
          },
          "url": {
            "type": "string",
            "description": "Image URL; may be empty."
          },
          "supplier_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Supplier id; null if unknown."
          },
          "is_display": {
            "type": "boolean",
            "description": "Shown to customers in the showroom catalog."
          },
          "regular_stock": {
            "type": "boolean",
            "description": "Always orderable from the supplier, so never sold out even with no units."
          },
          "length": {
            "type": "integer",
            "format": "int32",
            "description": "Length in inches; 0 if not set."
          },
          "width": {
            "type": "integer",
            "format": "int32",
            "description": "Width in inches; 0 if not set."
          },
          "retail_price": {
            "type": [
              "string",
              "null"
            ],
            "description": "Retail price as a decimal string, e.g. `\"199.00\"`; null if not set."
          },
          "cost": {
            "type": [
              "string",
              "null"
            ],
            "description": "Purchase cost as a decimal string; null if not set."
          },
          "available": {
            "type": "integer",
            "format": "int64",
            "description": "Units in stock that are not installed on a sold slab."
          }
        }
      },
      "SinkCount": {
        "type": "object",
        "description": "Sinks of one model on a sale.",
        "required": [
          "name",
          "count"
        ],
        "properties": {
          "name": {
            "type": "string",
            "description": "The sink model."
          },
          "count": {
            "type": "integer",
            "format": "int64",
            "description": "How many of it were sold."
          }
        }
      },
      "SinkTypeInUse": {
        "type": "object",
        "description": "409 body of `DELETE /v1/sink-types/{id}`: the type is still used.",
        "required": [
          "error",
          "sinks"
        ],
        "properties": {
          "error": {
            "type": "string",
            "description": "\"This type is used by undeleted sinks and cannot be deleted.\""
          },
          "sinks": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/StoneUsingType"
            },
            "description": "Live sink models of that type, by name; delete or retype them first."
          }
        }
      },
      "SkillInfo": {
        "type": "object",
        "description": "A skill a position may have: something its people may do on the tabs\nthey open.",
        "required": [
          "key",
          "label",
          "description"
        ],
        "properties": {
          "key": {
            "type": "string",
            "description": "Stable key (`sell_slabs`, `edit_transactions`, `edit_quotes`,\n`plan_schedule`, `see_readiness`, `send_sms`, `best_days`, `events_map`)."
          },
          "label": {
            "type": "string",
            "description": "Its name on the Company page."
          },
          "description": {
            "type": "string",
            "description": "What it lets people do."
          }
        }
      },
      "Skipped": {
        "type": "object",
        "description": "An unscheduled event the plan left out.",
        "required": [
          "event_id",
          "title",
          "reason"
        ],
        "properties": {
          "event_id": {
            "type": "integer",
            "format": "int32",
            "description": "The event."
          },
          "title": {
            "type": "string",
            "description": "Its name."
          },
          "reason": {
            "type": "string",
            "description": "Why it was left out."
          }
        }
      },
      "SlabBackground": {
        "type": "object",
        "description": "The company's slab picture background.",
        "required": [
          "url",
          "spot"
        ],
        "properties": {
          "url": {
            "type": "string",
            "description": "The background picture: the `url` of an upload to the `stones` folder\n(`POST /v1/uploads`)."
          },
          "spot": {
            "type": "array",
            "items": {
              "type": "array",
              "items": {
                "type": "number",
                "format": "double"
              }
            },
            "description": "Where the stone picture goes: four `[x, y]` corners as fractions of\nthe picture (0 to 1), clockwise from top left."
          }
        },
        "additionalProperties": false
      },
      "SlabChoice": {
        "type": "object",
        "description": "A slab of the inventory.",
        "required": [
          "id",
          "remnant"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int64",
            "description": "`slab_inventory.id`."
          },
          "bundle": {
            "type": [
              "string",
              "null"
            ],
            "description": "Its bundle."
          },
          "length": {
            "type": [
              "number",
              "null"
            ],
            "format": "double",
            "description": "Length, inches."
          },
          "width": {
            "type": [
              "number",
              "null"
            ],
            "format": "double",
            "description": "Width, inches."
          },
          "url": {
            "type": [
              "string",
              "null"
            ],
            "description": "Its picture."
          },
          "remnant": {
            "type": "boolean",
            "description": "A remnant (a piece left from another slab)."
          }
        }
      },
      "SlabCounts": {
        "type": "object",
        "description": "Slab counts of a stone. Counts the stone's own slabs plus those of the\nstones it draws from (linked stones). Cut and deleted slabs are never\ncounted.",
        "required": [
          "total",
          "available",
          "whole_total",
          "whole_available"
        ],
        "properties": {
          "total": {
            "type": "integer",
            "format": "int64",
            "description": "Slabs and remnants in the yard, sold or not."
          },
          "available": {
            "type": "integer",
            "format": "int64",
            "description": "Slabs and remnants neither tied to a sale nor on hold."
          },
          "whole_total": {
            "type": "integer",
            "format": "int64",
            "description": "Whole slabs (not remnants) in the yard, sold or not."
          },
          "whole_available": {
            "type": "integer",
            "format": "int64",
            "description": "Whole slabs (not remnants) neither tied to a sale nor on hold."
          }
        }
      },
      "SlabHold": {
        "type": "object",
        "description": "A hold on an available slab: nobody else should sell it until it ends.",
        "required": [
          "until"
        ],
        "properties": {
          "until": {
            "type": "string",
            "format": "date-time",
            "description": "When the hold ends by itself."
          },
          "held_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When it was put on hold."
          },
          "held_by_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "Name of the user who put it on hold; null when unknown."
          },
          "customer_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "The customer it is held for; null when nobody in particular."
          },
          "customer_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "Name of that customer."
          }
        }
      },
      "SlabInput": {
        "type": "object",
        "description": "A slab to set.",
        "required": [
          "slab_id",
          "is_full"
        ],
        "properties": {
          "slab_id": {
            "type": "integer",
            "format": "int64",
            "description": "`slab_inventory.id`."
          },
          "is_full": {
            "type": "boolean",
            "description": "`false`: only part of it."
          }
        },
        "additionalProperties": false
      },
      "SlabParentSale": {
        "type": "object",
        "description": "Who bought and sold the slab a remnant was cut from.",
        "required": [
          "id"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "Sale id of the parent slab."
          },
          "customer_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "Customer name; null when the sale has no customer."
          },
          "seller_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "Seller name; null when unknown."
          }
        }
      },
      "SlabSale": {
        "type": "object",
        "description": "The sale a slab belongs to, as shown when hovering a sold slab.",
        "required": [
          "id",
          "sink_names"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "Sale id; open it with the sale routes."
          },
          "sale_date": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When the sale was made; null for old sales without a date."
          },
          "customer_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "Customer name; null when the sale has no customer."
          },
          "seller_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "Name of the user who sold it; null when unknown."
          },
          "notes": {
            "type": [
              "string",
              "null"
            ],
            "description": "Notes on the whole sale."
          },
          "square_feet": {
            "type": [
              "string",
              "null"
            ],
            "description": "Total square feet of the sale, decimal string (e.g. \"55.50\")."
          },
          "slab_notes": {
            "type": [
              "string",
              "null"
            ],
            "description": "Notes on this slab."
          },
          "room": {
            "type": [
              "string",
              "null"
            ],
            "description": "Room this slab is used in, e.g. \"Kitchen\"."
          },
          "slab_square_feet": {
            "type": [
              "string",
              "null"
            ],
            "description": "Square feet of this slab used in the room, decimal string."
          },
          "sink_names": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Names of the sinks installed on any slab of this sale, one entry per\nsink (repeated names mean several units), in installation order."
          }
        }
      },
      "SlabStone": {
        "type": "object",
        "description": "The stone a slab belongs to.",
        "required": [
          "id"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "Stone id."
          },
          "name": {
            "type": [
              "string",
              "null"
            ],
            "description": "Stone name."
          },
          "type": {
            "type": [
              "string",
              "null"
            ],
            "description": "Material type, e.g. `granite`."
          }
        }
      },
      "SlabSummary": {
        "type": "object",
        "description": "A slab by id, with the stone it belongs to.",
        "required": [
          "id",
          "is_leftover",
          "stone"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int64",
            "description": "Slab id."
          },
          "bundle": {
            "type": [
              "string",
              "null"
            ],
            "description": "Bundle label, e.g. \"B-12-1\"."
          },
          "is_leftover": {
            "type": "boolean",
            "description": "Marked as a leftover piece."
          },
          "stone": {
            "$ref": "#/components/schemas/SlabStone",
            "description": "The slab's stone."
          }
        }
      },
      "SmsAlerts": {
        "type": "object",
        "description": "The texts to alert about.",
        "required": [
          "alerts"
        ],
        "properties": {
          "alerts": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/DesktopAlert"
            },
            "description": "One per phone (its latest unread text from the customer), newest\nfirst, at most 50."
          }
        }
      },
      "SmsContact": {
        "type": "object",
        "description": "Someone to text.",
        "required": [
          "id",
          "name",
          "phone"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "Customer or supplier id."
          },
          "name": {
            "type": "string",
            "description": "Their name."
          },
          "phone": {
            "type": "string",
            "description": "The phone as saved (may be empty): of a customer found by a phone,\nthe number that matched, which may be the second phone."
          }
        }
      },
      "SmsContacts": {
        "type": "object",
        "description": "`GET /v1/customers/sms-contacts`.",
        "required": [
          "customers",
          "suppliers"
        ],
        "properties": {
          "customers": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SmsContact"
            },
            "description": "Up to 10 customers, best match first."
          },
          "suppliers": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SmsContact"
            },
            "description": "Up to 10 suppliers by name or phone."
          }
        }
      },
      "SmsFile": {
        "type": "object",
        "description": "A file prepared for the text (`POST /v1/sms/attachments`).",
        "required": [
          "s3_key",
          "content_type"
        ],
        "properties": {
          "s3_key": {
            "type": "string",
            "description": "Its key, under `sms-attachments/<company id>/`."
          },
          "content_type": {
            "type": "string",
            "description": "Its type (JPEG, PNG, GIF, PDF, Office, text or CSV)."
          },
          "filename": {
            "type": "string",
            "description": "The name it was uploaded with."
          },
          "width": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Pixel width of an image."
          },
          "height": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Pixel height of an image."
          }
        }
      },
      "SmsFollowupsRun": {
        "type": "object",
        "description": "What a run did.",
        "required": [
          "processed",
          "sent",
          "failed",
          "stopped",
          "scheduled_sms",
          "delayed"
        ],
        "properties": {
          "processed": {
            "type": "integer",
            "description": "Flow enrollments looked at.",
            "minimum": 0
          },
          "sent": {
            "type": "integer",
            "description": "Flow steps sent.",
            "minimum": 0
          },
          "failed": {
            "type": "integer",
            "description": "Flow runs that failed.",
            "minimum": 0
          },
          "stopped": {
            "type": "integer",
            "description": "Flow runs stopped by a reply or call.",
            "minimum": 0
          },
          "scheduled_sms": {
            "$ref": "#/components/schemas/DripRun",
            "description": "Drip texts of lead lists."
          },
          "delayed": {
            "$ref": "#/components/schemas/DueRun",
            "description": "Scheduled emails and texts."
          }
        }
      },
      "SmsLine": {
        "type": "object",
        "description": "A Telnyx line the caller can switch their inbox to and text from.",
        "required": [
          "number_id",
          "e164",
          "label"
        ],
        "properties": {
          "number_id": {
            "type": "integer",
            "format": "int32",
            "description": "Filter value for `line_id`."
          },
          "e164": {
            "type": "string",
            "description": "The number, E.164."
          },
          "label": {
            "type": "string",
            "description": "Its label; may be empty."
          }
        }
      },
      "SmsProvider": {
        "type": "string",
        "description": "The SMS provider a company texts through: `cloudtalk`, `ringcentral`, or\n`telnyx` (Granite Manager: texts from the company's Telnyx numbers).",
        "enum": [
          "cloudtalk",
          "ringcentral",
          "telnyx"
        ]
      },
      "SmsSendError": {
        "type": "object",
        "description": "A text that did not (fully) go out.",
        "required": [
          "error",
          "sent_messages"
        ],
        "properties": {
          "error": {
            "type": "string",
            "description": "A token the page translates (`agent_not_linked`, `rate_limited`,\n`agent_no_number`, `cloudtalk_insufficient_funds`, ...)."
          },
          "sent_messages": {
            "type": "integer",
            "description": "Messages that went out before one failed.",
            "minimum": 0
          },
          "unsent_s3_keys": {
            "type": [
              "array",
              "null"
            ],
            "items": {
              "type": "string"
            },
            "description": "Files of the messages that did not go out (set when some did)."
          }
        }
      },
      "SmsTemplate": {
        "type": "object",
        "description": "An SMS template.",
        "required": [
          "id",
          "name",
          "body",
          "position",
          "scope",
          "can_edit",
          "minute_delay",
          "customer_sources",
          "sales_rep_ids",
          "attachments"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "The template."
          },
          "name": {
            "type": "string",
            "description": "Shown in the picker."
          },
          "body": {
            "type": "string",
            "description": "The text, with `{{variables}}`."
          },
          "position": {
            "type": "integer",
            "format": "int32",
            "description": "Order among the company's (or the user's) templates."
          },
          "scope": {
            "$ref": "#/components/schemas/TemplateScope"
          },
          "can_edit": {
            "type": "boolean",
            "description": "The caller may change it."
          },
          "created_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When it was made."
          },
          "updated_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When it last changed."
          },
          "lead_list_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Drip: the deal list that starts it; null: never automatic."
          },
          "hour_delay": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Drip: hours after a deal enters the list."
          },
          "minute_delay": {
            "type": "integer",
            "format": "int32",
            "description": "Drip: minutes on top of `hour_delay`, 0 to 59."
          },
          "customer_sources": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Drip: customer sources (`customers.source`) that get it."
          },
          "sales_rep_ids": {
            "type": "array",
            "items": {
              "type": "integer",
              "format": "int32"
            },
            "description": "Company drip: sales reps whose deals get it; empty: every rep's."
          },
          "attachments": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SmsTemplateFile"
            },
            "description": "Files sent with the text (and by its drip and flows)."
          }
        }
      },
      "SmsTemplateFile": {
        "type": "object",
        "description": "A file sent with an SMS template.",
        "required": [
          "s3_key",
          "url",
          "content_type",
          "filename"
        ],
        "properties": {
          "s3_key": {
            "type": "string",
            "description": "Its key, under `sms-attachments/<company id>/`."
          },
          "url": {
            "type": "string",
            "description": "Its public link."
          },
          "content_type": {
            "type": "string",
            "description": "Its type (JPEG, PNG, GIF, PDF, Office, text or CSV)."
          },
          "filename": {
            "type": "string",
            "description": "The name it was uploaded with."
          },
          "width": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Pixel width of an image."
          },
          "height": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Pixel height of an image."
          }
        }
      },
      "SmsTemplateUpdate": {
        "type": "object",
        "description": "Body of `PUT /v1/sms-templates/{id}`.",
        "required": [
          "name",
          "body"
        ],
        "properties": {
          "name": {
            "type": "string",
            "description": "Shown in the picker."
          },
          "body": {
            "type": "string",
            "description": "The text, with `{{variables}}`, up to 1600 characters."
          },
          "drip": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/Drip",
                "description": "When it sends itself; left out keeps the drip."
              },
              {
                "type": "null"
              }
            ]
          },
          "attachments": {
            "type": [
              "array",
              "null"
            ],
            "items": {
              "$ref": "#/components/schemas/SmsFile"
            },
            "description": "Up to ten files sent with the text; left out keeps the template's."
          }
        }
      },
      "SmsTemplates": {
        "type": "object",
        "description": "`GET /v1/sms-templates`.",
        "required": [
          "templates",
          "deal_lists"
        ],
        "properties": {
          "templates": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SmsTemplate"
            },
            "description": "In picker order."
          },
          "deal_lists": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/DripList"
            },
            "description": "With `scope=company`: deal lists for drips."
          }
        }
      },
      "SourceName": {
        "type": "object",
        "description": "Body of `POST /v1/customer-sources` and `PUT /v1/customer-sources/{id}`.",
        "required": [
          "name"
        ],
        "properties": {
          "name": {
            "type": "string",
            "description": "1 to 255 characters."
          }
        }
      },
      "SpamAction": {
        "type": "string",
        "description": "What happens to likely spam: `ring` (allow to ring, marked as\npossible spam), `block` (like a blocked number) or `voicemail`.",
        "enum": [
          "Ring",
          "Block",
          "Voicemail"
        ]
      },
      "SpecialOrderInput": {
        "type": "object",
        "description": "A special order the user is pricing (from the previous answer).",
        "required": [
          "pricePerSqft"
        ],
        "properties": {
          "pricePerSqft": {
            "type": "number",
            "format": "double",
            "description": "Price per sq ft."
          },
          "lengthInches": {
            "type": [
              "number",
              "null"
            ],
            "format": "double",
            "description": "Slab length in inches, when known."
          },
          "widthInches": {
            "type": [
              "number",
              "null"
            ],
            "format": "double",
            "description": "Slab width in inches, when known."
          }
        }
      },
      "SplitCreate": {
        "type": "object",
        "description": "Body of `POST /v1/customers/{id}/qbo-invoices/split`.",
        "required": [
          "invoice",
          "invoices"
        ],
        "properties": {
          "invoice": {
            "$ref": "#/components/schemas/EditableInvoice",
            "description": "The invoice as the editor left it, each priced line at its full\namount (`id` and `sync_token` unused)."
          },
          "quote_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "The quote it is made from, which keeps the first invoice's id."
          },
          "draft": {
            "type": [
              "array",
              "null"
            ],
            "items": {
              "$ref": "#/components/schemas/Line"
            },
            "description": "The lines the editor opened with, as for one invoice."
          },
          "invoices": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SplitInvoice"
            },
            "description": "The invoices, in order; each priced line's shares add up to it."
          },
          "parts": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Part"
            },
            "description": "Each line's part of the quote."
          }
        }
      },
      "SplitCreated": {
        "type": "object",
        "description": "`POST /v1/customers/{id}/qbo-invoices/split`.",
        "required": [
          "invoices"
        ],
        "properties": {
          "invoices": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/EditableInvoice"
            },
            "description": "The invoices as `QuickBooks` made them, in order."
          }
        }
      },
      "SplitInvoice": {
        "type": "object",
        "description": "One invoice of a split.",
        "required": [
          "shares"
        ],
        "properties": {
          "label": {
            "type": [
              "string",
              "null"
            ],
            "description": "Its message to the customer (e.g. \"Deposit\"); none keeps the\ninvoice's message."
          },
          "shares": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Share"
            },
            "description": "What it charges of each priced line; a line it leaves out is $0."
          }
        }
      },
      "SplitTemplate": {
        "type": "object",
        "description": "`GET /v1/qbo/invoice-split`.",
        "required": [
          "classes"
        ],
        "properties": {
          "invoices": {
            "type": [
              "array",
              "null"
            ],
            "items": {
              "$ref": "#/components/schemas/LayoutInvoice"
            },
            "description": "The company's newest split of a quote with these parts (else with\nmore, else any); none before its first split."
          },
          "classes": {
            "type": "object",
            "description": "The class the rep last gave each part's lines; null for the\ninvoice's class.",
            "additionalProperties": {
              "type": [
                "string",
                "null"
              ]
            },
            "propertyNames": {
              "type": "string"
            }
          }
        }
      },
      "SquareFeet": {
        "type": "object",
        "description": "Body of `PUT /v1/transactions/{id}/slabs/{slab_id}/square-feet`.",
        "properties": {
          "square_feet": {
            "type": [
              "number",
              "null"
            ],
            "format": "double",
            "description": "The room's square feet, from 0 to 99,999,999.99; null to clear."
          }
        },
        "additionalProperties": false
      },
      "StaffStoneSettings": {
        "type": "object",
        "description": "`GET /v1/stones/settings`.",
        "required": [
          "stone_view",
          "show_all_locations",
          "show_schedule_visit",
          "customer_stones_per_row",
          "staff_stones_per_row",
          "locations",
          "slab_background_pending"
        ],
        "properties": {
          "stone_view": {
            "$ref": "#/components/schemas/StoneView",
            "description": "`stones` (default) or `materials`."
          },
          "show_all_locations": {
            "type": "boolean",
            "description": "The company's staff can pick another location on the Stones page\n(look only)."
          },
          "show_schedule_visit": {
            "type": "boolean",
            "description": "The public stones page shows Schedule a visit (when times are open)."
          },
          "customer_stones_per_row": {
            "type": "integer",
            "format": "int32",
            "description": "Cards per row of the customer stones page on a wide screen: 4, 6 or\n7 (the default). Phones show 2 per row whatever it is.",
            "minimum": 0
          },
          "staff_stones_per_row": {
            "type": "integer",
            "format": "int32",
            "description": "Cards per row of the company's own stones pages (Admin › Stones and\nthe employees' Stones page) on a wide screen, for everyone who has not\npicked their own on their device: 4, 6 or 7 (the default). Phones show\n2 per row whatever it is.",
            "minimum": 0
          },
          "locations": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/StoneLocation"
            },
            "description": "Every location of the company's business, its own included, by name;\nempty when it has no other locations."
          },
          "slab_background": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/SlabBackground",
                "description": "The company's slab picture background: new stone pictures are placed\non it. Null when it has none."
              },
              {
                "type": "null"
              }
            ]
          },
          "slab_background_pending": {
            "type": "integer",
            "format": "int64",
            "description": "Stone pictures still showing an older background (see\n`POST /v1/stones/settings/slab-background/apply`)."
          }
        }
      },
      "Stage": {
        "type": "string",
        "description": "Where a project is: the board's four lists, and Paid & Completed.",
        "enum": [
          "new",
          "templated",
          "fabrication",
          "installed",
          "completed"
        ]
      },
      "StageChange": {
        "type": "object",
        "description": "A line of a project's history.",
        "required": [
          "id",
          "to_stage",
          "source_action",
          "created_at"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "Its id."
          },
          "from_stage": {
            "type": [
              "string",
              "null"
            ],
            "description": "The stage before; null for the first line."
          },
          "to_stage": {
            "type": "string",
            "description": "The stage after."
          },
          "source_action": {
            "type": "string",
            "description": "What did it: `deal-handoff`, `stage-change`, `fabricated`, `template-completed`, `install-completed`, ..."
          },
          "reason": {
            "type": [
              "string",
              "null"
            ],
            "description": "Why, for a correction or cancel."
          },
          "part_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "The part it is about, on a project with parts."
          },
          "author": {
            "type": [
              "string",
              "null"
            ],
            "description": "Its author's name."
          },
          "created_at": {
            "type": "string",
            "description": "When it was made, UTC ISO."
          }
        }
      },
      "StageDays": {
        "type": "object",
        "description": "Average days deals spent in a stage, of the stays that ended in the month.",
        "required": [
          "list_id",
          "name",
          "avg_days",
          "stays"
        ],
        "properties": {
          "list_id": {
            "type": "integer",
            "format": "int32",
            "description": "The stage (deal list) id."
          },
          "name": {
            "type": "string",
            "description": "The stage's name."
          },
          "avg_days": {
            "type": "number",
            "format": "double",
            "description": "Average days per stay, one decimal."
          },
          "stays": {
            "type": "integer",
            "format": "int64",
            "description": "Stays that ended in the month."
          }
        }
      },
      "StageInput": {
        "type": "object",
        "description": "Body of `PUT /v1/sales-playbook/stages/{id}`.",
        "required": [
          "next_touch_required"
        ],
        "properties": {
          "limit_days": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "1–365 days; null: no limit."
          },
          "next_touch_required": {
            "type": "boolean",
            "description": "True: a deal needs an open next touch to leave this stage."
          }
        },
        "additionalProperties": false
      },
      "StageOrder": {
        "type": "object",
        "description": "Body of `PUT /v1/deal-pipelines/{id}/stage-order`.",
        "required": [
          "list_ids"
        ],
        "properties": {
          "list_ids": {
            "type": "array",
            "items": {
              "type": "integer",
              "format": "int32"
            },
            "description": "Every stage of the pipeline, first to last."
          }
        },
        "additionalProperties": false
      },
      "StageRun": {
        "type": "object",
        "description": "One stage's counts.",
        "required": [
          "processed",
          "sent",
          "skipped",
          "failed"
        ],
        "properties": {
          "processed": {
            "type": "integer",
            "description": "Checklists looked at.",
            "minimum": 0
          },
          "sent": {
            "type": "integer",
            "description": "Surveys sent.",
            "minimum": 0
          },
          "skipped": {
            "type": "integer",
            "description": "Not due, already sent, or nothing to send to.",
            "minimum": 0
          },
          "failed": {
            "type": "integer",
            "description": "Failed (an email failure is retried next run).",
            "minimum": 0
          }
        }
      },
      "StageVisit": {
        "type": "object",
        "description": "A stay of a deal in a stage.",
        "required": [
          "list_id"
        ],
        "properties": {
          "list_id": {
            "type": "integer",
            "format": "int32",
            "description": "Stage id."
          },
          "entered_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When the deal entered the stage."
          },
          "exited_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When it left; null for the current stage."
          }
        }
      },
      "StartIntent": {
        "type": "string",
        "description": "Start or switch to it.",
        "enum": [
          "start",
          "switch"
        ]
      },
      "StartReactivation": {
        "type": "object",
        "description": "Body of `POST /v1/billing/reactivation`.",
        "required": [
          "payment_method_id"
        ],
        "properties": {
          "payment_method_id": {
            "type": "string",
            "description": "The Stripe card to pay with (`pm_...`): a saved card of the company,\nor one Stripe.js just created."
          }
        }
      },
      "StartRequest": {
        "allOf": [
          {
            "$ref": "#/components/schemas/Target"
          },
          {
            "type": "object",
            "required": [
              "intent",
              "preview"
            ],
            "properties": {
              "intent": {
                "$ref": "#/components/schemas/StartIntent"
              },
              "preview": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/PreviewMessage"
                },
                "description": "The approved messages."
              },
              "force_generate": {
                "type": "boolean",
                "description": "Start it even though the customer should not be followed up now."
              }
            }
          }
        ],
        "description": "`POST /v1/followups/ai-cadence`."
      },
      "StartStatus": {
        "type": "string",
        "description": "Where the payment stands.",
        "enum": [
          "paid",
          "requires_payment"
        ]
      },
      "StartedCall": {
        "type": "object",
        "description": "`POST /v1/calls/{provider}`.",
        "properties": {
          "call_status": {
            "type": [
              "string",
              "null"
            ],
            "description": "`RingCentral`'s call status, e.g. `InProgress`."
          },
          "ringing_line": {
            "type": [
              "string",
              "null"
            ],
            "description": "The caller's own line `RingCentral` rings first."
          }
        }
      },
      "StartedReport": {
        "type": "object",
        "description": "Body of `POST /v1/posthog-autofix/runs/{id}/started`.",
        "required": [
          "issue_id",
          "github_run_url"
        ],
        "properties": {
          "issue_id": {
            "type": "string",
            "description": "The run's PostHog issue id, checked against the ledger row."
          },
          "github_run_url": {
            "type": "string",
            "description": "The GitHub Actions run, e.g. `https://github.com/<owner>/<repo>/actions/runs/<id>`."
          }
        },
        "additionalProperties": false
      },
      "StatsPart": {
        "type": "string",
        "description": "A part of `GET /v1/me/dashboard/stats`.",
        "enum": [
          "sales",
          "deal_conversion",
          "top_stones",
          "sent_emails",
          "sent_sms",
          "sales_goal",
          "leaderboard"
        ]
      },
      "StatusSlab": {
        "type": "object",
        "description": "A slab or remnant with its stone, supplier, hold and sale.",
        "required": [
          "id",
          "is_remnant",
          "stone_id"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int64",
            "description": "Slab id."
          },
          "bundle": {
            "type": [
              "string",
              "null"
            ],
            "description": "Bundle label."
          },
          "is_remnant": {
            "type": "boolean",
            "description": "A remnant cut from another slab (false for a whole slab)."
          },
          "length": {
            "type": [
              "string",
              "null"
            ],
            "description": "Length in inches as entered."
          },
          "width": {
            "type": [
              "string",
              "null"
            ],
            "description": "Width in inches as entered."
          },
          "stone_id": {
            "type": "integer",
            "format": "int32",
            "description": "Stone id."
          },
          "stone_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "Stone name."
          },
          "supplier_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Supplier id; null when the stone has none."
          },
          "supplier_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "Supplier name."
          },
          "added_date": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When the slab was added."
          },
          "hold_until": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When the hold ends (on hold only)."
          },
          "held_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When it was put on hold (on hold only)."
          },
          "held_by_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "Who put it on hold (on hold only)."
          },
          "sale_date": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When it was sold (sold only)."
          },
          "seller_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "Who sold it (sold only)."
          },
          "customer_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "Who bought it (sold only)."
          }
        }
      },
      "Step": {
        "type": "object",
        "description": "A step of a touch plan.",
        "required": [
          "id",
          "list_id",
          "day",
          "kind",
          "text",
          "is_enabled"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "Step id."
          },
          "list_id": {
            "type": "integer",
            "format": "int32",
            "description": "The stage (deal list) whose plan it is in."
          },
          "sub_stage_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "The sub-stage whose plan it is; null: the stage plan."
          },
          "day": {
            "type": "integer",
            "format": "int32",
            "description": "Days after entering the (sub-)stage."
          },
          "kind": {
            "type": "string",
            "description": "`call`, `sms`, `email`, `task` or `move`."
          },
          "text": {
            "type": "string",
            "description": "What to do or say."
          },
          "assignee_user_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Who does it; null: the deal's sales rep."
          },
          "is_enabled": {
            "type": "boolean",
            "description": "False: the step is kept but not added to deals."
          }
        }
      },
      "StepAuto": {
        "type": "object",
        "description": "What checks a process step off by itself.",
        "required": [
          "trigger"
        ],
        "properties": {
          "trigger": {
            "type": "string",
            "description": "What happens: `email_template`, `text_template`, `customer_replied`,\n`file_added`, `sent_to_sign`, `signed`, `questionnaire_filled`,\n`template_booked`, `install_booked`, `invoice_sent`, `payment_any`,\n`payment_full`, `task_done`, `days_after` or `stage_moved` (the project\nmoves on to the next stage, by hand or by itself)."
          },
          "ref_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "The email or text template (`email_template`, `text_template`)."
          },
          "ref_ids": {
            "type": "array",
            "items": {
              "type": "integer",
              "format": "int32"
            },
            "description": "Several templates; any one of them counts (`email_template`, `text_template`)."
          },
          "text": {
            "type": [
              "string",
              "null"
            ],
            "description": "Part of the document's or task's name (`sent_to_sign`, `signed`, `task_done`)."
          },
          "days": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Days after the step before (`days_after`)."
          },
          "moves": {
            "type": "boolean",
            "description": "Then moves the project on to the next stage: Awaiting Template to\nTemplated, Templated to In Fabrication. Only on those two stages, and\nnot with `stage_moved`."
          }
        }
      },
      "StepChannel": {
        "type": "string",
        "description": "How a step is delivered.",
        "enum": [
          "sms",
          "email"
        ]
      },
      "StepDone": {
        "type": "object",
        "description": "Whether a project has done a step.",
        "required": [
          "done"
        ],
        "properties": {
          "done": {
            "type": "boolean",
            "description": "Done, or undone."
          },
          "part_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "The part, on a project with parts; left out: its least finished part."
          },
          "answer": {
            "type": [
              "boolean",
              "null"
            ],
            "description": "With `done`, the answer to the step's question; false marks the steps\nthat depend on it Not needed. Left out counts as Yes."
          }
        }
      },
      "StepEventRule": {
        "type": "object",
        "description": "One event a step changes when it is checked off.",
        "required": [
          "target"
        ],
        "properties": {
          "target": {
            "type": "string",
            "description": "Which of the project's events: `templates`, `installations` or\n`event:<id>` (an event template of Admin > Quotes > Automation)."
          },
          "readiness": {
            "type": [
              "string",
              "null"
            ],
            "description": "New readiness: `not_ready`, `called` (Awaiting confirmation), `ready`\nor `confirmed`; null leaves it."
          },
          "shop_status": {
            "type": [
              "string",
              "null"
            ],
            "description": "New shop status: `cut` or `complete`; null leaves it."
          }
        }
      },
      "StepInput": {
        "type": "object",
        "description": "Body of `POST /v1/sales-playbook/steps` and `PUT /v1/sales-playbook/steps/{id}`.",
        "required": [
          "list_id",
          "day",
          "kind",
          "text"
        ],
        "properties": {
          "list_id": {
            "type": "integer",
            "format": "int32",
            "description": "The stage whose plan it is in."
          },
          "sub_stage_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "A sub-stage of that stage; null: the stage plan."
          },
          "day": {
            "type": "integer",
            "format": "int32",
            "description": "0–365 days after entering."
          },
          "kind": {
            "type": "string",
            "description": "`call`, `sms`, `email`, `task` or `move`."
          },
          "text": {
            "type": "string",
            "description": "What the rep does, e.g. the text to send or what to say; at most 500 characters."
          },
          "assignee_user_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "A user of the company who does it; null: the deal's sales rep."
          },
          "is_enabled": {
            "type": "boolean",
            "description": "Missing: on."
          }
        },
        "additionalProperties": false
      },
      "StepItemDone": {
        "type": "object",
        "description": "A tick of a step's own to-do list item on a project.",
        "required": [
          "item_id",
          "done_at"
        ],
        "properties": {
          "item_id": {
            "type": "integer",
            "format": "int32",
            "description": "The item."
          },
          "part_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "The part; null on a project without parts."
          },
          "done_by": {
            "type": [
              "string",
              "null"
            ],
            "description": "Who ticked it."
          },
          "done_at": {
            "type": "string",
            "description": "When, UTC ISO."
          }
        }
      },
      "StepItemInput": {
        "type": "object",
        "description": "One item of a step's own to-do list.",
        "required": [
          "label"
        ],
        "properties": {
          "id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "The item's id to keep it (and its ticks); null for a new one."
          },
          "label": {
            "type": "string",
            "description": "1 to 200 characters."
          }
        }
      },
      "StepNote": {
        "type": "object",
        "description": "A step's note on a project (optional, like its files).",
        "required": [
          "step_id",
          "note",
          "updated_at"
        ],
        "properties": {
          "step_id": {
            "type": "integer",
            "format": "int32",
            "description": "The step."
          },
          "part_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "The part; null on a project without parts."
          },
          "note": {
            "type": "string",
            "description": "The text."
          },
          "updated_by": {
            "type": [
              "string",
              "null"
            ],
            "description": "Who wrote it last."
          },
          "updated_at": {
            "type": "string",
            "description": "When, UTC ISO."
          }
        }
      },
      "StepNoteInput": {
        "type": "object",
        "description": "Body of `PUT /v1/projects/{id}/steps/{step_id}/note`.",
        "required": [
          "note"
        ],
        "properties": {
          "note": {
            "type": "string",
            "description": "Up to 5,000 characters; empty removes the note."
          },
          "part_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "The part, on a project with parts; left out: its least finished part."
          }
        }
      },
      "StepOwner": {
        "type": "object",
        "description": "Who is responsible for a step on one project, and when it is due.",
        "required": [
          "step_id",
          "picked"
        ],
        "properties": {
          "step_id": {
            "type": "integer",
            "format": "int32",
            "description": "The step."
          },
          "user_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "The person; null for nobody."
          },
          "user_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "That person's name."
          },
          "picked": {
            "type": "boolean",
            "description": "Picked on this project, in place of the company's rule."
          },
          "due": {
            "type": [
              "string",
              "null"
            ],
            "description": "When it is due, `YYYY-MM-DD` store date; null for no due date or a\nstage the project has not reached."
          }
        }
      },
      "StepOwnerInput": {
        "type": "object",
        "description": "Body of `PUT /v1/projects/{id}/steps/{step_id}/owner`.",
        "properties": {
          "user_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "The person on this project; null goes back to the company's rule."
          }
        }
      },
      "StepSetup": {
        "type": "object",
        "description": "Body of `PUT /v1/projects/process-steps/{step_id}/setup`.",
        "properties": {
          "responsible_user_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "The person responsible on every project; null for none (or the sales rep)."
          },
          "responsible_sales_rep": {
            "type": "boolean",
            "description": "The project's sales rep is responsible (wins over `responsible_user_id`)."
          },
          "due_days": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Due this many days after the project reaches the step's stage; null for no due date."
          },
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/StepItemInput"
            },
            "description": "The step's own to-do list, in order (replaces it; ticks of kept items stay)."
          }
        }
      },
      "StockExchange": {
        "type": "string",
        "description": "A public company's stock exchange.",
        "enum": [
          "Nasdaq",
          "Nyse",
          "Amex",
          "Amx",
          "Asx",
          "B3",
          "Bme",
          "Bse",
          "Fra",
          "Icex",
          "Jpx",
          "Jse",
          "Krx",
          "Lon",
          "Nse",
          "Omx",
          "Sehk",
          "Sse",
          "Sto",
          "Swx",
          "Szse",
          "Tsx",
          "Twse",
          "Vse"
        ]
      },
      "Stone": {
        "type": "object",
        "description": "A stone (a color/material the company sells) with its slab inventory.",
        "required": [
          "id",
          "is_display",
          "on_sale",
          "regular_stock",
          "slabs"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "Stone id."
          },
          "name": {
            "type": [
              "string",
              "null"
            ],
            "description": "Display name, e.g. \"Absolute Black\"."
          },
          "type": {
            "type": [
              "string",
              "null"
            ],
            "description": "Material type, lowercase: `granite`, `quartz`, `marble`, `quartzite`..."
          },
          "url": {
            "type": [
              "string",
              "null"
            ],
            "description": "Image URL; null when the stone has no picture."
          },
          "supplier_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Supplier id; null if unknown."
          },
          "is_display": {
            "type": "boolean",
            "description": "Shown in catalogs. Always true unless `include_hidden` was asked for."
          },
          "on_sale": {
            "type": "boolean",
            "description": "Marked as on sale."
          },
          "regular_stock": {
            "type": "boolean",
            "description": "Always orderable from the supplier, so never sold out even without slabs."
          },
          "length": {
            "type": [
              "number",
              "null"
            ],
            "format": "float",
            "description": "Typical slab length in inches; null if not set."
          },
          "width": {
            "type": [
              "number",
              "null"
            ],
            "format": "float",
            "description": "Typical slab width in inches; null if not set."
          },
          "retail_price": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Retail price in whole dollars. 0 means the stone is sold by the slab\nat `cost_per_sqft`."
          },
          "cost_per_sqft": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Cost per square foot in whole dollars."
          },
          "level": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Price level, a number of `GET /v1/stone-levels` (1 = cheapest); null if not set."
          },
          "finishing": {
            "type": [
              "string",
              "null"
            ],
            "description": "Surface finish: `polished`, `leathered` or `honed`; null if not set."
          },
          "samples_amount": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Number of samples on hand."
          },
          "samples_importance": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "How important it is to keep samples in stock; null if not set."
          },
          "bundle_number": {
            "type": [
              "string",
              "null"
            ],
            "description": "Supplier bundle number, free text."
          },
          "bundle_location": {
            "type": [
              "string",
              "null"
            ],
            "description": "Where the bundle is stored in the yard, free text."
          },
          "block_number": {
            "type": [
              "string",
              "null"
            ],
            "description": "Number of the quarry block the bundle was cut from, free text."
          },
          "material_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Material the stone belongs to (`GET /v1/stones/materials`); null until\nthe company first uses the materials view."
          },
          "delivery_date": {
            "type": [
              "string",
              "null"
            ],
            "description": "Expected delivery date, `YYYY-MM-DD`; null if not set."
          },
          "created_date": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When the stone was added."
          },
          "slabs": {
            "$ref": "#/components/schemas/SlabCounts",
            "description": "Slabs on hand."
          }
        }
      },
      "StoneChoice": {
        "type": "object",
        "description": "A stone of the company, to match a Horus name to.",
        "required": [
          "id",
          "name"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "Stone id."
          },
          "name": {
            "type": "string",
            "description": "Stone name."
          }
        }
      },
      "StoneColors": {
        "type": "object",
        "description": "The colors the AI picked.",
        "required": [
          "colorIds"
        ],
        "properties": {
          "colorIds": {
            "type": "array",
            "items": {
              "type": "integer",
              "format": "int32"
            },
            "description": "Ids from `GET /v1/colors`: the main color first, then the other\ncolors the stone likely shows, surest first; at most 4. Empty when\nthe AI could not tell."
          }
        }
      },
      "StoneColorsInput": {
        "type": "object",
        "description": "Body of `POST /v1/ai/stone-colors`.",
        "required": [
          "contentBase64"
        ],
        "properties": {
          "contentBase64": {
            "type": "string",
            "description": "The stone's photo, base64: a JPEG, PNG or WebP of at most 4 MB."
          }
        }
      },
      "StoneDetail": {
        "type": "object",
        "description": "One stone with everything an edit form shows.",
        "required": [
          "id",
          "slab_background_on",
          "is_display",
          "on_sale",
          "regular_stock",
          "color_ids"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "Stone id."
          },
          "name": {
            "type": [
              "string",
              "null"
            ],
            "description": "Display name, e.g. \"Absolute Black\"."
          },
          "type": {
            "type": [
              "string",
              "null"
            ],
            "description": "Material type, lowercase: `granite`, `quartz`, `marble`, `quartzite`..."
          },
          "url": {
            "type": [
              "string",
              "null"
            ],
            "description": "Image URL; null when the stone has no picture."
          },
          "original_url": {
            "type": [
              "string",
              "null"
            ],
            "description": "The picture as uploaded, when `url` was made from it (on the slab\npicture background or with the close-up circle); edit this one."
          },
          "closeup_url": {
            "type": [
              "string",
              "null"
            ],
            "description": "Close-up shown in a red circle on `url`; null when none."
          },
          "closeup_place": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/CloseupPlace",
                "description": "Where the close-up circle is on the picture; null: at the top right."
              },
              {
                "type": "null"
              }
            ]
          },
          "slab_background_on": {
            "type": "boolean",
            "description": "Shown on the company's slab picture background (when it has one)."
          },
          "supplier_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Supplier id; null if unknown."
          },
          "is_display": {
            "type": "boolean",
            "description": "Shown in the employee and customer catalogs."
          },
          "on_sale": {
            "type": "boolean",
            "description": "Marked as on sale."
          },
          "regular_stock": {
            "type": "boolean",
            "description": "Always orderable from the supplier, so never sold out even without slabs."
          },
          "length": {
            "type": [
              "number",
              "null"
            ],
            "format": "float",
            "description": "Typical slab length in inches; null if not set."
          },
          "width": {
            "type": [
              "number",
              "null"
            ],
            "format": "float",
            "description": "Typical slab width in inches; null if not set."
          },
          "retail_price": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Retail price in whole dollars. 0 means the stone is sold by the slab."
          },
          "cost_per_sqft": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Cost per square foot in whole dollars."
          },
          "level": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Price level, a number of `GET /v1/stone-levels` (1 = cheapest); null if not set."
          },
          "finishing": {
            "type": [
              "string",
              "null"
            ],
            "description": "Surface finish: `polished`, `leathered` or `honed`; null if not set."
          },
          "samples_amount": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Number of samples on hand."
          },
          "samples_importance": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "How important it is to keep samples in stock; null if not set."
          },
          "bundle_number": {
            "type": [
              "string",
              "null"
            ],
            "description": "Supplier bundle number, free text."
          },
          "bundle_location": {
            "type": [
              "string",
              "null"
            ],
            "description": "Where the bundle is stored in the yard, free text."
          },
          "block_number": {
            "type": [
              "string",
              "null"
            ],
            "description": "Number of the quarry block the bundle was cut from, free text."
          },
          "material_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Material the stone belongs to (`GET /v1/stones/materials`); null until\nthe company first uses the materials view."
          },
          "delivery_date": {
            "type": [
              "string",
              "null"
            ],
            "description": "Expected delivery date, `YYYY-MM-DD`; null if not set."
          },
          "created_date": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When the stone was added."
          },
          "color_ids": {
            "type": "array",
            "items": {
              "type": "integer",
              "format": "int32"
            },
            "description": "Ids of the colors the stone is tagged with, ascending."
          }
        }
      },
      "StoneImage": {
        "type": "object",
        "description": "An installed (project) photo shown for a stone.",
        "required": [
          "id"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "Photo id."
          },
          "url": {
            "type": [
              "string",
              "null"
            ],
            "description": "Photo URL."
          },
          "source_stone": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/StoneRef",
                "description": "Set for photos of a stone this one links photos from; null for the\nstone's own photos (only those can be deleted here)."
              },
              {
                "type": "null"
              }
            ]
          }
        }
      },
      "StoneImageLookup": {
        "type": "object",
        "description": "`GET /v1/quotes/stone-image`.",
        "properties": {
          "image": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/StoneImage",
                "description": "The color's photo; null when the company's catalog has no stone of\nthat name with a photo (e.g. an Other Color typed by hand)."
              },
              {
                "type": "null"
              }
            ]
          }
        }
      },
      "StoneInput": {
        "type": "object",
        "description": "Body of `POST /v1/stones` and `PUT /v1/stones/{id}`.",
        "required": [
          "name",
          "type",
          "finishing"
        ],
        "properties": {
          "name": {
            "type": "string",
            "description": "Display name; required."
          },
          "type": {
            "type": "string",
            "description": "Material; one of the company's stone types (`GET /v1/stone-types`)."
          },
          "finishing": {
            "type": "string",
            "description": "One of the company's stone finishes (`GET /v1/stone-finishes`). With\nmaterials first, a stone whose material has a finish gets the\nmaterial's instead."
          },
          "image_url": {
            "type": [
              "string",
              "null"
            ],
            "description": "Image: the `url` of an upload to the `stones` folder\n(`POST /v1/uploads`). A new stone without one gets a placeholder\nimage; when editing, omit it to keep the current image."
          },
          "remove_image": {
            "type": "boolean",
            "description": "Editing only: `true` removes the stone's image (the placeholder shows\ninstead, the close-up is kept for the next image). Ignored with a new\n`image_url`, which replaces the image anyway."
          },
          "closeup_url": {
            "type": [
              "string",
              "null"
            ],
            "description": "Close-up of the stone: the `url` of an upload to the `stones` folder,\nshown in a red circle at the top right of the image. When editing,\nomit it to keep the current one; null removes it."
          },
          "closeup_place": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/CloseupPlace",
                "description": "Where the close-up circle goes on the image. When editing, omit it to\nkeep the current place; null puts it back at the top right."
              },
              {
                "type": "null"
              }
            ]
          },
          "slab_background_on": {
            "type": [
              "boolean",
              "null"
            ],
            "description": "Put the image on the company's slab picture background (when it has\none). A new stone without it: true; when editing, omit it to keep it."
          },
          "is_display": {
            "type": "boolean",
            "description": "Shown in the catalogs."
          },
          "on_sale": {
            "type": "boolean",
            "description": "Marked as on sale."
          },
          "regular_stock": {
            "type": "boolean",
            "description": "Always orderable, never sold out."
          },
          "supplier_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Supplier id of the company (`GET /v1/suppliers`); null for none."
          },
          "length": {
            "type": [
              "number",
              "null"
            ],
            "format": "double",
            "description": "Typical slab length in inches."
          },
          "width": {
            "type": [
              "number",
              "null"
            ],
            "format": "double",
            "description": "Typical slab width in inches."
          },
          "cost_per_sqft": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Cost per square foot, whole dollars."
          },
          "retail_price": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Retail price per square foot, whole dollars; 0 = priced by slab."
          },
          "level": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Price level, one of the company's levels (`GET /v1/stone-levels`; 1\nto 7 until it adds more); null for none. With materials first, a\nstone whose material has a level gets the material's instead."
          },
          "bundle_number": {
            "type": [
              "string",
              "null"
            ],
            "description": "Supplier bundle number."
          },
          "bundle_location": {
            "type": [
              "string",
              "null"
            ],
            "description": "Where the bundle is in the yard."
          },
          "block_number": {
            "type": [
              "string",
              "null"
            ],
            "description": "Number of the quarry block the bundle was cut from."
          },
          "delivery_date": {
            "type": [
              "string",
              "null"
            ],
            "description": "Expected delivery, `YYYY-MM-DD`; null for none."
          },
          "color_ids": {
            "type": "array",
            "items": {
              "type": "integer",
              "format": "int32"
            },
            "description": "Colors to tag the stone with (`GET /v1/colors`); replaces the old ones."
          },
          "material_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Material (folder) to add the stone to: an `id` from\n`GET /v1/stones/materials`. The stone then takes the material's name,\nwhatever `name` says. Null: the stone goes to the material of its\nname, created when missing. Only adding a stone uses it; editing\nignores it (renaming moves the stone to the material of its new name)."
          }
        },
        "additionalProperties": false
      },
      "StoneLevel": {
        "type": "object",
        "description": "A stone level of the company.",
        "required": [
          "number"
        ],
        "properties": {
          "number": {
            "type": "integer",
            "format": "int32",
            "description": "The level: what stones and materials store in `level`, and what\nprice groups (`levelFrom`/`levelTo`) and commission rules\n(`level_min`/`level_max`) compare. Never changes."
          },
          "name": {
            "type": [
              "string",
              "null"
            ],
            "description": "Its name shown next to the number (\"Standard\"); null shows just\n\"Level N\"."
          }
        }
      },
      "StoneLinks": {
        "type": "object",
        "description": "Which stones link to which.",
        "required": [
          "slab_sources",
          "slab_dependents",
          "image_sources"
        ],
        "properties": {
          "slab_sources": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/StoneRef"
            },
            "description": "Stones this stone draws slabs from (their slabs count as its own)."
          },
          "slab_dependents": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/StoneRef"
            },
            "description": "Stones that draw slabs from this one."
          },
          "image_sources": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/StoneRef"
            },
            "description": "Stones whose installed photos this stone shows."
          }
        }
      },
      "StoneLocation": {
        "type": "object",
        "description": "A location of the caller's business.",
        "required": [
          "id",
          "name"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "Company id; pass it as `location`."
          },
          "name": {
            "type": "string",
            "description": "Company name, e.g. \"GMQ TOPS Mobile\"."
          }
        }
      },
      "StoneMaterial": {
        "type": "object",
        "description": "A material with the slab counts of its stones.",
        "required": [
          "id",
          "name",
          "color_ids",
          "stones",
          "is_display",
          "regular_stock",
          "on_sale",
          "installed",
          "slabs"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "Material id."
          },
          "name": {
            "type": "string",
            "description": "Name, e.g. \"Fantasy Brown\"."
          },
          "type": {
            "type": [
              "string",
              "null"
            ],
            "description": "Stone type, lowercase: `granite`, `quartz`..."
          },
          "level": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "The material's level (a number of `GET /v1/stone-levels`). With materials first, every bundle\nof the material has it; null: each bundle keeps its own."
          },
          "finishing": {
            "type": [
              "string",
              "null"
            ],
            "description": "The material's finish. With materials first, every bundle of the\nmaterial has it; null: each bundle keeps its own."
          },
          "color_ids": {
            "type": "array",
            "items": {
              "type": "integer",
              "format": "int32"
            },
            "description": "The material's colors (`GET /v1/colors`); its bundles take them."
          },
          "url": {
            "type": [
              "string",
              "null"
            ],
            "description": "Photo: the material's own, else the first stone photo."
          },
          "stones": {
            "type": "integer",
            "format": "int64",
            "description": "Stones (bundles) of the material that match the filters; 0 for a\nmaterial with no stone yet."
          },
          "is_display": {
            "type": "boolean",
            "description": "Any of its stones is shown in catalogs."
          },
          "regular_stock": {
            "type": "boolean",
            "description": "Any of its stones is regular stock."
          },
          "on_sale": {
            "type": "boolean",
            "description": "Any of its stones is on sale."
          },
          "installed": {
            "type": "integer",
            "format": "int64",
            "description": "Installed project photos across its stones."
          },
          "slabs": {
            "$ref": "#/components/schemas/SlabCounts",
            "description": "Slab counts summed over its stones."
          }
        }
      },
      "StoneRef": {
        "type": "object",
        "description": "A stone, by id and name.",
        "required": [
          "id"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "Stone id."
          },
          "name": {
            "type": [
              "string",
              "null"
            ],
            "description": "Stone name."
          }
        }
      },
      "StoneSettings": {
        "type": "object",
        "description": "What the public showroom follows\n(`GET /v1/public/companies/{id}/stone-view`).",
        "required": [
          "stone_view"
        ],
        "properties": {
          "stone_view": {
            "$ref": "#/components/schemas/StoneView",
            "description": "`stones` (default) or `materials`."
          },
          "customer_stones_per_row": {
            "type": "integer",
            "format": "int32",
            "description": "Cards per row of the customer stones page on a wide screen: 4, 6 or\n7 (the default). Phones show 2 per row whatever it is.",
            "minimum": 0
          }
        },
        "additionalProperties": false
      },
      "StoneSlab": {
        "type": "object",
        "description": "A slab or remnant of a stone, as the slabs dialog lists it.",
        "required": [
          "id",
          "is_leftover",
          "child_count"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int64",
            "description": "Slab id."
          },
          "bundle": {
            "type": [
              "string",
              "null"
            ],
            "description": "Bundle label written on the slab, e.g. \"B-12-1\" or \"Slab 2\". Remnants\nkeep the label of the slab they were cut from."
          },
          "url": {
            "type": [
              "string",
              "null"
            ],
            "description": "Photo of this slab; null when it has none (show the stone image)."
          },
          "length": {
            "type": [
              "string",
              "null"
            ],
            "description": "Length in inches as entered, e.g. \"126.5\"."
          },
          "width": {
            "type": [
              "string",
              "null"
            ],
            "description": "Width in inches as entered, e.g. \"63\"."
          },
          "parent_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int64",
            "description": "The slab this remnant was cut from; null for a whole slab."
          },
          "is_leftover": {
            "type": "boolean",
            "description": "Marked as a leftover piece."
          },
          "child_count": {
            "type": "integer",
            "format": "int64",
            "description": "Remnants cut from this slab that are not deleted (sold, free or cut).\nA slab with remnants can only be sold partially."
          },
          "source_stone": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/StoneRef",
                "description": "Set when the slab belongs to a stone this stone draws from (linked\nstones): that stone's id and name. Null for the stone's own slabs."
              },
              {
                "type": "null"
              }
            ]
          },
          "sale_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Id of the sale the slab is part of; null while it is available. Set\neven when the sale row itself is missing (then `sale` is null)."
          },
          "sale": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/SlabSale",
                "description": "The sale the slab is part of; null while it is available."
              },
              {
                "type": "null"
              }
            ]
          },
          "parent_sale": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/SlabParentSale",
                "description": "The sale of the slab this remnant was cut from; null for whole slabs\nand for remnants of unsold slabs."
              },
              {
                "type": "null"
              }
            ]
          },
          "hold": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/SlabHold",
                "description": "The slab's hold while it is on hold (unsold, hold not ended yet);\nnull otherwise. Set with `PUT /v1/slabs/{id}/hold`."
              },
              {
                "type": "null"
              }
            ]
          }
        }
      },
      "StoneType": {
        "type": "object",
        "description": "A stone type (material) of the company, e.g. \"granite\".",
        "required": [
          "id",
          "name"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int64",
            "description": "Stone type id."
          },
          "name": {
            "type": "string",
            "description": "Type name as entered; stones store it in their `type`."
          }
        }
      },
      "StoneTypeInUse": {
        "type": "object",
        "description": "409 body of `DELETE /v1/stone-types/{id}`: the type is still used.",
        "required": [
          "error",
          "stones"
        ],
        "properties": {
          "error": {
            "type": "string",
            "description": "\"This type is used by undeleted stones and cannot be deleted.\""
          },
          "stones": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/StoneUsingType"
            },
            "description": "Live stones of that type, by name; delete or retype them first."
          }
        }
      },
      "StoneTypeInput": {
        "type": "object",
        "description": "Body of `POST /v1/stone-types` and `PATCH /v1/stone-types/{id}`.",
        "required": [
          "name"
        ],
        "properties": {
          "name": {
            "type": "string",
            "description": "1 to 255 characters; unique per company, ignoring case."
          }
        },
        "additionalProperties": false
      },
      "StoneUsingType": {
        "type": "object",
        "description": "A stone (or sink model) that uses a type.",
        "required": [
          "id"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "Stone id."
          },
          "name": {
            "type": [
              "string",
              "null"
            ],
            "description": "Stone name."
          }
        }
      },
      "StoneView": {
        "type": "string",
        "description": "What the Stones page shows first.",
        "enum": [
          "stones",
          "materials"
        ]
      },
      "StopDistance": {
        "type": "object",
        "description": "A later stop and how far the job is from it.",
        "required": [
          "event_id",
          "miles"
        ],
        "properties": {
          "event_id": {
            "type": "integer",
            "format": "int32",
            "description": "The stop's event id."
          },
          "miles": {
            "type": "number",
            "format": "double",
            "description": "Miles as the crow flies, one decimal."
          },
          "minutes": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Driving minutes from the job to the stop (Google), whole minutes;\n`null` when Google has no route or fails.",
            "minimum": 0
          }
        }
      },
      "StripeBalance": {
        "type": "object",
        "description": "The Stripe account's money.",
        "required": [
          "available_cents",
          "pending_cents",
          "payouts"
        ],
        "properties": {
          "available_cents": {
            "type": "integer",
            "format": "int64",
            "description": "Ready to be paid out, in US cents."
          },
          "pending_cents": {
            "type": "integer",
            "format": "int64",
            "description": "Not cleared yet (bank payments take a few days), in US cents."
          },
          "payouts": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Payout"
            },
            "description": "The latest payouts, newest first."
          }
        }
      },
      "StripeLink": {
        "type": "object",
        "description": "A link to open in the browser.",
        "required": [
          "url"
        ],
        "properties": {
          "url": {
            "type": "string",
            "description": "Stripe's page (Checkout or the billing portal)."
          }
        }
      },
      "SubStage": {
        "type": "object",
        "description": "A sub-stage.",
        "required": [
          "id",
          "list_id",
          "name",
          "own_plan"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "Sub-stage id."
          },
          "list_id": {
            "type": "integer",
            "format": "int32",
            "description": "The stage (deal list) it belongs to."
          },
          "name": {
            "type": "string",
            "description": "Display name."
          },
          "own_plan": {
            "type": "boolean",
            "description": "Has its own touch plan; off, it uses the stage's plan."
          },
          "instructions": {
            "type": [
              "string",
              "null"
            ],
            "description": "What the sales rep does on this sub-stage (plain text, call scripts\nand the like); null: none, the stage's instructions apply."
          }
        }
      },
      "SubStageChoice": {
        "type": "object",
        "description": "Body of `PUT /v1/deals/{id}/sub-stage`.",
        "required": [
          "sub_stage_id"
        ],
        "properties": {
          "sub_stage_id": {
            "type": "integer",
            "format": "int32",
            "description": "A sub-stage of the deal's stage."
          }
        },
        "additionalProperties": false
      },
      "SubStageInput": {
        "type": "object",
        "description": "Body of `POST /v1/sales-playbook/stages/{id}/sub-stages`.",
        "required": [
          "name"
        ],
        "properties": {
          "name": {
            "type": "string",
            "description": "Display name, at most 120 characters."
          },
          "own_plan": {
            "type": "boolean",
            "description": "Has its own touch plan. Missing: no."
          }
        },
        "additionalProperties": false
      },
      "SubdomainCheck": {
        "type": "object",
        "description": "`GET /v1/public/signup/subdomain/{subdomain}`.",
        "required": [
          "subdomain",
          "available"
        ],
        "properties": {
          "subdomain": {
            "type": "string",
            "description": "The address, lowercased."
          },
          "available": {
            "type": "boolean",
            "description": "It can be signed up with."
          },
          "reason": {
            "type": [
              "string",
              "null"
            ],
            "description": "Why not, for the form; null when available."
          }
        }
      },
      "Subscription": {
        "type": "object",
        "description": "The company's subscription as stored (refreshed from Stripe).",
        "required": [
          "payment_status",
          "subscription_status",
          "outstanding_balance_cents"
        ],
        "properties": {
          "plan_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "Plan name, or null."
          },
          "price_id": {
            "type": [
              "string",
              "null"
            ],
            "description": "Stripe price id of the current plan, or null."
          },
          "monthly_price_cents": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int64",
            "description": "Monthly price in cents, or null."
          },
          "payment_status": {
            "type": "string",
            "description": "`active`, `past_due`, `suspended` or `none`."
          },
          "subscription_status": {
            "type": "string",
            "description": "Stripe's subscription status (`active`, `canceled`, `incomplete`, ...)."
          },
          "current_period_end": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "Next billing date (ISO 8601), or null."
          },
          "last_successful_payment_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "Last successful payment (ISO 8601), or null."
          },
          "outstanding_balance_cents": {
            "type": "integer",
            "format": "int64",
            "description": "Sum of open invoices, in cents."
          }
        }
      },
      "SubscriptionPrice": {
        "type": "object",
        "description": "Body of `PUT /v1/superuser/companies/{id}/subscription-price`.",
        "required": [
          "price_cents"
        ],
        "properties": {
          "price_cents": {
            "type": "integer",
            "format": "int32",
            "description": "The monthly price in US cents, 50 ($0.50) to 10000000 ($100,000)."
          }
        }
      },
      "SubscriptionSummary": {
        "type": "object",
        "description": "A Stripe subscription as the page and the superuser screen show it.",
        "required": [
          "id",
          "status",
          "renews"
        ],
        "properties": {
          "id": {
            "type": "string",
            "description": "Stripe's subscription id (`sub_...`)."
          },
          "status": {
            "type": "string",
            "description": "Stripe's status: `active`, `trialing`, `past_due`, `unpaid`, `paused`,\n`incomplete` (first payment pending), `incomplete_expired` or `canceled`."
          },
          "price_cents": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int64",
            "description": "What each month costs, in US cents; null when Stripe has no amount."
          },
          "renews": {
            "type": "boolean",
            "description": "True when Stripe will charge it again: a live subscription that is not\nset to cancel."
          },
          "next_payment_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "The next charge, when it renews (the end of the current period)."
          },
          "ends_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When a subscription set to cancel stops (no charge after it); null\notherwise."
          }
        }
      },
      "Suggestion": {
        "type": "object",
        "description": "An address suggestion.",
        "required": [
          "place_id",
          "description",
          "address"
        ],
        "properties": {
          "place_id": {
            "type": "string",
            "description": "Google place id."
          },
          "description": {
            "$ref": "#/components/schemas/SuggestionText",
            "description": "What Google suggests."
          },
          "address": {
            "$ref": "#/components/schemas/ParsedAddress",
            "description": "Its parts."
          }
        }
      },
      "SuggestionHide": {
        "type": "object",
        "description": "Body of `POST /v1/deal-activities/suggestions/hidden`.",
        "required": [
          "name"
        ],
        "properties": {
          "name": {
            "type": "string",
            "description": "The suggested name to stop suggesting (up to 255 characters)."
          }
        }
      },
      "SuggestionOutcome": {
        "type": "string",
        "description": "What the rep did with a suggestion.",
        "enum": [
          "taken",
          "typed",
          "dismissed",
          "ignored"
        ]
      },
      "SuggestionRow": {
        "type": "object",
        "description": "The newest matching message of a conversation.",
        "required": [
          "thread_id",
          "body"
        ],
        "properties": {
          "thread_id": {
            "type": "string",
            "description": "Conversation to open."
          },
          "subject": {
            "type": [
              "string",
              "null"
            ],
            "description": "Subject."
          },
          "body": {
            "type": "string",
            "description": "Plain text body (the client makes the snippet)."
          },
          "sent_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When it was sent."
          },
          "sender_email": {
            "type": [
              "string",
              "null"
            ],
            "description": "From header."
          },
          "receiver_email": {
            "type": [
              "string",
              "null"
            ],
            "description": "To header."
          },
          "sender_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "Sender's user or customer name."
          },
          "receiver_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "Receiver's user or customer name."
          }
        }
      },
      "SuggestionSource": {
        "type": "string",
        "description": "Where the composer runs.",
        "enum": [
          "web",
          "app"
        ]
      },
      "SuggestionText": {
        "type": "object",
        "description": "Suggestion text.",
        "required": [
          "text"
        ],
        "properties": {
          "text": {
            "type": "string",
            "description": "e.g. `11378 Gammel Pl, Fishers, IN, USA`."
          }
        }
      },
      "Supplier": {
        "type": "object",
        "description": "A supplier the company buys from.",
        "required": [
          "id",
          "name"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "Supplier id."
          },
          "name": {
            "type": "string",
            "description": "Supplier name."
          }
        }
      },
      "SupplierEntry": {
        "type": "object",
        "description": "A supplier with its contact details and files.",
        "required": [
          "id",
          "files"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "Supplier id."
          },
          "supplier_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "Name."
          },
          "manager": {
            "type": [
              "string",
              "null"
            ],
            "description": "Contact person."
          },
          "phone": {
            "type": [
              "string",
              "null"
            ],
            "description": "Phone."
          },
          "email": {
            "type": [
              "string",
              "null"
            ],
            "description": "Email."
          },
          "notes": {
            "type": [
              "string",
              "null"
            ],
            "description": "Notes."
          },
          "website": {
            "type": [
              "string",
              "null"
            ],
            "description": "Website."
          },
          "files": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SupplierFile"
            },
            "description": "Its files, oldest first."
          }
        }
      },
      "SupplierFile": {
        "type": "object",
        "description": "A file (price list, catalog) of a supplier.",
        "required": [
          "id",
          "name",
          "url"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int64",
            "description": "File id."
          },
          "name": {
            "type": "string",
            "description": "File name."
          },
          "url": {
            "type": "string",
            "description": "Where it is stored."
          }
        }
      },
      "SupplierFilesRun": {
        "type": "object",
        "description": "What a run did.",
        "required": [
          "processed"
        ],
        "properties": {
          "processed": {
            "type": "integer",
            "format": "int32",
            "description": "Files claimed and processed (ready or failed).",
            "minimum": 0
          }
        }
      },
      "SupplierInput": {
        "type": "object",
        "description": "Body of `POST /v1/suppliers` and `PUT /v1/suppliers/{id}`. Blank\noptional fields are saved as null.",
        "required": [
          "supplier_name"
        ],
        "properties": {
          "supplier_name": {
            "type": "string",
            "description": "Display name (required, trimmed, at most 255 characters)."
          },
          "website": {
            "type": [
              "string",
              "null"
            ],
            "description": "Website URL (`http://...` or `https://...`, at most 255 characters)."
          },
          "manager": {
            "type": [
              "string",
              "null"
            ],
            "description": "Contact person (at most 255 characters)."
          },
          "phone": {
            "type": [
              "string",
              "null"
            ],
            "description": "Phone number: at least 10 digits, at most 50 characters."
          },
          "email": {
            "type": [
              "string",
              "null"
            ],
            "description": "Email address (at most 255 characters)."
          },
          "notes": {
            "type": [
              "string",
              "null"
            ],
            "description": "Notes (at most 255 characters)."
          }
        },
        "additionalProperties": false
      },
      "SupplierOffer": {
        "type": "object",
        "description": "A price found in a supplier's price list.",
        "required": [
          "supplier",
          "name",
          "thickness",
          "price",
          "unit",
          "file"
        ],
        "properties": {
          "supplier": {
            "type": "string",
            "description": "Supplier, as the list names it."
          },
          "name": {
            "type": "string",
            "description": "Color or product name as the list writes it."
          },
          "thickness": {
            "type": "string",
            "description": "Thickness as written (`2cm`, `3cm`) or empty."
          },
          "price": {
            "type": "number",
            "format": "double",
            "description": "The price in dollars."
          },
          "unit": {
            "$ref": "#/components/schemas/PriceUnit",
            "description": "`sqft` or `slab`. A price over $250 is per slab (no stone costs that\na square foot), with or without a size; a smaller one is per slab\nwhen the list says so, unless the slab's size makes that under $5 a\nsquare foot."
          },
          "slab": {
            "type": [
              "array",
              "null"
            ],
            "items": {
              "type": "number",
              "format": "double"
            },
            "description": "Slab size in inches, longer side first; null when the list gives none."
          },
          "file": {
            "type": "string",
            "description": "Name of the price file it was read from."
          },
          "file_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int64",
            "description": "`supplier_files.id` of that file: one of the searched files the AI\ncited (by its SOURCE number, else its exact name); null when it\ncited none, so no link is guessed."
          },
          "url": {
            "type": [
              "string",
              "null"
            ],
            "description": "Where that file is stored, to open it; null with `file_id`."
          }
        }
      },
      "SupplierPriceFile": {
        "type": "object",
        "description": "A supplier price file with its processing state.",
        "required": [
          "id",
          "name",
          "url",
          "status",
          "create_date"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int64",
            "description": "The file."
          },
          "name": {
            "type": "string",
            "description": "Name the admin gave it."
          },
          "url": {
            "type": "string",
            "description": "The file in the bucket."
          },
          "status": {
            "type": "string",
            "description": "`pending`, `processing`, `ready` or `failed`."
          },
          "error_token": {
            "type": [
              "string",
              "null"
            ],
            "description": "Why it failed (`download_failed`, `empty_result`, `too_large`,\n`too_many_pages`, `unsupported_format`, `extract_error`, `stalled`),\nelse null."
          },
          "create_date": {
            "type": "string",
            "description": "When it was added (ISO 8601)."
          }
        }
      },
      "SupportAutocompleteInput": {
        "type": "object",
        "description": "Body of `POST /v1/support/agent/conversations/{id}/autocomplete`.",
        "properties": {
          "draft": {
            "type": "string",
            "description": "What the member has typed so far (empty: how the answer starts)."
          },
          "warm": {
            "type": "boolean",
            "description": "Only gather the request (on focus), so the next suggestion is quick."
          }
        },
        "additionalProperties": false
      },
      "SupportCompletion": {
        "type": "object",
        "description": "The suggestion.",
        "required": [
          "completion"
        ],
        "properties": {
          "completion": {
            "type": "string",
            "description": "The text to add after the draft; empty when nothing fits."
          }
        }
      },
      "SupportEscalationsRun": {
        "type": "object",
        "description": "What a run did.",
        "required": [
          "processed"
        ],
        "properties": {
          "processed": {
            "type": "integer",
            "description": "Support requests escalated.",
            "minimum": 0
          }
        }
      },
      "SupportMessage": {
        "type": "object",
        "description": "One message of a support conversation.",
        "required": [
          "id",
          "conversation_id",
          "from_support",
          "internal",
          "body",
          "images",
          "created_at"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int64",
            "description": "Message id; ids grow, so the newest one is the `after` of the next poll."
          },
          "conversation_id": {
            "type": "integer",
            "format": "int32",
            "description": "The conversation (support request) it belongs to."
          },
          "from_support": {
            "type": "boolean",
            "description": "Written by the support team (else by the client)."
          },
          "internal": {
            "type": "boolean",
            "description": "An internal note of the team; the client never sees these."
          },
          "body": {
            "type": "string",
            "description": "The text, as written."
          },
          "reply_to": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/SupportReplyTo",
                "description": "The message this one answers, like a Telegram reply (its quote);\nnull when it answers none or that message was deleted."
              },
              {
                "type": "null"
              }
            ]
          },
          "author_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "Who wrote it (the team member's or the client's name); null when unknown."
          },
          "author_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "The team's view only: the user who wrote it, so the Support app\nlets each member change and delete only their own answers."
          },
          "images": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Pictures added to it: links that work for one to two hours (the\npictures are private; read the messages again for fresh ones)."
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "description": "When it was written (ISO 8601, UTC)."
          },
          "page_path": {
            "type": [
              "string",
              "null"
            ],
            "description": "The team's view only: the CRM page the client was on."
          },
          "replay_url": {
            "type": [
              "string",
              "null"
            ],
            "description": "The team's view only: the PostHog recording of the client's\nsession, at the moment they wrote."
          },
          "user_agent": {
            "type": [
              "string",
              "null"
            ],
            "description": "The team's view only: the client's browser."
          },
          "screen": {
            "type": [
              "string",
              "null"
            ],
            "description": "The team's view only: the client's window size (`1440x900`)."
          }
        }
      },
      "SupportReaction": {
        "type": "object",
        "description": "One person's reaction on a support message.",
        "required": [
          "message_id",
          "emoji",
          "from_support",
          "mine"
        ],
        "properties": {
          "message_id": {
            "type": "integer",
            "format": "int64",
            "description": "The message it is on."
          },
          "emoji": {
            "type": "string",
            "description": "The emoji."
          },
          "name": {
            "type": [
              "string",
              "null"
            ],
            "description": "Who reacted; null when the user has no name."
          },
          "from_support": {
            "type": "boolean",
            "description": "The support team reacted (else the client)."
          },
          "mine": {
            "type": "boolean",
            "description": "The caller's own reaction."
          }
        }
      },
      "SupportReplyTo": {
        "type": "object",
        "description": "The quote of the message an answer replies to.",
        "required": [
          "id",
          "from_support",
          "body",
          "has_images"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int64",
            "description": "The quoted message's id (scroll to it)."
          },
          "from_support": {
            "type": "boolean",
            "description": "Written by the support team (else by the client)."
          },
          "author_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "Who wrote it; null when unknown."
          },
          "body": {
            "type": "string",
            "description": "Its text, at most 200 characters."
          },
          "has_images": {
            "type": "boolean",
            "description": "It has pictures or videos (show \"Photo\" when the text is empty)."
          }
        }
      },
      "SupportThread": {
        "type": "object",
        "description": "`GET /v1/support/thread`.",
        "required": [
          "messages",
          "active",
          "unread"
        ],
        "properties": {
          "messages": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SupportMessage"
            },
            "description": "The caller's messages with support and support's answers, oldest\nfirst, over all their requests (internal notes left out)."
          },
          "active": {
            "type": "boolean",
            "description": "A request of theirs is open or waiting on them: poll for answers\nwhile the support chat is on screen. False: nothing to wait for."
          },
          "status": {
            "type": [
              "string",
              "null"
            ],
            "description": "The status of their latest request (`open`, `waiting`, `resolved`);\nnull when they never wrote to support."
          },
          "unread": {
            "type": "integer",
            "format": "int64",
            "description": "Their requests with an answer they have not read."
          }
        }
      },
      "SupportUpdate": {
        "type": "object",
        "description": "Body of `PUT /v1/supports/{id}`.",
        "required": [
          "name"
        ],
        "properties": {
          "name": {
            "type": "string",
            "description": "New name (1–100 characters)."
          },
          "url": {
            "type": [
              "string",
              "null"
            ],
            "description": "A newly uploaded picture replacing the old one; leave out to keep it."
          }
        },
        "additionalProperties": false
      },
      "SurveyAnswer": {
        "type": "object",
        "description": "One answered survey.",
        "required": [
          "id",
          "sales_rep_rating",
          "technician_rating",
          "installation_rating"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "Survey id."
          },
          "customer_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "The name the customer left; null when they stayed anonymous."
          },
          "sales_rep_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "The sales rep's name."
          },
          "sales_rep_rating": {
            "type": "integer",
            "format": "int32",
            "description": "1–5."
          },
          "sales_rep_comments": {
            "type": [
              "string",
              "null"
            ],
            "description": "What the customer said about the rep."
          },
          "technician_rating": {
            "type": "integer",
            "format": "int32",
            "description": "1–5."
          },
          "technician_comments": {
            "type": [
              "string",
              "null"
            ],
            "description": "What the customer said about the technician."
          },
          "installer_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "The installer's name."
          },
          "installation_rating": {
            "type": "integer",
            "format": "int32",
            "description": "1–5."
          },
          "installation_comments": {
            "type": [
              "string",
              "null"
            ],
            "description": "What the customer said about the installation."
          },
          "created_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When it was answered."
          }
        }
      },
      "SurveyForm": {
        "type": "object",
        "description": "What the survey form shows.",
        "required": [
          "company_name",
          "sales_reps",
          "installers"
        ],
        "properties": {
          "company_name": {
            "type": "string",
            "description": "Company name; empty when the company does not exist."
          },
          "sales_reps": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SurveyPerson"
            },
            "description": "The company's sales reps, by name."
          },
          "installers": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SurveyPerson"
            },
            "description": "The company's installers, by name."
          }
        }
      },
      "SurveyInput": {
        "type": "object",
        "description": "Body of `POST /v1/public/companies/{company_id}/surveys`.",
        "required": [
          "sales_rep_id",
          "installer_id",
          "sales_rep_rating",
          "technician_rating",
          "installation_rating"
        ],
        "properties": {
          "customer_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "The customer's name, only if they choose to give it (up to 255\ncharacters); null or blank keeps the answers anonymous."
          },
          "sales_rep_id": {
            "type": "integer",
            "format": "int32",
            "description": "The sales rep rated; one of the company's sales reps."
          },
          "installer_id": {
            "type": "integer",
            "format": "int32",
            "description": "The installer rated; one of the company's installers."
          },
          "sales_rep_rating": {
            "type": "integer",
            "format": "int32",
            "description": "1 to 5."
          },
          "sales_rep_comments": {
            "type": [
              "string",
              "null"
            ],
            "description": "Comments on the sales rep."
          },
          "technician_rating": {
            "type": "integer",
            "format": "int32",
            "description": "1 to 5."
          },
          "technician_comments": {
            "type": [
              "string",
              "null"
            ],
            "description": "Comments on the installer."
          },
          "installation_rating": {
            "type": "integer",
            "format": "int32",
            "description": "1 to 5."
          },
          "installation_comments": {
            "type": [
              "string",
              "null"
            ],
            "description": "Comments on the installation."
          },
          "checklist_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "The checklist of the survey link (`c`), with its signed token (`t`):\nrecording the completion stops the reminders. The answers are saved\nwithout them, so the survey stays anonymous."
          },
          "token": {
            "type": [
              "string",
              "null"
            ],
            "description": "The link's token for `checklist_id`."
          }
        },
        "additionalProperties": false
      },
      "SurveyPerson": {
        "type": "object",
        "description": "A person the customer can rate.",
        "required": [
          "id"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "User id."
          },
          "name": {
            "type": [
              "string",
              "null"
            ],
            "description": "Name."
          }
        }
      },
      "SurveyResults": {
        "type": "object",
        "description": "The page's data.",
        "required": [
          "days",
          "items",
          "stats",
          "sent_by_day"
        ],
        "properties": {
          "days": {
            "type": "integer",
            "format": "int64",
            "description": "The range used."
          },
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SurveyAnswer"
            },
            "description": "Answers, newest first."
          },
          "stats": {
            "$ref": "#/components/schemas/SurveyStats",
            "description": "Totals."
          },
          "sent_by_day": {
            "type": "array",
            "items": {
              "type": "integer",
              "format": "int64"
            },
            "description": "Invitations sent per day, oldest first, one entry per day of the range."
          }
        }
      },
      "SurveyRun": {
        "type": "object",
        "description": "What a run did.",
        "required": [
          "processed",
          "sent",
          "skipped",
          "failed",
          "waiting_for_send_window",
          "initial",
          "reminder1",
          "day5_email",
          "reminder2"
        ],
        "properties": {
          "processed": {
            "type": "integer",
            "description": "Checklists looked at, all stages.",
            "minimum": 0
          },
          "sent": {
            "type": "integer",
            "description": "Surveys sent, all stages.",
            "minimum": 0
          },
          "skipped": {
            "type": "integer",
            "description": "Skipped, all stages.",
            "minimum": 0
          },
          "failed": {
            "type": "integer",
            "description": "Failed, all stages.",
            "minimum": 0
          },
          "waiting_for_send_window": {
            "type": "boolean",
            "description": "Outside the send window: nothing was looked at."
          },
          "initial": {
            "$ref": "#/components/schemas/StageRun",
            "description": "The first invitation."
          },
          "reminder1": {
            "$ref": "#/components/schemas/StageRun",
            "description": "Day 3 reminder."
          },
          "day5_email": {
            "$ref": "#/components/schemas/StageRun",
            "description": "Day 5 email."
          },
          "reminder2": {
            "$ref": "#/components/schemas/StageRun",
            "description": "Day 7 reminder."
          }
        }
      },
      "SurveyStats": {
        "type": "object",
        "description": "Survey totals of the range.",
        "required": [
          "invited",
          "answers",
          "sales_reps"
        ],
        "properties": {
          "invited": {
            "type": "integer",
            "format": "int64",
            "description": "Customers sent the survey."
          },
          "answers": {
            "type": "integer",
            "format": "int64",
            "description": "Surveys answered."
          },
          "sales_reps": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/RepRating"
            },
            "description": "Sales reps, best rated first."
          }
        }
      },
      "Switch": {
        "type": "object",
        "description": "Body of the switch routes.",
        "required": [
          "enabled"
        ],
        "properties": {
          "enabled": {
            "type": "boolean",
            "description": "On or off."
          }
        }
      },
      "SwitchableCompany": {
        "type": "object",
        "description": "A company the super admin may act in.",
        "required": [
          "id",
          "name"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "Company id."
          },
          "name": {
            "type": "string",
            "description": "Name."
          }
        }
      },
      "SyncInput": {
        "type": "object",
        "description": "Body of `PUT /v1/me/touch-sync`.",
        "required": [
          "enabled"
        ],
        "properties": {
          "enabled": {
            "type": "boolean",
            "description": "True: touches show in the caller's Todo List; false: they stay on the deals only."
          }
        },
        "additionalProperties": false
      },
      "SyncProblemInput": {
        "type": "object",
        "description": "Body of `PUT /v1/quotes/{id}/invoice-problems/sync`.",
        "required": [
          "message"
        ],
        "properties": {
          "message": {
            "type": "string",
            "description": "What happened and how to fix it, in plain words; at most 600 characters."
          },
          "invoice_id": {
            "type": [
              "string",
              "null"
            ],
            "description": "The `QuickBooks` invoice that was not updated, when one was."
          }
        }
      },
      "SyncResult": {
        "type": "object",
        "description": "What a sync did.",
        "required": [
          "synced",
          "qbo",
          "jobs"
        ],
        "properties": {
          "synced": {
            "type": "integer",
            "description": "Quotes worked out.",
            "minimum": 0
          },
          "qbo": {
            "type": "string",
            "description": "`ok`, `not_connected` (payments unknown) or `error` (some lookups failed)."
          },
          "jobs": {
            "type": "integer",
            "description": "Finished templates and installs worked out (a row per person on each).",
            "minimum": 0
          }
        }
      },
      "TableCustomer": {
        "type": "object",
        "description": "A customer of the table.",
        "required": [
          "id"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "Id."
          },
          "name": {
            "type": [
              "string",
              "null"
            ],
            "description": "Name."
          },
          "created_date": {
            "type": [
              "string",
              "null"
            ],
            "description": "UTC, ISO 8601."
          },
          "source": {
            "type": [
              "string",
              "null"
            ],
            "description": "Customer source (`leads`, `check-in`, ...)."
          },
          "referral_source": {
            "type": [
              "string",
              "null"
            ],
            "description": "How they heard of the company."
          },
          "form_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "The lead form."
          },
          "invalid_lead": {
            "type": [
              "string",
              "null"
            ],
            "description": "Why the lead is invalid."
          },
          "sales_rep_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "The sales rep's name."
          }
        }
      },
      "TableDeal": {
        "type": "object",
        "description": "A deal of the table's customers.",
        "required": [
          "id",
          "customer_id",
          "sales_rep_name"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int64",
            "description": "Id."
          },
          "customer_id": {
            "type": "integer",
            "format": "int32",
            "description": "The customer."
          },
          "amount": {
            "type": [
              "number",
              "null"
            ],
            "format": "double",
            "description": "Amount."
          },
          "status": {
            "type": [
              "string",
              "null"
            ],
            "description": "Stage name."
          },
          "lost_reason": {
            "type": [
              "string",
              "null"
            ],
            "description": "Why it was lost."
          },
          "is_won": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "1 won, 0 lost, null open."
          },
          "sales_rep_name": {
            "type": "string",
            "description": "The sales rep's name."
          }
        }
      },
      "TakePayment": {
        "type": "object",
        "description": "Body of `POST /v1/payments`.",
        "required": [
          "method",
          "amount_cents"
        ],
        "properties": {
          "customer_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "The customer who pays; left out or null: a payment without a\ncustomer, for no job."
          },
          "project_key": {
            "type": [
              "string",
              "null"
            ],
            "description": "The job, or an open `QuickBooks` invoice (`invoice-<id>`), from `GET\n/v1/payments/jobs`. Left out without a customer."
          },
          "method": {
            "$ref": "#/components/schemas/PaymentMethod",
            "description": "How the customer will pay."
          },
          "amount_cents": {
            "type": "integer",
            "format": "int64",
            "description": "What goes toward the job, in US cents (see `POST\n/v1/customers/{id}/payments`)."
          },
          "add_card_fee": {
            "type": "boolean",
            "description": "A card payment only: add the card fee (3% of the amount) on top, so\nthe customer pays it, by any card (credit or debit): the card price,\nshown next to the bank transfer price. Left out or false: the\ncompany's own split."
          }
        },
        "additionalProperties": false
      },
      "Target": {
        "type": "object",
        "description": "Whose follow-up.",
        "properties": {
          "customer_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "The customer (else the phone's customer, if any)."
          },
          "phone_digits": {
            "type": [
              "string",
              "null"
            ],
            "description": "The SMS thread's phone digits."
          }
        }
      },
      "TargetRepo": {
        "type": "string",
        "description": "The repository a run changed.",
        "enum": [
          "granite-webhooks",
          "general_datebase"
        ]
      },
      "TaskEdit": {
        "type": "object",
        "description": "Body of `PUT /v1/projects/{id}/tasks/{task_id}`: the task as it now is.",
        "required": [
          "name"
        ],
        "properties": {
          "name": {
            "type": "string",
            "description": "1 to 255 characters."
          },
          "assignedUserId": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Who does it: anyone in the company; null for nobody."
          },
          "deadline": {
            "type": [
              "string",
              "null"
            ],
            "description": "`YYYY-MM-DD` or `YYYY-MM-DDTHH:MM[:SS]` store wall time; null for none."
          },
          "urls": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Every picture it keeps, in order: its own pictures to keep and new\n`url`s that `POST /v1/uploads` (folder `events`) returned. At most 20."
          }
        }
      },
      "TaskInput": {
        "type": "object",
        "description": "Body of `POST /v1/projects/{id}/tasks`.",
        "required": [
          "name"
        ],
        "properties": {
          "name": {
            "type": "string",
            "description": "1 to 255 characters."
          },
          "assignedUserId": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Who does it: anyone in the company; null for nobody."
          },
          "deadline": {
            "type": [
              "string",
              "null"
            ],
            "description": "`YYYY-MM-DD` or `YYYY-MM-DDTHH:MM[:SS]` store wall time."
          },
          "priority": {
            "type": [
              "string",
              "null"
            ],
            "description": "`low`, `medium` (default) or `high`."
          },
          "urls": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Pictures: `url`s that `POST /v1/uploads` (folder `events`) returned.\nAt most 20; may be left out."
          },
          "items": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "A to-do list: its items, in order (1 to 200 characters each, blank\nones dropped, at most 60). Empty or left out: a plain task."
          }
        }
      },
      "TaskItem": {
        "type": "object",
        "description": "One item of a to-do list task.",
        "required": [
          "id",
          "task_id",
          "label"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "Its id."
          },
          "task_id": {
            "type": "integer",
            "format": "int32",
            "description": "The task it belongs to."
          },
          "label": {
            "type": "string",
            "description": "What to do."
          },
          "done_at": {
            "type": [
              "string",
              "null"
            ],
            "description": "When it was ticked off, UTC ISO; null while open."
          },
          "done_by": {
            "type": [
              "string",
              "null"
            ],
            "description": "Who ticked it off."
          }
        }
      },
      "TaskProgress": {
        "type": "object",
        "description": "A feature tour's saved progress.",
        "required": [
          "version",
          "status",
          "done_steps",
          "points_awarded"
        ],
        "properties": {
          "version": {
            "type": "integer",
            "format": "int64",
            "description": "Registry version the progress was recorded against."
          },
          "status": {
            "type": "string",
            "description": "`in_progress`, `closed` or `completed`."
          },
          "step_key": {
            "type": [
              "string",
              "null"
            ],
            "description": "The step the user is on."
          },
          "done_steps": {
            "type": "object",
            "description": "Steps done, by stored key."
          },
          "completed_at": {
            "type": [
              "string",
              "null"
            ],
            "description": "When it was completed (UTC, ISO 8601)."
          },
          "points_awarded": {
            "type": "integer",
            "format": "int64",
            "description": "Points it paid (completed tours only, never negative)."
          },
          "last_active_at": {
            "type": [
              "string",
              "null"
            ],
            "description": "Last activity (UTC, ISO 8601)."
          },
          "started_at": {
            "type": [
              "string",
              "null"
            ],
            "description": "When it started (UTC, ISO 8601)."
          },
          "closed_at": {
            "type": [
              "string",
              "null"
            ],
            "description": "When it was last closed (UTC, ISO 8601): a skip, unless completed since."
          },
          "usage_skipped_at": {
            "type": [
              "string",
              "null"
            ],
            "description": "When the tour was replayed as a feature the user already uses (UTC,\nISO 8601), or when the server found they had used it well before the\ntour's row was created. Such a tour pays 0 points. Null otherwise."
          },
          "start_trigger": {
            "type": [
              "string",
              "null"
            ],
            "description": "What started the tour: `auto`, `user` or `gesture` (the first event\nthat said). Null when no event said."
          }
        }
      },
      "TaskTime": {
        "type": "object",
        "description": "How long a task is usually given: the average of its earlier uses.",
        "required": [
          "name",
          "minutes",
          "has_time"
        ],
        "properties": {
          "name": {
            "type": "string",
            "description": "The task's name, as last written."
          },
          "minutes": {
            "type": "integer",
            "format": "int64",
            "description": "Average minutes from giving it to its due date."
          },
          "has_time": {
            "type": "boolean",
            "description": "Whether its last use had a time of day, not just a date."
          }
        }
      },
      "TaskTimeReset": {
        "type": "object",
        "description": "Body of `POST /v1/projects/{id}/task-times/reset`.",
        "required": [
          "name"
        ],
        "properties": {
          "name": {
            "type": "string",
            "description": "The task whose remembered time to forget."
          }
        }
      },
      "TaskUpdate": {
        "type": "object",
        "description": "Body of `PATCH /v1/projects/{id}/tasks/{task_id}`.",
        "required": [
          "completed"
        ],
        "properties": {
          "completed": {
            "type": "boolean",
            "description": "Done (true) or open again (false)."
          },
          "response": {
            "type": [
              "string",
              "null"
            ],
            "description": "With `completed: true`: the optional reply for the task's giver (at\nmost 1,000 characters; blank clears it). Left out: the reply stays.\nReopening a task clears it."
          }
        }
      },
      "TaxRate": {
        "type": "object",
        "description": "`GET /v1/company/tax-rate`.",
        "required": [
          "state_tax_pct"
        ],
        "properties": {
          "state_tax_pct": {
            "type": "number",
            "format": "double",
            "description": "The company's state sales tax in percent; 0 when not set."
          }
        }
      },
      "TeachProgress": {
        "type": "object",
        "description": "The training progress.",
        "required": [
          "users",
          "attempts"
        ],
        "properties": {
          "users": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ProgressUser"
            },
            "description": "The company's sales reps, by name."
          },
          "attempts": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/AnswerAttempt"
            },
            "description": "Their answers, by employee, newest try first."
          }
        }
      },
      "Team": {
        "type": "object",
        "description": "`GET /v1/onboarding/team`.",
        "required": [
          "enabled",
          "capabilities",
          "members"
        ],
        "properties": {
          "enabled": {
            "type": "boolean",
            "description": "The company's guided tours are on; off, `members` is empty."
          },
          "capabilities": {
            "$ref": "#/components/schemas/TeamCapabilities",
            "description": "The company's capabilities."
          },
          "members": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TeamMember"
            },
            "description": "The company's employees, by name."
          }
        }
      },
      "TeamCapabilities": {
        "type": "object",
        "description": "What the company can do, as the tour registry gates on it.",
        "required": [
          "cloudtalk",
          "quickbooks",
          "verified_domain",
          "sms_provider",
          "followup_tours",
          "onboarding",
          "inbound_email",
          "questionnaires"
        ],
        "properties": {
          "cloudtalk": {
            "type": "boolean",
            "description": "`CloudTalk` is connected."
          },
          "quickbooks": {
            "type": "boolean",
            "description": "A `QuickBooks` company is linked."
          },
          "verified_domain": {
            "type": "boolean",
            "description": "SES has verified the company's mail domain."
          },
          "sms_provider": {
            "type": "boolean",
            "description": "`CloudTalk` or `RingCentral` is connected."
          },
          "followup_tours": {
            "type": "boolean",
            "description": "The follow-up tours are switched on (`FOLLOWUP_ONBOARDING_ENABLED`)."
          },
          "onboarding": {
            "type": "boolean",
            "description": "The company's guided tours are on."
          },
          "inbound_email": {
            "type": "boolean",
            "description": "Inbound email is set up (the company has a mail domain): the Emails\ninbox and message composer are offered."
          },
          "questionnaires": {
            "type": "boolean",
            "description": "The company has at least one sales questionnaire (not deleted)."
          }
        }
      },
      "TeamMember": {
        "type": "object",
        "description": "One employee.",
        "required": [
          "user_id",
          "name",
          "email",
          "is_admin",
          "can_manage_users",
          "is_shop_worker",
          "is_shop_manager",
          "has_sms_line",
          "progress",
          "usage",
          "phone_line",
          "message_composer",
          "signature_access"
        ],
        "properties": {
          "user_id": {
            "type": "integer",
            "format": "int32",
            "description": "User id."
          },
          "name": {
            "type": "string",
            "description": "Name."
          },
          "email": {
            "type": "string",
            "description": "Email."
          },
          "is_admin": {
            "type": "boolean",
            "description": "Admin access."
          },
          "can_manage_users": {
            "type": "boolean",
            "description": "Holds the Manager position (may manage users)."
          },
          "is_shop_worker": {
            "type": "boolean",
            "description": "Holds the Shop Worker position."
          },
          "is_shop_manager": {
            "type": "boolean",
            "description": "Holds the Shop Manager position."
          },
          "has_sms_line": {
            "type": "boolean",
            "description": "Has a texting line of their own (`CloudTalk` agent and number, or a\n`RingCentral` extension and number)."
          },
          "progress": {
            "$ref": "#/components/schemas/OnboardingState",
            "description": "Saved progress (empty before any)."
          },
          "usage": {
            "type": "object",
            "description": "Features the member already uses: usage check id -> when they first\nused it (UTC, ISO 8601). Only the checks the tours name.",
            "additionalProperties": {
              "type": "string"
            },
            "propertyNames": {
              "type": "string"
            }
          },
          "sections": {
            "type": [
              "array",
              "null"
            ],
            "items": {
              "type": "string"
            },
            "description": "The tabs the member's positions open in this company, as the app\nshell's `sections` gives them to the member; null when they limit\nnothing."
          },
          "account_created_at": {
            "type": [
              "string",
              "null"
            ],
            "description": "When the member's account was created (UTC, ISO 8601)."
          },
          "phone_line": {
            "type": "boolean",
            "description": "The member has a phone line to call from: a `CloudTalk` agent and\nnumber, a `RingCentral` extension and number, or a Telnyx number of\nthis company they may call from."
          },
          "message_composer": {
            "type": "boolean",
            "description": "The member can write messages to customers: the company has inbound\nemail, or the member has a texting line of their own (`CloudTalk` or\n`RingCentral` line, or a Telnyx line when the company texts through\nTelnyx)."
          },
          "signature_access": {
            "type": "boolean",
            "description": "The member may use e-signatures (their own `is_signature_available`\nflag; the company also needs a `SignWell` key)."
          }
        }
      },
      "TelegramLink": {
        "type": "object",
        "description": "Body of `POST /v1/me/telegram/{bot}`: what the Telegram login widget returned.",
        "required": [
          "crm_user_id",
          "telegram_id",
          "auth_date",
          "hash",
          "first_name"
        ],
        "properties": {
          "crm_user_id": {
            "type": "integer",
            "format": "int32",
            "description": "The CRM user the page linked for; must be the caller."
          },
          "telegram_id": {
            "$ref": "#/components/schemas/TelegramNumber",
            "description": "Telegram user id."
          },
          "auth_date": {
            "$ref": "#/components/schemas/TelegramNumber",
            "description": "Unix seconds of the login."
          },
          "hash": {
            "type": "string",
            "description": "Telegram's signature."
          },
          "first_name": {
            "type": "string",
            "description": "Telegram first name."
          },
          "last_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "Telegram last name."
          },
          "username": {
            "type": [
              "string",
              "null"
            ],
            "description": "Telegram username."
          },
          "photo_url": {
            "type": [
              "string",
              "null"
            ],
            "description": "Telegram photo."
          }
        }
      },
      "TelegramNumber": {
        "oneOf": [
          {
            "type": "integer",
            "format": "int64"
          },
          {
            "type": "string"
          }
        ],
        "description": "A Telegram id the widget sends as a number or a string."
      },
      "TelegramStatus": {
        "type": "object",
        "description": "Whether the signed-in user's Telegram is linked to each of the two bots.",
        "required": [
          "leads_linked",
          "notifications_linked"
        ],
        "properties": {
          "leads_linked": {
            "type": "boolean",
            "description": "Linked to the lead alerts bot."
          },
          "notifications_linked": {
            "type": "boolean",
            "description": "Linked to the CRM notifications bot."
          },
          "leads_bot_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int64",
            "description": "Telegram user id of the lead alerts bot, for the Telegram login\nwidget; null when the bot is not configured."
          },
          "notifications_bot_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int64",
            "description": "Telegram user id of the notifications bot; null when not configured."
          }
        }
      },
      "TelnyxCompanyConfig": {
        "type": "object",
        "description": "A company's Telnyx setup.",
        "required": [
          "enabled",
          "recordingMode",
          "holidays",
          "dailyCallLimit",
          "webhookBase"
        ],
        "properties": {
          "enabled": {
            "type": "boolean",
            "description": "Calling is on: off, no phone of the company can call or ring."
          },
          "credentialConnectionId": {
            "type": [
              "string",
              "null"
            ],
            "description": "The Telnyx credential connection the phones register on (their\ncalls come to `{webhookBase}/outbound`); null when not set."
          },
          "texmlAppId": {
            "type": [
              "string",
              "null"
            ],
            "description": "The TeXML application of the company's numbers (calls come to\n`{webhookBase}/inbound`); null when not set."
          },
          "outboundVoiceProfileId": {
            "type": [
              "string",
              "null"
            ],
            "description": "The Telnyx outbound voice profile; null when not set."
          },
          "billingGroupId": {
            "type": [
              "string",
              "null"
            ],
            "description": "The Telnyx billing group; null when not set."
          },
          "telnyxAccountId": {
            "type": [
              "string",
              "null"
            ],
            "description": "The company's Telnyx account id (Mission Control's account SID, the\n`AccountSid` of Telnyx's TeXML requests). When set, every TeXML\nrequest to the company's webhooks must carry it (403 otherwise); null\n= not checked."
          },
          "aiAssistantId": {
            "type": [
              "string",
              "null"
            ],
            "description": "The Telnyx AI Assistant that takes calls nobody answers (numbers\nwhose no-answer action is `ai`); null = voicemail instead."
          },
          "fallbackTexmlUrl": {
            "type": [
              "string",
              "null"
            ],
            "description": "Where callers go when our webhook fails (a TeXML Bin with the AI\nAssistant, then voicemail); null = `TELNYX_FALLBACK_TEXML_URL`."
          },
          "recordingMode": {
            "$ref": "#/components/schemas/RecordingMode",
            "description": "Which calls are recorded: `off`, `inbound` or `both`."
          },
          "recordingNoticeUrl": {
            "type": [
              "string",
              "null"
            ],
            "description": "The notice played to the customer on recorded outgoing calls (an\naudio file URL), before the call is bridged; null = \"This call may be\nrecorded.\" is said to both sides once the customer answers, before\nthe recording starts."
          },
          "messagingProfileId": {
            "type": [
              "string",
              "null"
            ],
            "description": "The Telnyx messaging profile the company's numbers text through (its\nwebhook URL is `{webhookBase}/messaging`); texting is on while calling\nis on and this is set; null = no texting through Telnyx."
          },
          "businessHours": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/WorkingHours",
                "description": "When the main line rings (its `tz` is the company time zone); null =\nalways."
              },
              {
                "type": "null"
              }
            ]
          },
          "holidays": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Dates the main line rings nobody, `YYYY-MM-DD` in the company time\nzone, sorted."
          },
          "minAppVersion": {
            "type": [
              "string",
              "null"
            ],
            "description": "The oldest app version that may call (e.g. `1.4.0`); null =\n`PHONE_MIN_APP_VERSION`."
          },
          "dailyCallLimit": {
            "type": "integer",
            "format": "int32",
            "description": "Outgoing calls one user may start per day."
          },
          "webhookBase": {
            "type": "string",
            "description": "The root of the company's Telnyx webhooks, to paste into Telnyx:\n`https://api.../v1/webhooks/telnyx/<token>` (`/inbound` and\n`/call-status` on the TeXML app, `/outbound` on the credential\nconnection). Read-only."
          }
        }
      },
      "TelnyxConfigInput": {
        "type": "object",
        "description": "Body of `PUT /v1/superuser/companies/{id}/telnyx`: the whole setup (as\n`TelnyxCompanyConfig`, without `webhookBase`). Blank text counts as\nnull.",
        "required": [
          "enabled",
          "dailyCallLimit"
        ],
        "properties": {
          "enabled": {
            "type": "boolean",
            "description": "Calling is on."
          },
          "credentialConnectionId": {
            "type": [
              "string",
              "null"
            ],
            "description": "Telnyx credential connection id (at most 64 characters, no spaces)."
          },
          "texmlAppId": {
            "type": [
              "string",
              "null"
            ],
            "description": "Telnyx TeXML application id (at most 64 characters, no spaces)."
          },
          "outboundVoiceProfileId": {
            "type": [
              "string",
              "null"
            ],
            "description": "Telnyx outbound voice profile id (at most 64 characters, no spaces)."
          },
          "billingGroupId": {
            "type": [
              "string",
              "null"
            ],
            "description": "Telnyx billing group id (at most 64 characters, no spaces)."
          },
          "telnyxAccountId": {
            "type": [
              "string",
              "null"
            ],
            "description": "The Telnyx account id (at most 64 characters, no spaces); null or\nblank = TeXML requests are not checked for it."
          },
          "aiAssistantId": {
            "type": [
              "string",
              "null"
            ],
            "description": "Telnyx AI Assistant id (at most 128 characters, no spaces)."
          },
          "fallbackTexmlUrl": {
            "type": [
              "string",
              "null"
            ],
            "description": "The fallback TeXML URL (`http(s)://`, at most 512 characters)."
          },
          "messagingProfileId": {
            "type": [
              "string",
              "null"
            ],
            "description": "Telnyx messaging profile id (at most 64 characters, no spaces); null\nor blank = no texting through Telnyx."
          },
          "minAppVersion": {
            "type": [
              "string",
              "null"
            ],
            "description": "A version like `1.4.0` (at most 16 characters)."
          },
          "dailyCallLimit": {
            "type": "integer",
            "format": "int32",
            "description": "0 to 1,000,000 outgoing calls per user per day."
          }
        }
      },
      "TelnyxConnection": {
        "type": "object",
        "description": "What connecting did.",
        "required": [
          "configured",
          "created",
          "imported"
        ],
        "properties": {
          "configured": {
            "type": "boolean",
            "description": "Calls can ring and be placed: the TeXML app and the credential\nconnection are set."
          },
          "created": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "What Telnyx made this time, of `billingGroup`, `voiceProfile`,\n`texmlApp`, `credentialConnection` and `messagingProfile`; empty when\neverything was there already and was only pointed at us again."
          },
          "imported": {
            "type": "integer",
            "description": "Numbers added from the TeXML app.",
            "minimum": 0
          }
        }
      },
      "Temperature": {
        "type": "string",
        "description": "Lead temperature.",
        "enum": [
          "hot",
          "medium",
          "cold"
        ]
      },
      "TemperatureInput": {
        "type": "object",
        "description": "Body of `PUT /v1/customers/{id}/temperature`.",
        "properties": {
          "temperature": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/Temperature",
                "description": "`hot`, `medium`, `cold`, or null to clear."
              },
              {
                "type": "null"
              }
            ]
          }
        },
        "additionalProperties": false
      },
      "TemplateAttachment": {
        "type": "object",
        "description": "A file sent with every email made from a template.",
        "required": [
          "id",
          "filename",
          "url",
          "content_type",
          "content_subtype"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "Attachment id."
          },
          "filename": {
            "type": "string",
            "description": "File name."
          },
          "url": {
            "type": "string",
            "description": "File URL."
          },
          "content_type": {
            "type": "string",
            "description": "MIME type, e.g. `image`."
          },
          "content_subtype": {
            "type": "string",
            "description": "MIME subtype, e.g. `png`."
          }
        }
      },
      "TemplateAttachmentInput": {
        "type": "object",
        "description": "Body of `POST /v1/email-templates/{id}/attachments`.",
        "required": [
          "url",
          "filename",
          "content_type"
        ],
        "properties": {
          "url": {
            "type": "string",
            "description": "URL of a file uploaded to the `email-templates` folder."
          },
          "filename": {
            "type": "string",
            "description": "File name shown and sent (1–255 characters)."
          },
          "content_type": {
            "type": "string",
            "description": "MIME type, e.g. `application/pdf`."
          }
        },
        "additionalProperties": false
      },
      "TemplateKind": {
        "type": "string",
        "description": "What a template is for.",
        "enum": [
          "reminder",
          "confirmation",
          "question"
        ]
      },
      "TemplateOrder": {
        "type": "object",
        "description": "The caller's sorting of one picker.",
        "required": [
          "mode"
        ],
        "properties": {
          "mode": {
            "$ref": "#/components/schemas/OrderingMode",
            "description": "Automatic or custom."
          }
        }
      },
      "TemplateOrderInput": {
        "type": "object",
        "description": "Body of `PUT /v1/schedule/notifications/templates/order`.",
        "required": [
          "ids"
        ],
        "properties": {
          "ids": {
            "type": "array",
            "items": {
              "type": "integer",
              "format": "int32"
            },
            "description": "Template ids, first to last. Ids of other companies are ignored."
          }
        }
      },
      "TemplateResult": {
        "type": "object",
        "description": "`POST /v1/sales-playbook/template`.",
        "required": [
          "stages"
        ],
        "properties": {
          "stages": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "The stages filled."
          }
        }
      },
      "TemplateScope": {
        "type": "string",
        "description": "Who sees a template.",
        "enum": [
          "company",
          "personal"
        ]
      },
      "TenDlcActions": {
        "type": "object",
        "description": "What the company's Managers may do with the registration now.",
        "required": [
          "edit",
          "markReady",
          "sendAnyway"
        ],
        "properties": {
          "edit": {
            "type": "boolean",
            "description": "Change the form (`PUT`): before it is sent, and after Telnyx refused\nit."
          },
          "markReady": {
            "type": "boolean",
            "description": "Mark it ready for a superuser (`POST .../ready`): a saved draft, or\none Telnyx refused once it is fixed (`problems` must be empty); not\nwhile its AI check waits or runs."
          },
          "sendAnyway": {
            "type": "boolean",
            "description": "Send it to the superusers although the AI check asked for changes\n(`POST .../send-anyway`; the AI can be wrong): a complete form whose\ncheck's result is `changes`."
          }
        }
      },
      "TenDlcAiCheck": {
        "type": "object",
        "description": "The AI check of the registration, as the API shows it.",
        "required": [
          "status",
          "fixes",
          "unclear"
        ],
        "properties": {
          "status": {
            "$ref": "#/components/schemas/TenDlcAiCheckStatus"
          },
          "requestedAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When it was asked for (the form was marked ready)."
          },
          "checkedAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When the result came; null before."
          },
          "summary": {
            "type": [
              "string",
              "null"
            ],
            "description": "The result in a few sentences; null before."
          },
          "fixes": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TenDlcAiFix"
            },
            "description": "What to change (`changes`); empty otherwise."
          },
          "unclear": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TenDlcAiUnclear"
            },
            "description": "What the AI could not verify, for the superusers."
          }
        }
      },
      "TenDlcAiCheckStatus": {
        "type": "string",
        "description": "Where the AI check of a registration is.",
        "enum": [
          "Pending",
          "Running",
          "Passed",
          "Changes",
          "Failed",
          "Overridden"
        ]
      },
      "TenDlcAiFix": {
        "type": "object",
        "description": "One change the AI asks for.",
        "required": [
          "location",
          "label",
          "problem",
          "current",
          "replacement"
        ],
        "properties": {
          "location": {
            "type": "string",
            "description": "What to change: a form field (`campaign.messageFlow`,\n`campaign.samples.1`, `campaign.privacyPolicyLink`,\n`campaign.termsAndConditionsLink`, `brand.phone`, `brand.email`,\n`campaign.other` for a choice on the form) or a page\n(`page:quoteForm`, `page:privacyPolicy`, `page:terms`,\n`page:website`, and the privacy and terms pages the quote form links\nto: `page:linkedPrivacy`, `page:linkedTerms`)."
          },
          "label": {
            "type": "string",
            "description": "The field or page, for people (\"How customers opt in\")."
          },
          "link": {
            "type": [
              "string",
              "null"
            ],
            "description": "The page's link; null for a form field."
          },
          "problem": {
            "type": "string",
            "description": "What is wrong and what the carriers require."
          },
          "current": {
            "type": "string",
            "description": "The text as it is now (the field, or the passage on the page); empty\nwhen the text is missing and must be added."
          },
          "replacement": {
            "type": "string",
            "description": "The text to use instead (or to add)."
          }
        }
      },
      "TenDlcAiUnclear": {
        "type": "object",
        "description": "Something the AI could not verify (a page it could not read): for the\nsuperusers to look at by hand.",
        "required": [
          "label",
          "note"
        ],
        "properties": {
          "label": {
            "type": "string",
            "description": "The check (\"Opt-in checkbox\")."
          },
          "note": {
            "type": "string",
            "description": "What could not be verified, and why."
          }
        }
      },
      "TenDlcBrandDraft": {
        "type": "object",
        "description": "The business behind the texts (the 10DLC brand). Any field may be empty\nwhile a draft; `problems` says what sending needs.",
        "properties": {
          "entityType": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/EntityType",
                "description": "The form of business; null until chosen."
              },
              {
                "type": "null"
              }
            ],
            "default": null
          },
          "displayName": {
            "type": "string",
            "description": "The name customers know the business by (DBA), shown to carriers; up\nto 100 characters.",
            "default": ""
          },
          "companyName": {
            "type": "string",
            "description": "The legal name, exactly as the IRS (or CRA) has it for the tax id;\nup to 100 characters.",
            "default": ""
          },
          "ein": {
            "type": "string",
            "description": "The tax id: a US EIN (`12-3456789`) or a Canadian business number\n(9 digits).",
            "default": ""
          },
          "country": {
            "type": "string",
            "description": "Where the business and its tax id are registered: `US` or `CA`.",
            "default": ""
          },
          "firstName": {
            "type": "string",
            "description": "A business contact's first name; may be empty. Up to 100 characters.",
            "default": ""
          },
          "lastName": {
            "type": "string",
            "description": "A business contact's last name; may be empty. Up to 100 characters.",
            "default": ""
          },
          "phone": {
            "type": "string",
            "description": "The business phone, a US or Canada number (saved as E.164 when it is\none).",
            "default": ""
          },
          "email": {
            "type": "string",
            "description": "The business email carriers may write to; up to 100 characters.",
            "default": ""
          },
          "website": {
            "type": "string",
            "description": "The business website (`https://...`), which carriers check; up to\n100 characters.",
            "default": ""
          },
          "street": {
            "type": "string",
            "description": "Street and number of the business address; up to 100 characters.",
            "default": ""
          },
          "city": {
            "type": "string",
            "description": "City; up to 100 characters.",
            "default": ""
          },
          "state": {
            "type": "string",
            "description": "State or province, 2 letters (`IN`).",
            "default": ""
          },
          "postalCode": {
            "type": "string",
            "description": "ZIP code (`46204`) or Canadian postal code (`K1A 0B1`).",
            "default": ""
          },
          "vertical": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/Vertical",
                "description": "The industry; null until chosen."
              },
              {
                "type": "null"
              }
            ],
            "default": null
          },
          "stockSymbol": {
            "type": "string",
            "description": "`PUBLIC_PROFIT` only: the stock symbol, up to 10 characters.",
            "default": ""
          },
          "stockExchange": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/StockExchange",
                "description": "`PUBLIC_PROFIT` only: the stock exchange; null otherwise."
              },
              {
                "type": "null"
              }
            ],
            "default": null
          },
          "businessContactEmail": {
            "type": "string",
            "description": "`PUBLIC_PROFIT` only: the business contact email Telnyx requires.",
            "default": ""
          }
        }
      },
      "TenDlcCampaignDraft": {
        "type": "object",
        "description": "How the business texts (the 10DLC campaign). Any field may be empty\nwhile a draft; `problems` says what sending needs.",
        "properties": {
          "usecase": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/UseCase",
                "description": "What the texts are about; null until chosen."
              },
              {
                "type": "null"
              }
            ],
            "default": null
          },
          "subUsecases": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/UseCase"
            },
            "description": "The kinds of texts of a `MIXED` (2 to 5) or `LOW_VOLUME` (1 to 5)\ncampaign; empty for the other use cases.",
            "default": []
          },
          "description": {
            "type": "string",
            "description": "What the business texts and why, 40 to 4096 characters.",
            "default": ""
          },
          "messageFlow": {
            "type": "string",
            "description": "How customers agree to get texts: where they give their number and\nwhat they are told; 40 to 2048 characters.",
            "default": ""
          },
          "samples": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Example texts, 2 to 5, each 20 to 255 characters, naming the\nbusiness and saying how to opt out (\"Reply STOP to opt out\").",
            "default": []
          },
          "helpMessage": {
            "type": "string",
            "description": "The answer to HELP: names the business and how to reach it; 20 to\n255 characters.",
            "default": ""
          },
          "helpKeywords": {
            "type": "string",
            "description": "The words that get the help answer, comma separated (`HELP,INFO`);\nmust include HELP.",
            "default": ""
          },
          "optinMessage": {
            "type": "string",
            "description": "The answer to an opt-in word, naming the business; 20 to 255\ncharacters.",
            "default": ""
          },
          "optinKeywords": {
            "type": "string",
            "description": "Opt-in words, comma separated (`START`).",
            "default": ""
          },
          "optoutMessage": {
            "type": "string",
            "description": "The answer to STOP, naming the business; 20 to 255 characters.",
            "default": ""
          },
          "optoutKeywords": {
            "type": "string",
            "description": "Opt-out words, comma separated; must include STOP.",
            "default": ""
          },
          "embeddedLink": {
            "type": "boolean",
            "description": "The texts carry links (needed when a sample has one).",
            "default": false
          },
          "embeddedLinkSample": {
            "type": "string",
            "description": "An example of a link the texts carry; may be empty. Up to 255\ncharacters.",
            "default": ""
          },
          "embeddedPhone": {
            "type": "boolean",
            "description": "The texts carry phone numbers (needed when a sample has one).",
            "default": false
          },
          "numberPool": {
            "type": "boolean",
            "description": "The texts go out from a pool of numbers (50 or more).",
            "default": false
          },
          "ageGated": {
            "type": "boolean",
            "description": "The texts are about age-restricted products.",
            "default": false
          },
          "directLending": {
            "type": "boolean",
            "description": "The texts are about direct lending or loans.",
            "default": false
          },
          "optinFormLink": {
            "type": "string",
            "description": "The page with the form customers fill out to give their number and\nagree to texts (the quote form), `https://...`; the AI check reads it.\nNot sent to Telnyx (the message flow names it).",
            "default": ""
          },
          "privacyPolicyLink": {
            "type": "string",
            "description": "The privacy policy page (`https://...`).",
            "default": ""
          },
          "termsAndConditionsLink": {
            "type": "string",
            "description": "The texting terms page (`https://...`).",
            "default": ""
          },
          "termsAccepted": {
            "type": "boolean",
            "description": "The carriers' terms for business texting are accepted (needed to\nsend).",
            "default": false
          }
        }
      },
      "TenDlcChatInput": {
        "type": "object",
        "description": "A question to the AI helper beside the form.",
        "required": [
          "messages",
          "draft"
        ],
        "properties": {
          "messages": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ChatTurn"
            },
            "description": "The conversation so far, oldest first, ending with the question\n(the latest [`chat::MAX_TURNS`] are read)."
          },
          "draft": {
            "$ref": "#/components/schemas/TenDlcDraft",
            "description": "The form as it is on screen, unsaved edits included."
          },
          "step": {
            "type": "string",
            "description": "The step on screen: `business`, `texting` or `review`."
          }
        },
        "additionalProperties": false
      },
      "TenDlcChecksRun": {
        "type": "object",
        "description": "What a run did.",
        "required": [
          "processed"
        ],
        "properties": {
          "processed": {
            "type": "integer",
            "description": "Registrations checked (0 or 1).",
            "minimum": 0
          }
        }
      },
      "TenDlcCompany": {
        "type": "object",
        "description": "A company, by id and name.",
        "required": [
          "companyId",
          "companyName"
        ],
        "properties": {
          "companyId": {
            "type": "integer",
            "format": "int32",
            "description": "The company."
          },
          "companyName": {
            "type": "string",
            "description": "Its name."
          }
        }
      },
      "TenDlcCost": {
        "type": "object",
        "description": "What Telnyx charges for a campaign.",
        "required": [
          "usecase"
        ],
        "properties": {
          "usecase": {
            "type": "string",
            "description": "The campaign's use case (`MIXED`, ...)."
          },
          "upFrontCost": {
            "type": [
              "string",
              "null"
            ],
            "description": "Charged when the campaign is created (Telnyx's amount, US dollars,\ne.g. `30.00`); null when Telnyx did not say."
          },
          "monthlyCost": {
            "type": [
              "string",
              "null"
            ],
            "description": "Charged monthly after the first three months (US dollars); null when\nTelnyx did not say."
          },
          "description": {
            "type": [
              "string",
              "null"
            ],
            "description": "Telnyx's note on the cost; null when none."
          }
        }
      },
      "TenDlcDraft": {
        "type": "object",
        "description": "The registration form: the business and how it texts.",
        "properties": {
          "brand": {
            "$ref": "#/components/schemas/TenDlcBrandDraft",
            "description": "The business (Brand).",
            "default": {
              "businessContactEmail": "",
              "city": "",
              "companyName": "",
              "country": "",
              "displayName": "",
              "ein": "",
              "email": "",
              "entityType": null,
              "firstName": "",
              "lastName": "",
              "phone": "",
              "postalCode": "",
              "state": "",
              "stockExchange": null,
              "stockSymbol": "",
              "street": "",
              "vertical": null,
              "website": ""
            }
          },
          "campaign": {
            "$ref": "#/components/schemas/TenDlcCampaignDraft",
            "description": "How it texts (Campaign).",
            "default": {
              "ageGated": false,
              "description": "",
              "directLending": false,
              "embeddedLink": false,
              "embeddedLinkSample": "",
              "embeddedPhone": false,
              "helpKeywords": "",
              "helpMessage": "",
              "messageFlow": "",
              "numberPool": false,
              "optinFormLink": "",
              "optinKeywords": "",
              "optinMessage": "",
              "optoutKeywords": "",
              "optoutMessage": "",
              "privacyPolicyLink": "",
              "samples": [],
              "subUsecases": [],
              "termsAccepted": false,
              "termsAndConditionsLink": "",
              "usecase": null
            }
          }
        }
      },
      "TenDlcFeedback": {
        "type": "object",
        "description": "One of Telnyx's (or a carrier's) reasons, phone numbers masked.",
        "required": [
          "title",
          "description"
        ],
        "properties": {
          "title": {
            "type": "string",
            "description": "What it is about, e.g. \"Tax Id\", \"Carrier review\"."
          },
          "description": {
            "type": "string",
            "description": "What is wrong, in Telnyx's words."
          },
          "fields": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "The form fields it names (Telnyx's names, e.g. `ein`, `sample1`);\nmay be empty."
          }
        }
      },
      "TenDlcLinkInput": {
        "type": "object",
        "description": "Body of `PUT /v1/superuser/companies/{id}/tendlc/link`.",
        "properties": {
          "formCompanyId": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "The company whose form this company uses from now on; null: it uses\nits own form again.",
            "default": null
          }
        }
      },
      "TenDlcList": {
        "type": "object",
        "description": "`GET /v1/superuser/tendlc`.",
        "required": [
          "registrations"
        ],
        "properties": {
          "registrations": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TenDlcListItem"
            },
            "description": "Those waiting for a superuser first (ready, rejected), then the\nnewest."
          }
        }
      },
      "TenDlcListItem": {
        "type": "object",
        "description": "One company's registration in the superusers' list.",
        "required": [
          "companyId",
          "companyName",
          "status",
          "displayName",
          "problemCount",
          "sharedWith"
        ],
        "properties": {
          "companyId": {
            "type": "integer",
            "format": "int32",
            "description": "The company (`/v1/superuser/companies/{id}/tendlc`)."
          },
          "companyName": {
            "type": "string",
            "description": "Its name."
          },
          "status": {
            "$ref": "#/components/schemas/TenDlcStatus",
            "description": "Where the registration is."
          },
          "displayName": {
            "type": "string",
            "description": "The business name on the form; may be empty."
          },
          "problemCount": {
            "type": "integer",
            "description": "What blocks sending it; 0 when complete.",
            "minimum": 0
          },
          "brandStatus": {
            "type": [
              "string",
              "null"
            ],
            "description": "Telnyx's brand status; null before sending."
          },
          "campaignStatus": {
            "type": [
              "string",
              "null"
            ],
            "description": "Telnyx's campaign status; null before."
          },
          "lastError": {
            "type": [
              "string",
              "null"
            ],
            "description": "What went wrong last; null when nothing."
          },
          "readyAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When a Manager last marked it ready; null when never."
          },
          "readyByName": {
            "type": [
              "string",
              "null"
            ],
            "description": "Who marked it ready; null when never."
          },
          "sentAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When it was first sent; null before."
          },
          "updatedAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When it last changed."
          },
          "sharedWith": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "The other companies that use this form (linked to it), by name;\nempty when none."
          }
        }
      },
      "TenDlcNumber": {
        "type": "object",
        "description": "One active number of the company (or of a company sharing its form) and\nits campaign assignment.",
        "required": [
          "e164",
          "label",
          "companyId",
          "companyName"
        ],
        "properties": {
          "e164": {
            "type": "string",
            "description": "The number, E.164."
          },
          "label": {
            "type": "string",
            "description": "Its label on the Phone page; may be empty."
          },
          "companyId": {
            "type": "integer",
            "format": "int32",
            "description": "The number's company."
          },
          "companyName": {
            "type": "string",
            "description": "The number's company's name."
          },
          "status": {
            "type": [
              "string",
              "null"
            ],
            "description": "Telnyx's assignment status (`PENDING_ASSIGNMENT`, `ASSIGNED`,\n`FAILED_ASSIGNMENT`, ...); null when never assigned."
          },
          "error": {
            "type": [
              "string",
              "null"
            ],
            "description": "Why the assignment failed (Telnyx's words, numbers masked); null\nwhen it did not."
          },
          "updatedAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When its assignment last changed; null when never assigned."
          }
        }
      },
      "TenDlcNumbersAssigned": {
        "type": "object",
        "description": "`POST /v1/superuser/companies/{id}/tendlc/numbers`.",
        "required": [
          "assigned",
          "failed",
          "skipped",
          "review"
        ],
        "properties": {
          "assigned": {
            "type": "integer",
            "description": "Numbers Telnyx took (assigned, or being assigned).",
            "minimum": 0
          },
          "failed": {
            "type": "integer",
            "description": "Numbers Telnyx refused or did not answer about (each one's `error`\nsays why; assign again to retry them).",
            "minimum": 0
          },
          "skipped": {
            "type": "integer",
            "description": "Numbers assigned to the campaign already.",
            "minimum": 0
          },
          "review": {
            "$ref": "#/components/schemas/TenDlcReview",
            "description": "The registration with its numbers."
          }
        }
      },
      "TenDlcProblem": {
        "type": "object",
        "description": "What blocks marking the form ready or sending it.",
        "required": [
          "field",
          "message"
        ],
        "properties": {
          "field": {
            "type": "string",
            "description": "The field, as a path of the form: `brand.ein`, `campaign.samples.1`,\n`campaign.subUsecases`."
          },
          "message": {
            "type": "string",
            "description": "What is wrong, for the person filling it in."
          }
        }
      },
      "TenDlcRegistration": {
        "type": "object",
        "description": "A company's 10DLC texting registration.",
        "required": [
          "saved",
          "status",
          "draft",
          "problems",
          "campaignLocked",
          "brandFeedback",
          "campaignFeedback",
          "actions",
          "sharedBy"
        ],
        "properties": {
          "saved": {
            "type": "boolean",
            "description": "A registration is saved; false before the first save (`draft` is\nthen a suggestion)."
          },
          "status": {
            "$ref": "#/components/schemas/TenDlcStatus",
            "description": "Where it is (`draft` before the first save)."
          },
          "draft": {
            "$ref": "#/components/schemas/TenDlcDraft",
            "description": "The form."
          },
          "problems": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TenDlcProblem"
            },
            "description": "What blocks marking it ready (or sending it); empty when complete."
          },
          "campaignLocked": {
            "type": "boolean",
            "description": "Telnyx has the campaign: only its sample texts, message flow and\nhelp message can change."
          },
          "brandStatus": {
            "type": [
              "string",
              "null"
            ],
            "description": "Telnyx's brand status: `OK`, `REGISTRATION_PENDING` or\n`REGISTRATION_FAILED`; null before sending."
          },
          "brandIdentityStatus": {
            "type": [
              "string",
              "null"
            ],
            "description": "TCR's check of the business: `SELF_DECLARED`, `VERIFIED`,\n`VETTED_VERIFIED` or `UNVERIFIED`; null before sending."
          },
          "campaignStatus": {
            "type": [
              "string",
              "null"
            ],
            "description": "Telnyx's campaign status (`TCR_PENDING` ... `MNO_PROVISIONED`, or\n`REFUSED` when Telnyx refused to create it); null before."
          },
          "brandFeedback": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TenDlcFeedback"
            },
            "description": "Why Telnyx refused the brand (its feedback), phone numbers masked;\nempty when nothing is wrong."
          },
          "campaignFeedback": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TenDlcFeedback"
            },
            "description": "Why Telnyx or a carrier refused the campaign, phone numbers masked;\nempty when nothing is wrong."
          },
          "lastError": {
            "type": [
              "string",
              "null"
            ],
            "description": "What went wrong last on our side (Telnyx did not answer, ...); null\nwhen nothing."
          },
          "draftSavedAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When the form was last saved; null before."
          },
          "draftSavedByName": {
            "type": [
              "string",
              "null"
            ],
            "description": "Who saved it last (name, else email); null when unknown."
          },
          "readyAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When it was last marked ready; null when never."
          },
          "readyByName": {
            "type": [
              "string",
              "null"
            ],
            "description": "Who marked it ready (name, else email); null when never."
          },
          "sentAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When it was first sent to Telnyx; null before."
          },
          "approvedAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When the carriers approved it; null before."
          },
          "rejectedAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When it was last refused; null when never."
          },
          "aiCheck": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/TenDlcAiCheck",
                "description": "The AI check that runs when a Manager marks it ready (the form and\nthe quote form, privacy policy and terms pages, as the carriers\ncheck them): waiting, running, passed (it went to the superusers),\nchanges (what to change) or failed (it went on unchecked); null when\nnever asked for."
              },
              {
                "type": "null"
              }
            ]
          },
          "actions": {
            "$ref": "#/components/schemas/TenDlcActions",
            "description": "What the company's Managers may do now."
          },
          "sharedBy": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "The companies that share this one form (one Brand and Campaign for\none business's locations), the form's company first; empty when only\none company uses it."
          }
        }
      },
      "TenDlcResendInput": {
        "type": "object",
        "description": "Body of `POST /v1/superuser/companies/{id}/tendlc/resend`.",
        "properties": {
          "appealReason": {
            "type": [
              "string",
              "null"
            ],
            "description": "For a campaign Telnyx or a carrier refused: what was fixed (on the\nwebsite, the opt-in page, ...), for Telnyx's compliance team to look\nagain (an appeal); up to 1000 characters. Null or empty: no appeal.",
            "default": null
          }
        }
      },
      "TenDlcReview": {
        "type": "object",
        "description": "A company's registration as a superuser reviews it.",
        "required": [
          "companyId",
          "companyName",
          "sharedWith",
          "registration",
          "telnyx",
          "numbers",
          "telnyxSetUp",
          "messagingProfileSet",
          "actions"
        ],
        "properties": {
          "companyId": {
            "type": "integer",
            "format": "int32",
            "description": "The company."
          },
          "companyName": {
            "type": "string",
            "description": "Its name."
          },
          "formCompany": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/TenDlcCompany",
                "description": "The company whose form this company uses, when a superuser linked it\nto another company's form (everything below is that form's); null\nwhen it uses its own."
              },
              {
                "type": "null"
              }
            ]
          },
          "sharedWith": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TenDlcCompany"
            },
            "description": "The companies linked to the form (they use it too), by name; empty\nwhen none."
          },
          "registration": {
            "$ref": "#/components/schemas/TenDlcRegistration",
            "description": "The registration (`draft` is a suggestion while `saved` is false)."
          },
          "telnyx": {
            "$ref": "#/components/schemas/TenDlcTelnyxIds",
            "description": "Telnyx's ids."
          },
          "numbers": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TenDlcNumber"
            },
            "description": "The active numbers of the form's company and of the companies linked\nto it, and their assignments."
          },
          "telnyxSetUp": {
            "type": "boolean",
            "description": "The company has a Telnyx setup (needed to send: its webhook token\nnames the company in Telnyx's notifications)."
          },
          "messagingProfileSet": {
            "type": "boolean",
            "description": "The company's Telnyx setup has a messaging profile (the numbers must\nbe on it to be assigned)."
          },
          "sentByName": {
            "type": [
              "string",
              "null"
            ],
            "description": "Who first sent it (name, else email); null before."
          },
          "resentAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When it was last sent again; null when never."
          },
          "refreshedAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When it was last read from Telnyx; null when never."
          },
          "actions": {
            "$ref": "#/components/schemas/TenDlcReviewActions",
            "description": "What the superuser may do now."
          }
        }
      },
      "TenDlcReviewActions": {
        "type": "object",
        "description": "What a superuser may do with the registration now.",
        "required": [
          "edit",
          "send",
          "resend",
          "refresh",
          "assignNumbers"
        ],
        "properties": {
          "edit": {
            "type": "boolean",
            "description": "Change the form (`PUT`)."
          },
          "send": {
            "type": "boolean",
            "description": "Send it to Telnyx the first time (`POST .../send`): complete, and\nno brand yet."
          },
          "resend": {
            "type": "boolean",
            "description": "Send it again after a rejection (`POST .../resend`): complete, and\nTelnyx has the brand."
          },
          "refresh": {
            "type": "boolean",
            "description": "Read it again from Telnyx (`POST .../refresh`)."
          },
          "assignNumbers": {
            "type": "boolean",
            "description": "Assign the company's numbers to the approved campaign\n(`POST .../numbers`)."
          }
        }
      },
      "TenDlcStatus": {
        "type": "string",
        "description": "Where a company's 10DLC registration is.",
        "enum": [
          "Draft",
          "Ready",
          "Sent",
          "CampaignPending",
          "Approved",
          "Rejected",
          "Suspended"
        ]
      },
      "TenDlcTelnyxIds": {
        "type": "object",
        "description": "Telnyx's ids of the registration.",
        "properties": {
          "brandId": {
            "type": [
              "string",
              "null"
            ],
            "description": "Telnyx's brand id; null before sending."
          },
          "tcrBrandId": {
            "type": [
              "string",
              "null"
            ],
            "description": "TCR's brand id (`B...`); null until registered."
          },
          "campaignId": {
            "type": [
              "string",
              "null"
            ],
            "description": "Telnyx's campaign id; null until created."
          },
          "tcrCampaignId": {
            "type": [
              "string",
              "null"
            ],
            "description": "TCR's campaign id (`C...`); null until registered."
          }
        }
      },
      "TestInstruction": {
        "type": "object",
        "description": "An instruction with a test.",
        "required": [
          "id",
          "title",
          "completed"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "The instruction."
          },
          "title": {
            "type": "string",
            "description": "Its title (\"Untitled instruction\" when blank)."
          },
          "completed": {
            "type": "boolean",
            "description": "The caller once answered every one of its questions right in one try."
          }
        }
      },
      "TestPush": {
        "type": "object",
        "description": "Body of `POST /v1/phone/pushes/test`.",
        "required": [
          "kind"
        ],
        "properties": {
          "kind": {
            "$ref": "#/components/schemas/TestPushKind"
          }
        }
      },
      "TestPushKind": {
        "type": "string",
        "description": "What `POST /v1/phone/pushes/test` sends.",
        "enum": [
          "activity_added",
          "note_added",
          "comment_added",
          "activity_reminder",
          "appointment_reminder",
          "lead_new",
          "lead_repeat",
          "lead_assigned",
          "lead_quote",
          "maintenance"
        ]
      },
      "TestQuestion": {
        "type": "object",
        "description": "A test question.",
        "required": [
          "id",
          "text",
          "instruction_id",
          "question_type"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "The question."
          },
          "text": {
            "type": "string",
            "description": "Its text."
          },
          "instruction_id": {
            "type": "integer",
            "format": "int32",
            "description": "The instruction it tests."
          },
          "question_type": {
            "type": "string",
            "description": "`MC` or `TF`."
          }
        }
      },
      "TestReport": {
        "type": "object",
        "description": "The agent's test, as it reported it.",
        "required": [
          "status"
        ],
        "properties": {
          "status": {
            "$ref": "#/components/schemas/TestStatus",
            "description": "Whether a test was written."
          },
          "files": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Test files, relative to the target repository."
          },
          "command": {
            "type": [
              "string",
              "null"
            ],
            "description": "The command that runs it, e.g. `cargo test -p api --test sms tts_reply`."
          },
          "why_not_possible": {
            "type": [
              "string",
              "null"
            ],
            "description": "Why no automated test was possible."
          },
          "manual_test_steps": {
            "type": [
              "string",
              "null"
            ],
            "description": "How a person checks the fix by hand."
          }
        }
      },
      "TestStatus": {
        "type": "string",
        "description": "Whether the agent wrote a test.",
        "enum": [
          "written",
          "not_possible",
          "not_applicable"
        ]
      },
      "TexmlRequest": {
        "type": "object",
        "description": "The fields of Telnyx's TeXML requests the callbacks read. Telnyx posts\nthem form-encoded; every field is optional and others are ignored.",
        "properties": {
          "AccountSid": {
            "type": [
              "string",
              "null"
            ],
            "description": "The Telnyx account; required, and must be the company's, when the\ncompany saved its account id (`telnyxAccountId`).",
            "default": null
          },
          "CallSid": {
            "type": [
              "string",
              "null"
            ],
            "description": "The call, or the leg, the request is about.",
            "default": null
          },
          "ConnectionId": {
            "type": [
              "string",
              "null"
            ],
            "description": "The Telnyx connection (the company's TeXML app); must be the\ncompany's when it set one.",
            "default": null
          },
          "From": {
            "type": [
              "string",
              "null"
            ],
            "description": "Who placed the call: E.164, or a SIP URI.",
            "default": null
          },
          "To": {
            "type": [
              "string",
              "null"
            ],
            "description": "Who was called: E.164, or a SIP URI.",
            "default": null
          },
          "CallStatus": {
            "type": [
              "string",
              "null"
            ],
            "description": "The call's status: `initiated`, `ringing`, `in-progress`,\n`completed`, `busy`, `no-answer`, `canceled` or `failed`; after an AI\nAssistant that could not start, `conversation_start_failed`.",
            "default": null
          },
          "CallDuration": {
            "type": [
              "string",
              "null"
            ],
            "description": "How long the call (or the leg) lasted, in seconds (0 to 86400).",
            "default": null
          },
          "DialCallStatus": {
            "type": [
              "string",
              "null"
            ],
            "description": "How a `<Dial>` ended: `completed` (answered), `busy`, `no-answer`,\n`canceled` or `failed`.",
            "default": null
          },
          "DialCallSid": {
            "type": [
              "string",
              "null"
            ],
            "description": "The leg a `<Dial>` connected.",
            "default": null
          },
          "DialCallDuration": {
            "type": [
              "string",
              "null"
            ],
            "description": "How long that leg talked, in seconds (0 to 86400).",
            "default": null
          },
          "RecordingSid": {
            "type": [
              "string",
              "null"
            ],
            "description": "The recording (its Telnyx id).",
            "default": null
          },
          "RecordingStatus": {
            "type": [
              "string",
              "null"
            ],
            "description": "The recording's status: `in-progress`, `completed` or `absent`.",
            "default": null
          },
          "RecordingDuration": {
            "type": [
              "string",
              "null"
            ],
            "description": "The recording's length, in seconds.",
            "default": null
          },
          "SpeechResult": {
            "type": [
              "string",
              "null"
            ],
            "description": "The words said at a `<Gather>` that listens for speech.",
            "default": null
          },
          "AnsweredBy": {
            "type": [
              "string",
              "null"
            ],
            "description": "What picked up a call placed with answering-machine detection:\n`human`, `machine_start`, `fax` or `unknown`.",
            "default": null
          },
          "Digits": {
            "type": [
              "string",
              "null"
            ],
            "description": "The keys pressed at a `<Gather>`.",
            "default": null
          },
          "HangupCause": {
            "type": [
              "string",
              "null"
            ],
            "description": "Why the call ended (Telnyx's hangup cause).",
            "default": null
          },
          "Reason": {
            "type": [
              "string",
              "null"
            ],
            "description": "Why the AI Assistant's conversation ended or did not start.",
            "default": null
          },
          "Timestamp": {
            "type": [
              "string",
              "null"
            ],
            "description": "When it happened (RFC 3339 or RFC 2822); used as the time of an\nanswer or an end, held between the call's start and now.",
            "default": null
          },
          "CallerId": {
            "type": [
              "string",
              "null"
            ],
            "description": "The caller's display name, when the network gave one (Telnyx's\ninbound call screening puts `SPAM LIKELY` there).",
            "default": null
          },
          "ShakenStirAttestation": {
            "type": [
              "string",
              "null"
            ],
            "description": "The caller-ID check's (STIR/SHAKEN) attestation, `A`, `B` or `C`,\nwhen the TeXML app sends STIR/SHAKEN data.",
            "default": null
          },
          "ShakenStirValidated": {
            "type": [
              "string",
              "null"
            ],
            "description": "Whether the caller-ID check passed (`true` / `false`), when sent.",
            "default": null
          }
        }
      },
      "TextCustomer": {
        "type": "object",
        "description": "The customer the other number belongs to.",
        "required": [
          "id",
          "name"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "The customer's id."
          },
          "name": {
            "type": "string",
            "description": "Their name."
          },
          "company": {
            "type": [
              "string",
              "null"
            ],
            "description": "Their company; null when none."
          }
        }
      },
      "TextError": {
        "type": "string",
        "description": "Why a text failed: `opted_out` (the person texted STOP),\n`invalid_number`, `carrier_rejected` or `failed` (anything else).",
        "enum": [
          "OptedOut",
          "InvalidNumber",
          "CarrierRejected",
          "Failed"
        ]
      },
      "TextLast": {
        "type": "object",
        "description": "The newest text of a thread.",
        "required": [
          "direction",
          "text",
          "hasMedia",
          "at",
          "status"
        ],
        "properties": {
          "direction": {
            "type": "string",
            "description": "`inbound` or `outbound`."
          },
          "text": {
            "type": "string",
            "description": "Its text; empty for a picture or file alone."
          },
          "hasMedia": {
            "type": "boolean",
            "description": "It carried pictures or files."
          },
          "at": {
            "type": "string",
            "format": "date-time",
            "description": "When it was sent or received (RFC 3339)."
          },
          "status": {
            "$ref": "#/components/schemas/TextStatus",
            "description": "Where it is."
          }
        }
      },
      "TextMedia": {
        "type": "object",
        "description": "A picture or file of a text.",
        "required": [
          "id",
          "contentType"
        ],
        "properties": {
          "id": {
            "type": "string",
            "description": "Its id (`GET /v1/phone/texts/media/{id}` gives a link to it)."
          },
          "contentType": {
            "type": "string",
            "description": "MIME type, e.g. `image/jpeg`."
          },
          "name": {
            "type": [
              "string",
              "null"
            ],
            "description": "The file's name; null when unknown."
          },
          "size": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int64",
            "description": "Its size in bytes; null when unknown."
          },
          "url": {
            "type": [
              "string",
              "null"
            ],
            "description": "A lasting link to the file (the one the website shows). Left out when\nthe file has none: then `GET /v1/phone/texts/media/{id}` gives a link."
          }
        }
      },
      "TextMessage": {
        "type": "object",
        "description": "One text.",
        "required": [
          "id",
          "direction",
          "text",
          "media",
          "status",
          "at"
        ],
        "properties": {
          "id": {
            "type": "string",
            "description": "Our id of the text (`before` when paging)."
          },
          "direction": {
            "type": "string",
            "description": "`inbound` or `outbound`."
          },
          "text": {
            "type": "string",
            "description": "The text; empty for pictures or files alone."
          },
          "media": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TextMedia"
            },
            "description": "Its pictures and files, in order."
          },
          "status": {
            "$ref": "#/components/schemas/TextStatus",
            "description": "Where it is."
          },
          "error": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/TextError",
                "description": "Why it failed; null unless `status` is `failed`."
              },
              {
                "type": "null"
              }
            ]
          },
          "at": {
            "type": "string",
            "format": "date-time",
            "description": "When it was sent or received (RFC 3339)."
          },
          "sentBy": {
            "type": [
              "string",
              "null"
            ],
            "description": "Who sent an outbound text; null for inbound and automated ones."
          }
        }
      },
      "TextMessageList": {
        "type": "object",
        "description": "`GET /v1/phone/texts/threads/{key}/messages`.",
        "required": [
          "messages",
          "thread"
        ],
        "properties": {
          "messages": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TextMessage"
            },
            "description": "Newest first."
          },
          "nextBefore": {
            "type": [
              "string",
              "null"
            ],
            "description": "`before` for the next (older) page; null on the last."
          },
          "thread": {
            "$ref": "#/components/schemas/TextThread",
            "description": "The thread."
          }
        }
      },
      "TextNotice": {
        "type": "object",
        "description": "A new text as its notification shows it.",
        "required": [
          "phone",
          "has_media"
        ],
        "properties": {
          "phone": {
            "type": "string",
            "description": "The other party's phone (last ten digits): the conversation is\n`GET /v1/sms/mine/threads/{phone}`."
          },
          "customer_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "The customer the phone belongs to; null when none."
          },
          "text": {
            "type": [
              "string",
              "null"
            ],
            "description": "What they wrote; null for a picture or file only."
          },
          "has_media": {
            "type": "boolean",
            "description": "It came with pictures or files."
          }
        }
      },
      "TextNumber": {
        "type": "object",
        "description": "One of our numbers.",
        "required": [
          "id",
          "e164",
          "label"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "The number's id (`ourNumberId` when texting from it)."
          },
          "e164": {
            "type": "string",
            "description": "E.164."
          },
          "label": {
            "type": "string",
            "description": "Its label, e.g. \"Main line\"; may be empty."
          }
        }
      },
      "TextStatus": {
        "type": "string",
        "description": "Where a text is: `queued` (Telnyx has it), `sent` (handed to the\ncarrier), `delivered`, `failed`, or `received` (an inbound text).",
        "enum": [
          "Queued",
          "Sent",
          "Delivered",
          "Failed",
          "Received"
        ]
      },
      "TextThread": {
        "type": "object",
        "description": "A conversation of one of my lines with one other number.",
        "required": [
          "key",
          "ourNumber",
          "otherNumber",
          "last",
          "unread"
        ],
        "properties": {
          "key": {
            "type": "string",
            "description": "Opaque and stable: our number and the other number."
          },
          "ourNumber": {
            "$ref": "#/components/schemas/TextNumber",
            "description": "Our line."
          },
          "otherNumber": {
            "type": "string",
            "description": "The other number, E.164."
          },
          "customer": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/TextCustomer",
                "description": "The customer with that number; null when none."
              },
              {
                "type": "null"
              }
            ]
          },
          "last": {
            "$ref": "#/components/schemas/TextLast",
            "description": "The newest text."
          },
          "unread": {
            "type": "integer",
            "format": "int64",
            "description": "My unread texts in it."
          }
        }
      },
      "TextThreadList": {
        "type": "object",
        "description": "`GET /v1/phone/texts/threads`.",
        "required": [
          "threads",
          "unread",
          "searched"
        ],
        "properties": {
          "threads": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TextThread"
            },
            "description": "Newest activity first."
          },
          "nextBefore": {
            "type": [
              "string",
              "null"
            ],
            "description": "`before` for the next page; null on the last."
          },
          "unread": {
            "type": "integer",
            "format": "int64",
            "description": "My unread texts over all my threads."
          },
          "searched": {
            "type": "boolean",
            "description": "`true` when `search` filtered these threads; `false` without one."
          }
        }
      },
      "Texting": {
        "type": "object",
        "description": "The Texts tab's switch and badge.",
        "required": [
          "enabled",
          "unread"
        ],
        "properties": {
          "enabled": {
            "type": "boolean",
            "description": "The company texts through Telnyx (its messaging profile is set and\ncalling is on): show the Texts tab."
          },
          "unread": {
            "type": "integer",
            "format": "int64",
            "description": "My unread texts (0 while texting is off)."
          }
        }
      },
      "ThreadCustomer": {
        "type": "object",
        "description": "Who the conversation is with.",
        "required": [
          "name",
          "email"
        ],
        "properties": {
          "id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Customer id, when the address belongs to one."
          },
          "name": {
            "type": "string",
            "description": "Customer, header or coworker name; the address, or `Customer`."
          },
          "email": {
            "type": "string",
            "description": "The address to reply to."
          }
        }
      },
      "ThreadDetail": {
        "type": "object",
        "description": "A conversation.",
        "required": [
          "thread_id",
          "customer",
          "sending_email",
          "messages",
          "participants",
          "customer_addresses"
        ],
        "properties": {
          "thread_id": {
            "type": "string",
            "description": "Conversation id."
          },
          "deal_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int64",
            "description": "Deal the conversation is on."
          },
          "customer": {
            "$ref": "#/components/schemas/ThreadCustomer",
            "description": "Who it is with."
          },
          "subject": {
            "type": [
              "string",
              "null"
            ],
            "description": "Subject of the first message."
          },
          "current_user_signature": {
            "type": [
              "string",
              "null"
            ],
            "description": "The caller's email signature."
          },
          "sending_email": {
            "type": "string",
            "description": "The address the caller's mail leaves from (theirs, or the shared one)."
          },
          "messages": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ThreadMessage"
            },
            "description": "Messages, oldest first (on a deal: the deal's and unassigned ones)."
          },
          "participants": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Participant"
            },
            "description": "Addresses of every message, in header order (no BCC)."
          },
          "customer_addresses": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Every address of the customer, primary first (empty when unknown)."
          }
        }
      },
      "ThreadIds": {
        "type": "object",
        "description": "Body of thread writes.",
        "required": [
          "thread_ids"
        ],
        "properties": {
          "thread_ids": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Conversation ids (only the caller's own threads are changed)."
          }
        }
      },
      "ThreadList": {
        "type": "object",
        "description": "A page of the inbox.",
        "required": [
          "threads",
          "total_count",
          "unread_count",
          "has_more"
        ],
        "properties": {
          "threads": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ThreadSummary"
            },
            "description": "This page."
          },
          "total_count": {
            "type": "integer",
            "format": "int64",
            "description": "Threads matching, over every page."
          },
          "unread_count": {
            "type": "integer",
            "format": "int64",
            "description": "Unread threads (ignoring the search when it matches nothing)."
          },
          "has_more": {
            "type": "boolean",
            "description": "Another page follows."
          }
        }
      },
      "ThreadMessage": {
        "type": "object",
        "description": "A message of a thread.",
        "required": [
          "id",
          "body",
          "attachments"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "Message id."
          },
          "subject": {
            "type": [
              "string",
              "null"
            ],
            "description": "Subject."
          },
          "body": {
            "type": "string",
            "description": "Plain text body."
          },
          "html_body": {
            "type": [
              "string",
              "null"
            ],
            "description": "HTML body, when the mail had one."
          },
          "sent_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When it was sent."
          },
          "sender_email": {
            "type": [
              "string",
              "null"
            ],
            "description": "From header."
          },
          "receiver_email": {
            "type": [
              "string",
              "null"
            ],
            "description": "First To header."
          },
          "receiver_user_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Receiving user, when known."
          },
          "employee_read_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When an employee opened it."
          },
          "sender_user_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Sending user; null for mail from outside."
          },
          "signature": {
            "type": [
              "string",
              "null"
            ],
            "description": "Email signature of the sending user."
          },
          "read_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When the recipient last opened it."
          },
          "attachments": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Attachment"
            },
            "description": "Attachments."
          }
        }
      },
      "ThreadSummary": {
        "type": "object",
        "description": "One conversation in the inbox.",
        "required": [
          "phone_digits",
          "last_message_text",
          "last_message_at",
          "last_direction",
          "message_count",
          "unread_count"
        ],
        "properties": {
          "phone_digits": {
            "type": "string",
            "description": "The other party's phone (the thread key)."
          },
          "customer_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "The customer with this phone."
          },
          "customer_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "The customer's name, else a supplier's."
          },
          "last_message_text": {
            "type": "string",
            "description": "Text of the latest message (a photo or file label when it has none)."
          },
          "last_message_at": {
            "type": "string",
            "format": "date-time",
            "description": "When the latest message was sent."
          },
          "last_direction": {
            "$ref": "#/components/schemas/Direction"
          },
          "last_agent": {
            "type": [
              "string",
              "null"
            ],
            "description": "Agent id on the latest message."
          },
          "message_count": {
            "type": "integer",
            "format": "int64",
            "description": "Messages in the conversation (matching the search, with one)."
          },
          "unread_count": {
            "type": "integer",
            "format": "int64",
            "description": "Unread messages (1 when marked unread by hand)."
          }
        }
      },
      "Tick": {
        "type": "object",
        "description": "Body of `PUT .../setup-checklist/items/{key}`.",
        "required": [
          "checked"
        ],
        "properties": {
          "checked": {
            "type": "boolean",
            "description": "Ticked by hand."
          }
        }
      },
      "TickReport": {
        "type": "object",
        "description": "What a tick did.",
        "required": [
          "processed",
          "discovered",
          "queued",
          "skipped",
          "duplicates",
          "dispatched",
          "previewed",
          "timed_out",
          "regressions",
          "assigned",
          "busy",
          "errors"
        ],
        "properties": {
          "processed": {
            "type": "integer",
            "description": "Ledger rows this tick changed (the time-triggered Lambda logs it).",
            "minimum": 0
          },
          "discovered": {
            "type": "integer",
            "description": "New bugs recorded (a bug is one signature of `$exception` events).",
            "minimum": 0
          },
          "queued": {
            "type": "integer",
            "description": "Bugs judged eligible and queued.",
            "minimum": 0
          },
          "skipped": {
            "type": "integer",
            "description": "Bugs skipped as noise, resolved, suppressed or not production.",
            "minimum": 0
          },
          "duplicates": {
            "type": "integer",
            "description": "Browser errors folded into the API error of the same request, or\ntoasts into the web error they repeat.",
            "minimum": 0
          },
          "dispatched": {
            "type": "integer",
            "description": "Fix runs started.",
            "minimum": 0
          },
          "previewed": {
            "type": "integer",
            "description": "Runs a dry run would have started (emailed instead).",
            "minimum": 0
          },
          "timed_out": {
            "type": "integer",
            "description": "Runs given up by the watchdog.",
            "minimum": 0
          },
          "regressions": {
            "type": "integer",
            "description": "Fixed issues that PostHog reopened (emailed).",
            "minimum": 0
          },
          "assigned": {
            "type": "integer",
            "description": "PostHog issues of opened fixes assigned to their reviewer (write-back).",
            "minimum": 0
          },
          "busy": {
            "type": "boolean",
            "description": "Another tick held the lock; this one did nothing."
          },
          "errors": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Steps that failed (PostHog or GitHub unreachable); retried next tick."
          }
        }
      },
      "Tidied": {
        "type": "object",
        "description": "The invoices created from quotes in one period.",
        "required": [
          "invoices",
          "changed"
        ],
        "properties": {
          "invoices": {
            "type": "integer",
            "format": "int32",
            "description": "How many were created.",
            "minimum": 0
          },
          "changed": {
            "type": "integer",
            "format": "int32",
            "description": "How many of them the office then changed in `QuickBooks`: a line\ndeleted or reworded, or another class, CC or product.",
            "minimum": 0
          }
        }
      },
      "Tidying": {
        "type": "object",
        "description": "How many of the invoices created from quotes the office still tidies in\n`QuickBooks` afterwards, lately and before that: fewer means the drafts\ncome out more the company's way.",
        "required": [
          "days",
          "recent",
          "before"
        ],
        "properties": {
          "days": {
            "type": "integer",
            "format": "int32",
            "description": "The days each period covers.",
            "minimum": 0
          },
          "recent": {
            "$ref": "#/components/schemas/Tidied",
            "description": "The last `days` days."
          },
          "before": {
            "$ref": "#/components/schemas/Tidied",
            "description": "The `days` days before those."
          }
        }
      },
      "TimeRules": {
        "type": "object",
        "description": "How long one kind of job takes, and the work day it fits in.",
        "required": [
          "base_minutes",
          "per_sqft_minutes",
          "per_waterfall_minutes",
          "per_sink_minutes",
          "per_cooktop_minutes",
          "per_backsplash_minutes",
          "per_full_backsplash_minutes",
          "per_tear_out_minutes",
          "travel_minutes",
          "day_start_minute",
          "day_end_minute",
          "work_days"
        ],
        "properties": {
          "base_minutes": {
            "type": "integer",
            "format": "int32",
            "description": "Minutes every job takes (setup, cleanup).",
            "minimum": 0
          },
          "per_sqft_minutes": {
            "type": "number",
            "format": "double",
            "description": "Minutes per square foot of the sale."
          },
          "per_waterfall_minutes": {
            "type": "integer",
            "format": "int32",
            "description": "Minutes per waterfall.",
            "minimum": 0
          },
          "per_sink_minutes": {
            "type": "integer",
            "format": "int32",
            "description": "Minutes per sink.",
            "minimum": 0
          },
          "per_cooktop_minutes": {
            "type": "integer",
            "format": "int32",
            "description": "Minutes per room with a cooktop cutout.",
            "minimum": 0
          },
          "per_backsplash_minutes": {
            "type": "integer",
            "format": "int32",
            "description": "Minutes per room with a 4\" backsplash.",
            "minimum": 0
          },
          "per_full_backsplash_minutes": {
            "type": "integer",
            "format": "int32",
            "description": "Minutes per room with a full-height backsplash.",
            "minimum": 0
          },
          "per_tear_out_minutes": {
            "type": "integer",
            "format": "int32",
            "description": "Minutes per room with a tear-out.",
            "minimum": 0
          },
          "travel_minutes": {
            "type": "integer",
            "format": "int32",
            "description": "Minutes kept free between two jobs of one person (driving).",
            "minimum": 0
          },
          "day_start_minute": {
            "type": "integer",
            "format": "int32",
            "description": "When the work day starts, in minutes after midnight (shop time).",
            "minimum": 0
          },
          "day_end_minute": {
            "type": "integer",
            "format": "int32",
            "description": "When it ends, in minutes after midnight (shop time).",
            "minimum": 0
          },
          "lunch_start_minute": {
            "type": "integer",
            "format": "int32",
            "description": "When lunch starts, in minutes after midnight (shop time).",
            "minimum": 0
          },
          "lunch_minutes": {
            "type": "integer",
            "format": "int32",
            "description": "How long lunch is; 0 means no lunch. The Auto-plan keeps it free.",
            "minimum": 0
          },
          "work_days": {
            "type": "array",
            "items": {
              "type": "integer",
              "format": "int32",
              "minimum": 0
            },
            "description": "Days people work: 0 Sunday ... 6 Saturday."
          }
        }
      },
      "TimeRulesInput": {
        "type": "object",
        "description": "Body of `PUT /v1/schedule/time-rules`.",
        "required": [
          "kind",
          "rules"
        ],
        "properties": {
          "kind": {
            "$ref": "#/components/schemas/JobKind",
            "description": "Which jobs these rules are for."
          },
          "rules": {
            "$ref": "#/components/schemas/TimeRules",
            "description": "The new rules."
          }
        }
      },
      "TimelineMessage": {
        "type": "object",
        "description": "A message of the conversation.",
        "required": [
          "at",
          "channel",
          "direction",
          "text"
        ],
        "properties": {
          "at": {
            "type": "string",
            "description": "When, `YYYY-MM-DD HH:MM` (UTC)."
          },
          "channel": {
            "type": "string",
            "description": "`sms` or `email`."
          },
          "direction": {
            "type": "string",
            "description": "`inbound` or `outbound`."
          },
          "text": {
            "type": "string",
            "description": "The text (an email starts with its subject line)."
          }
        }
      },
      "TitleVariable": {
        "type": "string",
        "description": "What an event template's title starts with.",
        "enum": [
          "quote_name",
          "customer_name"
        ]
      },
      "Todo": {
        "type": "object",
        "description": "A to-do.",
        "required": [
          "id",
          "rich_text",
          "is_done"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "The to-do."
          },
          "rich_text": {
            "type": "string",
            "description": "The task."
          },
          "is_done": {
            "type": "boolean",
            "description": "Ticked off."
          },
          "position": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "Order in the list."
          },
          "created_date": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When it was added."
          }
        }
      },
      "TodoDone": {
        "type": "object",
        "description": "Body of `PUT /v1/me/todos/{id}/done`.",
        "required": [
          "done"
        ],
        "properties": {
          "done": {
            "type": "boolean",
            "description": "Ticked off or not."
          }
        }
      },
      "TodoPerson": {
        "type": "object",
        "description": "Someone to give a to-do to.",
        "required": [
          "id",
          "name"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "Their user id."
          },
          "name": {
            "type": "string",
            "description": "Their name."
          }
        }
      },
      "TodoText": {
        "type": "object",
        "description": "Body of `POST /v1/me/todos` and `PUT /v1/me/todos/{id}`.",
        "required": [
          "rich_text"
        ],
        "properties": {
          "rich_text": {
            "type": "string",
            "description": "The task, 1 to 255 characters."
          }
        }
      },
      "TokenInput": {
        "type": "object",
        "description": "Body of `POST /v1/auth/login/authenticator`.",
        "required": [
          "token"
        ],
        "properties": {
          "token": {
            "type": "string",
            "description": "The sign-in's token (`LoginChallenge.token`)."
          }
        }
      },
      "TopSoldColor": {
        "type": "object",
        "description": "A stone's sold slabs.",
        "required": [
          "slabs_sold",
          "square_feet"
        ],
        "properties": {
          "stone_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "The stone."
          },
          "slabs_sold": {
            "type": "integer",
            "format": "int64",
            "description": "Slabs sold."
          },
          "square_feet": {
            "type": "number",
            "format": "double",
            "description": "Their square feet."
          }
        }
      },
      "TopSoldStone": {
        "type": "object",
        "description": "A stone the signed-in user sold slabs of this month.",
        "required": [
          "stone_id",
          "stone_name",
          "slabs_sold",
          "square_feet"
        ],
        "properties": {
          "stone_id": {
            "type": "integer",
            "format": "int32",
            "description": "Stone id."
          },
          "stone_name": {
            "type": "string",
            "description": "Stone name, e.g. \"Absolute Black\"."
          },
          "slabs_sold": {
            "type": "integer",
            "format": "int64",
            "description": "Full slabs sold (remnants cut from them are not counted again)."
          },
          "square_feet": {
            "type": "string",
            "description": "Square feet of those slabs, decimal string; \"0.00\" when no slab has a size."
          }
        }
      },
      "Touch": {
        "type": "object",
        "description": "A touch the caller does.",
        "required": [
          "activity_id",
          "deal_id",
          "name",
          "kind",
          "stage_name"
        ],
        "properties": {
          "activity_id": {
            "type": "integer",
            "format": "int32",
            "description": "The deal activity (`PATCH /v1/deals/{id}/activities/{activity_id}` ticks it)."
          },
          "deal_id": {
            "type": "integer",
            "format": "int64",
            "description": "The deal the touch is for."
          },
          "customer_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "The deal's customer; null when the customer has no name."
          },
          "name": {
            "type": "string",
            "description": "What to do, e.g. \"Call\" or the step's text."
          },
          "kind": {
            "type": "string",
            "description": "`call`, `sms`, `email`, `task` or `move`."
          },
          "deadline": {
            "type": [
              "string",
              "null"
            ],
            "description": "Store wall time `YYYY-MM-DDTHH:MM:SS`."
          },
          "sub_stage_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "The deal's sub-stage; null when the stage has none."
          },
          "stage_name": {
            "type": "string",
            "description": "The deal's stage."
          }
        }
      },
      "TransactionDetail": {
        "type": "object",
        "description": "A transaction as its dialog shows it.",
        "required": [
          "sale",
          "slabs",
          "sinks"
        ],
        "properties": {
          "sale": {
            "$ref": "#/components/schemas/SaleHeader",
            "description": "The sale."
          },
          "slabs": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SaleSlabRow"
            },
            "description": "Its slabs, in order."
          },
          "sinks": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SaleSinkRow"
            },
            "description": "Its sinks."
          }
        }
      },
      "TransactionRow": {
        "type": "object",
        "description": "A sale in the list.",
        "required": [
          "id",
          "total_slabs",
          "status"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "Sale id."
          },
          "sale_date": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When it was sold."
          },
          "customer_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "Customer name."
          },
          "seller_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "Seller name."
          },
          "bundle": {
            "type": [
              "string",
              "null"
            ],
            "description": "Bundles, comma separated."
          },
          "cancelled_date": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When it was cancelled."
          },
          "installed_date": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When it was installed."
          },
          "stone_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "`name:ACTIVE|DELETED` per stone, comma separated."
          },
          "project_address": {
            "type": [
              "string",
              "null"
            ],
            "description": "Project address."
          },
          "sf": {
            "type": [
              "number",
              "null"
            ],
            "format": "double",
            "description": "Square feet (the shop view: each room's, added up)."
          },
          "bundle_with_cut": {
            "type": [
              "string",
              "null"
            ],
            "description": "`bundle:CUT|UNCUT:ACTIVE|DELETED` per slab, comma separated."
          },
          "all_cut": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int64",
            "description": "1 when every slab is cut."
          },
          "any_cut": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int64",
            "description": "1 when a slab is cut."
          },
          "total_slabs": {
            "type": "integer",
            "format": "int64",
            "description": "Slabs on the sale."
          },
          "cut_slabs": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int64",
            "description": "Of them cut."
          },
          "sink_type": {
            "type": [
              "string",
              "null"
            ],
            "description": "Sink models, joined."
          },
          "faucet_type": {
            "type": [
              "string",
              "null"
            ],
            "description": "Faucet models, joined."
          },
          "status": {
            "type": "string",
            "description": "`Sold`, `Partially Cut`, `Cut`, `Installed` or `Cancelled`."
          }
        }
      },
      "TranscribeInput": {
        "type": "object",
        "description": "Body of `POST /v1/ai/transcribe`.",
        "required": [
          "audio_base64",
          "mime"
        ],
        "properties": {
          "audio_base64": {
            "type": "string",
            "description": "The recording, base64 (at most 4 MB)."
          },
          "mime": {
            "type": "string",
            "description": "Its type as the browser recorded it: `audio/webm`, `audio/mp4`,\n`audio/ogg`, `audio/mpeg` or `audio/wav` (codec parameters allowed)."
          }
        },
        "additionalProperties": false
      },
      "Transcript": {
        "type": "object",
        "description": "What was said.",
        "required": [
          "text"
        ],
        "properties": {
          "text": {
            "type": "string",
            "description": "The words, as text; empty when nothing was said."
          }
        }
      },
      "TranscriptInput": {
        "type": "object",
        "description": "Body of `POST /v1/call-transcripts`.",
        "required": [
          "call_id"
        ],
        "properties": {
          "call_id": {
            "type": "string",
            "description": "`CloudTalk`'s numeric call id, the `RingCentral` call id, or a\nGranite Manager call `tx_<id>` (`Cdr.id` of `GET /v1/calls/telnyx`)."
          },
          "recording_link": {
            "type": [
              "string",
              "null"
            ],
            "description": "The call's `recording_link`: a `RingCentral` media token, a\n`CloudTalk` URL, or the Granite Manager call `tx_<id>`."
          }
        }
      },
      "TranscriptStatus": {
        "type": "string",
        "description": "The AI note's progress: `none` (not recorded or AI notes off),\n`pending`, `processing`, `done`, `failed` or `skipped`.",
        "enum": [
          "None",
          "Pending",
          "Processing",
          "Done",
          "Failed",
          "Skipped"
        ]
      },
      "Trigger": {
        "type": "string",
        "description": "What moves a job to another status.",
        "enum": [
          "confirmation_sent",
          "customer_confirmed",
          "customer_declined",
          "date_removed"
        ]
      },
      "TriggerOption": {
        "type": "object",
        "description": "One option of a catalog extra (`arrOptions[].id` of a `GET /v1/quote-extras` item).",
        "required": [
          "extra_id",
          "option_id"
        ],
        "properties": {
          "extra_id": {
            "type": "integer",
            "format": "int64",
            "description": "The catalog extra."
          },
          "option_id": {
            "type": "string",
            "description": "The option's id in that extra."
          }
        },
        "additionalProperties": false
      },
      "TypeName": {
        "type": "object",
        "description": "Body of `POST /v1/customer-types` and `PUT /v1/customer-types/{id}`.",
        "required": [
          "name"
        ],
        "properties": {
          "name": {
            "type": "string",
            "description": "1 to 255 characters."
          }
        }
      },
      "Typing": {
        "type": "object",
        "description": "`POST /v1/support/agent/conversations/{id}/typing`.",
        "required": [
          "typing"
        ],
        "properties": {
          "typing": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TypingAgent"
            },
            "description": "The other members writing an answer to it right now."
          }
        }
      },
      "TypingAgent": {
        "type": "object",
        "description": "A member writing an answer to a request right now.",
        "required": [
          "id"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "User id."
          },
          "name": {
            "type": [
              "string",
              "null"
            ],
            "description": "Name; null when the user has none."
          }
        }
      },
      "TypingChange": {
        "type": "object",
        "description": "Body of `POST /v1/support/agent/conversations/{id}/typing`.",
        "properties": {
          "typing": {
            "type": "boolean",
            "description": "False when the member emptied the answer box; left out: true."
          }
        },
        "additionalProperties": false
      },
      "UndoSend": {
        "type": "object",
        "description": "Whether Undo send is on.",
        "required": [
          "on"
        ],
        "properties": {
          "on": {
            "type": "boolean",
            "description": "On: a sent text or email waits 10 seconds with Undo before it goes out. Off: it goes\nout at once."
          }
        }
      },
      "UnpricedModel": {
        "type": "object",
        "description": "A model with free-looking usage and no price.",
        "required": [
          "model",
          "calls"
        ],
        "properties": {
          "model": {
            "type": "string",
            "description": "Model name."
          },
          "calls": {
            "type": "integer",
            "format": "int64",
            "description": "Successful calls logged at $0."
          }
        }
      },
      "Unread": {
        "type": "object",
        "description": "Unseen incoming calls of the last 30 days in a user's Recents, for the\nbadge.",
        "required": [
          "missed",
          "voicemail",
          "aiMessage"
        ],
        "properties": {
          "missed": {
            "type": "integer",
            "format": "int64",
            "description": "Unseen missed calls (nobody answered, no message left)."
          },
          "voicemail": {
            "type": "integer",
            "format": "int64",
            "description": "Unseen voicemails."
          },
          "aiMessage": {
            "type": "integer",
            "format": "int64",
            "description": "Unseen messages the AI Assistant took."
          }
        }
      },
      "UnreadCount": {
        "type": "object",
        "description": "The inbox badge.",
        "required": [
          "count"
        ],
        "properties": {
          "count": {
            "type": "integer",
            "format": "int64",
            "description": "Unread inbox threads; 0 when the company has no inbound email."
          },
          "latest_inbound_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int64",
            "description": "Newest unread message id, to notice new mail between polls."
          }
        }
      },
      "UnsavedDrawing": {
        "type": "object",
        "description": "An unsaved drawing.",
        "required": [
          "doc"
        ],
        "properties": {
          "doc": {
            "type": "object",
            "description": "The drawing (`QuoteDoc`)."
          }
        },
        "additionalProperties": false
      },
      "UpdateCompanyGoal": {
        "type": "object",
        "description": "`PUT /v1/company/sales-goal` body.",
        "properties": {
          "monthly_sales_goal": {
            "type": [
              "number",
              "null"
            ],
            "format": "double",
            "description": "The goal each month; null clears it."
          }
        }
      },
      "UpdateCrewChecklistInput": {
        "type": "object",
        "description": "Body of `PUT /v1/crew-checklists/{id}`.",
        "required": [
          "name"
        ],
        "properties": {
          "name": {
            "type": "string",
            "description": "The name: 1 to 120 characters (trimmed)."
          },
          "items": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "The checks, in order (replaces them): each 1 to 200 characters\n(trimmed; blank ones are dropped), at most 80. Jobs already saved stay\nas they were."
          }
        }
      },
      "UpdateSalesGoal": {
        "type": "object",
        "description": "A new monthly sales goal.",
        "required": [
          "monthly_sales_goal"
        ],
        "properties": {
          "monthly_sales_goal": {
            "type": "number",
            "format": "double",
            "description": "Goal for each month in USD, above 0 and below 10 billion; rounded to\ncents."
          }
        }
      },
      "UpdateSlab": {
        "type": "object",
        "description": "Body of `PATCH /v1/slabs/{id}`: the fields to change. Length and width\ngo together.",
        "properties": {
          "length": {
            "type": [
              "number",
              "null"
            ],
            "format": "double",
            "description": "New length in inches; a positive number, decimals allowed."
          },
          "width": {
            "type": [
              "number",
              "null"
            ],
            "format": "double",
            "description": "New width in inches; a positive number, decimals allowed."
          },
          "bundle": {
            "type": [
              "string",
              "null"
            ],
            "description": "New bundle label (the slab number); not empty."
          }
        },
        "additionalProperties": false
      },
      "Upload": {
        "type": "object",
        "description": "Where to upload, and the URL to give the record afterwards.",
        "required": [
          "upload_url",
          "url"
        ],
        "properties": {
          "upload_url": {
            "type": "string",
            "description": "`PUT` the file body here (valid 15 minutes) with the `Content-Type`\ngiven in the request."
          },
          "url": {
            "type": "string",
            "description": "Public URL of the file once uploaded; pass it to the record's route.\nFor `chats`, a private `s3://` reference to pass to the chat's route\n(no browser can open it; the chat answers with links that can)."
          },
          "token": {
            "type": [
              "string",
              "null"
            ],
            "description": "`emails` only: proof the caller uploaded `url`; send it with the\nattachment to `POST /v1/emails`."
          }
        }
      },
      "UploadFolder": {
        "type": "string",
        "description": "Where an upload goes; each record type takes files of its own folder.",
        "enum": [
          "stones",
          "sinks",
          "faucets",
          "deals",
          "emails",
          "events",
          "quotes",
          "template-images",
          "documents",
          "images",
          "supports",
          "bug-reports",
          "email-templates",
          "leads",
          "sms-uploads",
          "supplier-files",
          "company-logos",
          "quote-forms",
          "user-photos",
          "chats"
        ]
      },
      "UploadFromUrlRequest": {
        "type": "object",
        "description": "Body of `POST /v1/uploads/from-url`.",
        "required": [
          "folder",
          "url"
        ],
        "properties": {
          "folder": {
            "$ref": "#/components/schemas/UploadFolder",
            "description": "Folder the picture goes to; only `template-images` (pictures in rich\ntext: instructions, email templates and bodies) is accepted."
          },
          "url": {
            "type": "string",
            "description": "The picture's address on another website: `https://` on the standard\nport, at most 2048 characters. It must answer with a JPEG, PNG, GIF or\nWebP picture of at most 10 MB."
          }
        },
        "additionalProperties": false
      },
      "UploadRequest": {
        "type": "object",
        "description": "Body of `POST /v1/uploads`.",
        "required": [
          "folder",
          "file_name",
          "content_type"
        ],
        "properties": {
          "folder": {
            "$ref": "#/components/schemas/UploadFolder",
            "description": "Folder of the record the file is for."
          },
          "file_name": {
            "type": "string",
            "description": "Original file name; only its extension is kept."
          },
          "content_type": {
            "type": "string",
            "description": "MIME type of the file: `image/jpeg`, `image/png`, `image/webp`,\n`image/gif`, `image/heic` or `image/heif`; for `deals` and `documents` also PDF, Word,\nExcel, CSV and plain text; for `supplier-files` also PDF, CSV, TSV and plain text; for `sms-uploads` also AVIF, Word, Excel, PDF,\nCSV, plain text and `application/octet-stream` (a file the browser could\nnot type); for `emails` and `email-templates` any type; for `chats` images only. Send the same value\nas the `Content-Type` header of the `PUT`."
          }
        },
        "additionalProperties": false
      },
      "Usage": {
        "type": "object",
        "description": "How much a company used a metric in the last `usage_days` days. Companies\nwith no use are left out.",
        "required": [
          "company_id",
          "metric",
          "count"
        ],
        "properties": {
          "company_id": {
            "type": "integer",
            "format": "int32",
            "description": "The company."
          },
          "metric": {
            "type": "string",
            "description": "A `metrics` key."
          },
          "count": {
            "type": "integer",
            "format": "int64",
            "description": "How many times, at least 1."
          }
        }
      },
      "UsageInput": {
        "type": "object",
        "description": "Body of `POST /v1/me/onboarding/usage`.",
        "required": [
          "check_id"
        ],
        "properties": {
          "check_id": {
            "type": "string",
            "description": "The usage check the user just passed. Only checks the app may report\nitself are accepted (the event and both checks in `usage.rs`, such as\n`quote_views_opened`); checks the server reads only from its own data\nare refused."
          }
        }
      },
      "UsageOverview": {
        "type": "object",
        "description": "`GET /v1/ai-usage/overview`.",
        "required": [
          "kpis",
          "features",
          "companies",
          "unpriced_models",
          "calls",
          "total_calls",
          "page",
          "page_size"
        ],
        "properties": {
          "kpis": {
            "$ref": "#/components/schemas/OverviewKpis",
            "description": "Spend totals."
          },
          "features": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/OverviewFeature"
            },
            "description": "Features with calls in the range, by key."
          },
          "companies": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/OverviewCompany"
            },
            "description": "Live companies, by name."
          },
          "unpriced_models": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/UnpricedModel"
            },
            "description": "Models used for free without a price row."
          },
          "calls": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/OverviewCall"
            },
            "description": "The page of calls, newest first."
          },
          "total_calls": {
            "type": "integer",
            "format": "int64",
            "description": "Calls in the range."
          },
          "page": {
            "type": "integer",
            "format": "int64",
            "description": "The page shown."
          },
          "page_size": {
            "type": "integer",
            "format": "int64",
            "description": "Calls per page."
          }
        }
      },
      "UseCase": {
        "type": "string",
        "description": "What the texts are about (TCR's campaign use case).",
        "enum": [
          "Mixed",
          "LowVolume",
          "CustomerCare",
          "AccountNotification",
          "DeliveryNotification",
          "Marketing",
          "PollingVoting",
          "TwoFactor",
          "SecurityAlert",
          "FraudAlert",
          "PublicServiceAnnouncement",
          "HigherEducation"
        ]
      },
      "UserActivity": {
        "type": "object",
        "description": "Something a user did.",
        "required": [
          "id",
          "source",
          "action",
          "tags"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int64",
            "description": "Id of the row in its source."
          },
          "source": {
            "type": "string",
            "description": "`deal_activity`, `deal_note`, `email`, `cloudtalk_sms`,\n`ringcentral_sms`, `telnyx_sms` (a text by provider), ..."
          },
          "user_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int64",
            "description": "Who did it, when known."
          },
          "user_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "Their name."
          },
          "action": {
            "type": "string",
            "description": "\"Add Note\", \"Sent email\", ..."
          },
          "created_at": {
            "type": [
              "string",
              "null"
            ],
            "description": "When (UTC, ISO 8601)."
          },
          "customer_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "The customer (or user, for \"Created user\")."
          },
          "customer_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int64",
            "description": "The customer."
          },
          "deal_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int64",
            "description": "The deal."
          },
          "thread_id": {
            "type": [
              "string",
              "null"
            ],
            "description": "The email thread."
          },
          "summary": {
            "type": [
              "string",
              "null"
            ],
            "description": "One line shown next to the action: email subject, activity name, ..."
          },
          "contact": {
            "type": [
              "string",
              "null"
            ],
            "description": "Who it went to: an email address or phone number."
          },
          "body": {
            "type": [
              "string",
              "null"
            ],
            "description": "Longer text (capped), shown when the row is expanded."
          },
          "file_url": {
            "type": [
              "string",
              "null"
            ],
            "description": "Image or document URL."
          },
          "due_at": {
            "type": [
              "string",
              "null"
            ],
            "description": "A deal activity's deadline (UTC, ISO 8601)."
          },
          "tags": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Labels: stage, amount, \"Received\", ..."
          }
        }
      },
      "UserChanges": {
        "type": "object",
        "description": "Body of `PUT /v1/admin/users/{id}`.",
        "required": [
          "name",
          "company_id"
        ],
        "properties": {
          "name": {
            "type": "string",
            "description": "Name (may stay empty while their invite is pending)."
          },
          "email": {
            "type": [
              "string",
              "null"
            ],
            "description": "New email; omitted or empty keeps the current one (every user has one)."
          },
          "phone_number": {
            "type": [
              "string",
              "null"
            ],
            "description": "Phone (10+ characters) or empty."
          },
          "company_id": {
            "type": "integer",
            "format": "int32",
            "description": "Move them to this company: superusers any, Super Admins one they are\nSuper Admin of (from one of those); others keep the user's company."
          },
          "positions": {
            "type": "array",
            "items": {
              "type": "integer",
              "format": "int32"
            },
            "description": "Position ids."
          },
          "marketing_company_ids": {
            "type": "array",
            "items": {
              "type": "integer",
              "format": "int32"
            },
            "description": "External marketing: the companies they market for."
          },
          "superadmin_company_ids": {
            "type": "array",
            "items": {
              "type": "integer",
              "format": "int32"
            },
            "description": "The companies they are Super Admin of (superusers any; Super Admins of\nthe user's company only their own)."
          },
          "template_company_ids": {
            "type": [
              "array",
              "null"
            ],
            "items": {
              "type": "integer",
              "format": "int32"
            },
            "description": "Template Guy: the other companies they work in besides their own\n(superusers any; Super Admins of the user's company only their own).\nOmitted keeps them."
          },
          "installer_company_ids": {
            "type": [
              "array",
              "null"
            ],
            "items": {
              "type": "integer",
              "format": "int32"
            },
            "description": "Installer: the same."
          },
          "is_admin": {
            "type": "boolean",
            "description": "Admin access (always on for Super Admins)."
          },
          "cloudtalk_agent_id": {
            "type": [
              "string",
              "null"
            ],
            "description": "`CloudTalk` agent id (digits) or empty."
          },
          "cloudtalk_phone_number": {
            "type": [
              "string",
              "null"
            ],
            "description": "`CloudTalk` number (10+ digits) or empty."
          },
          "ringcentral_phone_number": {
            "type": [
              "string",
              "null"
            ],
            "description": "`RingCentral` number (10+ digits) or empty; the extension is looked up\nfrom it."
          }
        },
        "additionalProperties": false
      },
      "UserForm": {
        "type": "object",
        "description": "The edit form.",
        "required": [
          "user",
          "positions",
          "marketing_company_ids",
          "superadmin_company_ids",
          "template_company_ids",
          "installer_company_ids",
          "companies",
          "logged_in_is_superuser",
          "superadmin_companies",
          "move_companies",
          "has_cloudtalk_api",
          "has_ringcentral_api",
          "other_scheduling_managers"
        ],
        "properties": {
          "user": {
            "$ref": "#/components/schemas/EditedUser",
            "description": "The user."
          },
          "positions": {
            "type": "array",
            "items": {
              "type": "integer",
              "format": "int32"
            },
            "description": "Their position ids."
          },
          "marketing_company_ids": {
            "type": "array",
            "items": {
              "type": "integer",
              "format": "int32"
            },
            "description": "Companies they market for (external marketing)."
          },
          "superadmin_company_ids": {
            "type": "array",
            "items": {
              "type": "integer",
              "format": "int32"
            },
            "description": "Companies they are Super Admin of."
          },
          "template_company_ids": {
            "type": "array",
            "items": {
              "type": "integer",
              "format": "int32"
            },
            "description": "Companies they are Template Guy in (their own and those a super admin\nadded; the caller picks from `superadmin_companies`)."
          },
          "installer_company_ids": {
            "type": "array",
            "items": {
              "type": "integer",
              "format": "int32"
            },
            "description": "Companies they are Installer in, the same way."
          },
          "companies": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CompanyName"
            },
            "description": "Companies the caller may grant external marketing for: superusers\nevery one; others the user's own, the ones already granted and, for a\nSuper Admin, the companies they are Super Admin of."
          },
          "logged_in_is_superuser": {
            "type": "boolean",
            "description": "The caller is a superuser."
          },
          "superadmin_companies": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CompanyName"
            },
            "description": "The companies the caller may make the user Super Admin of (superusers:\nevery one; Super Admins of the user's company: the ones they are Super\nAdmin of); empty when they can't."
          },
          "move_companies": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CompanyName"
            },
            "description": "Companies the caller may move the user to (superusers: every one;\nSuper Admins: the ones they are Super Admin of, when the user is in\none of them); empty when they can't move them."
          },
          "has_cloudtalk_api": {
            "type": "boolean",
            "description": "Their company has `CloudTalk`."
          },
          "has_ringcentral_api": {
            "type": "boolean",
            "description": "Their company has `RingCentral`."
          },
          "other_scheduling_managers": {
            "type": "integer",
            "format": "int64",
            "description": "Other live Scheduling Managers of their company: at 0 the form warns\nbefore it takes the position off them (survey texts stop)."
          }
        }
      },
      "UserLimit": {
        "type": "object",
        "description": "How many users a company has and may have.",
        "required": [
          "company_id",
          "current_count"
        ],
        "properties": {
          "company_id": {
            "type": "integer",
            "format": "int32",
            "description": "Company id."
          },
          "current_count": {
            "type": "integer",
            "format": "int64",
            "description": "Users counting toward the limit (check-in-only accounts do not)."
          },
          "max_users": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "The limit; null for none."
          }
        }
      },
      "UserNameRow": {
        "type": "object",
        "description": "A user's id and display name.",
        "required": [
          "id"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "User id."
          },
          "name": {
            "type": [
              "string",
              "null"
            ],
            "description": "Display name."
          }
        }
      },
      "UserRecordingVoice": {
        "type": "object",
        "description": "Body of `PUT /v1/phone/admin/users/{id}/recording-voice`.",
        "required": [
          "on"
        ],
        "properties": {
          "on": {
            "type": "boolean",
            "description": "True: the user's calls say the recording notice."
          }
        }
      },
      "UsersPage": {
        "type": "object",
        "description": "The Users page.",
        "required": [
          "users",
          "companies",
          "is_super_user",
          "can_grant_super_admin",
          "user_limits",
          "has_cloudtalk_api",
          "has_ringcentral_api"
        ],
        "properties": {
          "users": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ManagedUser"
            },
            "description": "The users, live only."
          },
          "companies": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CompanyName"
            },
            "description": "Companies the caller may pick."
          },
          "company_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "The company listed; null for every company (superusers)."
          },
          "is_super_user": {
            "type": "boolean",
            "description": "The caller is a superuser."
          },
          "can_grant_super_admin": {
            "type": "boolean",
            "description": "The caller may make users Super Admin (superusers, and Super Admins of\nthe company)."
          },
          "user_limits": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/UserLimit"
            },
            "description": "Each pickable company's user count and limit."
          },
          "has_cloudtalk_api": {
            "type": "boolean",
            "description": "The listed company has `CloudTalk`."
          },
          "has_ringcentral_api": {
            "type": "boolean",
            "description": "The listed company has `RingCentral`."
          }
        }
      },
      "Verification": {
        "type": "string",
        "description": "What the workflow proved about the agent's commits.",
        "enum": [
          "verified",
          "unverified",
          "not_applicable"
        ]
      },
      "Vertical": {
        "type": "string",
        "description": "The brand's industry (TCR's verticals).",
        "enum": [
          "Agriculture",
          "Communication",
          "Construction",
          "Education",
          "Energy",
          "Entertainment",
          "Financial",
          "Gambling",
          "Government",
          "Healthcare",
          "Hospitality",
          "HumanResources",
          "Insurance",
          "Legal",
          "Manufacturing",
          "Ngo",
          "Political",
          "Postal",
          "Professional",
          "RealEstate",
          "Retail",
          "Technology",
          "Transportation"
        ]
      },
      "ViaCellInput": {
        "type": "object",
        "description": "Body of `POST /v1/phone/calls/via-cell`.",
        "required": [
          "to"
        ],
        "properties": {
          "to": {
            "type": "string",
            "description": "The number to call, US or Canada (E.164 or 10 digits)."
          },
          "callerNumberId": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "The caller ID the customer sees (one of my caller IDs); null = my\ndefault."
          },
          "customerId": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "The customer being called, when known; ignored unless a customer of\nmy company (the number's customer is used then)."
          }
        }
      },
      "ViewAppointment": {
        "type": "object",
        "description": "One of the customer's appointments (a schedule event). Only what the\ncustomer needs: never the event's title, description or notes, which are\nthe shop's own words.",
        "required": [
          "id",
          "start_date",
          "end_date",
          "all_day",
          "unscheduled",
          "photos"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "Event id."
          },
          "kind": {
            "type": [
              "string",
              "null"
            ],
            "description": "`templates`, `installations` or `estimates` (the built-in calendars);\n`None` for any other calendar."
          },
          "start_date": {
            "type": "string",
            "description": "Start (ISO 8601, UTC). While `unscheduled` it only holds when the\nevent was added."
          },
          "end_date": {
            "type": "string",
            "description": "End (ISO 8601, UTC)."
          },
          "all_day": {
            "type": "boolean",
            "description": "The whole day, no time."
          },
          "unscheduled": {
            "type": "boolean",
            "description": "Waiting for a date: the shop has not picked the day yet."
          },
          "location": {
            "type": [
              "string",
              "null"
            ],
            "description": "The address."
          },
          "crew_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "Who comes (the person the event is assigned to)."
          },
          "crew_status": {
            "type": [
              "string",
              "null"
            ],
            "description": "How the crew is getting on today: `on_my_way`, `arrived` or\n`completed`."
          },
          "photos": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "The crew's job photos for the customer (the job card's Photos\nbutton), oldest first. Photos in the event's comments are not here."
          }
        }
      },
      "ViewContact": {
        "type": "object",
        "description": "Who the customer deals with.",
        "properties": {
          "company_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "The company's name."
          },
          "company_address": {
            "type": [
              "string",
              "null"
            ],
            "description": "The company's address."
          },
          "rep": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/ViewRep",
                "description": "The customer's sales rep (their **Sales Rep**, else whoever sold\ntheir latest project); `None` when neither."
              },
              {
                "type": "null"
              }
            ]
          }
        }
      },
      "ViewCrew": {
        "type": "object",
        "description": "The crew on the way to one of the customer's visits.",
        "required": [
          "latitude",
          "longitude",
          "recorded_at"
        ],
        "properties": {
          "crew_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "Who is coming."
          },
          "latitude": {
            "type": "number",
            "format": "double",
            "description": "Where their phone was last."
          },
          "longitude": {
            "type": "number",
            "format": "double",
            "description": "Where their phone was last."
          },
          "recorded_at": {
            "type": "string",
            "description": "When (ISO 8601, UTC)."
          },
          "minutes_away": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int64",
            "description": "Driving minutes from there to the visit in today's traffic; `None`\nwhen Google cannot tell."
          }
        }
      },
      "ViewDocument": {
        "type": "object",
        "description": "A document sent to the customer.",
        "required": [
          "kind",
          "id",
          "name",
          "status"
        ],
        "properties": {
          "kind": {
            "type": "string",
            "description": "`contract` (sent for signature) or `quote`."
          },
          "id": {
            "type": "integer",
            "format": "int64",
            "description": "The signature request or the quote."
          },
          "name": {
            "type": "string",
            "description": "Its name."
          },
          "status": {
            "type": "string",
            "description": "A contract's `sent`, `viewed` or `signed`; a quote's own status."
          },
          "created_at": {
            "type": [
              "string",
              "null"
            ],
            "description": "When it was made (ISO 8601, UTC)."
          },
          "link": {
            "type": [
              "string",
              "null"
            ],
            "description": "A quote's page on this site (`/quote-portal/<token>`); a contract\nopens with `.../documents/{id}`."
          }
        }
      },
      "ViewGate": {
        "type": "object",
        "description": "Whether the visitor may see the page, and where a code would go.",
        "required": [
          "verified",
          "has_email",
          "has_phone",
          "code_sent"
        ],
        "properties": {
          "verified": {
            "type": "boolean",
            "description": "The visitor entered a code for this page (valid for 7 days)."
          },
          "customer_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "The customer's name, once verified."
          },
          "has_email": {
            "type": "boolean",
            "description": "The customer has an email a code can go to."
          },
          "masked_email": {
            "type": [
              "string",
              "null"
            ],
            "description": "That email, masked (`a***@example.com`)."
          },
          "has_phone": {
            "type": "boolean",
            "description": "The customer has a phone a code can be texted to, and the company can\ntext it."
          },
          "masked_phone": {
            "type": [
              "string",
              "null"
            ],
            "description": "That phone, masked (`***-***-0188`)."
          },
          "code_sent": {
            "type": "boolean",
            "description": "A code was sent and has not expired."
          },
          "code_channel": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/CodeChannel",
                "description": "How the pending code went; null without one."
              },
              {
                "type": "null"
              }
            ]
          }
        }
      },
      "ViewJob": {
        "type": "object",
        "description": "One job of the customer: a deal they signed, or a sale that is not part\nof such a deal. The same jobs the CRM lists on the customer's Projects\ntab (`GET /v1/customers/{id}/projects`).",
        "required": [
          "project_key",
          "price_cents",
          "open_cents",
          "invoice_ids"
        ],
        "properties": {
          "project_key": {
            "type": "string",
            "description": "`deal-<deal id>` or `sale-<sale id>`."
          },
          "name": {
            "type": [
              "string",
              "null"
            ],
            "description": "The deal's title, else the address of the work; null without either."
          },
          "price_cents": {
            "type": "integer",
            "format": "int64",
            "description": "What it costs, in US cents: the deal's amount, else its sales' prices."
          },
          "open_cents": {
            "type": "integer",
            "format": "int64",
            "description": "What the customer can still pay on it on their page, in US cents:\nthe price less what was paid, what is on its way and the links the\ncompany sent that nobody paid yet."
          },
          "invoice_ids": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "The `QuickBooks` invoice ids of its quotes, so an invoice's Pay picks\nthis job."
          }
        }
      },
      "ViewPayment": {
        "type": "object",
        "description": "A payment as the customer sees it: the company's side of the fee is left\nout.",
        "required": [
          "id",
          "project_key",
          "method",
          "status",
          "amount_cents",
          "customer_fee_cents",
          "refunded_cents",
          "url",
          "created_at"
        ],
        "properties": {
          "id": {
            "type": "string",
            "description": "The payment's id (`pay_...`)."
          },
          "project_key": {
            "type": "string",
            "description": "The job it is for: `deal-<deal id>` or `sale-<sale id>`, one of\n`projects`."
          },
          "project_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "The job's name: the deal's title, else the sale's address; null\nwithout either."
          },
          "sale_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "The sale it was made for, when it was made for a sale."
          },
          "method": {
            "$ref": "#/components/schemas/PaymentMethod",
            "description": "How it is paid."
          },
          "status": {
            "$ref": "#/components/schemas/CustomerPaymentStatus",
            "description": "Where it is; withdrawn links are not listed."
          },
          "amount_cents": {
            "type": "integer",
            "format": "int32",
            "description": "What goes toward the job, in US cents."
          },
          "customer_fee_cents": {
            "type": "integer",
            "format": "int32",
            "description": "The customer's part of the fee, added on top."
          },
          "refunded_cents": {
            "type": "integer",
            "format": "int32",
            "description": "What was given back to the customer, in US cents (0 unless refunded)."
          },
          "url": {
            "type": "string",
            "description": "The page to pay on, while `created`."
          },
          "failure_reason": {
            "type": [
              "string",
              "null"
            ],
            "description": "Why it failed, as a short plain phrase (\"insufficient funds\"); null\nunless `failed`."
          },
          "created_at": {
            "type": "string",
            "description": "When the link was made (ISO 8601, UTC)."
          }
        }
      },
      "ViewProject": {
        "type": "object",
        "description": "One of the customer's projects (a sale).",
        "required": [
          "id"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "Sale id."
          },
          "sale_date": {
            "type": [
              "string",
              "null"
            ],
            "description": "When it was sold (ISO 8601, UTC)."
          },
          "price": {
            "type": [
              "number",
              "null"
            ],
            "format": "double",
            "description": "Price."
          },
          "seller_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "The sales rep."
          },
          "stone_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "The stone."
          },
          "stone_pictures": {
            "type": [
              "string",
              "null"
            ],
            "description": "The stone's pictures, comma-separated URLs."
          },
          "sink": {
            "type": [
              "string",
              "null"
            ],
            "description": "The sink."
          },
          "status": {
            "type": [
              "string",
              "null"
            ],
            "description": "`Sold`, `Partially Cut`, `Cut`, `Installed` or `Cancelled`."
          },
          "project_address": {
            "type": [
              "string",
              "null"
            ],
            "description": "Where the work is."
          },
          "square_feet": {
            "type": [
              "number",
              "null"
            ],
            "format": "double",
            "description": "Countertop area in square feet."
          },
          "installed_date": {
            "type": [
              "string",
              "null"
            ],
            "description": "When it was installed (ISO 8601, UTC)."
          },
          "slab_pictures": {
            "type": [
              "string",
              "null"
            ],
            "description": "Pictures of the customer's own slabs, comma-separated URLs."
          },
          "cut_date": {
            "type": [
              "string",
              "null"
            ],
            "description": "When the last slab was cut, once every slab is (ISO 8601, UTC)."
          },
          "template_date": {
            "type": [
              "string",
              "null"
            ],
            "description": "Its latest template visit with a date (ISO 8601, UTC): past, or coming\nand Confirmed. A visit belongs to a project by [`project_of`]."
          },
          "install_date": {
            "type": [
              "string",
              "null"
            ],
            "description": "Its latest installation visit with a date (ISO 8601, UTC): past, or\ncoming and Confirmed."
          }
        }
      },
      "ViewRep": {
        "type": "object",
        "description": "The customer's sales rep.",
        "required": [
          "email"
        ],
        "properties": {
          "name": {
            "type": [
              "string",
              "null"
            ],
            "description": "Name."
          },
          "email": {
            "type": "string",
            "description": "Work email."
          },
          "phone": {
            "type": [
              "string",
              "null"
            ],
            "description": "Their own phone, else their Granite Manager line, else their CloudTalk\nor `RingCentral` number (as the AI's emails sign)."
          }
        }
      },
      "Visibility": {
        "type": "object",
        "description": "Body of `PUT /v1/teach-mode/questions/{id}/visibility`.",
        "required": [
          "visible"
        ],
        "properties": {
          "visible": {
            "type": "boolean",
            "description": "Published to employees (false: a draft)."
          }
        }
      },
      "VisitKind": {
        "type": "string",
        "description": "A kind of visit a customer can book online.",
        "enum": [
          "estimate",
          "showroom"
        ]
      },
      "VisitKindOption": {
        "type": "object",
        "description": "A kind of visit offered.",
        "required": [
          "kind",
          "title",
          "description",
          "minutes"
        ],
        "properties": {
          "kind": {
            "$ref": "#/components/schemas/VisitKind",
            "description": "`estimate` or `showroom`."
          },
          "title": {
            "type": "string",
            "description": "Its name for the customer, e.g. \"In-home estimate\"."
          },
          "description": {
            "type": "string",
            "description": "One line on what happens."
          },
          "minutes": {
            "type": "integer",
            "format": "int32",
            "description": "How long it takes, in minutes.",
            "minimum": 0
          }
        }
      },
      "VisitOptions": {
        "type": "object",
        "description": "`GET /v1/public/customer-view/{company_id}/{view_id}/visits/options`.",
        "required": [
          "available",
          "time_zone",
          "kinds",
          "days",
          "salespeople"
        ],
        "properties": {
          "available": {
            "type": "boolean",
            "description": "Some time is open: false when the company has no booking hours, no\nsalespeople, no Estimates calendar, or everyone is booked."
          },
          "time_zone": {
            "type": "string",
            "description": "IANA time zone the company's hours are in: show the times in it."
          },
          "kinds": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/VisitKindOption"
            },
            "description": "The kinds of visit; every one takes the same times."
          },
          "address": {
            "type": [
              "string",
              "null"
            ],
            "description": "The customer's address on file (where an in-home estimate goes), or\nnull."
          },
          "showroom_address": {
            "type": [
              "string",
              "null"
            ],
            "description": "The showroom's address, or null."
          },
          "email": {
            "type": [
              "string",
              "null"
            ],
            "description": "Where the confirmation is emailed, or null when the customer has no\nemail (then it is texted)."
          },
          "days": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/OpenDay"
            },
            "description": "The days of the next 30 that have open times."
          },
          "salespeople": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/VisitSalesperson"
            },
            "description": "The Sales Reps and Sales Managers free at some open time, by name."
          }
        }
      },
      "VisitSalesperson": {
        "type": "object",
        "description": "A salesperson a visit can be booked with.",
        "required": [
          "id",
          "name"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "description": "User id; send it as `salesperson_id` to book with them."
          },
          "name": {
            "type": "string",
            "description": "Their name."
          }
        }
      },
      "WaitingCustomer": {
        "type": "object",
        "description": "A customer whose text waits for the caller's reply.",
        "required": [
          "phone_digits",
          "text",
          "at"
        ],
        "properties": {
          "phone_digits": {
            "type": "string",
            "description": "10 digits."
          },
          "customer_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "The customer with that phone; null when it is on no customer."
          },
          "customer_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "That customer's name."
          },
          "text": {
            "type": "string",
            "description": "Their last text."
          },
          "at": {
            "type": "string",
            "format": "date-time",
            "description": "When they sent it."
          }
        }
      },
      "WalkIn": {
        "type": "object",
        "description": "Body of `PUT /v1/customer-sources/{id}/walk-in`.",
        "required": [
          "walk_in"
        ],
        "properties": {
          "walk_in": {
            "type": "boolean",
            "description": "Whether the source's customers count as walk-ins."
          }
        }
      },
      "WebDeviceRegistration": {
        "type": "object",
        "description": "Body of `POST /v1/phone/web/devices`.",
        "properties": {
          "deviceName": {
            "type": "string",
            "description": "Shown in \"Signed-in devices\", e.g. \"Chrome on Windows\" (cut to 100\ncharacters; empty = \"Browser\")."
          }
        }
      },
      "WebLink": {
        "type": "object",
        "description": "A link that opens a CRM page signed in.",
        "required": [
          "link_path",
          "expires_in"
        ],
        "properties": {
          "link_path": {
            "type": "string",
            "description": "The link's path on this API (`/v1/auth/web-link/{token}`): open the\nAPI's base URL followed by it in the phone's browser."
          },
          "expires_in": {
            "type": "integer",
            "format": "int64",
            "description": "Seconds the link works for (120)."
          }
        }
      },
      "WebLinkInput": {
        "type": "object",
        "description": "Body of `POST /v1/auth/web-link`.",
        "required": [
          "path"
        ],
        "properties": {
          "path": {
            "type": "string",
            "description": "The CRM page to open: a path on the company's CRM host, starting with\none `/`, e.g. `/employee/quote/12` (a quote's editor) or\n`/employee/quotes/add` (a new quote). At most 512 characters."
          }
        },
        "additionalProperties": false
      },
      "WebPhone": {
        "type": "object",
        "description": "This browser's phone.",
        "required": [
          "id",
          "sessionId",
          "sipUsername",
          "callKey",
          "serverTime"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int64",
            "description": "The browser's phone device: send it as the `X-Granite-Device-Id` SIP\nheader of every call, and use it in `/v1/phone/web/devices/{id}/...`."
          },
          "sessionId": {
            "type": "integer",
            "format": "int64",
            "description": "Its device session (`SignedInDevice.id` in `GET /v1/me/devices`)."
          },
          "sipUsername": {
            "type": "string",
            "description": "Its SIP user on Telnyx (`gencred...`)."
          },
          "callKey": {
            "type": "string",
            "description": "The key that signs this browser's calls (`X-Granite-Call-Auth`, made\nas the app makes it): base64url of 32 bytes. Keep it in memory only;\nregistering again gives it again."
          },
          "serverTime": {
            "type": "string",
            "format": "date-time",
            "description": "Our clock now (RFC 3339), to sign calls with."
          }
        }
      },
      "WebPhoneBootstrap": {
        "type": "object",
        "description": "`GET /v1/phone/web/bootstrap`.",
        "required": [
          "serverTime",
          "callingEnabled",
          "recordingMode",
          "callerIds",
          "settings",
          "availability",
          "coworkers"
        ],
        "properties": {
          "serverTime": {
            "type": "string",
            "format": "date-time",
            "description": "Our clock now (RFC 3339): the browser signs its calls with our time,\nso a wrong computer clock does not get them refused."
          },
          "callingEnabled": {
            "type": "boolean",
            "description": "The browser can call and ring: the company's calling is on, with its\ncredential connection set. False: show \"calling is off\"."
          },
          "recordingMode": {
            "$ref": "#/components/schemas/RecordingMode",
            "description": "Which calls the company records: `off`, `inbound` or `both`."
          },
          "callerIds": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CallerId"
            },
            "description": "The numbers the user may call from (direct lines first); empty: the\nuser cannot call."
          },
          "defaultNumberId": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "The caller ID calls use unless another is picked: the user's default\nwhile it is theirs, else their first direct line, else the first."
          },
          "settings": {
            "$ref": "#/components/schemas/PhoneSettings",
            "description": "The user's phone settings (the verified cell for Call via my cell)."
          },
          "availability": {
            "$ref": "#/components/schemas/Availability",
            "description": "Whether calls ring the user now (Do not disturb, working hours)."
          },
          "coworkers": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Coworker"
            },
            "description": "The company's other users with a phone number, by name: the\nphone's Contacts tab lists them to call."
          }
        }
      },
      "WebPresence": {
        "type": "object",
        "description": "Body of `PUT /v1/phone/web/devices/{id}/presence`.",
        "required": [
          "online"
        ],
        "properties": {
          "online": {
            "type": "boolean",
            "description": "True: the tab is connected to Telnyx and rings (for the next 150\nseconds; say it again every minute). False: it stops ringing at once."
          }
        }
      },
      "WebhookOk": {
        "type": "object",
        "description": "The webhook was taken.",
        "required": [
          "ok"
        ],
        "properties": {
          "ok": {
            "type": "boolean",
            "description": "Always true."
          }
        }
      },
      "WebhookReceived": {
        "type": "object",
        "description": "Answer to Stripe.",
        "required": [
          "received"
        ],
        "properties": {
          "received": {
            "type": "boolean",
            "description": "Always true."
          }
        }
      },
      "WeekStart": {
        "type": "string",
        "description": "The first day of a week.",
        "enum": [
          "sunday",
          "monday"
        ]
      },
      "WidgetAction": {
        "type": "string",
        "description": "What a user did with a widget.",
        "enum": [
          "click",
          "change",
          "add",
          "remove"
        ]
      },
      "WidgetAnalytics": {
        "type": "object",
        "description": "Dashboard widget analytics.",
        "required": [
          "top_used",
          "events",
          "current_widgets"
        ],
        "properties": {
          "top_used": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/WidgetUse"
            },
            "description": "Uses per user, widget and target, most first."
          },
          "events": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/WidgetEvent"
            },
            "description": "Every event, newest first."
          },
          "current_widgets": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/DashboardWidget"
            },
            "description": "Every user's dashboard widgets, by company, user and position."
          }
        }
      },
      "WidgetEvent": {
        "type": "object",
        "description": "One use of a dashboard widget, for product analytics.",
        "required": [
          "widget_id",
          "action",
          "target"
        ],
        "properties": {
          "widget_id": {
            "$ref": "#/components/schemas/DashboardWidget",
            "description": "The widget used."
          },
          "action": {
            "$ref": "#/components/schemas/WidgetAction",
            "description": "What was done."
          },
          "target": {
            "type": "string",
            "description": "What in the widget was used, e.g. `quick-links` or `sales-goal`;\n1 to 64 characters after trimming."
          }
        }
      },
      "WidgetLayout": {
        "type": "object",
        "description": "`GET /v1/stats/widget-layout`.",
        "required": [
          "hidden_by_default"
        ],
        "properties": {
          "saved": {
            "type": [
              "object",
              "null"
            ],
            "description": "The layout this browser saved for the company, as the page stored it;\nnull when none."
          },
          "hidden_by_default": {
            "type": "boolean",
            "description": "The company starts with an empty board (new companies) instead of the\ndefault widgets."
          }
        }
      },
      "WidgetUse": {
        "type": "object",
        "description": "How often users clicked or changed something on a widget.",
        "required": [
          "company_id",
          "user_id",
          "widget_id",
          "target",
          "action",
          "uses"
        ],
        "properties": {
          "company_id": {
            "type": "integer",
            "format": "int32",
            "description": "The company."
          },
          "company_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "Its name."
          },
          "user_id": {
            "type": "integer",
            "format": "int32",
            "description": "The user."
          },
          "user_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "Their name."
          },
          "widget_id": {
            "type": "string",
            "description": "The widget."
          },
          "target": {
            "type": "string",
            "description": "What was clicked or changed."
          },
          "action": {
            "type": "string",
            "description": "`click` or `change`."
          },
          "uses": {
            "type": "integer",
            "format": "int64",
            "description": "How many times."
          }
        }
      },
      "WonDeal": {
        "type": "object",
        "description": "A won deal, its customer and when it was marked won.",
        "required": [
          "id",
          "customer_id",
          "walk_in",
          "won_at"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "format": "int64"
          },
          "customer_id": {
            "type": "integer",
            "format": "int32"
          },
          "customer_name": {
            "type": [
              "string",
              "null"
            ]
          },
          "customer_source": {
            "type": [
              "string",
              "null"
            ],
            "description": "The customer's source key (`check-in`, `leads`, `call-in`, ...)."
          },
          "referral_source": {
            "type": [
              "string",
              "null"
            ]
          },
          "walk_in": {
            "type": "boolean",
            "description": "The customer came in as a walk-in (the company's walk-in sources)."
          },
          "customer_created_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When the customer was added (for a walk-in: the day they came in)."
          },
          "user_id": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "The deal's sales rep."
          },
          "sales_rep": {
            "type": [
              "string",
              "null"
            ]
          },
          "amount": {
            "type": [
              "string",
              "null"
            ]
          },
          "won_at": {
            "type": "string",
            "format": "date-time",
            "description": "When the deal was marked won (the quote's Mark as sold, or the deal\nset to Won): the moment of the sale."
          }
        }
      },
      "WorkingDay": {
        "type": "object",
        "description": "One time range of a weekday.",
        "required": [
          "day",
          "start",
          "end"
        ],
        "properties": {
          "day": {
            "type": "integer",
            "format": "int32",
            "description": "The weekday: 0 = Sunday, 1 = Monday ... 6 = Saturday.",
            "minimum": 0
          },
          "start": {
            "type": "string",
            "description": "Local start, `HH:MM` (24-hour), e.g. `08:00`."
          },
          "end": {
            "type": "string",
            "description": "Local end, `HH:MM`, after `start`; `24:00` = midnight at the end of\nthe day."
          }
        }
      },
      "WorkingHours": {
        "type": "object",
        "description": "When a user takes calls (null in the API: always). Outside these hours\ntheir phones do not ring; calls go to the number's fallback and still\nshow in Recents.",
        "required": [
          "tz",
          "days"
        ],
        "properties": {
          "tz": {
            "type": "string",
            "description": "IANA time zone the hours are in, e.g. `America/Indiana/Indianapolis`."
          },
          "days": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/WorkingDay"
            },
            "description": "The time ranges, any number per weekday (at most 28 in all, at least\none); a weekday without a range is a day off."
          }
        }
      }
    },
    "securitySchemes": {
      "agent_runner_key": {
        "type": "http",
        "scheme": "bearer",
        "description": "`AGENT_RUNNER_KEY`, sent by the claude-job-runner."
      },
      "agent_token": {
        "type": "http",
        "scheme": "bearer",
        "description": "An agent token (`agt_...`, `POST /v1/ai/agentic-questions/{id}/agent-token`), sent by the Agent page's agent."
      },
      "autofix_callback": {
        "type": "http",
        "scheme": "bearer",
        "description": "`POSTHOG_AUTOFIX_CALLBACK_SECRET`, sent by the posthog-autofix GitHub workflow."
      },
      "device_token": {
        "type": "apiKey",
        "in": "header",
        "name": "X-Granite-Device",
        "description": "Device token of a signed-in Granite Manager app (`POST /v1/auth/device-sessions`)."
      },
      "job_key": {
        "type": "apiKey",
        "in": "header",
        "name": "Authorization",
        "description": "`LAMBDA_KEY`, sent by the time-triggered Lambda."
      },
      "session_cookie": {
        "type": "apiKey",
        "in": "cookie",
        "name": "__session",
        "description": "Signed React Router session cookie set by the Granite Manager login."
      }
    }
  },
  "tags": [
    {
      "name": "me",
      "description": "The signed-in user"
    },
    {
      "name": "customers",
      "description": "Customers and leads of the company"
    },
    {
      "name": "users",
      "description": "Other users of the company"
    },
    {
      "name": "stones",
      "description": "Stones (slab materials) and their slab inventory"
    },
    {
      "name": "instructions",
      "description": "The company's how-to pages"
    },
    {
      "name": "places",
      "description": "Address suggestions from Google Places"
    },
    {
      "name": "calls",
      "description": "Calls through the company's telephony provider"
    },
    {
      "name": "quotes",
      "description": "Quote tools"
    },
    {
      "name": "auth",
      "description": "Sign-in, sign-out, password reset and the session cookie"
    },
    {
      "name": "delayed",
      "description": "Scheduled emails and texts"
    },
    {
      "name": "ai-usage",
      "description": "AI usage for the super-user dashboard"
    },
    {
      "name": "ai",
      "description": "AI helpers for writing messages"
    },
    {
      "name": "public",
      "description": "The public showroom and self sign-up; no session needed"
    },
    {
      "name": "catalog",
      "description": "Suppliers, colors and stone types the inventory forms pick from"
    },
    {
      "name": "uploads",
      "description": "Presigned uploads of images to storage"
    },
    {
      "name": "sales",
      "description": "Sales of slabs, sinks and faucets to customers"
    },
    {
      "name": "slabs",
      "description": "Single slabs and remnants of a stone"
    },
    {
      "name": "sinks",
      "description": "Sink models and their stock"
    },
    {
      "name": "faucets",
      "description": "Faucet models and their stock"
    },
    {
      "name": "checklists",
      "description": "Post-installation checklists installers fill in and customers sign"
    },
    {
      "name": "shop",
      "description": "The fabrication shop's own pages"
    },
    {
      "name": "reports",
      "description": "Admin reports"
    },
    {
      "name": "marketing",
      "description": "The marketing team's portal: a company's leads"
    },
    {
      "name": "company",
      "description": "The company the request acts in"
    },
    {
      "name": "stats",
      "description": "The signed-in user's own sales and messaging numbers"
    },
    {
      "name": "dashboard",
      "description": "The signed-in user's employee dashboard layout"
    },
    {
      "name": "leaderboard",
      "description": "The company's points leaderboard"
    },
    {
      "name": "schedule",
      "description": "Calendars and events of the company schedule"
    },
    {
      "name": "questionnaires",
      "description": "Sales discovery questionnaires and the answers per deal"
    },
    {
      "name": "emails",
      "description": "The caller's mailbox: folders, conversations, read state"
    },
    {
      "name": "deals",
      "description": "The sales pipeline: deals, their stages, activities and notes"
    },
    {
      "name": "sms",
      "description": "SMS conversations through CloudTalk or RingCentral"
    },
    {
      "name": "notifications",
      "description": "The notification bell"
    },
    {
      "name": "support",
      "description": "The support chat: CRM users write to Granite Manager's support team, and the team (superusers with two-step sign-in) answers from the Support app"
    },
    {
      "name": "quickbooks",
      "description": "QuickBooks Online invoices and customers"
    },
    {
      "name": "invoices",
      "description": "Invoices the CRM keeps itself, for companies without QuickBooks"
    },
    {
      "name": "followups",
      "description": "AI follow-ups: the company rule they obey, timelines and enrollments"
    },
    {
      "name": "billing",
      "description": "The company's Granite Manager subscription (Stripe)"
    },
    {
      "name": "payments",
      "description": "The payments page (payments.granite-manager.com): a company's monthly Stripe subscription, opened from its signed payment link (no session)"
    },
    {
      "name": "jobs",
      "description": "Scheduled jobs the time-triggered Lambda runs (job key, no session)"
    },
    {
      "name": "posthog-autofix",
      "description": "Callbacks of the PostHog auto-fix GitHub workflow (callback secret, no session)"
    },
    {
      "name": "phone",
      "description": "Granite Manager, business calling through Telnyx: the app's sign-in and devices, calls, contacts and settings, and their admin pages"
    },
    {
      "name": "telnyx-webhooks",
      "description": "Telnyx's TeXML and Call Control callbacks for Granite Manager (signed by Telnyx, no session)"
    }
  ]
}
