Edge Server (1.0)

Download OpenAPI specification:

Edge Server is a REST and sync server for Couchbase Mobile databases.

Database

Create and manage databases

Get server information

Returns information about the Edge Server node.

Responses

Response samples

Content type
application/json
{
  • "ADMIN": true,
  • "couchdb": "Welcome",
  • "vendor": {
    },
  • "version": "Couchbase Edge Server/1.0.0(1;a765231)"
}

Get list of all database names

Returns list of all database names.

Responses

Response samples

Content type
application/json
{
  • "rows": [
    ],
  • "total_rows": 0
}

Get database information

Retrieve information about the database.

path Parameters
db
required
string
Example: db1

The name of the database to run the operation against.

Responses

Response samples

Content type
application/json
{
  • "db_name": "db",
  • "update_seq": 123456,
  • "committed_update_seq": 123456,
  • "instance_start_time": 1644600082279583,
  • "state": "Online",
  • "server_uuid": "995618a6a6cc9ac79731bd13240e19b5"
}

Create a document with automatically-generated docID

path Parameters
db
required
string
Example: db1

The name of the database to run the operation against.

query Parameters
expires
integer

A timestamp in UNIX seconds indicating when a doc should expire. The document will expire and be automatically purged at this time. If ttl is also specified the lower of the resulting timestamps is used.

ttl
integer

The time-to-live (in seconds) for the document. The document will expire and be automatically purged after this time. If expires is also specified the lower of the resulting timestamps is used.

Request Body schema: application/json
property name*
additional property
any

Responses

Request samples

Content type
application/json
{ }

Response samples

Content type
application/json
{
  • "id": "string",
  • "ok": true,
  • "rev": "string",
  • "expires": 0
}

Document

Create and manage documents

Gets all the documents in the database with the given parameters

Returns all documents in the database based on the specified parameters.

path Parameters
keyspace
required
string
Examples:
  • db1 - Default scope and collection
  • db1.collection1 - Named collection within the default scope
  • db1.scope1.collection1 - Fully-qualified scope and collection

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.

query Parameters
descending
boolean
Default: false

Reverses sort order (descending docID)

include_docs
boolean

Include the body associated with each document.

keys
Array of strings

An array of document ID strings to filter by.

limit
number

This limits the number of result rows returned. Using a value of 0 has the same effect as the value 1.

skip
number

Offset into the result rows returned. Combined with limit can be useful for paging.

startkey
string

Return records starting with the specified key.

endkey
string

Stop returning records when this key is reached.

Responses

Response samples

Content type
application/json
{
  • "rows": [
    ],
  • "total_rows": 0,
  • "update_seq": 0
}

Get all the documents in the database using JSON arguments instead of query arguments

Returns all documents in the database based on the specified parameters.

path Parameters
keyspace
required
string
Examples:
  • db1 - Default scope and collection
  • db1.collection1 - Named collection within the default scope
  • db1.scope1.collection1 - Fully-qualified scope and collection

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.

Request Body schema: application/json
descending
boolean
Default: false

Reverses sort order (descending docID)

include_docs
boolean
Default: true

Adds body of each doc

keys
Array of strings

List of docIDs to limit results to

limit
number

Limits number of results

skip
number

Offset into results

startkey
string

docID to start at

endkey
string

docID to end at (max value, or min if descending)

Responses

Request samples

Content type
application/json
{
  • "descending": false,
  • "include_docs": true,
  • "keys": [
    ],
  • "limit": 0,
  • "skip": 0,
  • "startkey": "string",
  • "endkey": "string"
}

Response samples

Content type
application/json
{
  • "rows": [
    ],
  • "total_rows": 0,
  • "update_seq": 0
}

/{db}/_all_docs

path Parameters
keyspace
required
string
Examples:
  • db1 - Default scope and collection
  • db1.collection1 - Named collection within the default scope
  • db1.scope1.collection1 - Fully-qualified scope and collection

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.

query Parameters
include_docs
boolean

Include the body associated with each document.

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 0 has the same effect as the value 1.

Responses

Response samples

Content type
application/json
{
  • "error": "string",
  • "reason": "string"
}

Bulk document operations

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 Edge Server 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.

path Parameters
keyspace
required
string
Examples:
  • db1 - Default scope and collection
  • db1.collection1 - Named collection within the default scope
  • db1.scope1.collection1 - Fully-qualified scope and collection

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.

Request Body schema: application/json
new_edits
boolean
Default: true

This controls whether to assign new revision identifiers to new edits (true) or use the existing ones (false).

required
Array of objects

Responses

Request samples

Content type
application/json
{
  • "new_edits": true,
  • "docs": [
    ]
}

Response samples

Content type
application/json
Example
[
  • {
    },
  • {
    },
  • {
    }
]

Get a document

Retrieve a document from the database by its doc ID.

path Parameters
keyspace
required
string
Examples:
  • db1 - Default scope and collection
  • db1.collection1 - Named collection within the default scope
  • db1.scope1.collection1 - Fully-qualified scope and collection

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.

query Parameters
rev
string
Example: rev=2-5145e1086bb8d1d71a531e9f6b543c58

The document revision to target.

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 revs_limit.

revs_limit
integer

Maximum amount of revisions to return for each document.

Responses

Response samples

Content type
application/json
{
  • "FailedLoginAttempts": 5,
  • "Friends": [
    ],
  • "_id": "AliceSettings",
  • "_rev": "1-64d4a1f179db5c1848fe52967b47c166",
  • "_cv": "1@src"
}

Upsert a document

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 Edge Server 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.

path Parameters
keyspace
required
string
Examples:
  • db1 - Default scope and collection
  • db1.collection1 - Named collection within the default scope
  • db1.scope1.collection1 - Fully-qualified scope and collection

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.

query Parameters
roundtrip
boolean

Block until document has been received by change cache

rev
string
Example: rev=2-5145e1086bb8d1d71a531e9f6b543c58

The document revision to target.

expires
integer

A timestamp in UNIX seconds indicating when a doc should expire. The document will expire and be automatically purged at this time. If ttl is also specified the lower of the resulting timestamps is used.

ttl
integer

The time-to-live (in seconds) for the document. The document will expire and be automatically purged after this time. If expires is also specified the lower of the resulting timestamps is used.

header Parameters
If-Match
string

The revision ID to target.

Request Body schema: application/json
_id
required
string

document ID

_rev
required
string

revision ID of the document

property name*
additional property
any

Responses

Request samples

Content type
application/json
{
  • "_id": "string",
  • "_rev": "string"
}

Response samples

Content type
application/json
{
  • "id": "string",
  • "ok": true,
  • "rev": "string",
  • "expires": 0
}

Delete a document

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.

path Parameters
keyspace
required
string
Examples:
  • db1 - Default scope and collection
  • db1.collection1 - Named collection within the default scope
  • db1.scope1.collection1 - Fully-qualified scope and collection

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.

query Parameters
rev
string
Example: rev=2-5145e1086bb8d1d71a531e9f6b543c58

The document revision to target.

expires
integer

A timestamp in UNIX seconds indicating when a doc should expire. The document will expire and be automatically purged at this time. If ttl is also specified the lower of the resulting timestamps is used.

ttl
integer

The time-to-live (in seconds) for the document. The document will expire and be automatically purged after this time. If expires is also specified the lower of the resulting timestamps is used.

header Parameters
If-Match
string

The revision ID to target.

Responses

Response samples

Content type
application/json
{
  • "id": "string",
  • "ok": true,
  • "rev": "string",
  • "expires": 0
}

Check if a document exists

Return a status code based on if the document exists or not.

path Parameters
keyspace
required
string
Examples:
  • db1 - Default scope and collection
  • db1.collection1 - Named collection within the default scope
  • db1.scope1.collection1 - Fully-qualified scope and collection

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.

query Parameters
rev
string
Example: rev=2-5145e1086bb8d1d71a531e9f6b543c58

The document revision to target.

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 revs_limit.

revs_limit
integer

Maximum amount of revisions to return for each document.

Responses

Response samples

Content type
application/json
{
  • "error": "string",
  • "reason": "string"
}

Get an attachment or sub-document from a document

This request retrieves a file attachment or sub-document 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.

path Parameters
keyspace
required
string
Examples:
  • db1 - Default scope and collection
  • db1.collection1 - Named collection within the default scope
  • db1.scope1.collection1 - Fully-qualified scope and collection

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.

key
required
string

If key identifies a document property that's a blob, the response will be the contents of the blob. Otherwise, the property value is returned as JSON. For compatibility with CouchDB, if key doesn't exist but _attachments/key does, the response will be a redirect to the latter path.

query Parameters
rev
string
Example: rev=2-5145e1086bb8d1d71a531e9f6b543c58

The document revision to target.

Responses

Response samples

Content type
{ }

Create or update an attachment or sub-document on a document

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.

path Parameters
keyspace
required
string
Examples:
  • db1 - Default scope and collection
  • db1.collection1 - Named collection within the default scope
  • db1.scope1.collection1 - Fully-qualified scope and collection

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.

key
required
string

If key identifies a document property that's a blob, the response will be the contents of the blob. Otherwise, the property value is returned as JSON. For compatibility with CouchDB, if key doesn't exist but _attachments/key does, the response will be a redirect to the latter path.

query Parameters
rev
string

The existing document revision ID to modify. Required only when modifying an existing document.

header Parameters
Content-Type
string
Default: application/octet-stream

The content type of the attachment.

Request Body schema:

The attachment data

string

The content to store in the body

Responses

Request samples

Content type
No sample

Response samples

Content type
application/json
{
  • "id": "string",
  • "ok": true,
  • "rev": "string",
  • "expires": 0
}

Delete an attachment or sub-document on a document

This request deletes an attachment associated with the document.

If the attachment exists, the attachment will be removed from the document.

path Parameters
keyspace
required
string
Examples:
  • db1 - Default scope and collection
  • db1.collection1 - Named collection within the default scope
  • db1.scope1.collection1 - Fully-qualified scope and collection

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.

key
required
string

If key identifies a document property that's a blob, the response will be the contents of the blob. Otherwise, the property value is returned as JSON. For compatibility with CouchDB, if key doesn't exist but _attachments/key does, the response will be a redirect to the latter path.

query Parameters
rev
string

The existing document revision ID to modify.

Responses

Response samples

Content type
application/json
{
  • "id": "string",
  • "ok": true,
  • "rev": "string",
  • "expires": 0
}

Replication

Create and manage replications

List of all active tasks

Get a list of all active tasks

Responses

Response samples

Content type
application/json
{
  • "rows": [
    ]
}

Get status of all replications

Get status of all replications

Responses

Response samples

Content type
application/json
{
  • "rows": [
    ],
  • "total_rows": 0
}

Start a replication

Instruct Edge Server to initiate replication/sync with another server, i.e. Sync Gateway. Not the same as /db/_blipsync, which is for clients initiating replication with the Edge Server.

Request Body schema: application/json
source
string

The source database name or URL

target
string

The destination database name or URL

bidirectional
boolean
Default: false

Set to true for bidirectional push/pull replication

continuous
boolean
Default: false

Set to true for continuous replication

Array of strings
object (AuthConfig)

Configuration for authentication to a remote server. Either for replication, or a proxy.

object (ProxyConfig)

Configuration of a proxy to use during replication.

Responses

Request samples

Content type
application/json
{
  • "source": "string",
  • "target": "string",
  • "bidirectional": false,
  • "continuous": false,
  • "collections": [
    ],
  • "auth": {
    },
  • "proxy": {
    }
}

Response samples

Content type
application/json
{
  • "error": "string",
  • "reason": "string"
}

Get status of a replication with the given taskID

Get status of a replication with the given taskID

path Parameters
taskid
required
number
Example: 1234

The ID of an active task.

Responses

Response samples

Content type
application/json
{
  • "id": 0
}

Stop replication with the given taskID

Instruct Edge Server to stop the replication with the given taskID

path Parameters
taskid
required
number
Example: 1234

The ID of an active task.

Responses

Response samples

Content type
application/json
{
  • "error": "string",
  • "reason": "string"
}

Get changes list

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.

path Parameters
keyspace
required
string
Examples:
  • db1 - Default scope and collection
  • db1.collection1 - Named collection within the default scope
  • db1.scope1.collection1 - Fully-qualified scope and collection

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.

query Parameters
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 (main_only) or all the leaf revision including conflicts and deleted former conflicts (all_docs).

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 filter query option must be set to sync_gateway/bychannels.

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 filter query option must be set to _doc_ids and the feed parameter must be normal. Also accepts a comma separated list of document IDs instead.

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 feed=longpoll or feed=continuous. This will override any timeouts to keep the feed alive indefinitely. Setting to 0 results in no heartbeat. The maximum heartbeat can be set in the server replication configuration.

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=longpoll or feed=continuous changes feeds. Setting to 0 results in no timeout.

feed
string
Default: "normal"
Enum: "longpoll" "continuous" "sse"

The type of changes feed to use.

Responses

Response samples

Content type
application/json
{
  • "results": [
    ],
  • "last_seq": "string"
}

Get changes list

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.

path Parameters
keyspace
required
string
Examples:
  • db1 - Default scope and collection
  • db1.collection1 - Named collection within the default scope
  • db1.scope1.collection1 - Fully-qualified scope and collection

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.

Request Body schema: application/json
limit
string

Maximum number of changes to return.

style
string

Controls whether to return the current winning revision (main_only) or all the leaf revision including conflicts and deleted former conflicts (all_docs).

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 filter query option must be set to sync_gateway/bychannels.

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 filter query option must be set to _doc_ids and the feed parameter must be normal.

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 feed=longpoll or feed=continuous. This will override any timeouts to keep the feed alive indefinitely. Setting to 0 results in no heartbeat. The maximum heartbeat can be set in the server replication configuration.

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=longpoll or feed=continuous changes feeds. Setting to 0 results in no timeout.

feed
string

The type of changes feed to use.

Responses

Request samples

Content type
application/json
{
  • "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"
}

Response samples

Content type
application/json
{
  • "results": [
    ],
  • "last_seq": "string"
}

Query

Run queries

Run an ad-hoc query

-| Run an ad-hoc query. Only possible when the database's enable_adhoc_queries property is true.

path Parameters
keyspace
required
string
Examples:
  • db1 - Default scope and collection
  • db1.collection1 - Named collection within the default scope
  • db1.scope1.collection1 - Fully-qualified scope and collection

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.

Request Body schema: application/json
query
required
string

SQL++ Query string

object

Query parameters

Responses

Request samples

Content type
application/json
{
  • "query": "string",
  • "parameters": { }
}

Response samples

Content type
application/json
[
  • { }
]

Run a pre-defined query

Run a pre-defined query as named by the database configuration's query object. If the query has parameters, they should be passed as query parameters like ?key=value.

path Parameters
keyspace
required
string
Examples:
  • db1 - Default scope and collection
  • db1.collection1 - Named collection within the default scope
  • db1.scope1.collection1 - Fully-qualified scope and collection

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.

name
required
string

Name of the query as defined in the database configuration.

Responses

Response samples

Content type
application/json
[
  • { }
]

Run a pre-defined query

Run a pre-defined query as named by the database configuration's query object. If the query has parameters, they should be passed as JSON object in the request body.

path Parameters
keyspace
required
string
Examples:
  • db1 - Default scope and collection
  • db1.collection1 - Named collection within the default scope
  • db1.scope1.collection1 - Fully-qualified scope and collection

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.

name
required
string

Name of the query as defined in the database configuration.

Request Body schema: application/json
property name*
additional property
any

Responses

Request samples

Content type
application/json
{ }

Response samples

Content type
application/json
[
  • { }
]