Public REST API (Static Page)
- reference
Description of the Sync Gateway Public REST API, alternative representation as a static page
Related REST API topics: Admin REST API (Static Page) | Metrics REST API (Static Page)
Overview
Version information
Version : 3.1
Host information
{protocol}://{hostname}:4984
Public API
Component | Description |
---|---|
protocol |
The protocol to use (HTTP or HTTPS) Values: |
hostname |
The hostname to use Example: |
Resources
This section describes the operations available with this REST API. The operations are grouped in the following categories.
Authentication
Database Management
Document
Document Attachment
Replication
Server
Session
Unsupported
Authentication
Manage OpenID Connect Authentication
OpenID Connect authentication initiation via Location header redirect
OpenID Connect authentication callback
OpenID Connect authentication initiation via WWW-Authenticate header
OpenID Connect token refresh
OpenID Connect mock provider
OpenID Connect mock login page handler
OpenID Connect mock login page
OpenID Connect public certificates for signing keys
Create a new Facebook-based session
Create a new Google-based session
OpenID Connect mock login page handler
OpenID Connect mock login page
OpenID Connect mock token
OpenID Connect authentication initiation via Location header redirect
GET /{db}/_oidc
Description
Called by clients to initiate the OpenID Connect Authorization Code Flow. Redirects to the OpenID Connect provider if successful.
-
application/json
Parameters
Name | Description | Schema |
---|---|---|
db |
The name of the database to run the operation against. |
String |
Name | Description | Schema |
---|---|---|
provider |
The OpenID Connect provider to use for authentication. The list of providers are defined in the Sync Gateway config. If left empty, the default provider will be used. |
String |
offline |
If true, the OpenID Connect provider is requested to confirm with the user the permissions requested and refresh the OIDC token. To do this, access_type=offline and prompt=consent is set on the redirection link. |
String |
Responses
HTTP Code | Description | Schema |
---|---|---|
302 |
Successfully connected with the OpenID Connect provider so now redirecting to the requested OIDC provider for authentication. |
|
400 |
The provider provided is not defined in the Sync Gateway config. If no provided was specified then there is no default provider set. |
|
404 |
Resource could not be found |
|
500 |
Unable to connect and validate with the OpenID Connect provider requested |
OpenID Connect authentication callback
GET /{db}/_oidc_callback
Description
The callback URL that the client is redirected to after authenticating with the OpenID Connect provider.
-
application/json
Parameters
Name | Description | Schema |
---|---|---|
db |
The name of the database to run the operation against. |
String |
Name | Description | Schema |
---|---|---|
error |
The OpenID Connect error, if any occurred. |
String |
code |
The OpenID Connect authentication code. |
String |
provider |
The OpenID Connect provider to use for authentication. The list of providers are defined in the Sync Gateway config. If left empty, the default provider will be used. |
String |
state |
The OpenID Connect state to verify against the state cookie. This is used to prevent cross-site request forgery (CSRF). This is not required if |
String |
Responses
HTTP Code | Description | Schema |
---|---|---|
200 |
Successfully authenticated with OpenID Connect. |
|
400 |
A problem occurred when reading the callback request body |
|
401 |
An error was received from the OpenID Connect provider. This means the error query parameter was filled. |
|
404 |
Resource could not be found |
|
500 |
A problem occurred in regards to the token |
OpenID Connect authentication initiation via WWW-Authenticate header
GET /{db}/_oidc_challenge
Description
Called by clients to initiate the OpenID Connect Authorization Code Flow. This will establish a connection with the provider, then put the redirect URL in the WWW-Authenticate
header.
-
application/json
Parameters
Name | Description | Schema |
---|---|---|
db |
The name of the database to run the operation against. |
String |
Name | Description | Schema |
---|---|---|
provider |
The OpenID Connect provider to use for authentication. The list of providers are defined in the Sync Gateway config. If left empty, the default provider will be used. |
String |
offline |
If true, the OpenID Connect provider is requested to confirm with the user the permissions requested and refresh the OIDC token. To do this, access_type=offline and prompt=consent is set on the redirection link. |
String |
Responses
HTTP Code | Description | Schema |
---|---|---|
400 |
The provider provided is not defined in the Sync Gateway config. If no provided was specified then there is no default provider set. |
|
401 |
Successfully connected with the OpenID Connect provider so now the client can login. |
|
404 |
Resource could not be found |
|
500 |
Unable to connect and validate with the OpenID Connect provider requested |
OpenID Connect token refresh
GET /{db}/_oidc_refresh
Description
Refresh the OpenID Connect token based on the provided refresh token.
-
application/json
Parameters
Name | Description | Schema |
---|---|---|
db |
The name of the database to run the operation against. |
String |
Name | Description | Schema |
---|---|---|
refresh_token |
The OpenID Connect refresh token. |
String |
provider |
The OpenID Connect provider to use for authentication. The list of providers are defined in the Sync Gateway config. If left empty, the default provider will be used. |
String |
Responses
HTTP Code | Description | Schema |
---|---|---|
200 |
Successfully authenticated with OpenID Connect. |
|
400 |
The provider provided is not defined in the Sync Gateway config. If no provided was specified then there is no default provider set. |
|
404 |
Resource could not be found |
|
500 |
Unable to connect and validate with the OpenID Connect provider requested |
OpenID Connect mock provider
GET /{db}/_oidc_testing/.well-known/openid-configuration
Description
Mock an OpenID Connect provider response for testing purposes. This returns a response that is the same structure as what Sync Gateway expects from an OIDC provider after initiating OIDC authentication.
-
application/json
Parameters
Name | Description | Schema |
---|---|---|
db |
The name of the database to run the operation against. |
String |
OpenID Connect mock login page handler
GET /{db}/_oidc_testing/authenticate
Description
Used to handle the login page displayed for the GET /{db}/_oidc_testing/authorize
endpoint.
-
application/json
Parameters
Name | Description | Schema |
---|---|---|
db |
The name of the database to run the operation against. |
String |
Name | Description | Schema |
---|---|---|
redirect_uri |
The Sync Gateway OpenID Connect callback URL. |
String |
scope |
The OpenID Connect authentication scope. |
String |
username |
String |
|
tokenttl |
Integer |
|
identity-token-formats |
String |
|
authenticated |
String |
OpenID Connect mock login page
GET /{db}/_oidc_testing/authorize
Parameters
Name | Description | Schema |
---|---|---|
db |
The name of the database to run the operation against. |
String |
Name | Description | Schema |
---|---|---|
scope |
The OpenID Connect authentication scope. |
String |
OpenID Connect public certificates for signing keys
GET /{db}/_oidc_testing/certs
Description
Return a mock OpenID Connect public key to be used as signing keys.
-
application/json
Parameters
Name | Description | Schema |
---|---|---|
db |
The name of the database to run the operation against. |
String |
Create a new Facebook-based session
POST /{db}/_facebook
This operation is deprecated, and will be removed in a future release. |
Description
Creates a new session based on a Facebook user. On a successful session creation, a session cookie is stored to keep the user authenticated for future API calls.
If CORS is enabled, the origin must match an allowed login origin otherwise an error will be returned.
-
application/json
-
application/json
Parameters
Name | Description | Schema |
---|---|---|
db |
The name of the database to run the operation against. |
String |
Name | Description | Schema |
---|---|---|
Body |
Responses
HTTP Code | Description | Schema |
---|---|---|
200 |
Session created successfully |
|
400 |
Origin is not in the approved list of allowed origins |
|
401 |
Received error from Facebook verifier |
|
404 |
Resource could not be found |
|
502 |
Received invalid response from the Facebook verifier |
|
504 |
Unable to send request to Facebook API |
Create a new Google-based session
POST /{db}/_google
This operation is deprecated, and will be removed in a future release. |
Description
Creates a new session based on a Google user. On a successful session creation, a session cookie is stored to keep the user authenticated for future API calls.
If CORS is enabled, the origin must match an allowed login origin otherwise an error will be returned.
-
application/json
-
application/json
Parameters
Name | Description | Schema |
---|---|---|
db |
The name of the database to run the operation against. |
String |
Name | Description | Schema |
---|---|---|
Body |
Responses
HTTP Code | Description | Schema |
---|---|---|
200 |
Session created successfully |
|
400 |
Origin is not in the approved list of allowed origins |
|
401 |
Received error from Google token verifier or invalid application ID in the config |
|
404 |
Resource could not be found |
|
502 |
Received invalid response from the Google token verifier |
|
504 |
Unable to send request to the Google token verifier |
OpenID Connect mock login page handler
POST /{db}/_oidc_testing/authenticate
Description
Used to handle the login page displayed for the GET /{db}/_oidc_testing/authorize
endpoint.
-
application/json
-
application/json
Parameters
Name | Description | Schema |
---|---|---|
db |
The name of the database to run the operation against. |
String |
Name | Description | Schema |
---|---|---|
redirect_uri |
The Sync Gateway OpenID Connect callback URL. |
String |
scope |
The OpenID Connect authentication scope. |
String |
Name | Description | Schema |
---|---|---|
Body |
Properties passed from the OpenID Connect mock login page to the handler |
OpenID Connect mock login page
POST /{db}/_oidc_testing/authorize
Parameters
Name | Description | Schema |
---|---|---|
db |
The name of the database to run the operation against. |
String |
Name | Description | Schema |
---|---|---|
scope |
The OpenID Connect authentication scope. |
String |
OpenID Connect mock token
POST /{db}/_oidc_testing/token
Description
Return a mock OpenID Connect token for the OIDC authentication flow.
-
application/json
-
application/json
Parameters
Name | Description | Schema |
---|---|---|
db |
The name of the database to run the operation against. |
String |
Name | Description | Schema |
---|---|---|
Body |
Responses
HTTP Code | Description | Schema |
---|---|---|
200 |
Properties expected back from an OpenID Connect provider after successful authentication |
|
400 |
Invalid token provided |
|
403 |
The OpenID Connect unsupported config option |
|
404 |
Resource could not be found |
Database Management
Table of Contents
Get database information
Get changes list
Check if database exists
/{db}/_changes
/{db}/_ensure_full_commit
Get changes list
Compare revisions to what is in the database
Create DB public API stub
Get database information
GET /{db}/
Parameters
Name | Description | Schema |
---|---|---|
db |
The name of the database to run the operation against. |
String |
Get changes list
GET /{keyspace}/_changes
Description
This request retrieves a sorted list of changes made to documents in the database, in time order of application. Each document appears at most once, ordered by its most recent change, regardless of how many times it has been changed.
This request can be used to listen for update and modifications to the database for post processing or synchronization. A continuously connected changes feed is a reasonable approach for generating a real-time log for most applications.
-
application/json
Parameters
Name | Description | Schema |
---|---|---|
keyspace |
The keyspace to run the operation against. A keyspace is a dot-separated string, comprised of a database name, and optionally a named scope and collection. |
String |
Name | Description | Schema |
---|---|---|
limit |
Maximum number of changes to return. |
Integer |
since |
Starts the results from the change immediately after the given sequence ID. Sequence IDs should be considered opaque; they come from the last_seq property of a prior response. |
String |
style |
Controls whether to return the current winning revision ( Values: |
String |
active_only |
Set true to exclude deleted documents and notifications for documents the user no longer has access to from the changes feed. |
Boolean |
include_docs |
Include the body associated with each document. |
Boolean |
revocations |
If true, revocation messages will be sent on the changes feed. |
Boolean |
filter |
Set a filter to either filter by channels or document IDs. Values: |
String |
channels |
A comma-separated list of channel names to filter the response to only the channels specified. To use this option, the |
String |
doc_ids |
A valid JSON array of document IDs to filter the documents in the response to only the documents specified. To use this option, the |
String array |
heartbeat |
The interval (in milliseconds) to send an empty line (CRLF) in the response. This is to help prevent gateways from deciding the socket is idle and therefore closing it. This is only applicable to Minimum: |
Integer |
timeout |
This is the maximum period (in milliseconds) to wait for a change before the response is sent, even if there are no results. This is only applicable for Minimum: |
Integer |
feed |
The type of changes feed to use. Values: |
String |
Check if database exists
HEAD /{db}/
Parameters
Name | Description | Schema |
---|---|---|
db |
The name of the database to run the operation against. |
String |
/{db}/_changes
HEAD /{keyspace}/_changes
/{db}/_ensure_full_commit
POST /{db}/_ensure_full_commit
Description
This endpoint is non-functional but is present for CouchDB compatibility.
-
application/json
Parameters
Name | Description | Schema |
---|---|---|
db |
The name of the database to run the operation against. |
String |
Get changes list
POST /{keyspace}/_changes
Description
This request retrieves a sorted list of changes made to documents in the database, in time order of application. Each document appears at most once, ordered by its most recent change, regardless of how many times it has been changed.
This request can be used to listen for update and modifications to the database for post processing or synchronization. A continuously connected changes feed is a reasonable approach for generating a real-time log for most applications.
-
application/json
-
application/json
Parameters
Name | Description | Schema |
---|---|---|
keyspace |
The keyspace to run the operation against. A keyspace is a dot-separated string, comprised of a database name, and optionally a named scope and collection. |
String |
Name | Description | Schema |
---|---|---|
Body |
Compare revisions to what is in the database
POST /{keyspace}/_revs_diff
Description
Takes a set of document IDs, each with a set of revision IDs. For each document, an array of unknown revisions are returned with an array of known revisions that may be recent ancestors.
-
application/json
-
application/json
Parameters
Name | Description | Schema |
---|---|---|
keyspace |
The keyspace to run the operation against. A keyspace is a dot-separated string, comprised of a database name, and optionally a named scope and collection. |
String |
Name | Description | Schema |
---|---|---|
Body |
Document
Create and manage documents
Delete a document
Delete a local document
Gets all the documents in the database with the given parameters
Get a document
Get local document
/{db}/_all_docs
Check if a document exists
Check if local document exists
Create a new document
Get all the documents in the database using a built-in view
Bulk document operations
Get multiple documents in a MIME multipart response
Upsert a document
Upsert a local document
Delete a document
DELETE /{keyspace}/{docid}
Description
Delete a document from the database. A new revision is created so the database can track the deletion in synchronized copies.
A revision ID either in the header or on the query parameters is required.
-
application/json
Parameters
Name | Description | Schema |
---|---|---|
keyspace |
The keyspace to run the operation against. A keyspace is a dot-separated string, comprised of a database name, and optionally a named scope and collection. |
String |
docid |
The document ID to run the operation against. |
String |
Name | Description | Schema |
---|---|---|
rev |
The document revision to target. |
String |
Name | Description | Schema |
---|---|---|
If-Match |
The revision ID to target. |
String |
Delete a local document
DELETE /{keyspace}/_local/{docid}
Description
This request deletes a local document.
Local document IDs begin with _local/
. Local documents are not replicated or indexed, don't support attachments, and don't save revision histories. In practice they are almost only used by Couchbase Lite's replicator, as a place to store replication checkpoint data.
-
application/json
Parameters
Name | Description | Schema |
---|---|---|
keyspace |
The keyspace to run the operation against. A keyspace is a dot-separated string, comprised of a database name, and optionally a named scope and collection. |
String |
docid |
The name of the local document ID excluding the |
String |
Name | Description | Schema |
---|---|---|
rev |
The revision ID of the revision to delete. |
String |
Gets all the documents in the database with the given parameters
GET /{keyspace}/_all_docs
Description
Returns all documents in the database based on the specified parameters.
-
application/json
Parameters
Name | Description | Schema |
---|---|---|
keyspace |
The keyspace to run the operation against. A keyspace is a dot-separated string, comprised of a database name, and optionally a named scope and collection. |
String |
Name | Description | Schema |
---|---|---|
include_docs |
Include the body associated with each document. |
Boolean |
channels |
Include the channels each document is part of that the calling user also has access too. |
Boolean |
access |
Include what user/roles that each document grants access too. |
Boolean |
revs |
Include all the revisions for each document under the |
Boolean |
update_seq |
Include the document sequence number |
Boolean |
keys |
An array of document ID strings to filter by. |
String array |
startkey |
Return records starting with the specified key. |
String |
endkey |
Stop returning records when this key is reached. |
String |
limit |
This limits the number of result rows returned. Using a value of |
Big Decimal |
Get a document
GET /{keyspace}/{docid}
Parameters
Name | Description | Schema |
---|---|---|
keyspace |
The keyspace to run the operation against. A keyspace is a dot-separated string, comprised of a database name, and optionally a named scope and collection. |
String |
docid |
The document ID to run the operation against. |
String |
Name | Description | Schema |
---|---|---|
rev |
The document revision to target. |
String |
open_revs |
Option to fetch specified revisions of the document. The value can be all to fetch all leaf revisions or an array of revision numbers (i.e. open_revs=["rev1", "rev2"]). Only leaf revision bodies that haven't been pruned are guaranteed to be returned. If this option is specified the response will be in multipart format. Use the |
String array |
show_exp |
Whether to show the expiry property ( |
Boolean |
revs_from |
Trim the revision history to stop at the first revision in the provided list. If no match is found, the revisions will be trimmed to the |
String array |
atts_since |
Include attachments only since specified revisions. Excludes the attachments for the specified revisions. Only gets used if |
String array |
revs_limit |
Maximum amount of revisions to return for each document. |
Integer |
attachments |
Include attachment bodies in response. |
Boolean |
replicator2 |
Returns the document with the required properties for replication. This is an enterprise-edition only feature. |
Boolean |
Responses
HTTP Code | Description | Schema |
---|---|---|
200 |
Document found and returned successfully |
|
400 |
Document ID is not in an allowed format therefore is invalid. This could be because it is over 250 characters or is prefixed with an underscore ("_"). |
|
404 |
Resource could not be found |
|
501 |
Not Implemented. It is likely this error was caused due to trying to use an enterprise-only feature on the community edition. |
Get local document
GET /{keyspace}/_local/{docid}
Description
This request retrieves a local document.
Local document IDs begin with _local/
. Local documents are not replicated or indexed, don't support attachments, and don't save revision histories. In practice they are almost only used by Couchbase Lite's replicator, as a place to store replication checkpoint data.
-
application/json
Parameters
Name | Description | Schema |
---|---|---|
keyspace |
The keyspace to run the operation against. A keyspace is a dot-separated string, comprised of a database name, and optionally a named scope and collection. |
String |
docid |
The name of the local document ID excluding the |
String |
/{db}/_all_docs
HEAD /{keyspace}/_all_docs
Parameters
Name | Description | Schema |
---|---|---|
keyspace |
The keyspace to run the operation against. A keyspace is a dot-separated string, comprised of a database name, and optionally a named scope and collection. |
String |
Name | Description | Schema |
---|---|---|
include_docs |
Include the body associated with each document. |
Boolean |
channels |
Include the channels each document is part of that the calling user also has access too. |
Boolean |
access |
Include what user/roles that each document grants access too. |
Boolean |
revs |
Include all the revisions for each document under the |
Boolean |
update_seq |
Include the document sequence number |
Boolean |
keys |
An array of document ID strings to filter by. |
String array |
startkey |
Return records starting with the specified key. |
String |
endkey |
Stop returning records when this key is reached. |
String |
limit |
This limits the number of result rows returned. Using a value of |
Big Decimal |
Check if a document exists
HEAD /{keyspace}/{docid}
Parameters
Name | Description | Schema |
---|---|---|
keyspace |
The keyspace to run the operation against. A keyspace is a dot-separated string, comprised of a database name, and optionally a named scope and collection. |
String |
docid |
The document ID to run the operation against. |
String |
Name | Description | Schema |
---|---|---|
rev |
The document revision to target. |
String |
open_revs |
Option to fetch specified revisions of the document. The value can be all to fetch all leaf revisions or an array of revision numbers (i.e. open_revs=["rev1", "rev2"]). Only leaf revision bodies that haven't been pruned are guaranteed to be returned. If this option is specified the response will be in multipart format. Use the |
String array |
show_exp |
Whether to show the expiry property ( |
Boolean |
revs_from |
Trim the revision history to stop at the first revision in the provided list. If no match is found, the revisions will be trimmed to the |
String array |
atts_since |
Include attachments only since specified revisions. Excludes the attachments for the specified revisions. Only gets used if |
String array |
revs_limit |
Maximum amount of revisions to return for each document. |
Integer |
attachments |
Include attachment bodies in response. |
Boolean |
replicator2 |
Returns the document with the required properties for replication. This is an enterprise-edition only feature. |
Boolean |
Check if local document exists
HEAD /{keyspace}/_local/{docid}
Description
This request checks if a local document exists.
Local document IDs begin with _local/
. Local documents are not replicated or indexed, don't support attachments, and don't save revision histories. In practice they are almost only used by Couchbase Lite's replicator, as a place to store replication checkpoint data.
-
application/json
Parameters
Name | Description | Schema |
---|---|---|
keyspace |
The keyspace to run the operation against. A keyspace is a dot-separated string, comprised of a database name, and optionally a named scope and collection. |
String |
docid |
The name of the local document ID excluding the |
String |
Create a new document
POST /{keyspace}/
Description
Create a new document in the keyspace.
This will generate a random document ID unless specified in the body.
A document can have a maximum size of 20MB.
-
application/json
-
application/json
Parameters
Name | Description | Schema |
---|---|---|
keyspace |
The keyspace to run the operation against. A keyspace is a dot-separated string, comprised of a database name, and optionally a named scope and collection. |
String |
Name | Description | Schema |
---|---|---|
roundtrip |
Block until document has been received by change cache |
Boolean |
Name | Description | Schema |
---|---|---|
Body |
Get all the documents in the database using a built-in view
POST /{keyspace}/_all_docs
Description
Returns all documents in the database based on the specified parameters.
-
application/json
-
application/json
Parameters
Name | Description | Schema |
---|---|---|
keyspace |
The keyspace to run the operation against. A keyspace is a dot-separated string, comprised of a database name, and optionally a named scope and collection. |
String |
Name | Description | Schema |
---|---|---|
include_docs |
Include the body associated with each document. |
Boolean |
channels |
Include the channels each document is part of that the calling user also has access too. |
Boolean |
access |
Include what user/roles that each document grants access too. |
Boolean |
revs |
Include all the revisions for each document under the |
Boolean |
update_seq |
Include the document sequence number |
Boolean |
startkey |
Return records starting with the specified key. |
String |
endkey |
Stop returning records when this key is reached. |
String |
limit |
This limits the number of result rows returned. Using a value of |
Big Decimal |
Name | Description | Schema |
---|---|---|
Body |
Bulk document operations
POST /{keyspace}/_bulk_docs
Description
This will allow multiple documented to be created, updated or deleted in bulk.
To create a new document, simply add the body in an object under docs
. A doc ID will be generated by Sync Gateway unless _id
is specified.
To update an existing document, provide the document ID (_id
) and revision ID (_rev
) as well as the new body values.
To delete an existing document, provide the document ID (_id
), revision ID (_rev
), and set the deletion flag (_deleted
) to true.
-
application/json
-
application/json
Parameters
Name | Description | Schema |
---|---|---|
keyspace |
The keyspace to run the operation against. A keyspace is a dot-separated string, comprised of a database name, and optionally a named scope and collection. |
String |
Name | Description | Schema |
---|---|---|
Body |
Get multiple documents in a MIME multipart response
POST /{keyspace}/_bulk_get
Description
This request returns any number of documents, as individual bodies in a MIME multipart response.
Each enclosed body contains one requested document. The bodies appear in the same order as in the request, but can also be identified by their X-Doc-ID
and X-Rev-ID
headers (if the attachments
query is true
).
A body for a document with no attachments will have content type application/json
and contain the document itself.
A body for a document that has attachments will be written as a nested multipart/related
body.
-
application/json
-
application/json
Parameters
Name | Description | Schema |
---|---|---|
keyspace |
The keyspace to run the operation against. A keyspace is a dot-separated string, comprised of a database name, and optionally a named scope and collection. |
String |
Name | Description | Schema |
---|---|---|
attachments |
This is for whether to include attachments in each of the documents returned or not. |
Boolean |
revs |
Include all the revisions for each document under the |
Boolean |
revs_limit |
The number of revisions to include in the response from the document history. This parameter only makes a different if the |
Integer |
Name | Description | Schema |
---|---|---|
X-Accept-Part-Encoding |
If this header includes |
String |
Accept-Encoding |
If this header includes |
String |
Name | Description | Schema |
---|---|---|
Body |
Upsert a document
PUT /{keyspace}/{docid}
Description
This will upsert a document meaning if it does not exist, then it will be created. Otherwise a new revision will be made for the existing document. A revision ID must be provided if targetting an existing document.
A document ID must be specified for this endpoint. To let Sync Gateway generate the ID, use the POST /{db}/
endpoint.
If a document does exist, then replace the document content with the request body. This means unspecified fields will be removed in the new revision.
The maximum size for a document is 20MB.
-
application/json
-
application/json
Parameters
Name | Description | Schema |
---|---|---|
keyspace |
The keyspace to run the operation against. A keyspace is a dot-separated string, comprised of a database name, and optionally a named scope and collection. |
String |
docid |
The document ID to run the operation against. |
String |
Name | Description | Schema |
---|---|---|
roundtrip |
Block until document has been received by change cache |
Boolean |
replicator2 |
Returns the document with the required properties for replication. This is an enterprise-edition only feature. |
Boolean |
new_edits |
Setting this to false indicates that the request body is an already-existing revision that should be directly inserted into the database, instead of a modification to apply to the current document. This mode is used for replication. This option must be used in conjunction with the |
Boolean |
rev |
The document revision to target. |
String |
Name | Description | Schema |
---|---|---|
If-Match |
The revision ID to target. |
String |
Name | Description | Schema |
---|---|---|
Body |
Upsert a local document
PUT /{keyspace}/_local/{docid}
Description
This request creates or updates a local document. Updating a local document requires that the revision ID be put in the body under _rev
.
Local document IDs are given a _local/
prefix. Local documents are not replicated or indexed, don't support attachments, and don't save revision histories. In practice they are almost only used by the client's replicator, as a place to store replication checkpoint data.
-
application/json
-
application/json
Parameters
Name | Description | Schema |
---|---|---|
keyspace |
The keyspace to run the operation against. A keyspace is a dot-separated string, comprised of a database name, and optionally a named scope and collection. |
String |
docid |
The name of the local document ID excluding the |
String |
Name | Description | Schema |
---|---|---|
Body |
The body of the document |
Document Attachment
Table of Contents
Delete an attachment on a document
Get an attachment from a document
Check if attachment exists
Create or update an attachment on a document
Delete an attachment on a document
DELETE /{keyspace}/{docid}/{attach}
Description
This request deletes an attachment associated with the document.
If the attachment exists, the attachment will be removed from the document.
-
application/json
Parameters
Name | Description | Schema |
---|---|---|
keyspace |
The keyspace to run the operation against. A keyspace is a dot-separated string, comprised of a database name, and optionally a named scope and collection. |
String |
docid |
The document ID to run the operation against. |
String |
attach |
The attachment name. This value must be URL encoded. For example, if the attachment name is |
String |
Name | Description | Schema |
---|---|---|
rev |
The existing document revision ID to modify. |
String |
Name | Description | Schema |
---|---|---|
If-Match |
An alternative way of specifying the document revision ID. |
String |
Get an attachment from a document
GET /{keyspace}/{docid}/{attach}
Description
This request retrieves a file attachment associated with the document.
The raw data of the associated attachment is returned (just as if you were accessing a static file). The Content-Type
response header is the same content type set when the document attachment was added to the database. The Content-Disposition
response header will be set if the content type is considered unsafe to display in a browser (unless overridden by by database config option serve_insecure_attachment_types
) which will force the attachment to be downloaded.
If the meta
query parameter is set then the response will be in JSON with the additional metadata tags.
-
application/json
Parameters
Name | Description | Schema |
---|---|---|
keyspace |
The keyspace to run the operation against. A keyspace is a dot-separated string, comprised of a database name, and optionally a named scope and collection. |
String |
docid |
The document ID to run the operation against. |
String |
attach |
The attachment name. This value must be URL encoded. For example, if the attachment name is |
String |
Name | Description | Schema |
---|---|---|
rev |
The document revision to target. |
String |
content_encoding |
Set to false to disable the |
Boolean |
meta |
Return only the metadata of the attachment in the response body. |
Boolean |
Name | Description | Schema |
---|---|---|
Range |
RFC-2616 bytes range header. |
String |
Check if attachment exists
HEAD /{keyspace}/{docid}/{attach}
Description
This request check if the attachment exists on the specified document.
-
application/json
Parameters
Name | Description | Schema |
---|---|---|
keyspace |
The keyspace to run the operation against. A keyspace is a dot-separated string, comprised of a database name, and optionally a named scope and collection. |
String |
docid |
The document ID to run the operation against. |
String |
attach |
The attachment name. This value must be URL encoded. For example, if the attachment name is |
String |
Name | Description | Schema |
---|---|---|
rev |
The document revision to target. |
String |
Create or update an attachment on a document
PUT /{keyspace}/{docid}/{attach}
Description
This request adds or updates an attachment associated with the document. If the document does not exist, it will be created and the attachment will be added to it.
If the attachment already exists, the data of the existing attachment will be replaced in the new revision.
The maximum content size of an attachment is 20MB. The Content-Type
header of the request specifies the content type of the attachment.
-
Attachment content type
-
application/json
Parameters
Name | Description | Schema |
---|---|---|
keyspace |
The keyspace to run the operation against. A keyspace is a dot-separated string, comprised of a database name, and optionally a named scope and collection. |
String |
docid |
The document ID to run the operation against. |
String |
attach |
The attachment name. This value must be URL encoded. For example, if the attachment name is |
String |
Name | Description | Schema |
---|---|---|
rev |
The existing document revision ID to modify. Required only when modifying an existing document. |
String |
Name | Description | Schema |
---|---|---|
Content-Type |
The content type of the attachment. |
String |
If-Match |
An alternative way of specifying the document revision ID. |
String |
Name | Description | Schema |
---|---|---|
Body |
The attachment data |
String |
Replication
Create and manage inter-Sync Gateway replications
Handle incoming BLIP Sync web socket request
GET /{db}/_blipsync
Description
This handles incoming BLIP Sync requests from either Couchbase Lite or another Sync Gateway node. The connection has to be upgradable to a websocket connection or else the request will fail.
-
application/json
Parameters
Name | Description | Schema |
---|---|---|
db |
The name of the database to run the operation against. |
String |
Name | Description | Schema |
---|---|---|
client |
This is the client type that is making the BLIP Sync request. Used to control client-type specific replication behaviour. Values: |
String |
Server
Manage server activities
Session
Manage user sessions
Log out
DELETE /{db}/_session
Description
Invalidates the session for the currently authenticated user and removes their session cookie.
If CORS is enabled, the origin must match an allowed login origin otherwise an error will be returned.
-
application/json
Parameters
Name | Description | Schema |
---|---|---|
db |
The name of the database to run the operation against. |
String |
Get information about the current user
GET /{db}/_session
Parameters
Name | Description | Schema |
---|---|---|
db |
The name of the database to run the operation against. |
String |
/{db}/_session
HEAD /{db}/_session
Parameters
Name | Description | Schema |
---|---|---|
db |
The name of the database to run the operation against. |
String |
Create a new user session
POST /{db}/_session
Description
Generates a login session for the user based on the credentials provided in the request body or if that fails (due to invalid credentials or none provided at all), generates the new session for the currently authenticated user instead. On a successful session creation, a session cookie is stored to keep the user authenticated for future API calls.
If CORS is enabled, the origin must match an allowed login origin otherwise an error will be returned.
-
application/json
-
application/json
Parameters
Name | Description | Schema |
---|---|---|
db |
The name of the database to run the operation against. |
String |
Name | Description | Schema |
---|---|---|
Body |
The body can depend on if using the Public or Admin APIs. |
Unsupported
Endpoints that are not supported by Sync Gateway
Delete a design document | Unsupported
Get views of a design document | Unsupported
Query a view on a design document | Unsupported
Check if view of design document exists | Unsupported
Update views of a design document | Unsupported
Delete a design document | Unsupported
DELETE /{db}/_design/{ddoc}
Parameters
Name | Description | Schema |
---|---|---|
db |
The name of the database to run the operation against. |
String |
ddoc |
The design document name. |
String |
Get views of a design document | Unsupported
GET /{db}/_design/{ddoc}
Parameters
Name | Description | Schema |
---|---|---|
db |
The name of the database to run the operation against. |
String |
ddoc |
The design document name. |
String |
Query a view on a design document | Unsupported
GET /{db}/_design/{ddoc}/_view/{view}
Parameters
Name | Description | Schema |
---|---|---|
db |
The name of the database to run the operation against. |
String |
ddoc |
The design document name. |
String |
view |
The view to target. |
String |
Name | Description | Schema |
---|---|---|
inclusive_end |
Indicates whether the specified end key should be included in the result. |
Boolean |
descending |
Return documents in descending order. |
Boolean |
include_docs |
Only works when using Couchbase Server 3.0 and earlier. Indicates whether to include the full content of the documents in the response. |
Boolean |
reduce |
Whether to execute a reduce function on the response or not. |
Boolean |
group |
Group the results using the reduce function to a group or single row. |
Boolean |
skip |
Skip the specified number of documents before starting to return results. |
Integer |
limit |
Return only the specified number of documents |
Integer |
group_level |
Specify the group level to be used. |
Integer |
startkey_docid |
Return documents starting with the specified document identifier. |
String |
endkey_docid |
Stop returning records when the specified document identifier is reached. |
String |
stale |
Allow the results from a stale view to be used, without triggering a rebuild of all views within the encompassing design document. Values: |
String |
startkey |
Return records starting with the specified key. |
String |
endkey |
Stop returning records when this key is reached. |
String |
key |
Return only the document that matches the specified key. |
String |
keys |
An array of document ID strings to filter by. |
String array |
Check if view of design document exists | Unsupported
HEAD /{db}/_design/{ddoc}
Description
This is unsupported
Check if a design document can be queried.
-
application/json
Parameters
Name | Description | Schema |
---|---|---|
db |
The name of the database to run the operation against. |
String |
ddoc |
The design document name. |
String |
Update views of a design document | Unsupported
PUT /{db}/_design/{ddoc}
Description
This is unsupported
Update the views of a design document.
-
application/json
-
application/json
Parameters
Name | Description | Schema |
---|---|---|
db |
The name of the database to run the operation against. |
String |
ddoc |
The design document name. |
String |
Name | Description | Schema |
---|---|---|
Body |
Definitions
This section describes the properties consumed and returned by this REST API.
ChangesFeed
DesignDoc
Document
Get200Response
Get200ResponseVendor
GetDb200Response
GetDbDesignDdoc200Response
GetDbDesignDdoc200ResponseOptions
GetDbDesignDdoc200ResponseViewsValue
GetDbDesignDdocViewView200Response
GetDbDesignDdocViewView200ResponseErrorsInner
GetDbDesignDdocViewView200ResponseRowsInner
GetDbOidcTestingCerts200Response
GetDbOidcTestingCerts200ResponseKeysInner
GetDbOidcTestingWellKnownOpenidConfiguration200Response
GetKeyspaceAllDocs200Response
GetKeyspaceAllDocs200ResponseRowsInner
GetKeyspaceAllDocs200ResponseRowsInnerValue
GetKeyspaceChanges200Response
GetKeyspaceChanges200ResponseResultsInner
GetKeyspaceChanges200ResponseResultsInnerChangesInner
GetKeyspaceDocid200Response
HTTP-Error
New-revision
NodeInfo
OpenID Connect callback properties
OIDCLoginPageHandler
OIDC-token
OpenID Connect callback properties
PostDbEnsureFullCommit201Response
PostDbFacebook401Response
PostDbFacebookRequest
PostDbGoogleRequest
PostDbOidcTestingAuthenticateRequest
PostDbOidcTestingTokenRequest
PostDbSession200Response
PostDbSession200ResponseUserCtx
PostDbSession200ResponseUserCtxChannelsValue
PostDbSessionRequest
PostKeyspaceAllDocsRequest
PostKeyspaceBulkDocs201ResponseInner
PostKeyspaceBulkDocsRequest
PostKeyspaceBulkGetRequest
PostKeyspaceBulkGetRequestDocsInner
PostKeyspaceChangesRequest
PostKeyspaceRequest
PostKeyspaceRequestAttachmentsValue
PostKeyspaceRequestRevisions
PostKeyspaceRevsDiff200Response
PostKeyspaceRevsDiff200ResponseDocid
PostKeyspaceRevsDiffRequest
PutKeyspaceLocalDocidRequest
User Session Information
UserSessionInformationUserCtx
ChangesFeed
Property | Schema | |
---|---|---|
results |
Unique items: |
|
last_seq |
The last change sequence number. |
String |
Document
Property | Schema | |
---|---|---|
_id |
The ID of the document. |
String |
_rev |
The revision of the document. |
String |
_exp |
Expiry time after which the document will be purged. The expiration time is set and managed on the Couchbase Server document. The value can be specified in two ways; in ISO-8601 format, for example the 6th of July 2022 at 17:00 in the BST timezone would be As with the existing explicit purge mechanism, this applies only to the local database; it has nothing to do with replication. This expiration time is not propagated when the document is replicated. The purge of the document does not cause it to be deleted on any other database. |
String |
_deleted |
Whether the document is a tombstone or not. If true, it is a tombstone. |
Boolean |
_revisions |
||
_attachments |
||
additional |
Any Type |
Get200Response
Property | Schema | |
---|---|---|
ADMIN |
|
Boolean |
couchdb |
CouchDB welcome |
String |
vendor |
Product vendor |
|
version |
Product version, including the build number and edition (i.e. |
String |
persistent_config |
Indication for whether sync gateway is running in persistent config mode or legacy config mode.
|
Boolean |
Get200ResponseVendor
Property | Schema | |
---|---|---|
name |
Product name |
String |
version |
API version.
Omitted if |
String |
GetDb200Response
Property | Schema | |
---|---|---|
db_name |
Database name |
String |
update_seq |
The last sequence number that was committed to the database. Will return 0 if the database is offline. |
Integer |
committed_update_seq |
The last sequence number that was committed to the database. Will return 0 if the database is offline. |
Integer |
instance_start_time |
Timestamp of when the database opened, in microseconds since the Unix epoch. |
Integer |
compact_running |
Indicates whether database compaction is currently taking place or not. |
Boolean |
purge_seq |
Unused field. |
Big Decimal |
disk_format_version |
Unused field. |
Big Decimal |
state |
The database state. Change using the Values: |
String |
server_uuid |
Unique server identifier. |
String |
GetDbDesignDdoc200Response
Property | Schema | |
---|---|---|
language |
String |
|
views |
||
options |
GetDbDesignDdoc200ResponseOptions
Property | Schema | |
---|---|---|
local_seq |
String |
|
include_design |
String |
|
raw |
String |
|
index_xattr_on_deleted_docs |
String |
GetDbDesignDdoc200ResponseViewsValue
Property | Schema | |
---|---|---|
map |
String |
|
reduce |
String |
GetDbDesignDdocViewView200Response
Property | Schema | |
---|---|---|
total_rows |
Integer |
|
rows |
||
errors |
GetDbDesignDdocViewView200ResponseErrorsInner
Property | Schema | |
---|---|---|
From |
String |
|
Reason |
String |
GetDbDesignDdocViewView200ResponseRowsInner
Property | Schema | |
---|---|---|
id |
String |
|
key |
Object |
|
value |
Object |
|
doc |
Object |
GetDbOidcTestingCerts200ResponseKeysInner
Property | Schema | |
---|---|---|
Key |
Object |
|
KeyID |
String |
|
Use |
String |
|
Certificates |
Object array |
|
Algorithm |
String |
GetDbOidcTestingWellKnownOpenidConfiguration200Response
Property | Schema | |
---|---|---|
issuer |
String |
|
authorization_endpoint |
String |
|
token_endpoint |
String |
|
jwks_uri |
String |
|
userinfo_endpoint |
String |
|
id_token_signing_alg_values_supported |
String |
|
response_types_supported |
String |
|
subject_types_supported |
String |
|
scopes_supported |
String |
|
claims_supported |
String |
|
token_endpoint_auth_methods_supported |
String |
GetKeyspaceAllDocs200Response
Property | Schema | |
---|---|---|
rows |
Unique items: |
|
total_rows |
Big Decimal |
|
update_seq |
Big Decimal |
GetKeyspaceAllDocs200ResponseRowsInner
Property | Schema | |
---|---|---|
key |
String |
|
id |
String |
|
value |
GetKeyspaceChanges200Response
Property | Schema | |
---|---|---|
results |
Unique items: |
|
last_seq |
The last change sequence number. |
String |
GetKeyspaceChanges200ResponseResultsInner
Property | Schema | |
---|---|---|
seq |
The change sequence number. |
Big Decimal |
id |
The document ID the change happened on. |
String |
changes |
List of document leafs with each leaf containing only a Unique items: |
GetKeyspaceChanges200ResponseResultsInnerChangesInner
Property | Schema | |
---|---|---|
rev |
The new revision that was caused by that change. |
String |
GetKeyspaceDocid200Response
Property | Schema | |
---|---|---|
_id |
The ID of the document. |
String |
_rev |
The revision ID of the document. |
String |
additional |
Any Type |
HTTP-Error
Property | Schema | |
---|---|---|
error |
The error name. |
String |
reason |
The error description. |
String |
New-revision
Property | Schema | |
---|---|---|
id |
The ID of the document. |
String |
ok |
Whether the request completed successfully. |
Boolean |
rev |
The revision of the document. |
String |
NodeInfo
Property | Schema | |
---|---|---|
ADMIN |
|
Boolean |
couchdb |
CouchDB welcome |
String |
vendor |
Product vendor |
|
version |
Product version, including the build number and edition (i.e. |
String |
persistent_config |
Indication for whether sync gateway is running in persistent config mode or legacy config mode.
|
Boolean |
OpenID Connect callback properties
Property | Schema | |
---|---|---|
id_token |
The OpenID Connect ID token |
String |
refresh_token |
The OpenID Connect ID refresh token |
String |
session_id |
The Sync Gateway session token |
String |
name |
The Sync Gateway user |
String |
access_token |
The OpenID Connect access token |
String |
token_type |
The OpenID Connect ID token type |
String |
expires_in |
The time until the id_token expires (TTL). |
Big Decimal |
OIDCLoginPageHandler
Property | Schema | |
---|---|---|
username |
String |
|
tokenttl |
String |
|
identity-token-formats |
String |
|
authenticated |
String |
OIDC-token
Property | Schema | |
---|---|---|
access_token |
String |
|
token_type |
String |
|
refresh_token |
String |
|
expires_in |
String |
|
id_token |
String |
OpenID Connect callback properties
Property | Schema | |
---|---|---|
id_token |
The OpenID Connect ID token |
String |
refresh_token |
The OpenID Connect ID refresh token |
String |
session_id |
The Sync Gateway session token |
String |
name |
The Sync Gateway user |
String |
access_token |
The OpenID Connect access token |
String |
token_type |
The OpenID Connect ID token type |
String |
expires_in |
The time until the id_token expires (TTL). |
Big Decimal |
PostDbEnsureFullCommit201Response
Property | Schema | |
---|---|---|
instance_start_time |
Timestamp of when the database opened, in microseconds since the Unix epoch. |
Integer |
ok |
Boolean |
PostDbFacebookRequest
Property | Schema | |
---|---|---|
access_token |
Facebook access token to base the new session on. |
String |
PostDbGoogleRequest
Property | Schema | |
---|---|---|
id_token |
Google ID token to base the new session on. |
String |
PostDbOidcTestingAuthenticateRequest
Property | Schema | |
---|---|---|
username |
String |
|
tokenttl |
String |
|
identity-token-formats |
String |
|
authenticated |
String |
PostDbOidcTestingTokenRequest
Property | Schema | |
---|---|---|
grant_type |
The grant type of the token to request. Can either be an |
String |
code |
|
String |
refresh_token |
|
String |
PostDbSession200Response
Property | Schema | |
---|---|---|
authentication_handlers |
Used for CouchDB compatability. Always contains "default" and "cookie". Values: |
String array |
ok |
Used for CouchDB compatability. Always true. |
Boolean |
userCtx |
PostDbSession200ResponseUserCtx
Property | Schema | |
---|---|---|
channels |
A map of the channels the user is in along with the sequence number the user was granted access. |
|
name |
The name of the user. Minimum length: |
String |
PostDbSession200ResponseUserCtxChannelsValue
One of the following:
-
Big Decimal
-
String
PostDbSessionRequest
Property | Schema | |
---|---|---|
name |
User name to generate the session for. |
String |
password |
Password of the user to generate the session for. |
String |
PostKeyspaceAllDocsRequest
Property | Schema | |
---|---|---|
keys |
List of the documents to retrieve. |
String array |
PostKeyspaceBulkDocs201ResponseInner
Property | Schema | |
---|---|---|
id |
The ID of the document that the operation was performed on. |
String |
rev |
The new revision of the document if the operation was a success. |
String |
error |
The error type if the operation of the document failed. |
String |
reason |
The reason the operation failed. |
String |
status |
The HTTP status code for why the operation failed. |
Integer |
PostKeyspaceBulkDocsRequest
Property | Schema | |
---|---|---|
new_edits |
This controls whether to assign new revision identifiers to new edits ( |
Boolean |
docs |
PostKeyspaceRequest array |
PostKeyspaceBulkGetRequestDocsInner
Property | Schema | |
---|---|---|
id |
ID of the document to retrieve. |
String |
PostKeyspaceChangesRequest
Property | Schema | |
---|---|---|
limit |
Maximum number of changes to return. |
String |
style |
Controls whether to return the current winning revision ( |
String |
active_only |
Set true to exclude deleted documents and notifications for documents the user no longer has access to from the changes feed. |
String |
include_docs |
Include the body associated with each document. |
Boolean |
revocations |
If true, revocation messages will be sent on the changes feed. |
String |
filter |
Set a filter to either filter by channels or document IDs. |
String |
channels |
A comma-separated list of channel names to filter the response to only the channels specified. To use this option, the |
String |
doc_ids |
A valid JSON array of document IDs to filter the documents in the response to only the documents specified. To use this option, the |
String |
heartbeat |
The interval (in milliseconds) to send an empty line (CRLF) in the response. This is to help prevent gateways from deciding the socket is idle and therefore closing it. This is only applicable to |
String |
timeout |
This is the maximum period (in milliseconds) to wait for a change before the response is sent, even if there are no results. This is only applicable for |
String |
feed |
The type of changes feed to use. |
String |
PostKeyspaceRequest
Property | Schema | |
---|---|---|
_id |
The ID of the document. |
String |
_rev |
The revision of the document. |
String |
_exp |
Expiry time after which the document will be purged. The expiration time is set and managed on the Couchbase Server document. The value can be specified in two ways; in ISO-8601 format, for example the 6th of July 2022 at 17:00 in the BST timezone would be As with the existing explicit purge mechanism, this applies only to the local database; it has nothing to do with replication. This expiration time is not propagated when the document is replicated. The purge of the document does not cause it to be deleted on any other database. |
String |
_deleted |
Whether the document is a tombstone or not. If true, it is a tombstone. |
Boolean |
_revisions |
||
_attachments |
||
additional |
Any Type |
PostKeyspaceRequestAttachmentsValue
Property | Schema | |
---|---|---|
content_type |
Content type of the attachment. |
String |
data |
The data in the attachment in base64. |
String |
PostKeyspaceRequestRevisions
Property | Schema | |
---|---|---|
start |
Prefix number for the latest revision. |
Big Decimal |
ids |
Array of valid revision IDs, in reverse order (latest first). |
String array |
PostKeyspaceRevsDiff200ResponseDocid
Property | Schema | |
---|---|---|
missing |
The revisions that are not in the database (and therefore |
String array |
possible_ancestors |
An array of known revisions that might be the recent ancestors. |
String array |
PostKeyspaceRevsDiffRequest
Property | Schema | |
---|---|---|
docid |
The document ID with an array of revisions to use for the comparison. |
String array |
PutKeyspaceLocalDocidRequest
Property | Schema | |
---|---|---|
_rev |
Revision to replace. Required if updating existing local document. |
String |
User Session Information
Property | Schema | |
---|---|---|
authentication_handlers |
The ways authentication can be established to authenticate as the user. |
String array |
ok |
Boolean |
|
userCtx |
UserSessionInformationUserCtx
Property | Schema | |
---|---|---|
channels |
A map of the channels the user has access to and the sequence number each channel was created at. The key is the channel name and the value is the sequence number. |
Object |
name |
The name of the user. |
String |