Download OpenAPI specification:Download
Sync Gateway manages access and synchronization between Couchbase Lite and Couchbase Server
{- "ADMIN": true,
- "couchdb": "Welcome",
- "vendor": {
- "name": "Couchbase Sync Gateway",
- "version": 3.1
}, - "version": "Couchbase Sync Gateway/3.1.0(1;a765231) EE",
- "persistent_config": true
}
Retrieve information about the database.
db required | string Example: db1 The name of the database to run the operation against. |
{- "db_name": "db",
- "update_seq": 123456,
- "committed_update_seq": 123456,
- "instance_start_time": 1644600082279583,
- "compact_running": true,
- "purge_seq": 0,
- "disk_format_version": 0,
- "state": "Online",
- "server_uuid": "995618a6a6cc9ac79731bd13240e19b5"
}
Check if a database exists by using the response status code.
db required | string Example: db1 The name of the database to run the operation against. |
{- "error": "not_found",
- "reason": "no such database \"invalid-db\""
}
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.
keyspace required | string Examples:
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. |
limit | integer Maximum number of changes to return. |
since | string 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. |
style | string Default: "main_only" Enum: "main_only" "all_docs" Controls whether to return the current winning revision ( |
active_only | boolean Default: "false" Set true to exclude deleted documents and notifications for documents the user no longer has access to from the changes feed. |
include_docs | boolean Include the body associated with each document. |
revocations | boolean If true, revocation messages will be sent on the changes feed. |
filter | string Enum: "sync_gateway/bychannel" "_doc_ids" Set a filter to either filter by channels or document IDs. |
channels | string A comma-separated list of channel names to filter the response to only the channels specified. To use this option, the |
doc_ids | Array of strings A valid JSON array of document IDs to filter the documents in the response to only the documents specified. To use this option, the |
heartbeat | integer >= 25000 Default: 0 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 |
timeout | integer [ 0 .. 900000 ] Default: 300000 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 |
feed | string Default: "normal" Enum: "normal" "longpoll" "continuous" "websocket" The type of changes feed to use. |
{- "results": [
- {
- "seq": 0,
- "id": "string",
- "changes": [
- {
- "rev": "string"
}
]
}
], - "last_seq": "string"
}
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.
keyspace required | string Examples:
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. |
limit | string Maximum number of changes to return. |
style | string Controls whether to return the current winning revision ( |
active_only | string Set true to exclude deleted documents and notifications for documents the user no longer has access to from the changes feed. |
include_docs | boolean Include the body associated with each document. |
revocations | string If true, revocation messages will be sent on the changes feed. |
filter | string Set a filter to either filter by channels or document IDs. |
channels | string A comma-separated list of channel names to filter the response to only the channels specified. To use this option, the |
doc_ids | string A valid JSON array of document IDs to filter the documents in the response to only the documents specified. To use this option, the |
heartbeat | string 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 |
timeout | string 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 |
feed | string The type of changes feed to use. |
{- "limit": "string",
- "style": "string",
- "active_only": "string",
- "include_docs": true,
- "revocations": "string",
- "filter": "string",
- "channels": "string",
- "doc_ids": "string",
- "heartbeat": "string",
- "timeout": "string",
- "feed": "string"
}
{- "results": [
- {
- "seq": 0,
- "id": "string",
- "changes": [
- {
- "rev": "string"
}
]
}
], - "last_seq": "string"
}
keyspace required | string Examples:
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. |
This endpoint is non-functional but is present for CouchDB compatibility.
db required | string Example: db1 The name of the database to run the operation against. |
{- "instance_start_time": 1644600082279583,
- "ok": true
}
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.
keyspace required | string Examples:
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. |
docid | Array of strings The document ID with an array of revisions to use for the comparison. |
{- "docid": [
- "string"
]
}
{- "docid": {
- "missing": [
- "string"
], - "possible_ancestors": [
- "string"
]
}
}
This will get the information about the current user.
db required | string Example: db1 The name of the database to run the operation against. |
{- "authentication_handlers": [
- "string"
], - "ok": true,
- "userCtx": {
- "channels": { },
- "name": "string"
}
}
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.
db required | string Example: db1 The name of the database to run the operation against. |
The body can depend on if using the Public or Admin APIs.
name | string User name to generate the session for. |
password | string Password of the user to generate the session for. |
{- "name": "string",
- "password": "string"
}
{- "authentication_handlers": [
- "default",
- "cookie"
], - "ok": true,
- "userCtx": {
- "channels": {
- "!": 1
}, - "name": "Bob"
}
}
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.
db required | string Example: db1 The name of the database to run the operation against. |
{- "error": "not_found",
- "reason": "no such database \"invalid-db\""
}
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.
db required | string Example: db1 The name of the database to run the operation against. |
access_token required | string Facebook access token to base the new session on. |
{- "access_token": "string"
}
{- "error": "string",
- "reason": "string"
}
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.
db required | string Example: db1 The name of the database to run the operation against. |
id_token required | string Google ID token to base the new session on. |
{- "id_token": "string"
}
{- "error": "string",
- "reason": "string"
}
Called by clients to initiate the OpenID Connect Authorization Code Flow. Redirects to the OpenID Connect provider if successful.
db required | string Example: db1 The name of the database to run the operation against. |
provider | string 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. |
offline | string 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. |
{- "error": "not_found",
- "reason": "no such database \"invalid-db\""
}
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.
db required | string Example: db1 The name of the database to run the operation against. |
provider | string 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. |
offline | string 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. |
{- "error": "not_found",
- "reason": "no such database \"invalid-db\""
}
The callback URL that the client is redirected to after authenticating with the OpenID Connect provider.
db required | string Example: db1 The name of the database to run the operation against. |
error | string The OpenID Connect error, if any occurred. |
code required | string The OpenID Connect authentication code. |
provider | string 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. |
state | string 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 |
{- "id_token": "string",
- "refresh_token": "string",
- "session_id": "string",
- "name": "string",
- "access_token": "string",
- "token_type": "string",
- "expires_in": 0
}
Refresh the OpenID Connect token based on the provided refresh token.
db required | string Example: db1 The name of the database to run the operation against. |
refresh_token required | string The OpenID Connect refresh token. |
provider | string 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. |
{- "id_token": "string",
- "refresh_token": "string",
- "session_id": "string",
- "name": "string",
- "access_token": "string",
- "token_type": "string",
- "expires_in": 0
}
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.
db required | string Example: db1 The name of the database to run the operation against. |
{- "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"
}
Return a mock OpenID Connect token for the OIDC authentication flow.
db required | string Example: db1 The name of the database to run the operation against. |
grant_type required | string The grant type of the token to request. Can either be an |
code | string
|
refresh_token | string
|
{- "grant_type": "string",
- "code": "string",
- "refresh_token": "string"
}
{- "access_token": "string",
- "token_type": "string",
- "refresh_token": "string",
- "expires_in": "string",
- "id_token": "string"
}
Return a mock OpenID Connect public key to be used as signing keys.
db required | string Example: db1 The name of the database to run the operation against. |
{- "keys": [
- {
- "Key": { },
- "KeyID": "string",
- "Use": "string",
- "Certificates": [
- { }
], - "Algorithm": "string"
}
]
}
Used to handle the login page displayed for the GET /{db}/_oidc_testing/authorize
endpoint.
db required | string Example: db1 The name of the database to run the operation against. |
redirect_uri | string The Sync Gateway OpenID Connect callback URL. |
scope required | string The OpenID Connect authentication scope. |
username required | string |
tokenttl required | integer |
identity-token-formats required | string |
authenticated required | string |
{- "error": "not_found",
- "reason": "no such database \"invalid-db\""
}
Used to handle the login page displayed for the GET /{db}/_oidc_testing/authorize
endpoint.
db required | string Example: db1 The name of the database to run the operation against. |
redirect_uri | string The Sync Gateway OpenID Connect callback URL. |
scope required | string The OpenID Connect authentication scope. |
Properties passed from the OpenID Connect mock login page to the handler
username required | string |
tokenttl required | string |
identity-token-formats required | string |
authenticated required | string |
{- "username": "string",
- "tokenttl": "string",
- "identity-token-formats": "string",
- "authenticated": "string"
}
{- "error": "not_found",
- "reason": "no such database \"invalid-db\""
}
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.
keyspace required | string Examples:
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. |
roundtrip | boolean Block until document has been received by change cache |
_id | string The ID of the document. |
_rev | string The revision of the document. |
_exp | string 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. |
_deleted | boolean Whether the document is a tombstone or not. If true, it is a tombstone. |
object | |
object | |
property name* additional property | any |
{- "_id": "string",
- "_rev": "string",
- "_exp": "string",
- "_deleted": true,
- "_revisions": {
- "start": 0,
- "ids": [
- "string"
]
}, - "_attachments": {
- "attachmentname1": {
- "content_type": "string",
- "data": "string"
}, - "attachmentname2": {
- "content_type": "string",
- "data": "string"
}
}
}
{- "id": "string",
- "ok": true,
- "rev": "string"
}
Returns all documents in the database based on the specified parameters.
keyspace required | string Examples:
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. |
include_docs | boolean Include the body associated with each document. |
channels | boolean Include the channels each document is part of that the calling user also has access too. |
access | boolean Include what user/roles that each document grants access too. |
revs | boolean Include all the revisions for each document under the |
update_seq | boolean Include the document sequence number |
keys | Array of strings An array of document ID strings to filter by. |
startkey | string Return records starting with the specified key. |
endkey | string Stop returning records when this key is reached. |
limit | number This limits the number of result rows returned. Using a value of |
{- "rows": [
- {
- "key": "string",
- "id": "string",
- "value": {
- "rev": "string"
}
}
], - "total_rows": 0,
- "update_seq": 0
}
Returns all documents in the database based on the specified parameters.
keyspace required | string Examples:
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. |
include_docs | boolean Include the body associated with each document. |
channels | boolean Include the channels each document is part of that the calling user also has access too. |
access | boolean Include what user/roles that each document grants access too. |
revs | boolean Include all the revisions for each document under the |
update_seq | boolean Include the document sequence number |
startkey | string Return records starting with the specified key. |
endkey | string Stop returning records when this key is reached. |
limit | number This limits the number of result rows returned. Using a value of |
keys required | Array of strings List of the documents to retrieve. |
{- "keys": [
- "string"
]
}
{- "rows": [
- {
- "key": "string",
- "id": "string",
- "value": {
- "rev": "string"
}
}
], - "total_rows": 0,
- "update_seq": 0
}
keyspace required | string Examples:
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. |
include_docs | boolean Include the body associated with each document. |
channels | boolean Include the channels each document is part of that the calling user also has access too. |
access | boolean Include what user/roles that each document grants access too. |
revs | boolean Include all the revisions for each document under the |
update_seq | boolean Include the document sequence number |
keys | Array of strings An array of document ID strings to filter by. |
startkey | string Return records starting with the specified key. |
endkey | string Stop returning records when this key is reached. |
limit | number This limits the number of result rows returned. Using a value of |
{- "error": "string",
- "reason": "string"
}
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.
keyspace required | string Examples:
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. |
new_edits | boolean Default: true This controls whether to assign new revision identifiers to new edits ( |
required | Array of objects (Document) |
{- "new_edits": true,
- "docs": [
- {
- "_id": "FooBar",
- "foo": "bar"
}, - {
- "_id": "AliceSettings",
- "_rev": "5-832a6db48ed130adadede928aee54576",
- "FailedLoginAttempts": 7
}, - {
- "_id": "BobSettings",
- "_rev": "1-fa76ba41ee5fdfee1b91fc478ed09e59",
- "_deleted": true
}
]
}
[- {
- "id": "FooBar",
- "rev": "1-cd809becc169215072fd567eebd8b8de"
}, - {
- "id": "AliceSettings",
- "rev": "6-b3e8dcf825b71ccee112f3572ec4323c"
}, - {
- "id": "BobSettings",
- "rev": "2-5145e1086bb8d1d71a531e9f6b543c58"
}
]
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.
keyspace required | string Examples:
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. |
attachments | boolean Default: "false" This is for whether to include attachments in each of the documents returned or not. |
revs | boolean Include all the revisions for each document under the |
revs_limit | integer The number of revisions to include in the response from the document history. This parameter only makes a different if the |
X-Accept-Part-Encoding | string If this header includes |
Accept-Encoding | string If this header includes |
required | Array of objects |
{- "docs": [
- {
- "id": "FooBar"
}, - {
- "id": "attachment"
}, - {
- "id": "AliceSettings"
}
]
}
{- "error": "not_found",
- "reason": "no such database \"invalid-db\""
}
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.
keyspace required | string Examples:
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. |
docid required | string The name of the local document ID excluding the |
{- "error": "string",
- "reason": "string"
}
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.
keyspace required | string Examples:
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. |
docid required | string The name of the local document ID excluding the |
The body of the document
_rev | string Revision to replace. Required if updating existing local document. |
{- "_rev": "string"
}
{- "id": "string",
- "ok": true,
- "rev": "string"
}
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.
keyspace required | string Examples:
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. |
docid required | string The name of the local document ID excluding the |
rev required | string The revision ID of the revision to delete. |
{- "error": "string",
- "reason": "string"
}
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.
keyspace required | string Examples:
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. |
docid required | string The name of the local document ID excluding the |
{- "error": "string",
- "reason": "string"
}
Retrieve a document from the database by its doc ID.
keyspace required | string Examples:
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. |
docid required | string Example: doc1 The document ID to run the operation against. |
rev | string Example: rev=2-5145e1086bb8d1d71a531e9f6b543c58 The document revision to target. |
open_revs | Array of strings 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 |
show_exp | boolean Whether to show the expiry property ( |
revs_from | Array of strings 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 |
atts_since | Array of strings Include attachments only since specified revisions. Excludes the attachments for the specified revisions. Only gets used if |
revs_limit | integer Maximum amount of revisions to return for each document. |
attachments | boolean Include attachment bodies in response. |
replicator2 | boolean Returns the document with the required properties for replication. This is an enterprise-edition only feature. |
{- "FailedLoginAttempts": 5,
- "Friends": [
- "Bob"
], - "_id": "AliceSettings",
- "_rev": "1-64d4a1f179db5c1848fe52967b47c166"
}
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.
keyspace required | string Examples:
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. |
docid required | string Example: doc1 The document ID to run the operation against. |
roundtrip | boolean Block until document has been received by change cache |
replicator2 | boolean Returns the document with the required properties for replication. This is an enterprise-edition only feature. |
new_edits | boolean Default: "true" 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 |
rev | string Example: rev=2-5145e1086bb8d1d71a531e9f6b543c58 The document revision to target. |
If-Match | string The revision ID to target. |
_id | string The ID of the document. |
_rev | string The revision of the document. |
_exp | string 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. |
_deleted | boolean Whether the document is a tombstone or not. If true, it is a tombstone. |
object | |
object | |
property name* additional property | any |
{- "_id": "string",
- "_rev": "string",
- "_exp": "string",
- "_deleted": true,
- "_revisions": {
- "start": 0,
- "ids": [
- "string"
]
}, - "_attachments": {
- "attachmentname1": {
- "content_type": "string",
- "data": "string"
}, - "attachmentname2": {
- "content_type": "string",
- "data": "string"
}
}
}
{- "id": "string",
- "ok": true,
- "rev": "string"
}
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.
keyspace required | string Examples:
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. |
docid required | string Example: doc1 The document ID to run the operation against. |
rev | string Example: rev=2-5145e1086bb8d1d71a531e9f6b543c58 The document revision to target. |
If-Match | string The revision ID to target. |
{- "id": "string",
- "ok": true,
- "rev": "string"
}
Return a status code based on if the document exists or not.
keyspace required | string Examples:
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. |
docid required | string Example: doc1 The document ID to run the operation against. |
rev | string Example: rev=2-5145e1086bb8d1d71a531e9f6b543c58 The document revision to target. |
open_revs | Array of strings 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 |
show_exp | boolean Whether to show the expiry property ( |
revs_from | Array of strings 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 |
atts_since | Array of strings Include attachments only since specified revisions. Excludes the attachments for the specified revisions. Only gets used if |
revs_limit | integer Maximum amount of revisions to return for each document. |
attachments | boolean Include attachment bodies in response. |
replicator2 | boolean Returns the document with the required properties for replication. This is an enterprise-edition only feature. |
{- "error": "string",
- "reason": "string"
}
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.
keyspace required | string Examples:
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. |
docid required | string Example: doc1 The document ID to run the operation against. |
attach required | string The attachment name. This value must be URL encoded. For example, if the attachment name is |
rev | string Example: rev=2-5145e1086bb8d1d71a531e9f6b543c58 The document revision to target. |
content_encoding | boolean Default: "true" Set to false to disable the |
meta | boolean Default: "false" Return only the metadata of the attachment in the response body. |
Range | string Example: bytes=123-456 RFC-2616 bytes range header. |
{- "error": "not_found",
- "reason": "no such database \"invalid-db\""
}
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.
keyspace required | string Examples:
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. |
docid required | string Example: doc1 The document ID to run the operation against. |
attach required | string The attachment name. This value must be URL encoded. For example, if the attachment name is |
rev | string The existing document revision ID to modify. Required only when modifying an existing document. |
Content-Type | string Default: application/octet-stream The content type of the attachment. |
If-Match | string An alternative way of specifying the document revision ID. |
The attachment data
The content to store in the body
{- "id": "string",
- "ok": true,
- "rev": "string"
}
This request check if the attachment exists on the specified document.
keyspace required | string Examples:
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. |
docid required | string Example: doc1 The document ID to run the operation against. |
attach required | string The attachment name. This value must be URL encoded. For example, if the attachment name is |
rev | string Example: rev=2-5145e1086bb8d1d71a531e9f6b543c58 The document revision to target. |
{- "error": "not_found",
- "reason": "no such database \"invalid-db\""
}
This request deletes an attachment associated with the document.
If the attachment exists, the attachment will be removed from the document.
keyspace required | string Examples:
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. |
docid required | string Example: doc1 The document ID to run the operation against. |
attach required | string The attachment name. This value must be URL encoded. For example, if the attachment name is |
rev | string The existing document revision ID to modify. |
If-Match | string An alternative way of specifying the document revision ID. |
{- "id": "string",
- "ok": true,
- "rev": "string"
}
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.
db required | string Example: db1 The name of the database to run the operation against. |
client | string Default: "cbl2" Enum: "cbl2" "sgr2" This is the client type that is making the BLIP Sync request. Used to control client-type specific replication behaviour. |
{- "error": "not_found",
- "reason": "no such database \"invalid-db\""
}
This is unsupported
Query a design document.
db required | string Example: db1 The name of the database to run the operation against. |
ddoc required | string The design document name. |
{- "language": "string",
- "views": {
- "viewname1": {
- "map": "string",
- "reduce": "string"
}, - "viewname2": {
- "map": "string",
- "reduce": "string"
}
}, - "options": {
- "local_seq": "string",
- "include_design": "string",
- "raw": "string",
- "index_xattr_on_deleted_docs": "string"
}
}
This is unsupported
Update the views of a design document.
db required | string Example: db1 The name of the database to run the operation against. |
ddoc required | string The design document name. |
language | string |
object | |
object |
{- "language": "string",
- "views": {
- "viewname1": {
- "map": "string",
- "reduce": "string"
}, - "viewname2": {
- "map": "string",
- "reduce": "string"
}
}, - "options": {
- "local_seq": "string",
- "include_design": "string",
- "raw": "string",
- "index_xattr_on_deleted_docs": "string"
}
}
{- "error": "not_found",
- "reason": "no such database \"invalid-db\""
}
This is unsupported
Delete a design document.
db required | string Example: db1 The name of the database to run the operation against. |
ddoc required | string The design document name. |
{- "error": "not_found",
- "reason": "no such database \"invalid-db\""
}
This is unsupported
Check if a design document can be queried.
db required | string Example: db1 The name of the database to run the operation against. |
ddoc required | string The design document name. |
{- "error": "not_found",
- "reason": "no such database \"invalid-db\""
}
This is unsupported
Query a view on a design document.
db required | string Example: db1 The name of the database to run the operation against. |
ddoc required | string The design document name. |
view required | string The view to target. |
inclusive_end | boolean Indicates whether the specified end key should be included in the result. |
descending | boolean Return documents in descending order. |
include_docs | boolean Only works when using Couchbase Server 3.0 and earlier. Indicates whether to include the full content of the documents in the response. |
reduce | boolean Whether to execute a reduce function on the response or not. |
group | boolean Group the results using the reduce function to a group or single row. |
skip | integer Skip the specified number of documents before starting to return results. |
limit | integer Return only the specified number of documents |
group_level | integer Specify the group level to be used. |
startkey_docid | string Return documents starting with the specified document identifier. |
endkey_docid | string Stop returning records when the specified document identifier is reached. |
stale | string Enum: "ok" "update_after" Allow the results from a stale view to be used, without triggering a rebuild of all views within the encompassing design document. |
startkey | string Return records starting with the specified key. |
endkey | string Stop returning records when this key is reached. |
key | string Return only the document that matches the specified key. |
keys | Array of strings An array of document ID strings to filter by. |
{- "total_rows": 0,
- "rows": [
- {
- "id": "string",
- "key": { },
- "value": { },
- "doc": { }
}
], - "errors": [
- {
- "From": "string",
- "Reason": "string"
}
]
}