---
title: "Compile a question into an API"
method: POST
path: "/api/v1/queries"
tags: ["Saved queries"]
---

# Compile a question into an API

`POST /api/v1/queries`

## Request

- Base URL: `https://unbrowse.ai`
- URL: `https://unbrowse.ai/api/v1/queries`
- Auth: one of:
  - OAuth 2 (authorization code, authorization URL `https://unbrowse.ai/authorize`, token URL `https://unbrowse.ai/oauth/token`, scopes: `unbrowse`)
  - HTTP bearer

Runs the question once with the example values (a real, verified run), pins the tool it used and learns which of the tool's inputs each {placeholder} fills. The answer names the query's URL: call it with GET /api/v1/q/{queryId}?param=… from then on. When a value is transformed on the way (a city to its code), say where it goes with `map`.

## Request body

- object
  - `query` string, required
  - `example` object: A value for each {placeholder}, used for the compiling run.
  - `map` object: Input name → "{param}" or a fixed value, where the example values alone are not enough.
  - `name` string
  - `maxAge` integer: Seconds an answer may be reused (0, the default: never). A reused answer is not billed.

## Response `201`

The saved query, with its url and an example call

- Object

## Other responses

- `400`: An error
- `401`: Missing or invalid credentials. The WWW-Authenticate header names the protected-resource metadata.
- `402`: An error
- `404`: An error
- `422`: An error
- `429`: An error

---

[API](https://skmtc.dev/unbrowse/apis/unbrowse-api.md) · [All operations](https://skmtc.dev/unbrowse/apis/unbrowse-api/llms.txt) · [OpenAPI document](https://skmtc.dev/unbrowse/apis/unbrowse-api/revisions/f49034a1fbff?raw)
