{ "basePath": "/", "swaggerVersion": "1.1", "apiVersion": "0.1", "apis": [ { "operations": [ { "errorResponses": [ { "reason": "is returned if the document was created successfully and waitForSync was true.

", "code": "201" }, { "reason": "is returned if the document was created successfully and waitForSync was false.

", "code": "202" }, { "reason": "is returned if the body does not contain a valid JSON representation of a document. The response body contains an error document in this case.

", "code": "400" }, { "reason": "is returned if the collection specified by collection is unknown. The response body contains an error document in this case.

", "code": "404" } ], "parameters": [ { "dataType": "Json", "paramType": "body", "required": true, "name": "document", "description": "A JSON representation of the document.

" }, { "dataType": "String", "paramType": "query", "required": true, "name": "collection", "description": "The collection name.

" }, { "dataType": "Boolean", "paramType": "query", "required": false, "name": "createCollection", "description": "If this parameter has a value of true or yes, then the collection is created if it does not yet exist. Other values will be ignored so the collection must be present for the operation to succeed.

Note: this flag is not supported in a cluster. Using it will result in an error.

" }, { "dataType": "Boolean", "paramType": "query", "required": false, "name": "waitForSync", "description": "Wait until document has been synced to disk.

" } ], "notes": "Creates a new document in the collection named collection. A JSON representation of the document must be passed as the body of the POST request.

If the document was created successfully, then the \"Location\" header contains the path to the newly created document. The \"ETag\" header field contains the revision of the document.

The body of the response contains a JSON object with the following attributes:

If the collection parameter waitForSync is false, then the call returns as soon as the document has been accepted. It will not wait until the document has been synced to disk.

Optionally, the URL parameter waitForSync can be used to force synchronisation of the document creation operation to disk even in case that the waitForSync flag had been disabled for the entire collection. Thus, the waitForSync URL parameter can be used to force synchronisation of just this specific operations. To use this, set the waitForSync parameter to true. If the waitForSync parameter is not specified or set to false, then the collection's default waitForSync behavior is applied. The waitForSync URL parameter cannot be used to disable synchronisation for collections that have a default waitForSync value of true.

", "summary": "Create document", "httpMethod": "POST", "examples": "

Create a document given a collection named products. Note that the revision identifier might or might not by equal to the auto-generated key.



shell> curl -X POST --data-binary @- --dump - http://localhost:8529/_api/document?collection=products <<EOF\n{ \"Hello\": \"World\" }\nEOF\n\nHTTP/1.1 201 Created\ncontent-type: application/json; charset=utf-8\netag: \"1674257461\"\nlocation: /_db/_system/_api/document/products/1674257461\n\n{ \n  \"error\" : false, \n  \"_id\" : \"products/1674257461\", \n  \"_rev\" : \"1674257461\", \n  \"_key\" : \"1674257461\" \n}\n



Create a document in a collection named products with a collection-level waitForSync value of false.



shell> curl -X POST --data-binary @- --dump - http://localhost:8529/_api/document?collection=products <<EOF\n{ \"Hello\": \"World\" }\nEOF\n\nHTTP/1.1 202 Accepted\ncontent-type: application/json; charset=utf-8\netag: \"1674781749\"\nlocation: /_db/_system/_api/document/products/1674781749\n\n{ \n  \"error\" : false, \n  \"_id\" : \"products/1674781749\", \n  \"_rev\" : \"1674781749\", \n  \"_key\" : \"1674781749\" \n}\n



Create a document in a collection with a collection-level waitForSync value of false, but using the waitForSync URL parameter.



shell> curl -X POST --data-binary @- --dump - http://localhost:8529/_api/document?collection=products&waitForSync=true <<EOF\n{ \"Hello\": \"World\" }\nEOF\n\nHTTP/1.1 201 Created\ncontent-type: application/json; charset=utf-8\netag: \"1675306037\"\nlocation: /_db/_system/_api/document/products/1675306037\n\n{ \n  \"error\" : false, \n  \"_id\" : \"products/1675306037\", \n  \"_rev\" : \"1675306037\", \n  \"_key\" : \"1675306037\" \n}\n



Create a document in a new, named collection



shell> curl -X POST --data-binary @- --dump - http://localhost:8529/_api/document?collection=products&createCollection=true <<EOF\n{ \"Hello\": \"World\" }\nEOF\n\nHTTP/1.1 202 Accepted\ncontent-type: application/json; charset=utf-8\netag: \"1675830325\"\nlocation: /_db/_system/_api/document/products/1675830325\n\n{ \n  \"error\" : false, \n  \"_id\" : \"products/1675830325\", \n  \"_rev\" : \"1675830325\", \n  \"_key\" : \"1675830325\" \n}\n



Unknown collection name:



shell> curl -X POST --data-binary @- --dump - http://localhost:8529/_api/document?collection=products <<EOF\n{ \"Hello\": \"World\" }\nEOF\n\nHTTP/1.1 404 Not Found\ncontent-type: application/json; charset=utf-8\n\n{ \n  \"error\" : true, \n  \"errorMessage\" : \"collection 'products' not found\", \n  \"code\" : 404, \n  \"errorNum\" : 1203 \n}\n



Illegal document:



shell> curl -X POST --data-binary @- --dump - http://localhost:8529/_api/document?collection=products <<EOF\n{ 1: \"World\" }\nEOF\n\nHTTP/1.1 400 Bad Request\ncontent-type: application/json; charset=utf-8\n\n{ \n  \"error\" : true, \n  \"errorMessage\" : \"expecting attribute name\", \n  \"code\" : 400, \n  \"errorNum\" : 600 \n}\n



", "nickname": "CreateDocument" } ], "path": "/_api/document" }, { "operations": [ { "errorResponses": [ { "reason": "is returned if the document was found

", "code": "200" }, { "reason": "is returned if the \"If-None-Match\" header is given and the document has the same version

", "code": "304" }, { "reason": "is returned if the document or collection was not found

", "code": "404" }, { "reason": "is returned if a \"If-Match\" header or rev is given and the found document has a different version. The response will also contain the found document's current revision in the _rev attribute. Additionally, the attributes _id and _key will be returned.

", "code": "412" } ], "parameters": [ { "dataType": "String", "paramType": "path", "required": true, "name": "document-handle", "description": "The handle of the document.

" }, { "dataType": "String", "paramType": "header", "name": "If-None-Match", "description": "If the \"If-None-Match\" header is given, then it must contain exactly one etag. The document is returned, if it has a different revision than the given etag. Otherwise an HTTP 304 is returned.

" }, { "dataType": "String", "paramType": "header", "name": "If-Match", "description": "If the \"If-Match\" header is given, then it must contain exactly one etag. The document is returned, if it has the same revision as the given etag. Otherwise a HTTP 412 is returned. As an alternative you can supply the etag in an attribute rev in the URL.

" } ], "notes": "Returns the document identified by document-handle. The returned document contains three special attributes: _id containing the document handle, _key containing key which uniquely identifies a document in a given collection and _rev containing the revision.

", "summary": "Read document", "httpMethod": "GET", "examples": "

Use a document handle:



shell> curl --dump - http://localhost:8529/_api/document/products/1676354613\n\nHTTP/1.1 200 OK\ncontent-type: application/json; charset=utf-8\netag: \"1676354613\"\n\n{ \n  \"hello\" : \"world\", \n  \"_id\" : \"products/1676354613\", \n  \"_rev\" : \"1676354613\", \n  \"_key\" : \"1676354613\" \n}\n



Use a document handle and an etag:



shell> curl --header 'If-None-Match: \"1676944437\"' --dump - http://localhost:8529/_api/document/products/1676944437\n\n



Unknown document handle:



shell> curl --dump - http://localhost:8529/_api/document/products/unknownhandle\n\nHTTP/1.1 404 Not Found\ncontent-type: application/json; charset=utf-8\n\n{ \n  \"error\" : true, \n  \"errorMessage\" : \"collection 'products' not found\", \n  \"code\" : 404, \n  \"errorNum\" : 1203 \n}\n



", "nickname": "ReadDocument" } ], "path": "/_api/document/{document-handle}" }, { "operations": [ { "errorResponses": [ { "reason": "All went good.

", "code": "200" }, { "reason": "The collection does not exist.

", "code": "404" } ], "parameters": [ { "dataType": "String", "paramType": "query", "required": true, "name": "collection", "description": "The name of the collection.

" }, { "dataType": "String", "paramType": "query", "required": false, "name": "type", "description": "The type of the result. The following values are allowed: