REST API

The Couchbase Lite REST API provides HTTP access to your databases. This introduces the REST API and includes an overview of the available resources.

Notation Conventions

Within the paths of the URIs presented in these guides:

For example, suppose you have a database named cookbook. In the database, the IDs for recipes start with the string "recipe" and IDs for design documents start with the string "ddoc". The following table shows examples of values you might use for the URI path in the request that you send to the database:

PathSample value
/<db> /cookbook
/<db>/_changes /cookbook/_changes
/<db>/<doc> /cookbook/recipe123
/_replicate /_replicate

HTTP requests and responses

The Couchbase Lite REST API uses the Hypertext Transfer Protocol (HTTP). Each API is an HTTP request. For each HTTP request that you send, you receive an HTTP response. HTTP requests consist of a request line, header lines, and a message body. HTTP responses consist of a status line, header lines, and a message body.

The examples in this document are shown in the basic HTTP format.

The message body for both the HTTP requests and HTTP responses is formatted as a JSON document. To learn more about JSON, check out JSON.org or the W3Schools JSON Tutorial.

Each HTTP response contains a status code. The following table lists some of the status codes returned by Couchbase Lite:

HTTP Status CodeReturned String
200OK
201Created
202Accepted
400Bad data encoding
400bad_request
400Invalid attachment
400Invalid database/document/revision ID
400Invalid JSON
400Invalid parameter in HTTP query or JSON body
401unauthorized
403forbidden
404Attachment not found
404deleted
404not_found
406not_acceptable
409conflict
412file_exists
415bad content type
500Application callback block failed
500Attachment store error
500Database error!
500Database locked
500Internal error
500Invalid data in database
502Invalid response from remote replication server