# Served Served is hosted SQLite. Each database is one ordinary SQLite file, reached over HTTP. This page is the whole API. Base URL: https://api.served.dev The same API as an OpenAPI 3.1 description: https://served.dev/openapi.json Every request needs the header: Authorization: Bearer API keys start with "served_". A person creates one at https://app.served.dev/dashboard. One key works for every database on the account. ## Endpoints POST /v1/databases create a database GET /v1/databases list databases GET /v1/databases/{name} size and last change of one database DELETE /v1/databases/{name} delete a database (cannot be undone) POST /v1/databases/{name}/query run SQL GET /v1/databases/{name}/download get the database as a SQLite file PUT /v1/databases/{name}/upload replace or create a database from a SQLite file GET /v1/account plan state, storage used and storage limit ## Create a database curl https://api.served.dev/v1/databases \ -H "Authorization: Bearer $SERVED_KEY" \ -d '{"name": "todo"}' {"name":"todo","url":"https://api.served.dev/v1/databases/todo","bytes":4096,"modified":"2026-11-27T10:00:00Z","created":true} A name is 1 to 63 characters: lowercase letters, digits, "-" and "_", starting with a letter or digit. An empty body gives a generated name. Creating a database that already exists is not an error: it returns 200 with "created": false, so it is safe to retry. ## Run SQL POST /v1/databases/{name}/query. The body is one of: 1. Bare SQL (any body that does not start with "{" or "["): curl https://api.served.dev/v1/databases/todo/query \ -H "Authorization: Bearer $SERVED_KEY" \ -d "CREATE TABLE items (id INTEGER PRIMARY KEY, title TEXT)" 2. One statement with parameters: {"sql": "INSERT INTO items (title) VALUES (?) RETURNING id", "args": ["milk"]} Named parameters: {"sql": "SELECT * FROM items WHERE title = :t", "args": {"t": "milk"}} 3. An array of statements, run as ONE transaction (all take effect or none): [{"sql": "INSERT INTO items (title) VALUES (?)", "args": ["eggs"]}, {"sql": "SELECT count(*) AS n FROM items"}] Result of forms 1 and 2: {"columns":["id"],"rows":[[1]],"rows_affected":1,"last_insert_id":1} Result of form 3: {"results":[{"columns":[],"rows":[],"rows_affected":1,"last_insert_id":2}, {"columns":["n"],"rows":[[2]],"rows_affected":0,"last_insert_id":2}]} Notes: - A "sql" string may hold several statements separated by ";". They run in order. The rows returned are those of the last statement that returns any. They are NOT a transaction unless you use form 3 or write BEGIN/COMMIT. - Always pass values as parameters ("args"), not by building SQL strings. - Each request uses a fresh connection. Connection settings such as "PRAGMA foreign_keys = ON", temp tables and open transactions do not carry over to the next request. Put them in the same request that needs them. - Values: NULL -> null, INTEGER and REAL -> number, TEXT -> string, BLOB -> {"base64": "..."}. Parameters use the same forms. - To see the schema: SELECT name, sql FROM sqlite_schema ## Download and upload 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. An upload must be one complete SQLite file. ## Errors Errors are JSON with a matching HTTP status: {"error":{"code":"SQLITE_CONSTRAINT","message":"UNIQUE constraint failed: items.title"}} 400 SQLITE_* SQLite refused the statement; the message is SQLite's own 400 bad_request the request is malformed 400 invalid_name the database name breaks the naming rule above 400 not_a_database the uploaded file is not a valid SQLite database 401 unauthorized missing or invalid API key 402 payment_required trial or subscription ended; a person must subscribe at https://app.served.dev/dashboard 403 SQLITE_AUTH a refused statement (see below) 404 not_found no database of that name; create it first 408 timeout ran longer than 30 seconds 409 SQLITE_BUSY another request held a lock; retry 413 result_too_large add a LIMIT, or download the database 413 request_too_large query body over 32 MB; upload a database file instead 429 too_many_requests more than 8 requests running at once on the account; retry 503 server_storage_low the server itself is short of disk; reads still work; retry writes later 507 storage_full storage limit reached; delete data or ask a person to raise it In a transaction (form 3), "statement" in the error is the index of the statement that failed, counting from 0. ## Limits 30 seconds per request. 32 MB per query request and per result. 8 requests at once per account. No limit on the number of databases. ## What is refused Anything SQLite accepts is allowed, except statements that reach outside the database: ATTACH or VACUUM INTO with a file path, load_extension(), fts3_tokenizer(), and setting PRAGMA hard_heap_limit, soft_heap_limit, max_page_count or temp_store_directory.