{
  "openapi": "3.1.0",
  "info": {
    "title": "Deeper Than Data agent",
    "version": "0.1.0",
    "summary": "The REST mirror of Deb, the Deeper Than Data AI agent.",
    "description": "Deb is Deeper Than Data's agent. Three calls: turn a problem into a one-page spec (scope_project), read the published price ranges (get_pricing) and leave us a message (book_conversation). The same three tools are on the MCP server at https://deeperthandata.com.au/mcp (Streamable HTTP, JSON responses, no sign-in). Every conversation is logged and kept; see https://deeperthandata.com.au/privacy. Limits: 6 messages a minute and 60 a day per IP, 120 per 10 minutes overall, a daily spend cap and a per-conversation cost cap. A person can also call +61 3 9072 1100.",
    "contact": {
      "name": "Deeper Than Data Pty Ltd",
      "email": "go@deeperthandata.com.au",
      "url": "https://deeperthandata.com.au/agent"
    },
    "termsOfService": "https://deeperthandata.com.au/privacy"
  },
  "servers": [
    {
      "url": "https://deeperthandata.com.au",
      "description": "Production"
    }
  ],
  "externalDocs": {
    "description": "How the agent works and is tested",
    "url": "https://deeperthandata.com.au/agent"
  },
  "x-mcp": {
    "url": "https://deeperthandata.com.au/mcp",
    "transport": "streamable-http",
    "authentication": "none",
    "tools": [
      "scope_project",
      "get_pricing",
      "book_conversation"
    ]
  },
  "paths": {
    "/agent/api/scope_project": {
      "post": {
        "operationId": "scope_project",
        "summary": "Scope a project",
        "description": "One turn of conversation with the agent. It turns a problem into a one-page spec (inputs, outputs, users, acceptance criteria, rough size of the job) and prices it against the published tiers. Send the person's words. Pass session_id from the last result to continue. Returns text and blocks.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ScopeRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "One turn: the reply, the blocks shown, the spec so far, and the cost.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TurnOutput"
                }
              }
            }
          },
          "400": {
            "description": "The message is missing.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "The agent's model credits have run out, so it is resting. Try again later.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Resting"
                }
              }
            }
          },
          "429": {
            "description": "Too many messages.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RateLimited"
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait",
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "503": {
            "description": "The agent is switched off, or has reached its daily spend cap, and is resting until midnight AEST.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Resting"
                }
              }
            }
          },
          "500": {
            "description": "The turn failed. The agent is resting.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Resting"
                }
              }
            }
          }
        }
      }
    },
    "/agent/api/pricing": {
      "get": {
        "operationId": "get_pricing",
        "summary": "Get pricing",
        "description": "The published price ranges by tier, in A$ including GST: setup, monthly, year 1 and each year after, what every tier includes, what is not included, and the terms. Ranges, not quotes.",
        "responses": {
          "200": {
            "description": "The published pricing.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Pricing"
                }
              }
            }
          }
        }
      }
    },
    "/agent/api/book_conversation": {
      "post": {
        "operationId": "book_conversation",
        "summary": "Book a conversation with us",
        "description": "Leave a message for our team. We reply within 2 business days to arrange a time. An email or a phone number is required; a request with neither is refused with 400. Include a short summary of what the person needs. Pass session_id to attach the spec from a scope_project conversation.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/BookRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The message was sent.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BookResponse"
                }
              }
            }
          },
          "400": {
            "description": "An email or a phone number is needed, or the email does not look right.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "The agent's model credits have run out, so it is resting. Try again later.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Resting"
                }
              }
            }
          },
          "429": {
            "description": "Too many messages.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RateLimited"
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait",
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "503": {
            "description": "The agent is switched off, or has reached its daily spend cap, and is resting until midnight AEST.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Resting"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Range": {
        "type": "object",
        "properties": {
          "min": {
            "type": "integer",
            "description": "Whole Australian dollars"
          },
          "max": {
            "type": "integer",
            "description": "Whole Australian dollars"
          }
        },
        "required": [
          "min",
          "max"
        ],
        "additionalProperties": false,
        "description": "A price range. Always a range, never a single figure."
      },
      "EarlyExit": {
        "type": "object",
        "properties": {
          "status": {
            "type": "string"
          },
          "text": {
            "type": "string"
          }
        },
        "required": [
          "status",
          "text"
        ],
        "additionalProperties": false
      },
      "Terms": {
        "type": "object",
        "properties": {
          "setup_payment": {
            "type": "string"
          },
          "subscription_start": {
            "type": "string"
          },
          "minimum_term_months": {
            "type": "integer"
          },
          "after_minimum": {
            "type": "string"
          },
          "acceptance": {
            "type": "string"
          },
          "ownership": {
            "type": "string"
          },
          "early_exit": {
            "$ref": "#/components/schemas/EarlyExit"
          },
          "change_allowance": {
            "$ref": "#/components/schemas/EarlyExit",
            "description": "What changes the monthly fee covers. Pending until we set the allowance in writing."
          }
        },
        "required": [
          "setup_payment",
          "subscription_start",
          "minimum_term_months",
          "after_minimum",
          "acceptance",
          "ownership",
          "early_exit",
          "change_allowance"
        ],
        "additionalProperties": false
      },
      "PublicTier": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "fits": {
            "type": "string",
            "description": "Who the tier suits"
          },
          "setup": {
            "$ref": "#/components/schemas/Range"
          },
          "monthly": {
            "$ref": "#/components/schemas/Range"
          },
          "includes": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "year_1": {
            "$ref": "#/components/schemas/Range"
          },
          "each_year_after": {
            "$ref": "#/components/schemas/Range"
          },
          "service": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "The tier's service level: release cadence and reply time. Tiers differ here, never in features."
          }
        },
        "required": [
          "id",
          "name",
          "fits",
          "setup",
          "monthly",
          "includes",
          "year_1",
          "each_year_after",
          "service"
        ],
        "additionalProperties": false
      },
      "Pilot": {
        "type": "object",
        "properties": {
          "enabled": {
            "type": "boolean"
          },
          "status": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "price": {
            "$ref": "#/components/schemas/Range"
          },
          "duration_days": {
            "type": "integer"
          },
          "payment": {
            "type": "string"
          },
          "condition": {
            "type": "string"
          },
          "places": {
            "type": "integer"
          },
          "closes": {
            "type": "string"
          },
          "includes": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "places_taken": {
            "type": "integer",
            "minimum": 0
          },
          "headline": {
            "type": "string"
          }
        },
        "required": [
          "enabled",
          "status",
          "name",
          "price",
          "duration_days",
          "payment",
          "condition",
          "places",
          "closes",
          "includes"
        ],
        "additionalProperties": false,
        "description": "The founding-client pilot. Present only while it is switched on."
      },
      "CostDriver": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "text": {
            "type": "string"
          }
        },
        "required": [
          "id",
          "name",
          "text"
        ],
        "additionalProperties": false,
        "description": "One thing that moves the price. Prices follow the job and its infrastructure, never users or seats."
      },
      "SmallJob": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string"
          },
          "price": {
            "$ref": "#/components/schemas/Range"
          },
          "turnaround": {
            "type": "string"
          },
          "fits": {
            "type": "string"
          },
          "includes": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        },
        "required": [
          "name",
          "price",
          "turnaround",
          "fits",
          "includes"
        ],
        "additionalProperties": false,
        "description": "A small bespoke build, handed over, priced as a range."
      },
      "Offering": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string"
          },
          "suits": {
            "type": "string"
          },
          "summary": {
            "type": "string"
          }
        },
        "required": [
          "name",
          "suits",
          "summary"
        ],
        "additionalProperties": false,
        "description": "One of the two offerings: who it suits, by the job."
      },
      "Bespoke": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string"
          },
          "suits": {
            "type": "string"
          },
          "summary": {
            "type": "string"
          },
          "proof": {
            "type": "object",
            "properties": {
              "href": {
                "type": "string"
              },
              "label": {
                "type": "string"
              },
              "text": {
                "type": "string"
              }
            },
            "required": [
              "href",
              "label",
              "text"
            ],
            "additionalProperties": false,
            "description": "Published work that shows this offering"
          },
          "cost_drivers": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CostDriver"
            }
          },
          "no_infrastructure": {
            "type": "string"
          },
          "small_jobs": {
            "$ref": "#/components/schemas/SmallJob"
          },
          "larger": {
            "type": "object",
            "properties": {
              "name": {
                "type": "string"
              },
              "text": {
                "type": "string"
              }
            },
            "required": [
              "name",
              "text"
            ],
            "additionalProperties": false
          }
        },
        "required": [
          "name",
          "suits",
          "summary",
          "proof",
          "cost_drivers",
          "no_infrastructure",
          "small_jobs",
          "larger"
        ],
        "additionalProperties": false,
        "description": "Bespoke analysis and software: one-off analysis and reports, forecasting, studies of the client's own or public data, and software built and handed over. The client owns the result; support afterwards is optional."
      },
      "Pricing": {
        "type": "object",
        "properties": {
          "currency": {
            "type": "string",
            "description": "Always AUD",
            "const": "AUD"
          },
          "gst": {
            "type": "string",
            "description": "Always included: every price is GST-inclusive",
            "const": "included"
          },
          "status": {
            "type": "string"
          },
          "saas": {
            "$ref": "#/components/schemas/Offering"
          },
          "cost_drivers": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CostDriver"
            }
          },
          "tiers": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PublicTier"
            }
          },
          "included_in_every_tier": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "not_included": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "bespoke": {
            "$ref": "#/components/schemas/Bespoke"
          },
          "terms": {
            "$ref": "#/components/schemas/Terms"
          },
          "pilot": {
            "$ref": "#/components/schemas/Pilot"
          }
        },
        "required": [
          "currency",
          "gst",
          "status",
          "tiers",
          "included_in_every_tier",
          "not_included",
          "terms",
          "cost_drivers",
          "saas",
          "bespoke"
        ],
        "additionalProperties": false,
        "description": "The published price ranges for both offerings: made-to-order SaaS (the tiers) and bespoke software. Ranges, not quotes."
      },
      "ChartSeries": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string"
          },
          "color": {
            "type": "string",
            "description": "A colour token",
            "enum": [
              "c1",
              "c2",
              "c3",
              "cn"
            ]
          },
          "dashed": {
            "type": "boolean"
          },
          "values": {
            "type": [
              "array",
              "null"
            ],
            "items": {
              "type": "number"
            },
            "description": "One value per x label"
          }
        },
        "required": [
          "name",
          "color",
          "values"
        ],
        "additionalProperties": false
      },
      "Chart": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "kind": {
            "type": "string",
            "enum": [
              "line",
              "bar"
            ]
          },
          "title": {
            "type": "string"
          },
          "unit": {
            "type": "string"
          },
          "x_label": {
            "type": "string"
          },
          "x": {
            "type": [
              "array",
              "null"
            ],
            "items": {
              "type": "string"
            }
          },
          "series": {
            "type": [
              "array",
              "null"
            ],
            "items": {
              "$ref": "#/components/schemas/ChartSeries"
            }
          },
          "caption": {
            "type": "string"
          },
          "source": {
            "type": "string",
            "description": "Where the numbers come from"
          },
          "link": {
            "type": "string",
            "description": "An id on the link allowlist, not a URL"
          }
        },
        "required": [
          "id",
          "kind",
          "title",
          "unit",
          "x_label",
          "x",
          "series",
          "caption",
          "source",
          "link"
        ],
        "additionalProperties": false,
        "description": "A chart built by the server from a published data dive."
      },
      "Table": {
        "type": "object",
        "properties": {
          "title": {
            "type": "string"
          },
          "columns": {
            "type": [
              "array",
              "null"
            ],
            "items": {
              "type": "string"
            }
          },
          "rows": {
            "type": [
              "array",
              "null"
            ],
            "items": {
              "type": [
                "array",
                "null"
              ],
              "items": {
                "type": "string"
              }
            }
          },
          "note": {
            "type": "string"
          }
        },
        "required": [
          "title",
          "columns",
          "rows"
        ],
        "additionalProperties": false
      },
      "TierView": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "fits": {
            "type": "string"
          },
          "setup": {
            "type": "string",
            "description": "For example A$9,000 to A$14,000"
          },
          "monthly": {
            "type": "string"
          },
          "year_1": {
            "type": "string"
          },
          "each_year_after": {
            "type": "string"
          },
          "includes": {
            "type": [
              "array",
              "null"
            ],
            "items": {
              "type": "string"
            }
          },
          "recommended": {
            "type": "boolean"
          }
        },
        "required": [
          "id",
          "name",
          "fits",
          "setup",
          "monthly",
          "year_1",
          "each_year_after",
          "includes"
        ],
        "additionalProperties": false
      },
      "Term": {
        "type": "object",
        "properties": {
          "label": {
            "type": "string"
          },
          "text": {
            "type": "string"
          }
        },
        "required": [
          "label",
          "text"
        ],
        "additionalProperties": false
      },
      "PilotView": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string"
          },
          "headline": {
            "type": "string"
          },
          "price": {
            "type": "string"
          },
          "duration": {
            "type": "string"
          },
          "payment": {
            "type": "string"
          },
          "condition": {
            "type": "string"
          },
          "places": {
            "type": "string"
          },
          "closes": {
            "type": "string"
          },
          "includes": {
            "type": [
              "array",
              "null"
            ],
            "items": {
              "type": "string"
            }
          }
        },
        "required": [
          "name",
          "price",
          "duration",
          "payment",
          "condition",
          "places",
          "closes",
          "includes"
        ],
        "additionalProperties": false
      },
      "Tiers": {
        "type": "object",
        "properties": {
          "title": {
            "type": "string"
          },
          "lead": {
            "type": "string"
          },
          "tiers": {
            "type": [
              "array",
              "null"
            ],
            "items": {
              "$ref": "#/components/schemas/TierView"
            }
          },
          "included": {
            "type": [
              "array",
              "null"
            ],
            "items": {
              "type": "string"
            }
          },
          "not_included": {
            "type": [
              "array",
              "null"
            ],
            "items": {
              "type": "string"
            }
          },
          "terms": {
            "type": [
              "array",
              "null"
            ],
            "items": {
              "$ref": "#/components/schemas/Term"
            }
          },
          "pilot": {
            "$ref": "#/components/schemas/PilotView"
          },
          "note": {
            "type": "string"
          }
        },
        "required": [
          "title",
          "lead",
          "tiers",
          "included",
          "not_included",
          "terms",
          "note"
        ],
        "additionalProperties": false
      },
      "Quote": {
        "type": "object",
        "properties": {
          "kind": {
            "type": "string",
            "enum": [
              "monthly",
              "one_off"
            ],
            "description": "monthly: a made-to-order SaaS tier's ranges. one_off: bespoke software, built and handed over, with no tier"
          },
          "price": {
            "type": "string",
            "description": "one_off only: the small-jobs range, or empty when quoted from the spec"
          },
          "tier": {
            "type": "string"
          },
          "setup": {
            "type": "string"
          },
          "monthly": {
            "type": "string"
          },
          "year_1": {
            "type": "string"
          },
          "each_year_after": {
            "type": "string"
          },
          "includes": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "What the estimate includes: the tier's inclusions, then what every tier includes"
          },
          "set_by": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "The cost drivers that set the tier, from the estimate tool"
          },
          "assumed": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Drivers not given yet, assumed at their lowest"
          },
          "note": {
            "type": "string"
          }
        },
        "required": [
          "tier",
          "setup",
          "monthly",
          "year_1",
          "each_year_after",
          "includes"
        ],
        "additionalProperties": false,
        "description": "The estimate against the spec. Always ranges with what is included, never a single figure."
      },
      "SpecCard": {
        "type": "object",
        "properties": {
          "title": {
            "type": "string"
          },
          "draft": {
            "type": "boolean",
            "description": "Always true: a spec card is a draft until we review it"
          },
          "problem": {
            "type": "string"
          },
          "outputs": {
            "type": [
              "array",
              "null"
            ],
            "items": {
              "type": "string"
            }
          },
          "inputs": {
            "type": [
              "array",
              "null"
            ],
            "items": {
              "type": "string"
            }
          },
          "users": {
            "type": "string"
          },
          "acceptance": {
            "type": [
              "array",
              "null"
            ],
            "items": {
              "type": "string"
            }
          },
          "first_version": {
            "type": "string"
          },
          "consequence": {
            "type": "string"
          },
          "who_does_it": {
            "type": "string",
            "description": "Who does this today: In-house, An outside firm or Nobody. Empty until asked."
          },
          "money_from": {
            "type": "string",
            "description": "Where the money comes from: An existing contract or role, A program, New money or Not sure yet. Empty until asked."
          },
          "size": {
            "type": "string"
          },
          "not_included": {
            "type": [
              "array",
              "null"
            ],
            "items": {
              "type": "string"
            }
          },
          "open": {
            "type": [
              "array",
              "null"
            ],
            "items": {
              "type": "string"
            },
            "description": "Questions still open"
          },
          "quote": {
            "$ref": "#/components/schemas/Quote"
          },
          "terms": {
            "type": [
              "array",
              "null"
            ],
            "items": {
              "$ref": "#/components/schemas/Term"
            }
          },
          "note": {
            "type": "string"
          }
        },
        "required": [
          "title",
          "draft",
          "problem",
          "outputs",
          "inputs",
          "users",
          "acceptance",
          "first_version",
          "consequence",
          "who_does_it",
          "money_from",
          "size",
          "not_included",
          "open",
          "terms",
          "note"
        ],
        "additionalProperties": false,
        "description": "The one-page spec the visitor leaves with."
      },
      "CTA": {
        "type": "object",
        "properties": {
          "action": {
            "type": "string",
            "enum": [
              "email_spec",
              "ask_feasibility",
              "send_to_pat",
              "copy_spec",
              "call",
              "book"
            ]
          },
          "label": {
            "type": "string",
            "description": "The set label for this action"
          },
          "link": {
            "type": "string",
            "description": "An id on the link allowlist"
          },
          "note": {
            "type": "string"
          }
        },
        "required": [
          "action",
          "label"
        ],
        "additionalProperties": false
      },
      "Proof": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "kind": {
            "type": "string"
          },
          "title": {
            "type": "string"
          },
          "label": {
            "type": "string",
            "description": "What the piece is, for example a prototype on made-up data"
          },
          "body": {
            "type": "string"
          },
          "items": {
            "type": [
              "array",
              "null"
            ],
            "items": {
              "type": "string"
            }
          },
          "link": {
            "type": "string",
            "description": "An id on the link allowlist"
          },
          "image": {
            "type": "string",
            "description": "A path to a site asset"
          }
        },
        "required": [
          "id",
          "kind",
          "title",
          "label",
          "body",
          "link"
        ],
        "additionalProperties": false
      },
      "Contact": {
        "type": "object",
        "properties": {
          "title": {
            "type": "string"
          },
          "summary": {
            "type": "string",
            "description": "The editable summary"
          },
          "note": {
            "type": "string"
          },
          "reason": {
            "type": "string",
            "enum": [
              "email_spec",
              "ask_feasibility",
              "send_to_pat",
              "copy_spec",
              "call",
              "book"
            ]
          },
          "email": {
            "type": "string"
          },
          "phone": {
            "type": "string"
          }
        },
        "required": [
          "title",
          "summary",
          "note",
          "reason"
        ],
        "additionalProperties": false
      },
      "TextBlock": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "Block id, unique within the turn"
          },
          "type": {
            "const": "text"
          },
          "text": {
            "type": "string"
          }
        },
        "required": [
          "id",
          "type",
          "text"
        ],
        "additionalProperties": false,
        "description": "A paragraph of text."
      },
      "ChartBlock": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "Block id, unique within the turn"
          },
          "type": {
            "const": "chart"
          },
          "chart": {
            "$ref": "#/components/schemas/Chart"
          }
        },
        "required": [
          "id",
          "type",
          "chart"
        ],
        "additionalProperties": false,
        "description": "A chart from a published data dive."
      },
      "TableBlock": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "Block id, unique within the turn"
          },
          "type": {
            "const": "table"
          },
          "table": {
            "$ref": "#/components/schemas/Table"
          }
        },
        "required": [
          "id",
          "type",
          "table"
        ],
        "additionalProperties": false,
        "description": "A table."
      },
      "TierCardBlock": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "Block id, unique within the turn"
          },
          "type": {
            "const": "tier_card"
          },
          "tiers": {
            "$ref": "#/components/schemas/Tiers"
          }
        },
        "required": [
          "id",
          "type",
          "tiers"
        ],
        "additionalProperties": false,
        "description": "The published tiers as ranges."
      },
      "SpecCardBlock": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "Block id, unique within the turn"
          },
          "type": {
            "const": "spec_card"
          },
          "spec": {
            "$ref": "#/components/schemas/SpecCard"
          }
        },
        "required": [
          "id",
          "type",
          "spec"
        ],
        "additionalProperties": false,
        "description": "The one-page spec so far."
      },
      "CtaBlock": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "Block id, unique within the turn"
          },
          "type": {
            "const": "cta"
          },
          "cta": {
            "$ref": "#/components/schemas/CTA"
          }
        },
        "required": [
          "id",
          "type",
          "cta"
        ],
        "additionalProperties": false,
        "description": "A call to action."
      },
      "ProofBlock": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "Block id, unique within the turn"
          },
          "type": {
            "const": "proof"
          },
          "proof": {
            "$ref": "#/components/schemas/Proof"
          }
        },
        "required": [
          "id",
          "type",
          "proof"
        ],
        "additionalProperties": false,
        "description": "A piece of published work."
      },
      "ContactBlock": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "Block id, unique within the turn"
          },
          "type": {
            "const": "contact"
          },
          "contact": {
            "$ref": "#/components/schemas/Contact"
          }
        },
        "required": [
          "id",
          "type",
          "contact"
        ],
        "additionalProperties": false,
        "description": "A form to leave us a message."
      },
      "Block": {
        "description": "One block. The server builds every block from the published work and the pricing config and checks it before sending. The model never supplies numbers, links or HTML. Links are ids on an allowlist.",
        "oneOf": [
          {
            "$ref": "#/components/schemas/TextBlock"
          },
          {
            "$ref": "#/components/schemas/ChartBlock"
          },
          {
            "$ref": "#/components/schemas/TableBlock"
          },
          {
            "$ref": "#/components/schemas/TierCardBlock"
          },
          {
            "$ref": "#/components/schemas/SpecCardBlock"
          },
          {
            "$ref": "#/components/schemas/CtaBlock"
          },
          {
            "$ref": "#/components/schemas/ProofBlock"
          },
          {
            "$ref": "#/components/schemas/ContactBlock"
          }
        ]
      },
      "Spec": {
        "type": "object",
        "properties": {
          "problem": {
            "type": "string"
          },
          "outputs": {
            "type": [
              "array",
              "null"
            ],
            "items": {
              "type": "string"
            }
          },
          "inputs": {
            "type": [
              "array",
              "null"
            ],
            "items": {
              "type": "string"
            }
          },
          "users": {
            "type": "string"
          },
          "acceptance": {
            "type": [
              "array",
              "null"
            ],
            "items": {
              "type": "string"
            }
          },
          "first_version": {
            "type": "string"
          },
          "consequence": {
            "type": "string"
          },
          "who_does_it": {
            "type": "string",
            "description": "Who does this today: In-house, An outside firm or Nobody. Empty until asked."
          },
          "money_from": {
            "type": "string",
            "description": "Where the money comes from: An existing contract or role, A program, New money or Not sure yet. Empty until asked."
          },
          "size": {
            "type": "string"
          },
          "not_included": {
            "type": [
              "array",
              "null"
            ],
            "items": {
              "type": "string"
            }
          },
          "title": {
            "type": "string"
          }
        },
        "required": [],
        "additionalProperties": false,
        "description": "The spec fields recorded so far. Fields not yet recorded are absent."
      },
      "ToolUse": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string"
          },
          "args": {
            "description": "The tool's arguments, as JSON"
          },
          "via": {
            "type": "string",
            "enum": [
              "reply",
              "server",
              "refused"
            ],
            "description": "How the tool ran: inside the reply call, or by the server refused: the call was not offered on this turn and did not run."
          }
        },
        "required": [
          "name"
        ],
        "additionalProperties": false
      },
      "TurnOutput": {
        "type": "object",
        "properties": {
          "session_id": {
            "type": "string",
            "description": "Pass this back to continue the conversation"
          },
          "turn": {
            "type": "integer"
          },
          "text": {
            "type": "string",
            "description": "The agent's reply"
          },
          "blocks": {
            "type": [
              "array",
              "null"
            ],
            "items": {
              "$ref": "#/components/schemas/Block"
            },
            "description": "What the agent showed"
          },
          "stage": {
            "type": "string",
            "enum": [
              "attract",
              "qualify",
              "tour",
              "show",
              "elicit",
              "price",
              "capture",
              "handoff"
            ]
          },
          "next": {
            "type": "string",
            "description": "The next thing the agent will ask or offer",
            "enum": [
              "can_describe",
              "problem",
              "show_proof",
              "outputs",
              "inputs",
              "users",
              "acceptance",
              "first_version",
              "consequence",
              "size",
              "who_does_it",
              "money_from",
              "current_tools",
              "current_spend",
              "approval_and_timing",
              "offer_price",
              "offer_spec",
              "offer_capture",
              "done"
            ]
          },
          "readiness": {
            "type": "string",
            "enum": [
              "warm",
              "exploratory"
            ]
          },
          "tools": {
            "type": [
              "array",
              "null"
            ],
            "items": {
              "$ref": "#/components/schemas/ToolUse"
            }
          },
          "recorded": {
            "type": [
              "array",
              "null"
            ],
            "items": {
              "type": "string"
            },
            "description": "Which spec fields this turn recorded"
          },
          "escalated": {
            "type": "boolean",
            "description": "True when a larger model answered this turn"
          },
          "cost_usd": {
            "type": "number",
            "description": "Cost of this turn in US dollars"
          },
          "session_cost_usd": {
            "type": "number",
            "description": "Cost of the whole conversation so far in US dollars"
          },
          "flags": {
            "type": [
              "array",
              "null"
            ],
            "items": {
              "type": "string"
            },
            "description": "Checks the server raised on this turn"
          },
          "plain_text": {
            "type": "string",
            "description": "The reply and the blocks as plain text"
          },
          "spec": {
            "$ref": "#/components/schemas/Spec"
          },
          "priced": {
            "type": "boolean"
          },
          "ended": {
            "type": "boolean"
          }
        },
        "required": [
          "session_id",
          "turn",
          "text",
          "blocks",
          "stage",
          "next",
          "readiness",
          "tools",
          "recorded",
          "escalated",
          "cost_usd",
          "session_cost_usd",
          "plain_text",
          "spec",
          "priced"
        ],
        "additionalProperties": false,
        "description": "One turn of the conversation. An empty list may arrive as null."
      },
      "Resting": {
        "type": "object",
        "properties": {
          "text": {
            "type": "string",
            "description": "A plain line with the email and phone number"
          },
          "email": {
            "type": "string"
          },
          "phone": {
            "type": "string"
          },
          "enabled": {
            "type": "boolean"
          }
        },
        "required": [
          "text"
        ],
        "additionalProperties": false,
        "description": "The agent is resting, or something went wrong. Email go@deeperthandata.com.au or call +61 3 9072 1100."
      },
      "RateLimited": {
        "type": "object",
        "properties": {
          "text": {
            "type": "string"
          },
          "limit": {
            "type": "string",
            "description": "Which limit was hit"
          }
        },
        "required": [
          "text"
        ],
        "additionalProperties": false,
        "description": "Too many messages. Limits: 6 a minute and 60 a day per IP, 120 per 10 minutes overall."
      },
      "Error": {
        "type": "object",
        "properties": {
          "error": {
            "type": "string"
          }
        },
        "required": [
          "error"
        ],
        "additionalProperties": false
      },
      "ScopeRequest": {
        "type": "object",
        "properties": {
          "message": {
            "type": "string",
            "description": "What the person said, or your question on their behalf",
            "maxLength": 4000,
            "minLength": 1
          },
          "session_id": {
            "type": "string",
            "description": "From the previous result, to continue the conversation"
          },
          "attribution": {
            "$ref": "#/components/schemas/Attribution"
          }
        },
        "required": [
          "message"
        ],
        "additionalProperties": false
      },
      "BookRequest": {
        "type": "object",
        "properties": {
          "summary": {
            "type": "string",
            "description": "A short summary of what the person needs",
            "maxLength": 4000
          },
          "name": {
            "type": "string"
          },
          "email": {
            "type": "string",
            "description": "An email or a phone number is required"
          },
          "phone": {
            "type": "string",
            "description": "A phone number or an email is required"
          },
          "organisation": {
            "type": "string"
          },
          "session_id": {
            "type": "string",
            "description": "To attach the spec from a scope_project conversation"
          },
          "attribution": {
            "$ref": "#/components/schemas/Attribution"
          }
        },
        "required": [
          "summary"
        ],
        "additionalProperties": false,
        "description": "An email or a phone number is required so we can reply. One enquiry per contact and session every 10 minutes; the same contact and summary again returns the first enquiry's id."
      },
      "BookResponse": {
        "type": "object",
        "properties": {
          "ok": {
            "type": "boolean"
          },
          "id": {
            "type": "string",
            "description": "Reference for the message"
          },
          "session_id": {
            "type": "string"
          },
          "text": {
            "type": "string"
          },
          "duplicate": {
            "type": "boolean",
            "description": "True when this exact enquiry was already received; the same id is returned and nothing new is created."
          }
        },
        "required": [
          "ok",
          "id",
          "session_id",
          "text"
        ],
        "additionalProperties": false
      },
      "Attribution": {
        "type": "object",
        "description": "Optional visit attribution. We keep the first campaign for a visit. Dive context names the published page and finding that led here.",
        "additionalProperties": false,
        "properties": {
          "visit_id": {
            "type": "string",
            "pattern": "^[a-f0-9]{16}$",
            "description": "The beacon visit id, if available."
          },
          "campaign": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "utm_source": {
                "type": "string",
                "maxLength": 200
              },
              "utm_medium": {
                "type": "string",
                "maxLength": 200
              },
              "utm_campaign": {
                "type": "string",
                "maxLength": 200
              },
              "utm_content": {
                "type": "string",
                "maxLength": 200
              },
              "utm_term": {
                "type": "string",
                "maxLength": 200
              },
              "ref": {
                "type": "string",
                "maxLength": 200
              }
            }
          },
          "dive_context": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "dive": {
                "type": "string",
                "description": "Published dive path, such as /dives/school-demand-victoria."
              },
              "finding": {
                "type": "string",
                "maxLength": 200,
                "description": "Finding or figure id that led to the conversation."
              }
            },
            "required": [
              "dive"
            ]
          }
        }
      }
    }
  }
}
