Couchbase Data API (1.0.0)

Download OpenAPI specification:

Introduction

The Capella Data API provides a RESTful interface for working with data. It enables users to perform operations such as creating, reading, updating, or deleting data directly against your cluster. It also provides passthrough access to the Couchbase Services REST APIs, which enable you to query your data with SQL+⁠+, use vector search for AI applications, and more.

Base URL

The base URL for the Data API is as follows:

https://{clusterId}.data.cloud.couchbase.com

where {clusterId} is unique to your Couchbase Capella cluster. For details, see Get Started with the Data API.

Health Check

General utilities for the Data API.

Get Caller Identity

Retrieves the identity of the user making the current request.

header Parameters
Authorization
required
string

Header for authentication.

Responses

Response samples

Content type
application/json
{
  • "user": "Administrator"
}

Basic Document Operations

Create, read, update, and delete operations for single documents.

Get Document

Retrieves the specified document.

path Parameters
bucketName
required
string

The name of the bucket containing the document.

scopeName
required
string

The name of the scope containing the document.

collectionName
required
string

The name of the collection containing the document.

documentKey
required
string

The ID of the document.

query Parameters
project
Array of strings

Specific fields to project from the document.

header Parameters
Authorization
required
string

Header for authentication.

Accept-Encoding
string

Specifies the compression used for the response in HTTP content-negotiation format.

Responses

Response samples

Content type
{
  • "title": "Brighton",
  • "name": "Brighton Palace Pier",
  • "alt": null,
  • "address": "Madeira Dr, Brighton BN2 1TW",
  • "directions": null,
  • "phone": "01273609361",
  • "tollfree": null,
  • "email": "info@brightonpalacepier.co.uk",
  • "hours": "11am–6pm",
  • "image": null,
  • "price": "£2",
  • "content": "The Brighton Palace Pier, commonly known as Brighton Pier or the Palace Pier, is a Grade II listed pleasure pier in Brighton, England, located in the city centre opposite the Old Steine. Established in 1899, it was the third pier to be constructed in Brighton after the Royal Suspension Chain Pier and the West Pier, but is now the only one still in operation.",
  • "geo": {
    },
  • "activity": "do",
  • "type": "landmark",
  • "id": 10044,
  • "country": "United Kingdom",
  • "city": "Brighton",
  • "state": null
}

Create Document

Creates a document with the given ID and contents.

path Parameters
bucketName
required
string

The name of the bucket containing the document.

scopeName
required
string

The name of the scope containing the document.

collectionName
required
string

The name of the collection containing the document.

documentKey
required
string

The ID of the document.

header Parameters
Authorization
required
string

Header for authentication.

Content-Encoding
string (DocumentEncoding)
Enum: "identity" "snappy"

The Content-Encoding of the body of the request.

Expires
string

The expiry time to set for the document, specified as a HTTP Date header or Go Duration string.

X-CB-Flags
integer <uint32>

Overrides the document flags to a custom value rather than using values based on the Content-Type header.

X-CB-DurabilityLevel
string (DurabilityLevel)
Enum: "None" "Majority" "MajorityAndPersistOnMaster" "PersistToMajority"

The level of durability required for this write operation. For details, see Durability.

Request Body schema: *
required
string <binary>

The contents of the document.

Responses

Response samples

Content type
application/json
{
  • "code": "InvalidArgument",
  • "message": "The request was malformed or invalid."
}

Update Document

Updates the specified document with the given contents.

path Parameters
bucketName
required
string

The name of the bucket containing the document.

scopeName
required
string

The name of the scope containing the document.

collectionName
required
string

The name of the collection containing the document.

documentKey
required
string

The ID of the document.

header Parameters
Authorization
required
string

Header for authentication.

Content-Encoding
string (DocumentEncoding)
Enum: "identity" "snappy"

The Content-Encoding of the body of the request.

If-Match
string

The CAS of the document to check before updating.

Expires
string

The expiry time to set for the document, specified as a HTTP Date header or Go Duration string.

X-CB-Flags
integer <uint32>

Overrides the document flags to a custom value rather than using values based on the Content-Type header.

X-CB-DurabilityLevel
string (DurabilityLevel)
Enum: "None" "Majority" "MajorityAndPersistOnMaster" "PersistToMajority"

The level of durability required for this write operation. For details, see Durability.

Request Body schema: *
required
string <binary>

The contents of the document.

Responses

Response samples

Content type
application/json
{
  • "code": "InvalidArgument",
  • "message": "The request was malformed or invalid."
}

Delete Document

Deletes the specified document.

path Parameters
bucketName
required
string

The name of the bucket containing the document.

scopeName
required
string

The name of the scope containing the document.

collectionName
required
string

The name of the collection containing the document.

documentKey
required
string

The ID of the document.

header Parameters
Authorization
required
string

Header for authentication.

If-Match
string

The CAS of the document to check before updating.

X-CB-DurabilityLevel
string (DurabilityLevel)
Enum: "None" "Majority" "MajorityAndPersistOnMaster" "PersistToMajority"

The level of durability required for this write operation. For details, see Durability.

Responses

Response samples

Content type
application/json
{
  • "code": "InvalidArgument",
  • "message": "The request was malformed or invalid."
}

Touch Document

Updates the expiry of a document. For details, see Expiration.

path Parameters
bucketName
required
string

The name of the bucket containing the document.

scopeName
required
string

The name of the scope containing the document.

collectionName
required
string

The name of the collection containing the document.

documentKey
required
string

The ID of the document.

header Parameters
Authorization
required
string

Header for authentication.

Accept-Encoding
string

Specifies the compression used for the response in HTTP content-negotiation format.

Request Body schema: application/json
required
expiry
string

The new expiry to set for the document, specified as an ISO8601 string.

returnContent
boolean

Specifies whether the document's contents should be returned in the response.

Responses

Request samples

Content type
application/json
{
  • "expiry": "YYYY-MM-DDTHH:MM:SS.sssZ",
  • "returnContent": true
}

Response samples

Content type
{
  • "title": "Brighton",
  • "name": "Brighton Palace Pier",
  • "alt": null,
  • "address": "Madeira Dr, Brighton BN2 1TW",
  • "directions": null,
  • "phone": "01273609361",
  • "tollfree": null,
  • "email": "info@brightonpalacepier.co.uk",
  • "hours": "11am–6pm",
  • "image": null,
  • "price": "£2",
  • "content": "The Brighton Palace Pier, commonly known as Brighton Pier or the Palace Pier, is a Grade II listed pleasure pier in Brighton, England, located in the city centre opposite the Old Steine. Established in 1899, it was the third pier to be constructed in Brighton after the Royal Suspension Chain Pier and the West Pier, but is now the only one still in operation.",
  • "geo": {
    },
  • "activity": "do",
  • "type": "landmark",
  • "id": 10044,
  • "country": "United Kingdom",
  • "city": "Brighton",
  • "state": null
}

Binary Operations

Append, prepend, increment, and decrement operations for binary documents.

Append to Document

Appends the specified contents to the end of the document.

path Parameters
bucketName
required
string

The name of the bucket containing the document.

scopeName
required
string

The name of the scope containing the document.

collectionName
required
string

The name of the collection containing the document.

documentKey
required
string

The ID of the document.

header Parameters
Authorization
required
string

Header for authentication.

If-Match
string

The CAS of the document to check before updating.

X-CB-DurabilityLevel
string (DurabilityLevel)
Enum: "None" "Majority" "MajorityAndPersistOnMaster" "PersistToMajority"

The level of durability required for this write operation. For details, see Durability.

Request Body schema: *
required
any

Responses

Response samples

Content type
application/json
{
  • "code": "InvalidArgument",
  • "message": "The request was malformed or invalid."
}

Prepend to Document

Prepends the specified contents to the start of the document.

path Parameters
bucketName
required
string

The name of the bucket containing the document.

scopeName
required
string

The name of the scope containing the document.

collectionName
required
string

The name of the collection containing the document.

documentKey
required
string

The ID of the document.

header Parameters
Authorization
required
string

Header for authentication.

If-Match
string

The CAS of the document to check before updating.

X-CB-DurabilityLevel
string (DurabilityLevel)
Enum: "None" "Majority" "MajorityAndPersistOnMaster" "PersistToMajority"

The level of durability required for this write operation. For details, see Durability.

Request Body schema: *
required
any

Responses

Response samples

Content type
application/json
{
  • "code": "InvalidArgument",
  • "message": "The request was malformed or invalid."
}

Increment Document

Increments the value of the document. The document must contain a parsable integer as its content. For details, see Counters.

If the document does not exist, sets the initial value of the document.

path Parameters
bucketName
required
string

The name of the bucket containing the document.

scopeName
required
string

The name of the scope containing the document.

collectionName
required
string

The name of the collection containing the document.

documentKey
required
string

The ID of the document.

header Parameters
Authorization
required
string

Header for authentication.

Expires
string

The expiry time to set for the document, specified as a HTTP Date header or Go Duration string.

X-CB-DurabilityLevel
string (DurabilityLevel)
Enum: "None" "Majority" "MajorityAndPersistOnMaster" "PersistToMajority"

The level of durability required for this write operation. For details, see Durability.

Request Body schema:
initial
integer <uint64>

The value to set the document to if the document does not exist.

delta
integer <uint64>

The value to increment the document by if it exists.

Responses

Request samples

Content type
{
  • "initial": 10,
  • "delta": 1
}

Response samples

Content type
application/json
10

Decrement Document

Decrements the value of the document. The document must contain a parsable integer as its content. For details, see Counters.

If the document does not exist, sets the initial value of the document.

path Parameters
bucketName
required
string

The name of the bucket containing the document.

scopeName
required
string

The name of the scope containing the document.

collectionName
required
string

The name of the collection containing the document.

documentKey
required
string

The ID of the document.

header Parameters
Authorization
required
string

Header for authentication.

Expires
string

The expiry time to set for the document, specified as a HTTP Date header or Go Duration string.

X-CB-DurabilityLevel
string (DurabilityLevel)
Enum: "None" "Majority" "MajorityAndPersistOnMaster" "PersistToMajority"

The level of durability required for this write operation. For details, see Durability.

Request Body schema:
initial
integer <uint64>

The value to set the document to if the document does not exist.

delta
integer <uint64>

The value to decrement the document by if it exists.

Responses

Request samples

Content type
{
  • "initial": 10,
  • "delta": 1
}

Response samples

Content type
application/json
11

Query with SQL++

Use the following endpoints to run SQL++ queries and set request-level parameters.

Query Service

Enables you to execute a SQL++ statement. This method allows you to run SELECT queries and other DML statements, and specify query parameters.

Authorizations:
Header
Request Body schema:
required

An object specifying one or more query parameters.

args
Array of any

Supplies the values for positional parameters in the statement. Applicable if the statement or prepared statement contains 1 or more positional parameters.

The value is an array of JSON values, one for each positional parameter in the statement.

Refer to Named Parameters and Positional Parameters for details.

atrcollection
string

Specifies the collection where the active transaction record (ATR) is stored. The collection must be present. If not specified, the ATR is stored in the default collection in the default scope in the bucket containing the first mutated document within the transaction.

The value must be a string in the form "bucket.scope.collection" or "namespace:bucket.scope.collection". If any part of the path contains a special character, that part of the path must be delimited in backticks ``.

auto_execute
boolean
Default: false

Specifies that prepared statements should be executed automatically as soon as they are created. This saves you from having to make two separate requests in cases where you want to prepare a statement and execute it immediately.

Refer to Auto-Execute for more information.

client_context_id
string

A piece of data supplied by the client that is echoed in the response, if present. SQL++ is agnostic about the content of this parameter; it is just echoed in the response.

  • Maximum allowed size is 64 characters; all others will be cut.
  • If it contains an escape character / or quote ", it will be rejected as error code 1110.
compression
string
Default: "NONE"
Enum: "ZIP" "RLE" "LZMA" "LZO" "NONE"

Compression format to use for response data on the wire.

Values are case-insensitive.

controls
boolean

Specifies if there should be a controls section returned with the request results.

When set to true, the query response document includes a controls section with runtime information provided along with the request, such as positional and named parameters or settings.

If the request qualifies for caching, these values will also be cached in the completed_requests system keyspace.

creds
Array of objects

In the Data API, this parameter is ignored and has no effect.

durability_level
string
Default: "majority"
Enum: "" "none" "majority" "majorityAndPersistActive" "persistToMajority"

The level of durability for mutations produced by the request.

If the request contains a BEGIN TRANSACTION statement, or a DML statement with the tximplicit parameter set to true, the durability level is specified for all mutations within that transaction.

Durability is also supported for non-transactional DML statements. In this case, the kvtimeout parameter is used as the durability timeout.

If not specified, the default durability level is "majority". Set the durability level to "none" or "" to specify no durability.

encoded_plan
string

In Couchbase Server 6.5 and later, this parameter is ignored and has no effect. It is included for compatibility with previous versions of Couchbase Server.

encoding
string
Default: "UTF-8"

Desired character encoding for the query results.

Only possible value is UTF-8 and is case-insensitive.

format
string
Default: "JSON"
Enum: "JSON" "XML" "CSV" "TSV"

Desired format for the query results.

Values are case-insensitive.

kvtimeout
string
Default: "2.5s"

The approximate time to wait for a KV get operation before timing out. This applies to statements within a transaction, and to non-transactional statements, whether durability_level is set or not.

If use_replica is enabled for a query, then this parameter also specifies the approximate time to wait before fetching data from a replica vBucket when the active vBucket is inaccessible.

The value for this parameter is a string. Its format includes an amount and a mandatory unit, e.g. 10ms (10 milliseconds) or 0.5s (half a second). Valid units are:

  • ns (nanoseconds)
  • us (microseconds)
  • ms (milliseconds)
  • s (seconds)
  • m (minutes)
  • h (hours)

Specify a duration of 0 or a negative duration to disable. When disabled, no timeout is applied and the KV operation runs for however long it takes.

max_parallelism
integer <int32>

Specifies the maximum parallelism for the query.

The default value is the same as the number of partitions of the index selected for the query.

memory_quota
integer <int32>
Default: 0

Specifies the maximum amount of memory the request may use, in MB.

Specify 0 (the default value) to disable. When disabled, there is no quota.

This parameter enforces a ceiling on the memory used for the tracked documents required for processing a request. It does not take into account any other memory that might be used to process a request, such as the stack, the operators, or some intermediate values.

Within a transaction, this setting enforces the memory quota for the transaction by tracking the delta table and the transaction log (approximately).

metrics
boolean
Default: true

Specifies that metrics should be returned with query results.

namespace
string

Specifies the namespace to use. Currently, only the default namespace is available.

numatrs
integer <int32>
Default: 1024

Specifies the total number of active transaction records. Must be a positive integer.

pipeline_batch
integer <int32>

Controls the number of items execution operators can batch for Fetch from the KV.

pipeline_cap
integer <int32>

Maximum number of items each execution operator can buffer between various operators.

prepared
string

Required if statement not provided.

The name of the prepared SQL++ statement to be executed. Refer to EXECUTE for examples.

If both prepared and statement are present and non-empty, an error is returned.

preserve_expiry
boolean
Default: false

Specifies whether documents should keep their current expiration setting when modified by a DML statement.

If true, documents will keep any existing expiration setting when modified by a DML statement. If the DML statement explicitly specifies the document expiration, the statement overrides this parameter, and the expiration is changed.

If false, document expiration is set to 0 when modified by a DML statement, unless the DML statement explicitly specifies the document expiration.

Not supported for statements in a transaction.

pretty
boolean

Specifies the query results returned in pretty format.

profile
string
Enum: "off" "phases" "timings"

Specifies if there should be a profile section returned with the request results. The valid values are:

  • off — No profiling information is added to the query response.

  • phases — The query response includes a profile section with stats and details about various phases of the query plan and execution. Three phase times will be included in the system:active_requests and system:completed_requests monitoring keyspaces.

  • timings — Besides the phase times, the profile section of the query response document will include a full query plan with timing and information about the number of processed documents at each phase. This information will be included in the system:active_requests and system:completed_requests keyspaces.

If profile is not set as one of the above values, then the profile setting does not change.

query_context
string
Default: "default:"

Specifies the namespace, bucket, and scope used to resolve partial keyspace references within the request.

The query context may be a full path, containing namespace, bucket, and scope; or a relative path, containing just the bucket and scope. Currently, only the default namespace is available. If the namespace name is omitted, the default namespace in the current session is used.

readonly
boolean
Default: false

Controls whether a query can change a resulting recordset.

If readonly is true, then the following statements are not allowed:

  • CREATE INDEX
  • DROP INDEX
  • INSERT
  • MERGE
  • UPDATE
  • UPSERT

When using GET requests, it's best to set readonly to true.

scan_cap
integer <int32>

Maximum buffered channel size between the indexer client and the query service for index scans. This parameter controls when to use scan backfill.

Use 0 or a negative number to disable. Smaller values reduce GC, while larger values reduce indexer backfill.

scan_consistency
string
Default: "not_bounded"
Enum: "not_bounded" "at_plus" "request_plus" "statement_plus"

Specifies the consistency guarantee or constraint for index scanning. The valid values are:

  • not_bounded — No timestamp vector is used in the index scan. This is the fastest mode, because it avoids the costs of obtaining the vector and waiting for the index to catch up to the vector.

  • at_plus — This implements bounded consistency. The request includes a scan_vector parameter and value, which is used as a lower bound. This can be used to implement read-your-own-writes (RYOW).

  • request_plus — This implements strong consistency per request. Before processing the request, a current vector is obtained. The vector is used as a lower bound for the statements in the request. If there are DML statements in the request, RYOW is also applied within the request. (If request_plus is specified in a query that runs during a failover of an index node, the query waits until the rebalance operation completes and the index data has rebalanced before returning a result.)

  • statement_plus — This implements strong consistency per statement. Before processing each statement, a current vector is obtained and used as a lower bound for that statement.

Values are case-insensitive.

For multi-statement requests, the default behavior is RYOW within each request. If you want to disable RYOW within a request, add a separate request_consistency parameter that can be set to not_bounded.

If the request contains a BEGIN TRANSACTION statement, or a DML statement with the tximplicit parameter set to true, then this parameter sets the transactional scan consistency. Refer to Transactional Scan Consistency for details.

scan_vector
object

Required if scan_consistency is at_plus and scan_vectors not provided.

Specify the lower bound vector timestamp for one keyspace when using at_plus scan consistency.

Scan vectors are built of two-element [value, guard] entries:

  • value: a vBucket's sequence number (a JSON number)
  • guard: a vBucket's UUID (a string)

Scan vectors have two forms:

  1. Full: an array of [value, guard] entries, giving an entry for every vBucket in the system.
  2. Sparse: an object providing entries for specific vBuckets, mapping a vBucket number (a string) to each [value, guard] entry.

Note that scan_vector can only be used if the query uses at most one keyspace; if it is used for a query referencing more than one keyspace, the query will fail with an error.

For queries referencing multiple keyspaces, use scan_vectors.

scan_vectors
object

Required if scan_consistency is at_plus and scan_vector not provided.

A map from keyspace names to scan vectors. See scan_vector.

The scan vectors can be Full or Sparse.

scan_wait
string <duration>
Default: ""

Can be supplied with scan_consistency values of request_plus, statement_plus and at_plus.

Specifies the maximum time the client is willing to wait for an index to catch up to the vector timestamp in the request.

Specifies how much time the client is willing to wait for the indexer to satisfy the required scan_consistency and scan_vector criteria. After receiving the scan request, if the indexer is unable to catch up within the scan_wait time and initiate the scan, the indexer aborts with an error and the scan fails.

Its format includes an amount and a mandatory unit, e.g. 10ms (10 milliseconds) or 0.5s (half a second). Valid units are:

  • ns (nanoseconds)
  • us (microseconds)
  • ms (milliseconds)
  • s (seconds)
  • m (minutes)
  • h (hours)

Specify 0 or a negative integer to disable.

signature
boolean
Default: true

Include a header for the results schema in the response.

sort_projection
boolean
Default: false

If true, causes statement projection terms to be sorted alphabetically.

If false (the default), statement projection terms are returned in the order specified by the query.

statement
string

Required if prepared not provided.

Any valid SQL++ statement for a POST request, or a read-only SQL++ statement (SELECT, EXPLAIN) for a GET request.

If both prepared and statement are present and non-empty, an error is returned.


When specifying the request parameters as form data, the statement may not contain an unescaped semicolon (;). If it does, the Query Service responds with error 1040. To avoid this, either URL-encode the semicolon as %3B, or just omit the semicolon if possible.

This restriction does not apply when specifying the request parameters in JSON format.

timeout
string <duration>

Maximum time to spend on the request before timing out.

The value for this parameter is a string. Its format includes an amount and a mandatory unit, e.g. 10ms (10 milliseconds) or 0.5s (half a second). Valid units are:

  • ns (nanoseconds)
  • us (microseconds)
  • ms (milliseconds)
  • s (seconds)
  • m (minutes)
  • h (hours)

Specify a duration of 0 or a negative duration to disable. When disabled, no timeout is applied and the request runs for however long it takes.

If tximplicit or txid is set, this parameter is ignored. The request inherits the remaining time of the transaction as timeout.

txdata
object

Transaction data. For internal use only.

txid
string <UUID>

Required for statements within a transaction.

Transaction ID. Specifies the transaction to which a statement belongs. For use with DML statements within a transaction, rollbacks, and commits.

The transaction ID should be the same as the transaction ID generated by the BEGIN TRANSACTION statement. The transaction must be active and non-expired.

tximplicit
boolean
Default: false

Specifies that a DML statement is a singleton transaction.

When this parameter is true, the Query service starts a transaction and executes the statement. If execution is successful, the Query service commits the transaction; otherwise the transaction is rolled back.

The statement may not be part of an ongoing transaction. If the txid request-level parameter is set, the tximplicit parameter is ignored.

txstmtnum
integer <int32>

Transaction statement number. The transaction statement number must be a positive integer, and must be higher than any previous transaction statement numbers in the transaction. If the transaction statement number is lower than the transaction statement number for any previous statement, an error is generated.

txtimeout
string <duration>

Maximum time to spend on a transaction before timing out. Only applies to BEGIN TRANSACTION statements, or DML statements for which tximplicit is set. For other statements, it is ignored.

Within a transaction, the request-level timeout parameter is ignored. The transaction timeout clock starts when the BEGIN WORK statement is successful. Once the transaction timeout is reached, no statement is allowed to continue in the transaction.

The value for this parameter is a string. Its format includes an amount and a mandatory unit, e.g. 10ms (10 milliseconds) or 0.5s (half a second). Valid units are:

  • ns (nanoseconds)
  • us (microseconds)
  • ms (milliseconds)
  • s (seconds)
  • m (minutes)
  • h (hours)

Specify a duration of 0 to disable. When disabled, the request-level timeout is set to the default.

The default is "15s" for cbq files or scripts, "2m" for interactive cbq sessions or redirected input.

use_cbo
boolean

Specifies whether the cost-based optimizer is enabled.

use_fts
boolean
Default: false

Specifies that the query should use a Search index.

If the query contains a USING FTS hint, that takes priority over this parameter.

If the query does not contain a USING FTS hint, and this parameter is set to true, all Search indexes are considered for the query. If a qualified Search index is available, it is selected for the query. If none of the available Search indexes are qualified, the available GSI indexes are considered instead.

Refer to Flex Indexes for more information.

use_replica
string
Default: "unset"
Enum: "off" "on" "unset"

Specifies whether a query can fetch data from a replica vBucket if active vBuckets are inaccessible. The possible values are:

  • off — read from replica is disabled for this request.

  • on — read from replica is enabled for this request, unless it has been disabled for all requests at node level.

  • unset — read from replica is specified by the node-level setting. If the node-level setting is also unset, read from replica is disabled for this request.

Do not enable read from replica when you require consistent results. Only SELECT queries that are not within a transaction can read from replica.

Reading from replica is only possible if the cluster uses Couchbase Server 7.6.0 or later.

Note that KV range scans cannot currently be started on a replica vBucket. If a query uses sequential scan and a data node becomes unavailable, the query might return an error, even if read from replica is enabled for the request.

$identifier*
additional property
any

Supplies the value for a named parameter in the statement. Applicable if the statement or prepared statement contains 1 or more named parameters.

The name of this property consists of two parts:

  1. The $ character or the @ character.
  2. An identifier that specifies the name of the parameter. This must start with an alpha character, followed by one or more alphanumeric characters.

The value of the named parameter can be any JSON value.

Refer to Named Parameters and Positional Parameters for details.

Responses

Request samples

Content type
{
  • "args": [
    ],
  • "atrcollection": "default:`travel-sample`.transaction.test",
  • "auto_execute": true,
  • "client_context_id": "string",
  • "compression": "zip",
  • "controls": true,
  • "creds": [ ],
  • "durability_level": "none",
  • "encoded_plan": "string",
  • "encoding": "UTF-8",
  • "format": "XML",
  • "kvtimeout": "10ms",
  • "max_parallelism": 3,
  • "memory_quota": 4,
  • "metrics": false,
  • "namespace": "default",
  • "numatrs": 512,
  • "pipeline_batch": 64,
  • "pipeline_cap": 1024,
  • "prepared": "[127.0.0.1:8091]pricy_hotel",
  • "preserve_expiry": true,
  • "pretty": false,
  • "profile": "phases",
  • "query_context": "default:travel-sample.inventory",
  • "readonly": true,
  • "scan_cap": 1024,
  • "scan_consistency": "at_plus",
  • "scan_vector": {
    },
  • "scan_vectors": { },
  • "scan_wait": "30m",
  • "signature": false,
  • "sort_projection": true,
  • "statement": "SELECT * FROM `travel-sample`.inventory.hotel LIMIT 1",
  • "timeout": "30m",
  • "txdata": { },
  • "txid": "d81d9b4a-b758-4f98-b007-87ba262d3a51",
  • "tximplicit": true,
  • "txstmtnum": 10,
  • "txtimeout": "30m",
  • "use_cbo": true,
  • "use_fts": true,
  • "use_replica": "on",
  • "$identifier1": "LAX",
  • "$identifier2": "LAX"
}

Response samples

Content type
application/json
{
  • "requestID": "615e0b26-dd61-4a1a-bda9-22333193b982",
  • "signature": {
    },
  • "results": [
    ],
  • "status": "success",
  • "metrics": {
    }
}

Read-Only Query Service

Enables you to execute a SQL++ statement. This method allows you to run SELECT queries, and specify query parameters.

This endpoint is intended for situations where use of the POST method is restricted.

Authorizations:
Header
query Parameters
required
object (Request Parameters)

Specify the parameters in the query URL in URL-encoded format. The format for URL-encoded parameters is consistent with the syntax for variables according to RFC 6570.

Responses

Response samples

Content type
application/json
{
  • "requestID": "615e0b26-dd61-4a1a-bda9-22333193b982",
  • "signature": {
    },
  • "results": [
    ],
  • "status": "success",
  • "metrics": {
    }
}

Query Indexes

Use the Query with SQL++ endpoints to manage primary and secondary indexes. Alternatively, you can use the Query Indexes endpoints in the Management API.

Query with Search

Use the following endpoints to query the contents of a Search index.

Get Document Count for an Index

Returns the number of documents indexed in the specified Search index.

Authorizations:
Statistics
path Parameters
INDEX_NAME
required
string

The name of the Search index definition. You must use the fully qualified name for the index, which includes the bucket and scope.

To view the full, scoped name for an index for use with this endpoint:

  1. Go to the Search tab in the Couchbase Server Web Console.
  2. Point to the Index Name for an index.

Responses

Response samples

Content type
application/json
{
  • "status": "ok",
  • "count": 285
}

Query a Search Index (Scoped)

Run a query formatted as a JSON object against the Search index definition specified in the endpoint URL. The endpoint returns a JSON object as a response. This endpoint is scoped and does not require a fully qualified {INDEX_NAME} value.

Authorizations:
Manage
path Parameters
BUCKET_NAME
required
string

The name of the bucket containing the Search index definition.

SCOPE_NAME
required
string

The name of the scope containing the Search index definition.

INDEX_NAME
required
string^[A-Za-z][0-9A-Za-z_\-]*$

The name of the Search index definition.

Request Body schema: application/json
required

A JSON object to define the settings for your Search query. For more information about how to create a Search query JSON object, see Search Request JSON Properties.

query
object

An object that contains the properties for one of the supported query types. For more information, see Query Object.

knn
Array of objects

An array that contains objects that describe a Vector Search query. For more information, see Knn Objects.

ctl
object

An object that contains properties for query consistency. For more information, see Ctl Object.

size
integer

Set the total number of results to return for a single page of search results.

from
integer

Set an offset value to change where pagination starts for search results.

highlight
object

Contains properties to control search result highlighting. For more information, see Highlight Objects.

fields
Array of strings

An array of strings to specify each indexed field you want to return in search results.

facets
object

Contains nested objects to define each facet you want to return with search results. For more information, see Facet Objects.

explain
boolean

Whether to create an explanation for a search result's score in search results.

sort
Array of any

Contains an array of strings or JSON objects to set how to sort search results. For more information, see Sort Object.

includeLocations
boolean

Whether to return the position of each occurrence of a search term inside a document.

score
string

Whether to include document relevancy scoring in search results.

search_after
Array of strings

Use to control pagination in search results.

search_before
Array of strings

Use to control pagination in search results.

collections
Array of strings

An array of strings that specify the collections where you want to run the query.

Responses

Request samples

Content type
application/json
{
  • "query": { },
  • "knn": [
    ],
  • "ctl": { },
  • "size": 0,
  • "from": 0,
  • "highlight": { },
  • "fields": [
    ],
  • "facets": { },
  • "explain": true,
  • "sort": [
    ],
  • "includeLocations": true,
  • "score": "string",
  • "search_after": [
    ],
  • "search_before": [
    ],
  • "collections": [
    ]
}

Response samples

Content type
application/json
Example
{
  • "status": {
    },
  • "request": {
    },
  • "hits": [
    ],
  • "total_hits": 27,
  • "cost": 108906,
  • "max_score": 0,
  • "took": 14964461,
  • "facets": null
}

Search Indexes

Use the following APIs to retrieve Search index definitions, create new Search indexes, or delete an existing Search index.

Get All Search Index Definitions (Scoped)

Returns all Search index definitions inside the bucket and scope specified in the endpoint URL as a JSON object.

Authorizations:
Read
path Parameters
BUCKET_NAME
required
string

The name of the bucket containing the Search index definition.

SCOPE_NAME
required
string

The name of the scope containing the Search index definition.

Responses

Response samples

Content type
application/json
{
  • "status": "ok",
  • "indexDefs": {
    }
}

Get Index Definition (Scoped)

Returns the Search index definition for the Search index specified in the endpoint URL as a JSON object. This endpoint is scoped and does not require a fully qualified {INDEX_NAME} value.

Authorizations:
Read
path Parameters
BUCKET_NAME
required
string

The name of the bucket containing the Search index definition.

SCOPE_NAME
required
string

The name of the scope containing the Search index definition.

INDEX_NAME
required
string^[A-Za-z][0-9A-Za-z_\-]*$

The name of the Search index definition.

Responses

Response samples

Content type
application/json
{
  • "status": "ok",
  • "indexDef": {
    },
  • "planPIndexes": [
    ],
  • "warnings": [ ]
}

Create or Update an Index Definition (Scoped)

If the Search index in the endpoint URL does not exist, this endpoint uses a JSON object in the request body to create a new index. If the Search index already exists, this endpoint updates the Search index definition. This endpoint is scoped and does not require a fully qualified {INDEX_NAME} value.

Authorizations:
Write
path Parameters
BUCKET_NAME
required
string

The name of the bucket containing the Search index definition.

SCOPE_NAME
required
string

The name of the scope containing the Search index definition.

INDEX_NAME
required
string^[A-Za-z][0-9A-Za-z_\-]*$

The name of the Search index definition.

Request Body schema: application/json
required

The full Search index definition. For a detailed list of all parameters for the request body, see Search Index JSON Properties.

name
required
string (Index Name)

The name of the Search index. For more information, see Initial Settings.

type
required
string (Index Type)

The type of the Search index. For more information, see Initial Settings.

sourceName
required
string (Source Name)

The name of the bucket where the Search index is stored. For more information, see Initial Settings.

sourceUUID
string (Source UUID)

The UUID of the bucket where the Search index is stored. For more information, see Initial Settings.

sourceParams
object (Source Parameters)

Advanced settings for Search index behavior. For more information, see Initial Settings.

sourceType
required
string (Source Type)

The type of the bucket where the Search index is stored. For more information, see Initial Settings.

params
required
object (Index Parameters)

The Search index's type identifier, type mappings, and analyzers. For more information, see Params Object.

required
object (Plan Parameters)

The Search index's partitioning and replication settings. For more information, see Plan Params Object.

prevIndexUUID
string

The UUID of the previous index. Intended for clients that want to check that they are not overwriting the Search index definition updates of concurrent clients.

uuid
string (Index UUID)

The UUID of the Search index. For more information, see Initial Settings.

Responses

Request samples

Content type
application/json
{
  • "name": "string",
  • "type": "string",
  • "sourceName": "string",
  • "sourceUUID": "string",
  • "sourceParams": { },
  • "sourceType": "string",
  • "params": { },
  • "planParams": {
    },
  • "prevIndexUUID": "string",
  • "uuid": "string"
}

Response samples

Content type
application/json
{
  • "status": "ok",
  • "name": "travel-sample.inventory.travel-test",
  • "uuid": "654cb62baebf2d26"
}

Delete Index Definition (Scoped)

Delete the Search index definition from the bucket and scope specified in the endpoint URL. This endpoint is scoped and does not require a fully qualified {INDEX_NAME} value.

Authorizations:
Write
path Parameters
BUCKET_NAME
required
string

The name of the bucket containing the Search index definition.

SCOPE_NAME
required
string

The name of the scope containing the Search index definition.

INDEX_NAME
required
string^[A-Za-z][0-9A-Za-z_\-]*$

The name of the Search index definition.

Responses

Response samples

Content type
application/json
{
  • "status": "ok",
  • "uuid": "687be6a2ad647c34"
}