{
  "openapi": "3.1.0",
  "info": {
    "title": "MillionShort API",
    "version": "1.0.0",
    "summary": "Search for AI agents on our own independent index.",
    "description": "Search the web and twelve specialist sources from one endpoint. The web index is Billions+\npages and is our own independent index.\n\nWhat makes it different: you can remove the most popular sites from the results\n(`remove_top_sites`) to reach the long tail, or keep only them (`only_top_sites`); boost, bury,\ninclude or exclude domains, page types and topics; filter by date, language and country; keep\nonly sites whose traffic is rising, sites popular in a country, or sites built with a given\nplatform; and every result says how popular its site is, how its traffic is moving, where it\nis popular, what it is built with and whether it carries a risk label. Ask for `highlights`\n(the passages that answer the query) or `include_content` (the page's text) in the same call.\n\n**Authentication.** `Authorization: Bearer ms-...` on every `/v1` call. Keys belong to a team\nand are shown once when created.\n\n**Envelope.** Every success is `{data, request_id, usage, warnings}`; every error is\n`{error: {code, message, retry_after_seconds, details}, request_id}`.\n\n**Credits.** 1 credit = $0.001. A search costs 1 credit per source searched and covers up to 10\nresults; each further 10 results (or part) on the call costs 0.5. `explain`, highlights and\nevery filter are free. `include_content` costs 1 per call, covering up to 10 results that come\nback with their page text (each further 10, or part, 1 more; none with text: nothing). 1 credit\n= 1 search; a page is half. `POST /v1/domain` costs 1 credit per call. `GET /v1/sources` is free. A call that\nfails is never charged. Every response carries `usage.{credits, cost_usd, breakdown}`.\n\n**Rate limits.** Requests per minute, searches of heavy sources per minute and searches in\nflight depend on the plan. `X-RateLimit-Limit`, `X-RateLimit-Remaining` and `X-RateLimit-Reset`\nare sent on every `/v1` response; a refused call is `429` with `Retry-After`.\n"
  },
  "servers": [
    {
      "url": "https://api.millionshort.com"
    }
  ],
  "security": [
    {
      "bearerAuth": []
    }
  ],
  "tags": [
    {
      "name": "search",
      "description": "Search, the list of sources, and domain facts."
    },
    {
      "name": "keys",
      "description": "A trial key for an agent, with no sign-up."
    },
    {
      "name": "account",
      "description": "The signed-in account, its API keys, usage, plan and credit packs. Uses the dashboard session, not an API key."
    }
  ],
  "paths": {
    "/v1/search": {
      "post": {
        "operationId": "search",
        "tags": [
          "search"
        ],
        "summary": "Search",
        "description": "Search one to five sources and get one ranked list back. Results from several sources are\nmerged by rank and de-duplicated. Synchronous.\n",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SearchRequest"
              },
              "examples": {
                "longTail": {
                  "summary": "The web without its 10,000 most popular sites",
                  "value": {
                    "query": "sourdough starter hydration",
                    "remove_top_sites": 10000
                  }
                },
                "severalSources": {
                  "summary": "Three sources, with the reasons for each result",
                  "value": {
                    "query": "transformer interpretability",
                    "sources": [
                      "web",
                      "academic",
                      "hn"
                    ],
                    "num_results": 20,
                    "explain": true
                  }
                },
                "dateAndLanguage": {
                  "summary": "News from the last week, in German",
                  "value": {
                    "query": "Bundestag Haushalt",
                    "sources": [
                      "news"
                    ],
                    "time_range": "week",
                    "language": "de"
                  }
                },
                "country": {
                  "summary": "British sites only",
                  "value": {
                    "query": "planning permission loft conversion",
                    "country": "GB"
                  }
                },
                "formats": {
                  "summary": "Tutorials and documentation, no listicles, forums moved to the end",
                  "value": {
                    "query": "rust lifetime elision",
                    "page_types": [
                      "tutorials",
                      "documentation"
                    ],
                    "bury_page_types": [
                      "forums"
                    ],
                    "exclude_page_types": [
                      "listicles"
                    ]
                  }
                },
                "topics": {
                  "summary": "Science and health pages ahead, no sports",
                  "value": {
                    "query": "creatine",
                    "boost_topics": [
                      "science",
                      "health"
                    ],
                    "exclude_topics": [
                      "sports"
                    ]
                  }
                },
                "risingSites": {
                  "summary": "Sites whose traffic is growing, outside the 100,000 most popular",
                  "value": {
                    "query": "ai code review tool",
                    "traffic_trend": [
                      "rising",
                      "spiking"
                    ],
                    "remove_top_sites": 100000
                  }
                },
                "popularWhere": {
                  "summary": "Sites that are popular in Germany or Austria",
                  "value": {
                    "query": "wärmepumpe förderung",
                    "popular_in": [
                      "DE",
                      "AT"
                    ]
                  }
                },
                "siteTech": {
                  "summary": "Shops built on one shop platform",
                  "value": {
                    "query": "handmade ceramic mugs",
                    "site_tech": [
                      "woocommerce"
                    ],
                    "page_types": [
                      "products"
                    ]
                  }
                },
                "safeAndLongTail": {
                  "summary": "Long-tail sites with no risk label",
                  "value": {
                    "query": "free vpn comparison",
                    "popularity_buckets": [
                      "long-tail",
                      "top-1m"
                    ],
                    "exclude_risky": true
                  }
                },
                "highlights": {
                  "summary": "Three highlights per result",
                  "value": {
                    "query": "sourdough starter hydration",
                    "max_highlights": 3
                  }
                },
                "content": {
                  "summary": "The page text with each result, cut at 4,000 characters",
                  "value": {
                    "query": "sourdough starter hydration",
                    "num_results": 5,
                    "include_content": true,
                    "max_characters": 4000
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Search results",
            "headers": {
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SearchResponse"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "502": {
            "$ref": "#/components/responses/SearchUnavailable"
          }
        }
      }
    },
    "/v1/sources": {
      "get": {
        "operationId": "listSources",
        "tags": [
          "search"
        ],
        "summary": "List sources, page types and topics",
        "description": "The source slugs `sources` accepts, how fresh each source is and which filters it applies, and the values `page_types`, `topics`, `traffic_trend` and `popularity_buckets` accept. Free.",
        "responses": {
          "200": {
            "description": "Sources, page types and topics",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SourcesResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/v1/domain": {
      "post": {
        "operationId": "getDomainInfo",
        "tags": [
          "search"
        ],
        "summary": "Popularity and risk for domains",
        "description": "For up to 25 domains, how popular each site is and whether it carries a risk label. 1 credit per call.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DomainRequest"
              },
              "examples": {
                "two": {
                  "value": {
                    "domains": [
                      "example.com",
                      "blog.example.org"
                    ]
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "One entry per domain, in the order sent",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DomainResponse"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "502": {
            "$ref": "#/components/responses/SearchUnavailable"
          }
        }
      }
    },
    "/v1/keys/agent": {
      "post": {
        "operationId": "createAgentKey",
        "tags": [
          "keys"
        ],
        "summary": "Get a trial key for an agent",
        "description": "One call, no sign-up: returns an `ms-` key with a small credit grant, shown once. The key\nis short-lived. No API key is needed; calls are limited per address.\n",
        "security": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AgentKeyRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The trial key (shown once)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AgentKeyResponse"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/account/me": {
      "get": {
        "operationId": "getAccount",
        "tags": [
          "account"
        ],
        "summary": "The signed-in user and their team",
        "security": [
          {
            "sessionAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "User, team and credit balance",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AccountResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          }
        }
      }
    },
    "/account/keys": {
      "get": {
        "operationId": "listApiKeys",
        "tags": [
          "account"
        ],
        "summary": "List the team's API keys",
        "description": "Newest first. Only a short prefix of each key is ever shown again.",
        "security": [
          {
            "sessionAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Keys",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiKeyListResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          }
        }
      },
      "post": {
        "operationId": "createApiKey",
        "tags": [
          "account"
        ],
        "summary": "Create an API key",
        "description": "The full key is in the response once and cannot be read again.",
        "security": [
          {
            "sessionAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "name"
                ],
                "properties": {
                  "name": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 100
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "The new key, with its full value",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiKeyCreatedResponse"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          }
        }
      }
    },
    "/account/keys/{key_id}": {
      "delete": {
        "operationId": "revokeApiKey",
        "tags": [
          "account"
        ],
        "summary": "Revoke an API key",
        "description": "The key stops working at once. Revoking is permanent.",
        "security": [
          {
            "sessionAuth": []
          }
        ],
        "parameters": [
          {
            "name": "key_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The revoked key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiKeyRevokedResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      }
    },
    "/account/usage": {
      "get": {
        "operationId": "getUsage",
        "tags": [
          "account"
        ],
        "summary": "Credit ledger and a 30-day summary",
        "security": [
          {
            "sessionAuth": []
          }
        ],
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 50
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "description": "The `next` value of the previous page.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Ledger entries, newest first",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UsageLedgerResponse"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          }
        }
      }
    },
    "/account/billing/packs": {
      "get": {
        "operationId": "listCreditPacks",
        "tags": [
          "account"
        ],
        "summary": "Credit packs on sale",
        "security": [
          {
            "sessionAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Packs and the price of one credit",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CreditPacksResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          }
        }
      }
    },
    "/account/billing/checkout": {
      "post": {
        "operationId": "createCheckout",
        "tags": [
          "account"
        ],
        "summary": "Start a checkout for a credit pack",
        "description": "Returns the address of a hosted checkout page. Credits are added when the payment completes.",
        "security": [
          {
            "sessionAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "pack"
                ],
                "properties": {
                  "pack": {
                    "type": "string",
                    "description": "A pack `id` from `GET /account/billing/packs`."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Where to send the browser",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CheckoutResponse"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          }
        }
      }
    },
    "/account/billing/plans": {
      "get": {
        "operationId": "listPlans",
        "tags": [
          "account"
        ],
        "summary": "Plans, and the plan this team is on",
        "description": "Each plan's monthly price, included credits and limits, with the team's own plan and credits.",
        "security": [
          {
            "sessionAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "The plans and the team's plan",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PlansResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          }
        }
      }
    },
    "/account/billing/subscribe": {
      "post": {
        "operationId": "createPlanCheckout",
        "tags": [
          "account"
        ],
        "summary": "Start a checkout for a monthly plan",
        "description": "Returns the address of a hosted checkout page. The plan starts when the first payment completes. A team that already has a plan changes or cancels it through `POST /account/billing/portal`.",
        "security": [
          {
            "sessionAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "plan"
                ],
                "properties": {
                  "plan": {
                    "type": "string",
                    "description": "The `id` of a plan that is `available` in `GET /account/billing/plans`."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Where to send the browser",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PlanCheckoutResponse"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          }
        }
      }
    },
    "/account/billing/portal": {
      "post": {
        "operationId": "createPlanPortal",
        "tags": [
          "account"
        ],
        "summary": "Open plan management",
        "description": "Returns the address of a hosted page for changing or cancelling the plan, the card and past invoices.",
        "security": [
          {
            "sessionAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Where to send the browser",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data",
                    "request_id"
                  ],
                  "properties": {
                    "request_id": {
                      "type": "string"
                    },
                    "data": {
                      "type": "object",
                      "required": [
                        "portal_url"
                      ],
                      "properties": {
                        "portal_url": {
                          "type": "string",
                          "format": "uri"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "description": "An API key: `Authorization: Bearer ms-<token>`."
      },
      "sessionAuth": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "JWT",
        "description": "The dashboard's signed-in session token. Not an API key."
      }
    },
    "headers": {
      "X-RateLimit-Limit": {
        "description": "Requests allowed per minute.",
        "schema": {
          "type": "integer"
        }
      },
      "X-RateLimit-Remaining": {
        "description": "Requests left in the current window.",
        "schema": {
          "type": "integer"
        }
      },
      "X-RateLimit-Reset": {
        "description": "Unix time at which the window is full again.",
        "schema": {
          "type": "integer"
        }
      }
    },
    "responses": {
      "BadRequest": {
        "description": "`INVALID_PARAM` (a parameter is wrong or unknown) or `UNSUPPORTED_OPTION` (an option this API version does not offer).",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorEnvelope"
            }
          }
        }
      },
      "Unauthorized": {
        "description": "Missing or invalid credentials",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorEnvelope"
            }
          }
        }
      },
      "Forbidden": {
        "description": "`ACCOUNT_NOT_ELIGIBLE`: this sign-in cannot open a free account (the email is not verified, is a disposable address, or already has an account). `ACCOUNT_SUSPENDED`: the account is suspended (contact support); nothing is charged.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorEnvelope"
            }
          }
        }
      },
      "TooManyRequests": {
        "description": "`RATE_LIMITED` (the plan's rate or concurrency limit), `INSUFFICIENT_CREDITS`, or `CAPACITY`\n(the service has no free capacity for this call right now; nothing is charged). Retry after\n`Retry-After` seconds.\n",
        "headers": {
          "Retry-After": {
            "description": "Seconds to wait before retrying.",
            "schema": {
              "type": "integer"
            }
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorEnvelope"
            }
          }
        }
      },
      "SearchUnavailable": {
        "description": "`SEARCH_UNAVAILABLE`: search could not be served right now. Nothing is charged; retry after `Retry-After` seconds.",
        "headers": {
          "Retry-After": {
            "description": "Seconds to wait before retrying.",
            "schema": {
              "type": "integer"
            }
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorEnvelope"
            }
          }
        }
      },
      "NotFound": {
        "description": "No such resource for this team",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorEnvelope"
            }
          }
        }
      }
    },
    "schemas": {
      "Usage": {
        "type": "object",
        "required": [
          "credits",
          "cost_usd",
          "breakdown"
        ],
        "properties": {
          "credits": {
            "type": "number",
            "description": "Credits charged for this call."
          },
          "cost_usd": {
            "type": "number",
            "description": "The same amount in US dollars."
          },
          "breakdown": {
            "type": "object",
            "description": "Credits by line item, for example `search` and `additional_results`.",
            "additionalProperties": {
              "type": "number"
            }
          }
        }
      },
      "Warning": {
        "type": "object",
        "required": [
          "code",
          "message"
        ],
        "description": "A notice that did not fail the call. Codes: `option_not_supported` (an accepted option that\ndoes nothing; see `option`), `source_unavailable` (a source did not answer and was not\ncharged; see `source`), `short_results` (fewer results than asked for),\n`filter_not_applied` (a filter that some sources could not apply; see `filter` and\n`sources`), `language_detected` (`language` was applied to a source that stores no language,\non a language detected from each result's text; see `sources`), `content_partial` (some results have no page text; see `with_content`),\n`content_unavailable` (page content is away right now; not charged).\n",
        "properties": {
          "code": {
            "type": "string",
            "enum": [
              "option_not_supported",
              "source_unavailable",
              "short_results",
              "filter_not_applied",
              "language_detected",
              "content_partial",
              "content_unavailable"
            ]
          },
          "message": {
            "type": "string"
          },
          "option": {
            "type": "string"
          },
          "source": {
            "type": "string"
          },
          "filter": {
            "type": "string",
            "description": "The request field that was not applied."
          },
          "sources": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "The sources it was not applied to. Absent when it was not applied at all."
          },
          "requested": {
            "type": "integer"
          },
          "returned": {
            "type": "integer"
          },
          "with_content": {
            "type": "integer"
          }
        }
      },
      "ErrorCode": {
        "type": "string",
        "enum": [
          "INVALID_PARAM",
          "UNSUPPORTED_OPTION",
          "AUTH_INVALID_KEY",
          "AUTH_MISSING_KEY",
          "RATE_LIMITED",
          "CAPACITY",
          "QUOTA_EXCEEDED",
          "INSUFFICIENT_CREDITS",
          "SEARCH_UNAVAILABLE",
          "NOT_FOUND",
          "ACCOUNT_NOT_ELIGIBLE",
          "ACCOUNT_SUSPENDED",
          "INTERNAL"
        ]
      },
      "ErrorEnvelope": {
        "type": "object",
        "required": [
          "error",
          "request_id"
        ],
        "properties": {
          "request_id": {
            "type": "string"
          },
          "error": {
            "type": "object",
            "required": [
              "code",
              "message"
            ],
            "properties": {
              "code": {
                "$ref": "#/components/schemas/ErrorCode"
              },
              "message": {
                "type": "string"
              },
              "retry_after_seconds": {
                "type": [
                  "integer",
                  "null"
                ]
              },
              "details": {
                "type": "object",
                "additionalProperties": true
              }
            }
          }
        }
      },
      "Source": {
        "type": "string",
        "enum": [
          "web",
          "news",
          "smallweb",
          "discussions",
          "hn",
          "social",
          "communities",
          "podcasts",
          "academic",
          "medical",
          "law",
          "finance",
          "contracts"
        ],
        "description": "A source slug. `GET /v1/sources` describes each one."
      },
      "SafeSearch": {
        "type": "string",
        "enum": [
          "off",
          "moderate",
          "strict"
        ],
        "default": "moderate"
      },
      "DomainList": {
        "type": "array",
        "maxItems": 25,
        "items": {
          "type": "string",
          "description": "A host name such as `example.com`. A leading `www.`, a scheme or a path is ignored."
        }
      },
      "PageType": {
        "type": "string",
        "enum": [
          "research",
          "directories",
          "creative-writing",
          "support",
          "comments",
          "faqs",
          "reference",
          "legal",
          "listicles",
          "news",
          "articles",
          "companies",
          "press-releases",
          "profiles",
          "blogs",
          "products",
          "forums",
          "spam",
          "data",
          "documentation",
          "transcripts",
          "tutorials",
          "reviews"
        ],
        "description": "A kind of page. `GET /v1/sources` gives a label for each."
      },
      "Topic": {
        "type": "string",
        "enum": [
          "adult",
          "art",
          "programming",
          "law",
          "education",
          "hardware",
          "entertainment",
          "social-life",
          "fashion",
          "business",
          "food",
          "games",
          "health",
          "history",
          "home",
          "industry",
          "literature",
          "politics",
          "religion",
          "science",
          "software",
          "sports",
          "transport",
          "travel"
        ],
        "description": "What a page is about. `GET /v1/sources` gives a label for each."
      },
      "TrafficTrend": {
        "type": "string",
        "enum": [
          "rising",
          "spiking",
          "steady",
          "falling",
          "dropped",
          "new"
        ],
        "description": "How visits to a site are moving. `rising`: growing. `spiking`: jumped sharply in the last\ndays. `steady`: no clear change. `falling`: shrinking. `dropped`: fell sharply in the last\ndays. `new`: the site appeared recently.\n"
      },
      "PopularityBucket": {
        "type": "string",
        "enum": [
          "top-100",
          "top-1k",
          "top-10k",
          "top-100k",
          "top-1m",
          "long-tail"
        ],
        "description": "Where a site sits among the most popular sites. `long-tail` is outside the top 1,000,000."
      },
      "CountryCode": {
        "type": "string",
        "pattern": "^[A-Za-z]{2}$",
        "description": "A two-letter country code such as `DE` or `US`. `UK` is read as `GB`."
      },
      "PageTypeList": {
        "type": "array",
        "uniqueItems": true,
        "items": {
          "$ref": "#/components/schemas/PageType"
        }
      },
      "TopicList": {
        "type": "array",
        "uniqueItems": true,
        "items": {
          "$ref": "#/components/schemas/Topic"
        }
      },
      "SearchRequest": {
        "type": "object",
        "required": [
          "query"
        ],
        "additionalProperties": false,
        "properties": {
          "query": {
            "type": "string",
            "minLength": 1,
            "maxLength": 400
          },
          "sources": {
            "type": "array",
            "minItems": 1,
            "maxItems": 5,
            "uniqueItems": true,
            "default": [
              "web"
            ],
            "items": {
              "$ref": "#/components/schemas/Source"
            },
            "description": "Sources to search. Each source searched costs 1 credit."
          },
          "num_results": {
            "type": "integer",
            "minimum": 1,
            "maximum": 50,
            "default": 10,
            "description": "How many results to return in total. With several sources this is the length of the one merged list, not a count per source."
          },
          "remove_top_sites": {
            "type": "integer",
            "minimum": 0,
            "maximum": 1000000,
            "default": 0,
            "description": "Remove results from the N most popular sites. 0 keeps everything. Free."
          },
          "only_top_sites": {
            "type": "integer",
            "minimum": 0,
            "maximum": 1000000,
            "default": 0,
            "description": "Keep only results from the N most popular sites. Cannot be combined with `remove_top_sites`."
          },
          "index_level": {
            "type": "string",
            "enum": [
              "full",
              "top100",
              "top1k",
              "top10k",
              "top100k",
              "top1m"
            ],
            "deprecated": true,
            "description": "Earlier spelling of `remove_top_sites`: `top10k` means `remove_top_sites: 10000`, `full` means 0."
          },
          "include_domains": {
            "allOf": [
              {
                "$ref": "#/components/schemas/DomainList"
              }
            ],
            "description": "Return results from these sites only."
          },
          "exclude_domains": {
            "allOf": [
              {
                "$ref": "#/components/schemas/DomainList"
              }
            ],
            "description": "Never return results from these sites."
          },
          "boost_domains": {
            "allOf": [
              {
                "$ref": "#/components/schemas/DomainList"
              }
            ],
            "description": "Move results from these sites ahead of the rest."
          },
          "bury_domains": {
            "allOf": [
              {
                "$ref": "#/components/schemas/DomainList"
              }
            ],
            "description": "Move results from these sites to the end."
          },
          "only_domains": {
            "allOf": [
              {
                "$ref": "#/components/schemas/DomainList"
              }
            ],
            "description": "Another name for `include_domains`. Both sent are merged."
          },
          "block_domains": {
            "allOf": [
              {
                "$ref": "#/components/schemas/DomainList"
              }
            ],
            "description": "Another name for `exclude_domains`. Both sent are merged."
          },
          "page_types": {
            "allOf": [
              {
                "$ref": "#/components/schemas/PageTypeList"
              }
            ],
            "description": "Keep only these kinds of page, for example `[tutorials, documentation]`. Applied by `web` and `news`; other sources in the call get a `filter_not_applied` warning."
          },
          "exclude_page_types": {
            "allOf": [
              {
                "$ref": "#/components/schemas/PageTypeList"
              }
            ],
            "description": "Never return these kinds of page, for example `[listicles, spam]`."
          },
          "boost_page_types": {
            "allOf": [
              {
                "$ref": "#/components/schemas/PageTypeList"
              }
            ],
            "description": "Move these kinds of page ahead of the rest, for example `[documentation]`."
          },
          "bury_page_types": {
            "allOf": [
              {
                "$ref": "#/components/schemas/PageTypeList"
              }
            ],
            "description": "Move these kinds of page to the end, for example `[forums]`."
          },
          "topics": {
            "allOf": [
              {
                "$ref": "#/components/schemas/TopicList"
              }
            ],
            "description": "Keep only these topics, for example `[science, health]`. Applied by `web` and `news`; other sources in the call get a `filter_not_applied` warning."
          },
          "exclude_topics": {
            "allOf": [
              {
                "$ref": "#/components/schemas/TopicList"
              }
            ],
            "description": "Never return these topics, for example `[adult]`."
          },
          "boost_topics": {
            "allOf": [
              {
                "$ref": "#/components/schemas/TopicList"
              }
            ],
            "description": "Move these topics ahead of the rest, for example `[programming]`."
          },
          "bury_topics": {
            "allOf": [
              {
                "$ref": "#/components/schemas/TopicList"
              }
            ],
            "description": "Move these topics to the end, for example `[entertainment]`."
          },
          "popularity_buckets": {
            "type": "array",
            "minItems": 1,
            "uniqueItems": true,
            "items": {
              "$ref": "#/components/schemas/PopularityBucket"
            },
            "description": "Keep results whose site is in one of these popularity buckets, for example `[long-tail, top-1m]`. See also `remove_top_sites` and `only_top_sites`."
          },
          "traffic_trend": {
            "type": "array",
            "minItems": 1,
            "uniqueItems": true,
            "items": {
              "$ref": "#/components/schemas/TrafficTrend"
            },
            "description": "Keep results whose site's traffic is moving this way, for example `[rising, spiking]`. Each result says its own in `traffic_trend`. The site filters are checked on the best matches for the query, and sites on the move are rare: expect a short list."
          },
          "popular_in": {
            "type": "array",
            "minItems": 1,
            "maxItems": 10,
            "uniqueItems": true,
            "items": {
              "$ref": "#/components/schemas/CountryCode"
            },
            "description": "Keep results whose site is popular in any of these countries, for example `[DE, AT]`. Each result lists its own in `popular_in`."
          },
          "site_tech": {
            "type": "array",
            "minItems": 1,
            "maxItems": 10,
            "uniqueItems": true,
            "items": {
              "type": "string",
              "minLength": 1,
              "maxLength": 40
            },
            "description": "Keep results whose site is built with any of these, for example `[wordpress, woocommerce]`. Names are matched without regard to case against what results return in `site_tech`. A name is letters, digits, spaces and `. + # / -`, starting with a letter or digit."
          },
          "exclude_risky": {
            "type": "boolean",
            "default": false,
            "description": "Drop results whose site carries a risk label (`risk` is not null)."
          },
          "start_date": {
            "type": [
              "string",
              "null"
            ],
            "format": "date",
            "description": "Results published on or after this day (`YYYY-MM-DD`). Applied by `news`, `hn`, `social`, `communities`, `podcasts`, `academic`, `medical`, `law`, `finance` and `contracts`. `web` pages carry no date: a `filter_not_applied` warning says so."
          },
          "end_date": {
            "type": [
              "string",
              "null"
            ],
            "format": "date",
            "description": "Results published on or before this day (`YYYY-MM-DD`). Same sources as `start_date`."
          },
          "time_range": {
            "type": [
              "string",
              "null"
            ],
            "enum": [
              "day",
              "week",
              "month",
              "year",
              null
            ],
            "description": "The last 1, 7, 30 or 365 days. Cannot be combined with `start_date` or `end_date`."
          },
          "language": {
            "type": [
              "string",
              "null"
            ],
            "pattern": "^[A-Za-z]{2}$",
            "description": "A two-letter language code such as `en` or `de`. Applied by `news`, `hn`, `social`, `communities`, `podcasts` and `academic`, which store a language. `web` stores none: the language of each web result is detected from its text, the filter is applied to the best matches, and a `language_detected` warning says so."
          },
          "country": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/CountryCode"
              },
              {
                "type": "null"
              }
            ],
            "description": "Results from this country. `web` and `news`: sites with the country's domain ending (`.de`, `.co.uk`; for `US` also `.gov`, `.edu` and `.mil`). `finance`: the filer's country. `contracts`: `US` or `CA`. Other sources get a `filter_not_applied` warning."
          },
          "max_highlights": {
            "type": "integer",
            "minimum": 0,
            "maximum": 5,
            "default": 0,
            "description": "Return up to this many passages per result that best answer the query, in `highlights`, with `highlight_spans`. 0 keeps `highlights` as the snippet alone. Free."
          },
          "highlight_characters": {
            "type": "integer",
            "minimum": 100,
            "maximum": 600,
            "default": 300,
            "description": "Target length of one highlight. Needs `max_highlights`."
          },
          "include_content": {
            "type": "boolean",
            "default": false,
            "description": "Add `content` to each result: the text of the page as we hold it, for `web` and `news` results. No request is made to the site. 1 credit per call, covering up to 10 results that come back with content; each further 10 (or part) 1 more; nothing when none comes back with content."
          },
          "max_characters": {
            "type": "integer",
            "minimum": 500,
            "maximum": 50000,
            "default": 10000,
            "description": "Longest `content.text` to return. Needs `include_content`."
          },
          "safe_search": {
            "$ref": "#/components/schemas/SafeSearch"
          },
          "max_chars_per_result": {
            "type": "integer",
            "minimum": 0,
            "maximum": 2000,
            "default": 800,
            "description": "Longest snippet to return per result, in characters. 0 returns no snippets."
          },
          "explain": {
            "type": "boolean",
            "default": false,
            "description": "Add `why` and `signals` to every result. Free."
          },
          "mode": {
            "type": "string",
            "enum": [
              "standard"
            ],
            "default": "standard",
            "description": "There is one mode. The field is accepted so existing clients keep working."
          }
        }
      },
      "Popularity": {
        "type": "object",
        "required": [
          "rank",
          "bucket"
        ],
        "properties": {
          "rank": {
            "type": [
              "integer",
              "null"
            ],
            "description": "The site's popularity rank (1 is the most popular), or null when it is outside the top 1,000,000 or unknown."
          },
          "bucket": {
            "type": "string",
            "enum": [
              "top-100",
              "top-1k",
              "top-10k",
              "top-100k",
              "top-1m",
              "long-tail",
              "unknown"
            ]
          }
        }
      },
      "Risk": {
        "type": "object",
        "required": [
          "level",
          "categories"
        ],
        "description": "Present when the site carries a risk label; otherwise null.",
        "properties": {
          "level": {
            "type": "string",
            "enum": [
              "labelled",
              "demoted",
              "blocked"
            ]
          },
          "categories": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        }
      },
      "Signals": {
        "type": "object",
        "description": "Only with `explain`.",
        "properties": {
          "text_rank": {
            "type": [
              "integer",
              "null"
            ],
            "description": "Position by text relevance alone."
          },
          "link_authority": {
            "type": [
              "number",
              "null"
            ],
            "minimum": 0,
            "maximum": 10,
            "description": "How well linked the site is, 0 to 10. Null when the source has none for the result."
          },
          "words": {
            "type": [
              "integer",
              "null"
            ],
            "description": "Length of the page in words."
          }
        }
      },
      "SearchResult": {
        "type": "object",
        "required": [
          "title",
          "url",
          "site",
          "source",
          "snippet",
          "highlights",
          "published_date",
          "page_type",
          "topic",
          "popularity",
          "risk",
          "position",
          "score",
          "extra"
        ],
        "properties": {
          "title": {
            "type": "string"
          },
          "url": {
            "type": "string",
            "format": "uri"
          },
          "site": {
            "type": [
              "string",
              "null"
            ],
            "description": "The host name",
            "without `www.`.": null
          },
          "source": {
            "$ref": "#/components/schemas/Source"
          },
          "snippet": {
            "type": "string",
            "description": "The passage of the page that matches the query."
          },
          "highlights": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "The snippet as a one-item list. With `max_highlights`: up to that many passages that best answer the query, best first."
          },
          "highlight_spans": {
            "type": "array",
            "description": "Only with `max_highlights`: one entry per highlight, in the same order.",
            "items": {
              "$ref": "#/components/schemas/HighlightSpan"
            }
          },
          "content": {
            "description": "Only with `include_content`: the page's text, or null when we hold none for this result.",
            "oneOf": [
              {
                "$ref": "#/components/schemas/PageContent"
              },
              {
                "type": "null"
              }
            ]
          },
          "language": {
            "type": [
              "string",
              "null"
            ],
            "pattern": "^[a-z]{2}$",
            "description": "The result's language as a two-letter code, or null when not known. Stored by the source for `news`, `hn`, `social`, `podcasts` and `academic`; detected from the result's text for `web`, where a result whose language cannot be told has null and does not pass a `language` filter."
          },
          "traffic_trend": {
            "description": "How visits to the result's site are moving, or null when not known.",
            "oneOf": [
              {
                "$ref": "#/components/schemas/TrafficTrend"
              },
              {
                "type": "null"
              }
            ]
          },
          "popular_in": {
            "type": [
              "array",
              "null"
            ],
            "maxItems": 12,
            "items": {
              "type": "string",
              "pattern": "^[A-Z]{2}$"
            },
            "description": "The countries (two-letter codes) where the result's site is among the popular sites, or null when not known."
          },
          "site_tech": {
            "type": [
              "array",
              "null"
            ],
            "maxItems": 8,
            "items": {
              "type": "string"
            },
            "description": "What the result's site is built with, for example `[WordPress, WooCommerce]`. An empty list when we looked and recognised nothing; null when we have not looked."
          },
          "published_date": {
            "type": [
              "string",
              "null"
            ],
            "description": "`YYYY-MM-DD`, or a year, when the source knows it. Web results have no date."
          },
          "page_type": {
            "type": [
              "string",
              "null"
            ],
            "description": "A page-type slug from `GET /v1/sources`."
          },
          "topic": {
            "type": [
              "string",
              "null"
            ],
            "description": "A topic slug from `GET /v1/sources`."
          },
          "popularity": {
            "$ref": "#/components/schemas/Popularity"
          },
          "risk": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/Risk"
              },
              {
                "type": "null"
              }
            ]
          },
          "position": {
            "type": "integer",
            "minimum": 1
          },
          "score": {
            "type": "number",
            "description": "Rank-based, from 1.0 for the first result downwards. Not comparable across calls."
          },
          "extra": {
            "type": "object",
            "description": "A few fields that only some sources have, such as `authors`, `venue`, `year`, `citations`, `points` or `filer`. Values are strings, numbers or booleans.",
            "additionalProperties": {
              "type": [
                "string",
                "number",
                "boolean"
              ]
            }
          },
          "why": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Only with `explain`: why this result is here, at this position."
          },
          "signals": {
            "$ref": "#/components/schemas/Signals"
          }
        }
      },
      "HighlightSpan": {
        "type": "object",
        "required": [
          "start",
          "end",
          "score"
        ],
        "properties": {
          "start": {
            "type": [
              "integer",
              "null"
            ],
            "minimum": 0,
            "description": "Character offset (in Unicode code points) of the highlight in `content.text` as this result returns it. Null when there is nothing to point into: `include_content` was not sent, the highlight lies past the `max_characters` cut, or we hold no page text for the result."
          },
          "end": {
            "type": [
              "integer",
              "null"
            ],
            "description": "The offset just past the highlight. Null with `start`."
          },
          "score": {
            "type": "number",
            "minimum": 0,
            "maximum": 1,
            "description": "1.0 is a full-length passage of plain prose that holds every word of the query."
          }
        }
      },
      "PageContent": {
        "type": "object",
        "required": [
          "text",
          "characters",
          "truncated",
          "captured_from",
          "captured_to"
        ],
        "properties": {
          "text": {
            "type": "string",
            "description": "The page's text: menus and page chrome removed, e-mail addresses and phone numbers redacted, cut at `max_characters`."
          },
          "characters": {
            "type": "integer",
            "description": "Length of `text`."
          },
          "truncated": {
            "type": "boolean",
            "description": "True when the page is longer than `text`."
          },
          "captured_from": {
            "type": "string",
            "format": "date",
            "description": "The earliest day this copy can have been taken. Treat the page as being this old."
          },
          "captured_to": {
            "type": "string",
            "format": "date",
            "description": "The latest day this copy can have been taken. The same day as `captured_from` for news."
          }
        }
      },
      "Freshness": {
        "type": "object",
        "required": [
          "cadence",
          "description"
        ],
        "properties": {
          "cadence": {
            "type": "string",
            "enum": [
              "minutes",
              "hourly",
              "twice_daily",
              "daily",
              "weekly",
              "snapshot"
            ],
            "description": "How often new material arrives."
          },
          "description": {
            "type": "string"
          },
          "captured_from": {
            "type": "string",
            "format": "date",
            "description": "Snapshot sources: the first day its pages were captured."
          },
          "captured_to": {
            "type": "string",
            "format": "date",
            "description": "Snapshot sources: the last day its pages were captured."
          }
        }
      },
      "SearchSummary": {
        "type": "object",
        "required": [
          "returned",
          "removed"
        ],
        "properties": {
          "returned": {
            "type": "integer"
          },
          "removed": {
            "type": "object",
            "required": [
              "popularity",
              "blocked",
              "duplicates",
              "risk",
              "safe_search"
            ],
            "description": "How many results were removed, by reason.",
            "properties": {
              "popularity": {
                "type": "integer",
                "description": "Removed by `remove_top_sites` or `only_top_sites`."
              },
              "blocked": {
                "type": "integer",
                "description": "Removed by `exclude_domains` (`block_domains`), `exclude_page_types` or `exclude_topics`."
              },
              "duplicates": {
                "type": "integer"
              },
              "risk": {
                "type": "integer"
              },
              "safe_search": {
                "type": "integer"
              },
              "filters": {
                "type": "integer",
                "description": "Removed by `popularity_buckets`, `traffic_trend`, `popular_in`, `site_tech` or `exclude_risky`."
              }
            }
          }
        }
      },
      "SearchResponse": {
        "type": "object",
        "required": [
          "data",
          "request_id",
          "usage",
          "warnings"
        ],
        "properties": {
          "request_id": {
            "type": "string"
          },
          "usage": {
            "$ref": "#/components/schemas/Usage"
          },
          "warnings": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Warning"
            },
            "description": "The same list as `data.warnings`."
          },
          "data": {
            "type": "object",
            "required": [
              "results",
              "summary",
              "warnings"
            ],
            "properties": {
              "results": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/SearchResult"
                }
              },
              "summary": {
                "$ref": "#/components/schemas/SearchSummary"
              },
              "warnings": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Warning"
                }
              }
            }
          }
        }
      },
      "SourcesResponse": {
        "type": "object",
        "required": [
          "data",
          "request_id",
          "usage"
        ],
        "properties": {
          "request_id": {
            "type": "string"
          },
          "usage": {
            "$ref": "#/components/schemas/Usage"
          },
          "warnings": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Warning"
            }
          },
          "data": {
            "type": "object",
            "required": [
              "sources",
              "page_types",
              "topics"
            ],
            "properties": {
              "sources": {
                "type": "array",
                "items": {
                  "type": "object",
                  "required": [
                    "slug",
                    "description",
                    "freshness"
                  ],
                  "properties": {
                    "slug": {
                      "$ref": "#/components/schemas/Source"
                    },
                    "description": {
                      "type": "string",
                      "description": "What the source contains."
                    },
                    "freshness": {
                      "$ref": "#/components/schemas/Freshness"
                    },
                    "filters": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      },
                      "description": "The request fields this source applies. A filter sent to a source that does not list it is reported in a `filter_not_applied` warning."
                    }
                  }
                }
              },
              "page_types": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Slug"
                }
              },
              "topics": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Slug"
                }
              },
              "traffic_trends": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Slug"
                },
                "description": "The values `traffic_trend` accepts."
              },
              "popularity_buckets": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/PopularityBucket"
                },
                "description": "The values `popularity_buckets` accepts."
              }
            }
          }
        }
      },
      "Slug": {
        "type": "object",
        "required": [
          "slug",
          "label"
        ],
        "properties": {
          "slug": {
            "type": "string"
          },
          "label": {
            "type": "string"
          }
        }
      },
      "DomainRequest": {
        "type": "object",
        "required": [
          "domains"
        ],
        "additionalProperties": false,
        "properties": {
          "domains": {
            "type": "array",
            "minItems": 1,
            "maxItems": 25,
            "items": {
              "type": "string",
              "description": "A host name such as `example.com`."
            }
          }
        }
      },
      "DomainInfo": {
        "type": "object",
        "required": [
          "domain",
          "popularity",
          "risk"
        ],
        "properties": {
          "domain": {
            "type": "string"
          },
          "popularity": {
            "$ref": "#/components/schemas/Popularity"
          },
          "risk": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/Risk"
              },
              {
                "type": "null"
              }
            ]
          }
        }
      },
      "DomainResponse": {
        "type": "object",
        "required": [
          "data",
          "request_id",
          "usage"
        ],
        "properties": {
          "request_id": {
            "type": "string"
          },
          "usage": {
            "$ref": "#/components/schemas/Usage"
          },
          "warnings": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Warning"
            }
          },
          "data": {
            "type": "object",
            "required": [
              "domains"
            ],
            "properties": {
              "domains": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/DomainInfo"
                }
              }
            }
          }
        }
      },
      "AgentKeyRequest": {
        "type": "object",
        "required": [
          "agent"
        ],
        "properties": {
          "agent": {
            "type": "string",
            "maxLength": 60,
            "description": "The agent's name."
          },
          "purpose": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 200
          }
        }
      },
      "AgentKeyResponse": {
        "type": "object",
        "required": [
          "data",
          "request_id"
        ],
        "properties": {
          "request_id": {
            "type": "string"
          },
          "usage": {
            "type": [
              "object",
              "null"
            ]
          },
          "warnings": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": true
            }
          },
          "data": {
            "type": "object",
            "required": [
              "api_key",
              "tier",
              "rate_limit",
              "team_id"
            ],
            "properties": {
              "api_key": {
                "type": "string",
                "description": "The `ms-...` key, shown exactly once."
              },
              "tier": {
                "type": "string",
                "enum": [
                  "trial"
                ]
              },
              "rate_limit": {
                "type": "string",
                "example": "60/min"
              },
              "expires_in_days": {
                "type": "integer",
                "example": 1,
                "description": "`expires_in_hours` rounded up to whole days."
              },
              "expires_in_hours": {
                "type": "integer",
                "example": 24
              },
              "expires_at": {
                "type": "string",
                "format": "date-time",
                "description": "When the key stops working."
              },
              "team_id": {
                "type": "string"
              }
            }
          }
        }
      },
      "AccountResponse": {
        "type": "object",
        "required": [
          "data",
          "request_id"
        ],
        "properties": {
          "request_id": {
            "type": "string"
          },
          "data": {
            "type": "object",
            "required": [
              "user",
              "team"
            ],
            "properties": {
              "user": {
                "type": "object",
                "properties": {
                  "email": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "role": {
                    "type": "string",
                    "enum": [
                      "owner",
                      "member"
                    ]
                  }
                }
              },
              "team": {
                "type": "object",
                "properties": {
                  "id": {
                    "type": "integer"
                  },
                  "name": {
                    "type": "string"
                  },
                  "tier": {
                    "type": "string"
                  },
                  "credit_balance": {
                    "type": "number",
                    "description": "Prepaid credits only. `credits` has the whole picture."
                  }
                }
              },
              "plan": {
                "$ref": "#/components/schemas/TeamPlan"
              },
              "credits": {
                "$ref": "#/components/schemas/TeamCredits"
              },
              "created_at": {
                "type": "string",
                "format": "date-time"
              }
            }
          }
        }
      },
      "TeamPlan": {
        "type": "object",
        "description": "The plan the team is on.",
        "properties": {
          "id": {
            "type": [
              "string",
              "null"
            ],
            "description": "A plan `id`, or null for a team with prepaid credits only."
          },
          "name": {
            "type": [
              "string",
              "null"
            ]
          },
          "status": {
            "type": [
              "string",
              "null"
            ],
            "description": "The state of a paid plan: `active`, `trialing`, `past_due`, `canceled`. Null on the free plan."
          },
          "cancel_at_period_end": {
            "type": "boolean"
          },
          "period_start": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "period_end": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When the included credits are next replaced."
          },
          "can_manage": {
            "type": "boolean",
            "description": "Whether `POST /account/billing/portal` has a plan to manage."
          }
        }
      },
      "TeamCredits": {
        "type": "object",
        "description": "Credits are spent in this order - the plan's included credits, then prepaid credits.",
        "properties": {
          "allowance_remaining": {
            "type": "number",
            "description": "Included credits left in this period. They do not carry over."
          },
          "allowance_monthly": {
            "type": "number",
            "description": "Included credits per period on this plan."
          },
          "balance": {
            "type": "number",
            "description": "Prepaid credits. They do not expire."
          },
          "available": {
            "type": "number",
            "description": "What the team can spend right now."
          },
          "overage": {
            "type": "object",
            "properties": {
              "mode": {
                "type": "string",
                "enum": [
                  "prepaid",
                  "metered"
                ]
              },
              "used": {
                "type": "number"
              },
              "cap": {
                "type": "number"
              }
            }
          }
        }
      },
      "Plan": {
        "type": "object",
        "required": [
          "id",
          "name",
          "available"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "monthly_usd": {
            "type": [
              "number",
              "null"
            ],
            "description": "Null means by agreement."
          },
          "monthly_credits": {
            "type": [
              "integer",
              "null"
            ]
          },
          "overage_usd_per_1k": {
            "type": [
              "number",
              "null"
            ],
            "description": "Price of 1,000 credits beyond the included ones. Null means none."
          },
          "requests_per_minute": {
            "type": [
              "integer",
              "null"
            ]
          },
          "heavy_sources_per_minute": {
            "type": [
              "integer",
              "null"
            ]
          },
          "concurrent_searches": {
            "type": [
              "integer",
              "null"
            ]
          },
          "available": {
            "type": "boolean",
            "description": "Whether the plan can be started from the dashboard today."
          }
        }
      },
      "PlansResponse": {
        "type": "object",
        "required": [
          "data",
          "request_id"
        ],
        "properties": {
          "request_id": {
            "type": "string"
          },
          "data": {
            "type": "object",
            "required": [
              "plans",
              "plan",
              "credits"
            ],
            "properties": {
              "plans": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Plan"
                }
              },
              "plan": {
                "$ref": "#/components/schemas/TeamPlan"
              },
              "credits": {
                "$ref": "#/components/schemas/TeamCredits"
              }
            }
          }
        }
      },
      "PlanCheckoutResponse": {
        "type": "object",
        "required": [
          "data",
          "request_id"
        ],
        "properties": {
          "request_id": {
            "type": "string"
          },
          "data": {
            "type": "object",
            "required": [
              "checkout_url",
              "plan"
            ],
            "properties": {
              "checkout_url": {
                "type": "string",
                "format": "uri"
              },
              "plan": {
                "type": "string"
              },
              "monthly_usd": {
                "type": "number"
              },
              "monthly_credits": {
                "type": "integer"
              }
            }
          }
        }
      },
      "ApiKey": {
        "type": "object",
        "required": [
          "id",
          "name",
          "prefix"
        ],
        "properties": {
          "id": {
            "type": "integer"
          },
          "name": {
            "type": "string"
          },
          "prefix": {
            "type": "string",
            "description": "The first characters of the key. Not a secret."
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "last_used_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "revoked_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          }
        }
      },
      "ApiKeyListResponse": {
        "type": "object",
        "required": [
          "data",
          "request_id"
        ],
        "properties": {
          "request_id": {
            "type": "string"
          },
          "data": {
            "type": "object",
            "required": [
              "keys"
            ],
            "properties": {
              "keys": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/ApiKey"
                }
              }
            }
          }
        }
      },
      "ApiKeyCreatedResponse": {
        "type": "object",
        "required": [
          "data",
          "request_id"
        ],
        "properties": {
          "request_id": {
            "type": "string"
          },
          "data": {
            "allOf": [
              {
                "$ref": "#/components/schemas/ApiKey"
              },
              {
                "type": "object",
                "required": [
                  "key"
                ],
                "properties": {
                  "key": {
                    "type": "string",
                    "description": "The full `ms-...` key. Shown this once."
                  }
                }
              }
            ]
          }
        }
      },
      "ApiKeyRevokedResponse": {
        "type": "object",
        "required": [
          "data",
          "request_id"
        ],
        "properties": {
          "request_id": {
            "type": "string"
          },
          "data": {
            "allOf": [
              {
                "$ref": "#/components/schemas/ApiKey"
              },
              {
                "type": "object",
                "properties": {
                  "revoked": {
                    "type": "boolean"
                  }
                }
              }
            ]
          }
        }
      },
      "UsageLedgerResponse": {
        "type": "object",
        "required": [
          "data",
          "request_id"
        ],
        "properties": {
          "request_id": {
            "type": "string"
          },
          "data": {
            "type": "object",
            "required": [
              "entries",
              "next",
              "summary"
            ],
            "properties": {
              "entries": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "endpoint": {
                      "type": "string"
                    },
                    "type": {
                      "type": "string",
                      "enum": [
                        "spend",
                        "topup",
                        "trial",
                        "allowance",
                        "refund"
                      ]
                    },
                    "credits": {
                      "type": "number"
                    },
                    "cost_usd": {
                      "type": "number"
                    },
                    "from_allowance": {
                      "type": "number",
                      "description": "Of a spend",
                      "the part that came out of the plan's included credits.": null
                    },
                    "from_overage": {
                      "type": "number",
                      "description": "Of a spend",
                      "the part beyond included and prepaid credits.": null
                    },
                    "breakdown": {
                      "type": "object",
                      "additionalProperties": true
                    },
                    "request_id": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "created_at": {
                      "type": "string",
                      "format": "date-time"
                    }
                  }
                }
              },
              "next": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "summary": {
                "type": "object",
                "properties": {
                  "balance": {
                    "type": "number"
                  },
                  "spent_30d": {
                    "type": "number"
                  },
                  "topped_up_30d": {
                    "type": "number"
                  },
                  "allowance_remaining": {
                    "type": "number"
                  },
                  "allowance_monthly": {
                    "type": "number"
                  },
                  "period_end": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "format": "date-time"
                  }
                }
              }
            }
          }
        }
      },
      "CreditPacksResponse": {
        "type": "object",
        "required": [
          "data",
          "request_id"
        ],
        "properties": {
          "request_id": {
            "type": "string"
          },
          "data": {
            "type": "object",
            "required": [
              "packs",
              "usd_per_credit"
            ],
            "properties": {
              "usd_per_credit": {
                "type": "number",
                "example": 0.001
              },
              "packs": {
                "type": "array",
                "items": {
                  "type": "object",
                  "required": [
                    "id",
                    "credits",
                    "amount_usd"
                  ],
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "credits": {
                      "type": "integer"
                    },
                    "amount_usd": {
                      "type": "number"
                    },
                    "list_usd": {
                      "type": "number"
                    },
                    "savings_pct": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "CheckoutResponse": {
        "type": "object",
        "required": [
          "data",
          "request_id"
        ],
        "properties": {
          "request_id": {
            "type": "string"
          },
          "data": {
            "type": "object",
            "required": [
              "checkout_url",
              "pack",
              "credits",
              "amount_usd"
            ],
            "properties": {
              "checkout_url": {
                "type": "string",
                "format": "uri"
              },
              "pack": {
                "type": "string"
              },
              "credits": {
                "type": "integer"
              },
              "amount_usd": {
                "type": "number"
              }
            }
          }
        }
      }
    }
  }
}
