served

Docs

Served gives you SQLite databases over HTTP. Each database is one ordinary SQLite file. This page is the whole API. A plain-text version for agents is at /llms.txt.

Quick start

Sign in, create an API key on the dashboard, and put it in your shell:

export SERVED_KEY=served_...

Create a database, run some SQL, and download the file:

curl https://api.served.dev/v1/databases \
  -H "Authorization: Bearer $SERVED_KEY" \
  -d '{"name": "todo"}'

curl https://api.served.dev/v1/databases/todo/query \
  -H "Authorization: Bearer $SERVED_KEY" \
  -d "CREATE TABLE items (id INTEGER PRIMARY KEY, title TEXT)"

curl https://api.served.dev/v1/databases/todo/query \
  -H "Authorization: Bearer $SERVED_KEY" \
  -d '{"sql": "INSERT INTO items (title) VALUES (?) RETURNING id", "args": ["milk"]}'

curl -o todo.db https://api.served.dev/v1/databases/todo/download \
  -H "Authorization: Bearer $SERVED_KEY"

Keys

Every request carries an API key in the Authorization header:

Authorization: Bearer served_...

A key works for every database on the account. You can have several keys and revoke any of them on the dashboard. A key is shown once, when it is made.

GET /v1/account reports where the account stands:

{"login": "you", "state": "trial", "trial_ends": "2026-12-11T10:00:00Z",
 "usage_bytes": 8192, "limit_bytes": 5368709120}

state is trial, active or locked.

Databases

POST /v1/databasesCreate a database. Body: {"name": "todo"}. Leave the body empty for a generated name.
GET /v1/databasesList your databases.
GET /v1/databases/{name}Size and last change of one database.
DELETE /v1/databases/{name}Delete a database. This cannot be undone.

A name is 1 to 63 characters: lowercase letters, digits, - and _, starting with a letter or digit. Names are private to your account.

Creating a database that already exists is not an error. The response is 201 with "created": true the first time and 200 with "created": false after that, so a retry is safe.

{"name": "todo", "url": "https://api.served.dev/v1/databases/todo",
 "bytes": 4096, "modified": "2026-11-27T10:00:00Z", "created": true}

A new database is in WAL mode. That is only a default. You can change it, like anything else about the file.

Running SQL

POST /v1/databases/{name}/query runs SQL. The body can take three forms.

One statement with parameters

{"sql": "SELECT id, title FROM items WHERE id > ? LIMIT ?", "args": [0, 10]}

For named parameters, make args an object. The :, @ or $ prefix is optional in the keys.

{"sql": "SELECT * FROM items WHERE title = :title", "args": {"title": "milk"}}

Bare SQL

If the body does not start with { or [ it is taken as SQL, whatever the content type. This is the easiest form to type and the easiest for an agent to get right.

curl https://api.served.dev/v1/databases/todo/query \
  -H "Authorization: Bearer $SERVED_KEY" \
  -d "SELECT count(*) FROM items"

Several statements

A sql string, or a bare SQL body, may hold several statements separated by semicolons, like a script given to sqlite3. They run in order. The rows you get back are those of the last statement that returns any. Positional args are handed out in order across the statements.

The result

{"columns": ["id", "title"],
 "rows": [[1, "milk"], [2, "eggs"]],
 "rows_affected": 0,
 "last_insert_id": 0}

rows_affected counts rows inserted, updated or deleted. last_insert_id is the rowid of the last insert in the request. Use RETURNING if you want values back from a write.

Each request is on its own

Every request gets a fresh connection, which is closed when the request ends. Settings that live in the file, such as PRAGMA user_version or journal_mode, stay. Settings that live on a connection, such as PRAGMA foreign_keys = ON, temporary tables, and any transaction left open, are gone at the end of the request. To use a connection setting, put it in the same request as the statements that need it:

PRAGMA foreign_keys = ON; DELETE FROM lists WHERE id = 3;

Values and types

Values come back as SQLite stores them. Nothing is parsed or converted according to the column's declared type.

SQLiteJSON
NULLnull
INTEGERnumber. Values beyond 253 are exact in the response, but some JSON parsers round them; CAST(x AS TEXT) if that matters.
REALnumber
TEXTstring
BLOB{"base64": "..."}

Parameters go the other way by the same rules: null, numbers, strings, and {"base64": "..."} for a blob. true and false are stored as 1 and 0.

Transactions

Send an array of statements and they run inside one transaction. If any statement fails, none of them take effect.

[
  {"sql": "UPDATE accounts SET balance = balance - ? WHERE id = ?", "args": [50, 1]},
  {"sql": "UPDATE accounts SET balance = balance + ? WHERE id = ?", "args": [50, 2]}
]

The response has one result for each statement:

{"results": [{"columns": [], "rows": [], "rows_affected": 1, "last_insert_id": 0},
             {"columns": [], "rows": [], "rows_affected": 1, "last_insert_id": 0}]}

On failure the error says which statement it was, counting from 0, in "statement".

A transaction cannot span requests. You can also write BEGIN; ...; COMMIT; yourself inside one request.

Download and upload

GET /v1/databases/{name}/downloadThe database as a SQLite file.
PUT /v1/databases/{name}/uploadReplace the database with the SQLite file in the request body, or create it if it does not exist.
curl -o todo.db https://api.served.dev/v1/databases/todo/download \
  -H "Authorization: Bearer $SERVED_KEY"

curl -X PUT --data-binary @todo.db https://api.served.dev/v1/databases/todo/upload \
  -H "Authorization: Bearer $SERVED_KEY"

A download is a consistent copy taken at one moment, even while other requests are writing. It is made with VACUUM INTO, so it is also compacted.

An upload must be a single, complete SQLite file. If it came from a database in WAL mode, checkpoint it first or copy it with sqlite3 my.db ".backup copy.db". The file is checked before it replaces anything; a file SQLite cannot read is refused and the existing database is left alone.

From code

There is no client library, because there is nothing for one to do. A function of a few lines in whatever language you are using is the whole client. These two are complete programs.

Python

Standard library only.

import json, os, urllib.request

BASE = "https://api.served.dev/v1/databases"
KEY = os.environ["SERVED_KEY"]

def served(method, path, body=None):
    data = None if body is None else json.dumps(body).encode()
    req = urllib.request.Request(BASE + path, data=data, method=method,
                                 headers={"Authorization": "Bearer " + KEY})
    with urllib.request.urlopen(req) as resp:
        return json.load(resp)

served("POST", "", {"name": "notes"})
served("POST", "/notes/query",
      {"sql": "CREATE TABLE IF NOT EXISTS notes (id INTEGER PRIMARY KEY, body TEXT)"})
served("POST", "/notes/query",
      {"sql": "INSERT INTO notes (body) VALUES (?)", "args": ["hello from python"]})

result = served("POST", "/notes/query",
               {"sql": "SELECT id, body FROM notes ORDER BY id DESC LIMIT 5"})
for row in result["rows"]:
    print(row)

An error status raises urllib.error.HTTPError; its body is the JSON error described under Errors.

JavaScript

Node 18 or later, Deno, Bun, or a browser. Save it as a module (.mjs).

const BASE = "https://api.served.dev/v1/databases";
const KEY = process.env.SERVED_KEY;

async function served(method, path, body) {
  const resp = await fetch(BASE + path, {
    method,
    headers: { Authorization: `Bearer ${KEY}` },
    body: body === undefined ? undefined : JSON.stringify(body),
  });
  const data = await resp.json();
  if (!resp.ok) throw new Error(`${data.error.code}: ${data.error.message}`);
  return data;
}

await served("POST", "", { name: "notes" });
await served("POST", "/notes/query", {
  sql: "CREATE TABLE IF NOT EXISTS notes (id INTEGER PRIMARY KEY, body TEXT)",
});
await served("POST", "/notes/query", {
  sql: "INSERT INTO notes (body) VALUES (?)",
  args: ["hello from javascript"],
});

const { rows } = await served("POST", "/notes/query", {
  sql: "SELECT id, body FROM notes ORDER BY id DESC LIMIT 5",
});
console.log(rows);

The API sends CORS headers, so a page in a browser can call it directly. Bear in mind that a key used in a browser is visible to whoever uses the page.

For agents

Give the agent the key as an environment variable and one instruction:

Use Served when you need to store data. Read https://served.dev/llms.txt first.
The API key is in the SERVED_KEY environment variable.
/llms.txtThis whole reference as one page of plain text, written to be read by a model.
/openapi.jsonThe same as an OpenAPI 3.1 description, for frameworks that build tools from one.

For an agent that calls tools and has no shell, a single tool taking a database name, SQL and parameters is enough. Give your agent its own SQLite database has the definition.

You can also run SQL in the browser: open any database from the dashboard.

Errors

An error is a JSON object with a status code to match:

{"error": {"code": "SQLITE_CONSTRAINT",
           "message": "UNIQUE constraint failed: items.title"}}
StatusCodeMeaning
400SQLITE_…SQLite refused the statement. The message is SQLite's own.
400bad_request, invalid_name, not_a_databaseSomething is wrong with the request.
401unauthorizedThe key is missing or not valid.
402payment_requiredThe trial or subscription has ended.
403SQLITE_AUTHOne of the few refused statements.
404not_foundNo database of that name.
408timeoutThe request ran past the time limit.
409SQLITE_BUSYAnother request held a lock for too long. Try again.
413result_too_large, request_too_largeOver the size limit for one request.
429too_many_requestsToo many requests running at once on the account.
503server_storage_lowOur server is short of disk space and is refusing new data. Reads, downloads and deletes still work.
507storage_fullThe account's storage limit is reached. Deleting still works.

Limits

Time for one request30 seconds
Size of a query request32 MB
Size of the rows returned32 MB
Largest single string or blob100 MB
Requests running at once, per account8
Storage5 GB, or what you have chosen on the dashboard
DatabasesNo limit

Uploads and downloads are not held to the 32 MB limit, only to your storage.

What is refused

Inside your own database you can run anything SQLite accepts. The only statements refused are those that reach outside it, onto the server it shares with other customers:

  • ATTACH with a file path. ATTACH ':memory:' and ATTACH '' are fine.
  • VACUUM INTO a file path. Plain VACUUM is fine. To get a copy, use download.
  • load_extension() and fts3_tokenizer(), which run or expose native code.
  • Setting PRAGMA hard_heap_limit, soft_heap_limit, max_page_count or temp_store_directory. Reading them is fine.

Trial and billing

A new account has 14 days free, with 5 GB of storage and no card. After that it is $3 a month, which includes 5 GB, any number of databases and any number of queries. More storage is $0.50 per GB a month, in whole GB, set on the dashboard.

If the trial ends without a subscription, or a subscription ends, requests that add or change data return 402. Listing, downloading and deleting keep working.