{
  "openapi": "3.0.3",
  "info": {
    "title": "Search API",
    "version": "1.1.0"
  },
  "servers": [
    {
      "url": "https://api.olostep.com"
    }
  ],
  "components": {
    "securitySchemes": {
      "Authorization": {
        "type": "http",
        "scheme": "bearer",
        "description": "Bearer authentication header of the form Bearer <token>, where <token> is your auth token."
      }
    },
    "schemas": {
      "ScrapeOptions": {
        "type": "object",
        "description": "Optional. When provided, each returned link is also scraped and its content embedded into the response. Per-page scrape credits are billed automatically by the underlying /v1/scrapes endpoint.",
        "properties": {
          "formats": {
            "type": "array",
            "description": "Output formats to request for each scraped page. Defaults to ['markdown'] when omitted. For now only 'html' and 'markdown' are supported on /v1/searches.",
            "items": {
              "type": "string",
              "enum": ["html", "markdown"]
            },
            "default": ["markdown"],
            "example": ["markdown"]
          },
          "remove_css_selectors": {
            "type": "string",
            "description": "Option to remove certain CSS selectors from the content. Forwarded to /v1/scrapes. Defaults to 'default' which strips ['nav','footer','script','style','noscript','svg',[role=alert],[role=banner],[role=dialog],[role=alertdialog],[role=region][aria-label*=skip i],[aria-modal=true]]. Pass 'none' to disable, or a JSON-stringified array of selectors to remove.",
            "default": "default"
          },
          "timeout": {
            "type": "integer",
            "description": "Wallclock budget in seconds for the entire scrape phase. After this elapses, the search returns with whatever links are available — content fields will be null for any links that hadn't finished scraping.",
            "minimum": 1,
            "maximum": 60,
            "default": 25
          }
        }
      },
      "SearchLink": {
        "type": "object",
        "properties": {
          "url": {
            "type": "string",
            "description": "The URL of the result."
          },
          "title": {
            "type": "string",
            "nullable": true,
            "description": "The title of the result page."
          },
          "description": {
            "type": "string",
            "nullable": true,
            "description": "A short snippet or description of the result."
          },
          "markdown_content": {
            "type": "string",
            "nullable": true,
            "description": "Markdown content of the page. Only present when scrape_options.formats includes 'markdown'. Null if the scrape failed, was empty, or hit the global timeout. For Reddit comment URLs, this is generated from the @olostep/reddit-post parser's structured JSON for higher quality."
          },
          "html_content": {
            "type": "string",
            "nullable": true,
            "description": "HTML content of the page. Only present when scrape_options.formats includes 'html'. Null if the scrape failed, was empty, or hit the global timeout."
          }
        }
      }
    }
  },
  "paths": {
    "/v1/searches/{search_id}": {
      "get": {
        "summary": "Get Search",
        "description": "Retrieve a previously completed search by its ID. Returns whatever was persisted at search time, including any scraped per-link content. Pure idempotent read — no re-scraping, no re-billing. A search created with `zero_data_retention: true` returns 200 with `query` `\"[redacted]\"`, `result.json_content` and `result.json_hosted_url` both `null`, and no links, people, or companies.",
        "security": [
          {
            "Authorization": []
          }
        ],
        "parameters": [
          {
            "name": "search_id",
            "in": "path",
            "required": true,
            "description": "Unique identifier for the search to be retrieved.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response with the search object.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "storage": {
                      "type": "object",
                      "description": "Retention applied to this search's stored files.",
                      "properties": {
                        "expires_in": {
                          "type": "string",
                          "enum": [
                            "7d",
                            "10d",
                            "30d",
                            "60d",
                            "90d",
                            "180d",
                            "365d",
                            "never"
                          ],
                          "example": "7d",
                          "description": "The retention in effect. 7d when storage was omitted on create."
                        }
                      }
                    },
                    "id": {
                      "type": "string"
                    },
                    "object": {
                      "type": "string"
                    },
                    "created": {
                      "type": "integer"
                    },
                    "metadata": {
                      "type": "object"
                    },
                    "query": {
                      "type": "string",
                      "description": "The query stored for this search. `\"[redacted]\"` when the search was created with `zero_data_retention`."
                    },
                    "credits_consumed": {
                      "type": "integer",
                      "description": "Total credits consumed by the original search request (15 base credits + sum of per-page scrape credits, if scrape_options was used)."
                    },
                    "result": {
                      "type": "object",
                      "properties": {
                        "json_content": {
                          "type": "string",
                          "nullable": true,
                          "description": "Stringified JSON of the stored search result. Null when `json_hosted_url` is set. Also null for a search created with `zero_data_retention`, because the result was not stored."
                        },
                        "json_hosted_url": {
                          "type": "string",
                          "nullable": true,
                          "description": "URL of the stored JSON file. Null when the result was not stored, including a search created with `zero_data_retention`."
                        },
                        "links": {
                          "type": "array",
                          "items": {
                            "$ref": "#/components/schemas/SearchLink"
                          }
                        },
                        "people": {
                          "type": "array",
                          "description": "Profiles found by a `people` search, each with its `linkedin_url`. Present instead of `links`.",
                          "items": {
                            "type": "object",
                            "additionalProperties": true
                          }
                        },
                        "companies": {
                          "type": "array",
                          "description": "Companies found by a `companies` search, each with its `linkedin_url`. Present instead of `links`.",
                          "items": {
                            "type": "object",
                            "additionalProperties": true
                          }
                        },
                        "parameters": {
                          "type": "object",
                          "description": "The filters a `people` or `companies` search ran with: those read from `query`, overridden by `category.parameters`. Numbers are returned as sent.",
                          "properties": {
                            "name": {
                              "type": "string"
                            },
                            "job_title": {
                              "type": "string"
                            },
                            "location": {
                              "type": "string"
                            },
                            "years_of_experience": {
                              "type": "integer"
                            },
                            "current_employer": {
                              "type": "string"
                            },
                            "size": {
                              "type": "integer"
                            },
                            "revenue_usd": {
                              "type": "integer"
                            }
                          },
                          "additionalProperties": true
                        },
"size_exceeded": {
                          "type": "boolean",
                          "description": "True when the inline per-link markdown_content / html_content payload exceeded the 9MB safety cap. When true, those fields are nulled in the response — fetch json_hosted_url to download the full payload from S3."
                        },
                        "credits_consumed": {
                          "type": "integer",
                          "description": "Same value as the top-level credits_consumed, repeated inside result for symmetry with /v1/scrapes."
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Invalid API Key"
          },
          "404": {
            "description": "Search Not Found"
          },
          "500": {
            "description": "Internal Server Error"
          }
        }
      }
    },
    "/v1/searches": {
      "post": {
        "summary": "Create Search",
        "description": "Search the web with a natural language query and get back a deduplicated list of relevant links with titles and descriptions.\n\nIt will search for the query semantically across the web and return results.\n\nOptionally, pass `scrape_options` to also scrape every returned URL and embed `markdown_content` / `html_content` directly into each link. Page scrapes are billed automatically against your team via the underlying /v1/scrapes endpoint.\n\nPass `zero_data_retention: true` to return the result inline and not store it. See [Zero data retention](/features/search#zero-data-retention).\n\nSee [Search feature](/features/search).",
        "security": [
          {
            "Authorization": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "storage": {
                    "type": "object",
                    "description": "Controls how long this search's stored files (its file and any scraped link content) are retained. When omitted, they are kept for 7 days. The value in effect is returned in the response as storage.expires_in. See the Storage section in the feature docs. An invalid value returns 400 with code invalid_storage_expires_in.",
                    "properties": {
                      "expires_in": {
                        "type": "string",
                        "enum": [
                          "7d",
                          "10d",
                          "30d",
                          "60d",
                          "90d",
                          "180d",
                          "365d",
                          "never"
                        ],
                        "default": "7d",
                        "description": "How long to keep the stored files. 7d is the default, never retains them indefinitely. Omitting expires_in inside storage also means 7d."
                      }
                    }
                  },
                  "query": {
                    "type": "string",
                    "description": "The search query in natural language, in any language. Required unless `category.type` is `people` or `companies`, where `category.parameters` can be sent instead. With `people` or `companies` it is translated into `category.parameters`.",
                    "example": "What's going on with OpenAI's Sora shutting down?"
                  },
                  "category": {
                    "type": "object",
                    "description": "What to search. `any` (default) is the web search. `people` and `companies` search professional profiles and companies: send `query` in natural language, `parameters`, or both. `limit`, `include_domains`, `exclude_domains` and `scrape_options` are then ignored. A people or companies search costs 40 credits when it returns at least one result, and 0 otherwise.",
                    "default": {
                      "type": "any"
                    },
                    "required": ["type"],
                    "properties": {
                      "type": {
                        "type": "string",
                        "enum": ["any", "people", "companies"],
                        "default": "any"
                      },
                      "parameters": {
                        "type": "object",
                        "description": "Filters of a people or companies search. Required unless `query` is sent. When both are sent, the fields set here win over the ones read from `query`. Fields of the other type are ignored.",
                        "properties": {
                          "name": {
                            "type": "string",
                            "minLength": 1,
                            "description": "Person name (`people`) or company name (`companies`)."
                          },
                          "job_title": {
                            "type": "string",
                            "minLength": 1,
                            "description": "Job title. `people` only."
                          },
                          "location": {
                            "type": "string",
                            "minLength": 1,
                            "description": "Location: city, region or country. For `companies`, the location of the company."
                          },
                          "years_of_experience": {
                            "type": "integer",
                            "minimum": 0,
                            "description": "Years of experience. `people` only."
                          },
                          "current_employer": {
                            "type": "string",
                            "minLength": 1,
                            "description": "Current employer. `people` only."
                          },
                          "size": {
                            "type": "integer",
                            "minimum": 1,
                            "description": "Company headcount. `companies` only."
                          },
                          "revenue_usd": {
                            "type": "integer",
                            "minimum": 0,
                            "description": "Company revenue in USD. `companies` only."
                          }
                        }
                      }
                    }
                  },
"limit": {
                    "type": "integer",
                    "description": "Maximum number of links to return after deduplication.",
                    "minimum": 1,
                    "maximum": 25,
                    "default": 12,
                    "example": 10
                  },
                  "include_domains": {
                    "type": "array",
                    "description": "Restrict results to these domains. Bare hosts only — leading `http(s)://` and trailing slashes are stripped automatically.",
                    "items": {
                      "type": "string"
                    },
                    "example": ["nytimes.com", "wsj.com"]
                  },
                  "exclude_domains": {
                    "type": "array",
                    "description": "Exclude results from these domains. Bare hosts only — leading `http(s)://` and trailing slashes are stripped automatically.",
                    "items": {
                      "type": "string"
                    },
                    "example": ["reddit.com"]
                  },
                  "fast_mode": {
                    "type": "boolean",
                    "description": "Request a direct, low-latency search using your query verbatim. Default mode performs a broader search pass for wider result coverage.",
                    "default": false
                  },
                  "zero_data_retention": {
                    "type": "boolean",
                    "description": "When true, Olostep does not store the search result: it is returned inline in `result.json_content` and `result.json_hosted_url` is null. Olostep keeps only the search id and creation time, with the query stored as \"[redacted]\". Cannot be combined with `storage`, `scrape_options` or the `Idempotency-Key` header (400). See [Zero data retention](/features/search#zero-data-retention).",
                    "default": false
                  },
                  "scrape_options": {
                    "$ref": "#/components/schemas/ScrapeOptions"
                  }
                }
              },
              "examples": {
                "minimal": {
                  "summary": "Minimal — query only",
                  "value": {
                    "query": "Best Answer Engine Optimization startups"
                  }
                },
                "withScrape": {
                  "summary": "With scrape_options + domain filters + limit",
                  "value": {
                    "query": "What's going on with OpenAI's Sora shutting down?",
                    "limit": 10,
                    "include_domains": ["nytimes.com", "wsj.com"],
                    "exclude_domains": ["pinterest.com"],
                    "scrape_options": {
                      "formats": ["markdown"],
                      "remove_css_selectors": "default",
                      "timeout": 25
                    }
                  }
                },
                "people": {
                  "summary": "People search from a natural-language query",
                  "value": {
                    "query": "Senior software engineers in Berlin with more than 5 years of experience",
                    "category": { "type": "people" }
                  }
                },
                "companies": {
                  "summary": "Company search with explicit parameters",
                  "value": {
                    "category": {
                      "type": "companies",
                      "parameters": { "location": "Berlin", "size": 200 }
                    }
                  }
                },
                "zeroDataRetention": {
                  "summary": "Do not store the search result",
                  "value": {
                    "query": "Best Answer Engine Optimization startups",
                    "zero_data_retention": true
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response with search results.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "storage": {
                      "type": "object",
                      "description": "Retention applied to this search's stored files.",
                      "properties": {
                        "expires_in": {
                          "type": "string",
                          "enum": [
                            "7d",
                            "10d",
                            "30d",
                            "60d",
                            "90d",
                            "180d",
                            "365d",
                            "never"
                          ],
                          "example": "7d",
                          "description": "The retention in effect. 7d when storage was omitted on create."
                        }
                      }
                    },
                    "id": {
                      "type": "string",
                      "example": "search_9bi0sbj9xa"
                    },
                    "object": {
                      "type": "string",
                      "example": "search"
                    },
                    "created": {
                      "type": "integer",
                      "example": 1760327323
                    },
                    "metadata": {
                      "type": "object"
                    },
                    "query": {
                      "type": "string",
                      "example": "Best Answer Engine Optimization startups"
                    },
                    "credits_consumed": {
                      "type": "integer",
                      "description": "Total credits consumed by this request: 15 base search credits + sum of per-page scrape credits when scrape_options was used.",
                      "example": 10
                    },
                    "result": {
                      "type": "object",
                      "properties": {
                        "json_content": {
                          "type": "string",
                          "nullable": true,
                          "description": "Stringified JSON of the full search result. Null when `json_hosted_url` is set. When `zero_data_retention` is true, the result is returned here and `json_hosted_url` is null."
                        },
                        "json_hosted_url": {
                          "type": "string",
                          "description": "URL of the stored JSON file. Null when `zero_data_retention` is true; the result is in `json_content` instead.",
                          "nullable": true
                        },
                        "links": {
                          "type": "array",
                          "description": "Deduplicated list of relevant links found across multiple searches. Each link may include `markdown_content` and/or `html_content` when scrape_options was provided.",
                          "items": {
                            "$ref": "#/components/schemas/SearchLink"
                          }
                        },
                        "people": {
                          "type": "array",
                          "description": "Profiles found by a `people` search, each with its `linkedin_url`. Present instead of `links`.",
                          "items": {
                            "type": "object",
                            "additionalProperties": true
                          }
                        },
                        "companies": {
                          "type": "array",
                          "description": "Companies found by a `companies` search, each with its `linkedin_url`. Present instead of `links`.",
                          "items": {
                            "type": "object",
                            "additionalProperties": true
                          }
                        },
                        "parameters": {
                          "type": "object",
                          "description": "The filters a `people` or `companies` search ran with: those read from `query`, overridden by `category.parameters`. Numbers are returned as sent.",
                          "properties": {
                            "name": {
                              "type": "string"
                            },
                            "job_title": {
                              "type": "string"
                            },
                            "location": {
                              "type": "string"
                            },
                            "years_of_experience": {
                              "type": "integer"
                            },
                            "current_employer": {
                              "type": "string"
                            },
                            "size": {
                              "type": "integer"
                            },
                            "revenue_usd": {
                              "type": "integer"
                            }
                          },
                          "additionalProperties": true
                        },
"size_exceeded": {
                          "type": "boolean",
                          "description": "True when inline per-link content exceeded the 9MB safety cap. When true, content fields are nulled in the response — use json_hosted_url to fetch the full payload."
                        },
                        "credits_consumed": {
                          "type": "integer",
                          "description": "Same value as the top-level credits_consumed."
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad Request — validation failed (missing query, invalid limit, unsupported scrape_options.formats value, etc.). Response body is `{ \"message\": \"<reason>\" }`. A `category` that fails validation, a people or companies search with neither `query` nor `category.parameters`, a `query` that contains no usable filter, or a people or companies search with a malformed `limit`, `include_domains`, `exclude_domains` or `scrape_options`, answers with the standard Olostep error envelope instead (`code` `validation_error`, the fields in `metadata.errors`). `zero_data_retention` set together with `storage` or `scrape_options`, or with the `Idempotency-Key` header, also returns 400 with that envelope (`storage cannot be set when zero_data_retention is true`, `scrape_options cannot be set when zero_data_retention is true`, `Idempotency-Key cannot be used when zero_data_retention is true`)."
          },
          "401": {
            "description": "Invalid API Key"
          },
          "500": {
            "description": "Internal Server Error"
          },
          "502": {
            "description": "Bad Gateway — a people or companies search could not be completed, or its `query` could not be translated into search parameters. Standard Olostep error envelope (`code` `upstream_error`). Retry later."
          },
          "503": {
            "description": "Service Unavailable — people and company search is temporarily overloaded. Standard Olostep error envelope (`code` `upstream_error`). Retry later."
          }
        }
      }
    }
  }
}
