{
"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:
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
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
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
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
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
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
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
shell> curl --header 'If-None-Match: \"1676944437\"' --dump - http://localhost:8529/_api/document/products/1676944437\n\n
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
shell> curl --dump - http://localhost:8529/_api/document/?collection=products\n\nHTTP/1.1 200 OK\ncontent-type: application/json; charset=utf-8\n\n{ \n \"documents\" : [ \n \"/_api/document/products/1677861941\", \n \"/_api/document/products/1678189621\", \n \"/_api/document/products/1677534261\" \n ] \n}\n
shell> curl --dump - http://localhost:8529/_api/document/?collection=products&type=key\n\nHTTP/1.1 200 OK\ncontent-type: application/json; charset=utf-8\n\n{ \n \"documents\" : [ \n \"1679434805\", \n \"1678779445\", \n \"1679107125\" \n ] \n}\n
shell> curl --dump - http://localhost:8529/_api/document/?collection=doesnotexist\n\nHTTP/1.1 404 Not Found\ncontent-type: application/json; charset=utf-8\n\n{ \n \"error\" : true, \n \"errorMessage\" : \"collection 'doesnotexist' not found\", \n \"code\" : 404, \n \"errorNum\" : 1203 \n}\n
shell> curl -X HEAD --dump - http://localhost:8529/_api/document/products/1680024629\n\n
shell> curl -X PUT --data-binary @- --dump - http://localhost:8529/_api/document/products/1680614453 <<EOF\n{\"Hello\": \"you\"}\nEOF\n\nHTTP/1.1 202 Accepted\ncontent-type: application/json; charset=utf-8\netag: \"1680942133\"\nlocation: /_db/_system/_api/document/products/1680614453\n\n{ \n \"error\" : false, \n \"_id\" : \"products/1680614453\", \n \"_rev\" : \"1680942133\", \n \"_key\" : \"1680614453\" \n}\n
shell> curl -X PUT --data-binary @- --dump - http://localhost:8529/_api/document/products/1681466421 <<EOF\n{}\nEOF\n\nHTTP/1.1 404 Not Found\ncontent-type: application/json; charset=utf-8\n\n{ \n \"error\" : true, \n \"errorMessage\" : \"document /_api/document/products/1681466421 not found\", \n \"code\" : 404, \n \"errorNum\" : 1202 \n}\n
shell> curl -X PUT --header 'If-Match: \"1682711605\"' --data-binary @- --dump - http://localhost:8529/_api/document/products/1682383925 <<EOF\n{\"other\":\"content\"}\nEOF\n\nHTTP/1.1 412 Precondition Failed\ncontent-type: application/json; charset=utf-8\netag: \"1682383925\"\n\n{ \n \"error\" : true, \n \"code\" : 412, \n \"errorNum\" : 1200, \n \"errorMessage\" : \"precondition failed\", \n \"_id\" : \"products/1682383925\", \n \"_rev\" : \"1682383925\", \n \"_key\" : \"1682383925\" \n}\n
shell> curl -X PUT --header 'If-Match: \"1683825717\"' --data-binary @- --dump - http://localhost:8529/_api/document/products/1683498037?policy=last <<EOF\n{}\nEOF\n\nHTTP/1.1 202 Accepted\ncontent-type: application/json; charset=utf-8\netag: \"1684087861\"\nlocation: /_db/_system/_api/document/products/1683498037\n\n{ \n \"error\" : false, \n \"_id\" : \"products/1683498037\", \n \"_rev\" : \"1684087861\", \n \"_key\" : \"1683498037\" \n}\n
shell> curl -X PUT --data-binary @- --dump - http://localhost:8529/_api/document/products/1684612149?rev=1684939829 <<EOF\n{\"other\":\"content\"}\nEOF\n\nHTTP/1.1 412 Precondition Failed\ncontent-type: application/json; charset=utf-8\netag: \"1684612149\"\n\n{ \n \"error\" : true, \n \"code\" : 412, \n \"errorNum\" : 1200, \n \"errorMessage\" : \"precondition failed\", \n \"_id\" : \"products/1684612149\", \n \"_rev\" : \"1684612149\", \n \"_key\" : \"1684612149\" \n}\n
shell> curl -X PATCH --data-binary @- --dump - http://localhost:8529/_api/document/products/1685726261 <<EOF\n{ \n \"hello\" : \"world\" \n}\nEOF\n\nHTTP/1.1 202 Accepted\ncontent-type: application/json; charset=utf-8\netag: \"1686053941\"\nlocation: /_db/_system/_api/document/products/1685726261\n\n{ \n \"error\" : false, \n \"_id\" : \"products/1685726261\", \n \"_rev\" : \"1686053941\", \n \"_key\" : \"1685726261\" \n}\nshell> curl -X PATCH --data-binary @- --dump - http://localhost:8529/_api/document/products/1685726261 <<EOF\n{ \n \"numbers\" : { \n \"one\" : 1, \n \"two\" : 2, \n \"three\" : 3, \n \"empty\" : null \n } \n}\nEOF\n\nHTTP/1.1 202 Accepted\ncontent-type: application/json; charset=utf-8\netag: \"1686643765\"\nlocation: /_db/_system/_api/document/products/1685726261\n\n{ \n \"error\" : false, \n \"_id\" : \"products/1685726261\", \n \"_rev\" : \"1686643765\", \n \"_key\" : \"1685726261\" \n}\nshell> curl --dump - http://localhost:8529/_api/document/products/1685726261\n\nHTTP/1.1 200 OK\ncontent-type: application/json; charset=utf-8\netag: \"1686643765\"\n\n{ \n \"one\" : \"world\", \n \"hello\" : \"world\", \n \"numbers\" : { \n \"empty\" : null, \n \"one\" : 1, \n \"two\" : 2, \n \"three\" : 3 \n }, \n \"_id\" : \"products/1685726261\", \n \"_rev\" : \"1686643765\", \n \"_key\" : \"1685726261\" \n}\nshell> curl -X PATCH --data-binary @- --dump - http://localhost:8529/_api/document/products/1685726261?keepNull=false <<EOF\n{ \n \"hello\" : null, \n \"numbers\" : { \n \"four\" : 4 \n } \n}\nEOF\n\nHTTP/1.1 202 Accepted\ncontent-type: application/json; charset=utf-8\netag: \"1687102517\"\nlocation: /_db/_system/_api/document/products/1685726261\n\n{ \n \"error\" : false, \n \"_id\" : \"products/1685726261\", \n \"_rev\" : \"1687102517\", \n \"_key\" : \"1685726261\" \n}\nshell> curl --dump - http://localhost:8529/_api/document/products/1685726261\n\nHTTP/1.1 200 OK\ncontent-type: application/json; charset=utf-8\netag: \"1687102517\"\n\n{ \n \"one\" : \"world\", \n \"numbers\" : { \n \"empty\" : null, \n \"one\" : 1, \n \"two\" : 2, \n \"three\" : 3, \n \"four\" : 4 \n }, \n \"_id\" : \"products/1685726261\", \n \"_rev\" : \"1687102517\", \n \"_key\" : \"1685726261\" \n}\n
shell> curl --dump - http://localhost:8529/_api/document/products/1687954485\n\nHTTP/1.1 200 OK\ncontent-type: application/json; charset=utf-8\netag: \"1687954485\"\n\n{ \n \"inhabitants\" : { \n \"china\" : 1366980000, \n \"india\" : 1263590000, \n \"usa\" : 319220000 \n }, \n \"_id\" : \"products/1687954485\", \n \"_rev\" : \"1687954485\", \n \"_key\" : \"1687954485\" \n}\nshell> curl -X PATCH --data-binary @- --dump - http://localhost:8529/_api/document/products/1687954485?mergeObjects=true <<EOF\n{ \n \"inhabitants\" : { \n \"indonesia\" : 252164800, \n \"brazil\" : 203553000 \n } \n}\nEOF\n\nshell> curl --dump - http://localhost:8529/_api/document/products/1687954485\n\nHTTP/1.1 200 OK\ncontent-type: application/json; charset=utf-8\netag: \"1688478773\"\n\n{ \n \"inhabitants\" : { \n \"china\" : 1366980000, \n \"india\" : 1263590000, \n \"usa\" : 319220000, \n \"indonesia\" : 252164800, \n \"brazil\" : 203553000 \n }, \n \"_id\" : \"products/1687954485\", \n \"_rev\" : \"1688478773\", \n \"_key\" : \"1687954485\" \n}\nshell> curl -X PATCH --data-binary @- --dump - http://localhost:8529/_api/document/products/1687954485?mergeObjects=false <<EOF\n{ \n \"inhabitants\" : { \n \"pakistan\" : 188346000 \n } \n}\nEOF\n\nHTTP/1.1 202 Accepted\ncontent-type: application/json; charset=utf-8\netag: \"1688937525\"\nlocation: /_db/_system/_api/document/products/1687954485\n\n{ \n \"error\" : false, \n \"_id\" : \"products/1687954485\", \n \"_rev\" : \"1688937525\", \n \"_key\" : \"1687954485\" \n}\nshell> curl --dump - http://localhost:8529/_api/document/products/1687954485\n\nHTTP/1.1 200 OK\ncontent-type: application/json; charset=utf-8\netag: \"1688937525\"\n\n{ \n \"inhabitants\" : { \n \"pakistan\" : 188346000 \n }, \n \"_id\" : \"products/1687954485\", \n \"_rev\" : \"1688937525\", \n \"_key\" : \"1687954485\" \n}\n
shell> curl -X DELETE --dump - http://localhost:8529/_api/document/products/1689527349\n\nHTTP/1.1 200 OK\ncontent-type: application/json; charset=utf-8\n\n{ \n \"error\" : false, \n \"_id\" : \"products/1689527349\", \n \"_rev\" : \"1689527349\", \n \"_key\" : \"1689527349\" \n}\n
shell> curl -X DELETE --dump - http://localhost:8529/_api/document/products/1690313781\n\nHTTP/1.1 404 Not Found\ncontent-type: application/json; charset=utf-8\n\n{ \n \"error\" : true, \n \"errorMessage\" : \"document /_api/document/products/1690313781 not found\", \n \"code\" : 404, \n \"errorNum\" : 1202 \n}\n
shell> curl -X DELETE --header 'If-Match: \"1691493429\"' --dump - http://localhost:8529/_api/document/products/1691165749\n\nHTTP/1.1 412 Precondition Failed\ncontent-type: application/json; charset=utf-8\netag: \"1691165749\"\n\n{ \n \"error\" : true, \n \"code\" : 412, \n \"errorNum\" : 1200, \n \"errorMessage\" : \"precondition failed\", \n \"_id\" : \"products/1691165749\", \n \"_rev\" : \"1691165749\", \n \"_key\" : \"1691165749\" \n}\n