{
"basePath": "/",
"swaggerVersion": "1.1",
"apiVersion": "0.1",
"apis": [
{
"operations": [
{
"errorResponses": [
{
"reason": "is returned if the document was created sucessfully and `waitForSync` was `true`. ",
"code": "201"
},
{
"reason": "is returned if the document was created sucessfully 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": "String",
"paramType": "body",
"required": "false",
"name": "body",
"description": "A valid json document for your data, for instance {\"hello\": \"world\"}."
},
{
"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. "
},
{
"dataType": "Boolean",
"paramType": "query",
"required": "false",
"name": "waitForSync",
"description": "Wait until document has been sync 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:
- `_id` contains the document handle of the newly created document
- `_key` contains the document key
- `_rev` contains the document revision
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 documents has been sync 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": "creates a 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.
unix> curl -X POST --data @- --dump - http://localhost:8529/_api/document?collection=products\n{ \"Hello\": \"World\" }\n\nHTTP/1.1 201 Created\ncontent-type: application/json; charset=utf-8\netag: \"13251162\"\nlocation: /_api/document/products/13251162\n\n{ \n \"error\" : false, \n \"_id\" : \"products/13251162\", \n \"_rev\" : \"13251162\", \n \"_key\" : \"13251162\" \n}\n\n
unix> curl -X POST --data @- --dump - http://localhost:8529/_api/document?collection=productsNoWait\n{ \"Hello\": \"World\" }\n\nHTTP/1.1 202 Accepted\ncontent-type: application/json; charset=utf-8\netag: \"16069210\"\nlocation: /_api/document/productsNoWait/16069210\n\n{ \n \"error\" : false, \n \"_id\" : \"productsNoWait/16069210\", \n \"_rev\" : \"16069210\", \n \"_key\" : \"16069210\" \n}\n\n
unix> curl -X POST --data @- --dump - http://localhost:8529/_api/document?collection=productsNoWait&waitForSync=true\n{ \"Hello\": \"World\" }\n\nHTTP/1.1 201 Created\ncontent-type: application/json; charset=utf-8\netag: \"14627418\"\nlocation: /_api/document/productsNoWait/14627418\n\n{ \n \"error\" : false, \n \"_id\" : \"productsNoWait/14627418\", \n \"_rev\" : \"14627418\", \n \"_key\" : \"14627418\" \n}\n\n
unix> curl -X POST --data @- --dump - http://localhost:8529/_api/document?collection=products&createCollection=true\n{ \"Hello\": \"World\" }\n\nHTTP/1.1 202 Accepted\ncontent-type: application/json; charset=utf-8\netag: \"23999066\"\nlocation: /_api/document/products/23999066\n\n{ \n \"error\" : false, \n \"_id\" : \"products/23999066\", \n \"_rev\" : \"23999066\", \n \"_key\" : \"23999066\" \n}\n\n
unix> curl -X POST --data @- --dump - http://localhost:8529/_api/document?collection=productsUnknown\n{ \"Hello\": \"World\" }\n\nHTTP/1.1 404 Not Found\ncontent-type: application/json; charset=utf-8\n\n{ \n \"error\" : true, \n \"errorMessage\" : \"collection /_api/collection/productsUnknown not found\", \n \"code\" : 404, \n \"errorNum\" : 1203 \n}\n\n
unix> curl -X POST --data @- --dump - http://localhost:8529/_api/document?collection=products\n{ 1: \"World\" }\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\n
unix> curl --dump - http://localhost:8529/_api/document/products1/19214938\n\nHTTP/1.1 200 OK\ncontent-type: application/json; charset=utf-8\netag: \"19214938\"\n\n{ \n \"hallo\" : \"world\", \n \"_id\" : \"products1/19214938\", \n \"_rev\" : \"19214938\", \n \"_key\" : \"19214938\" \n}\n\n
unix> curl --header 'if-none-match: \"29110874\"' --dump - http://localhost:8529/_api/document/products2/29110874\n\nHTTP/1.1 200 OK\ncontent-type: application/json; charset=utf-8\netag: \"29110874\"\n\n{ \n \"hallo\" : \"world\", \n \"_id\" : \"products2/29110874\", \n \"_rev\" : \"29110874\", \n \"_key\" : \"29110874\" \n}\n\n
unix> 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\" : \"document /_api/document/products/unknownhandle not found\", \n \"code\" : 404, \n \"errorNum\" : 1202 \n}\n\n
unix> curl --dump - http://localhost:8529/_api/document/?collection=24457818\n\nHTTP/1.1 200 OK\ncontent-type: application/json; charset=utf-8\n\n{ \n \"documents\" : [ \n \"/_api/document/products3/26358362\", \n \"/_api/document/products3/25440858\", \n \"/_api/document/products3/26096218\" \n ] \n}\n\n
unix> curl --data @- --dump - http://localhost:8529/_api/document/productshead/32256602\n{}\n\n
> curl --data @- -X PUT --dump - http://localhost:8529/_api/document/73482/29853486\n{ \"World\" : \"Hello\" }\n\nHTTP/1.1 200 OK\ncontent-type: application/json; charset=utf-8\n\n{\n \"_rev\": \"29919022\",\n \"_id\": \"73482/29853486\",\n \"error\": false\n}\n
unix> curl -X PUT --data @- --dump - http://localhost:8529/_api/document/products5/30618202\n{}\n\nHTTP/1.1 202 Accepted\ncontent-type: application/json; charset=utf-8\netag: \"31208026\"\nlocation: /_api/document/products5/30618202\n\n{ \n \"error\" : false, \n \"_id\" : \"products5/30618202\", \n \"_rev\" : \"31208026\", \n \"_key\" : \"30618202\" \n}\n\n
unix> curl -X PUT --data @- --dump - http://localhost:8529/_api/document/products6/22360666\n{}\n\nHTTP/1.1 202 Accepted\ncontent-type: application/json; charset=utf-8\netag: \"22950490\"\nlocation: /_api/document/products6/22360666\n\n{ \n \"error\" : false, \n \"_id\" : \"products6/22360666\", \n \"_rev\" : \"22950490\", \n \"_key\" : \"22360666\" \n}\n\n
unix> curl -X PUT --data @- --dump - http://localhost:8529/_api/document/products7/17642074\n{}\n\nHTTP/1.1 202 Accepted\ncontent-type: application/json; charset=utf-8\netag: \"18100826\"\nlocation: /_api/document/products7/17642074\n\n{ \n \"error\" : false, \n \"_id\" : \"products7/17642074\", \n \"_rev\" : \"18100826\", \n \"_key\" : \"17642074\" \n}\n\n
unix> curl -X PUT --data @- --dump - http://localhost:8529/_api/document/products8/20722266\n{}\n\nHTTP/1.1 202 Accepted\ncontent-type: application/json; charset=utf-8\netag: \"21312090\"\nlocation: /_api/document/products8/20722266\n\n{ \n \"error\" : false, \n \"_id\" : \"products8/20722266\", \n \"_rev\" : \"21312090\", \n \"_key\" : \"20722266\" \n}\n\n
> curl --data @- -X PATCH --dump - http://localhost:8529/_api/document/73482/7229681\n{ \"hello\": \"world\" }\n\nHTTP/1.1 200 OK\ncontent-type: application/json; charset=utf-8\n\n{\n \"_rev\": \"11916057\",\n \"_id\": \"73482/7229681\",\n \"error\": false\n}\n\n> curl --data @- -X PATCH --dump - http://localhost:8529/_api/document/73482/7229681\n{ \"numbers\": { \"one\": 1, \"two\": 2, \"three\": 3, \"empty\": null } }\n\nHTTP/1.1 200 OK\ncontent-type: application/json; charset=utf-8\n\n{\n \"_rev\": \"12309273\",\n \"_id\": \"73482/7229681\",\n \"error\": false\n}\n\n> curl -X GET --dump - http://localhost:8529/_api/document/73482/7229681\n{ \"numbers\": { \"one\": 1, \"two\": 2, \"three\": 3, \"empty\": null } }\n\nHTTP/1.1 200 OK\ncontent-type: application/json; charset=utf-8\n\n{\n \"hello\": \"world\",\n \"numbers\": {\n \"empty\": null,\n \"one\": 1,\n \"two\": 2,\n \"three\": 3\n },\n \"_rev\": \"12309273\",\n \"_id\": \"73482/7229681\"\n}\n\n> curl --data @- -X PATCH --dump - http://localhost:8529/_api/document/73482/7229681?keepNull=false\n{ \"hello\": null, \"numbers\": { \"four\": 4 } }\n\n{\n \"_rev\": \"12571417\",\n \"_id\": \"73482/7229681\",\n \"error\": false\n}\n\n> curl -X GET --dump - http://localhost:8529/_api/document/73482/7229681\n\nHTTP/1.1 200 OK\ncontent-type: application/json; charset=utf-8\n\n{\n \"numbers\": {\n \"empty\": null,\n \"one\": 1,\n \"two\": 2,\n \"three\": 3,\n \"four\": 4,\n },\n \"_rev\": \"12571417\",\n \"_id\": \"73482/7229681\"\n}\n
> curl -X DELETE --dump - http://localhost:8529/_api/document/73482/30967598\n\nHTTP/1.1 200 OK\ncontent-type: application/json; charset=utf-8\n\n{\n \"_rev\": \"30967598\",\n \"_id\": \"73482/30967598\",\n \"error\": false\n}\n
> curl -X DELETE --dump - http://localhost:8529/_api/document/73482/234567\n\nHTTP/1.1 404 Not Found\ncontent-type: application/json; charset=utf-8\n\n{\n \"errorMessage\": \"document /_api/document/73482/234567 not found\",\n \"errorNum\": 1202,\n \"code\": 404,\n \"error\": true\n}\n
> curl -X DELETE '-H if-match: \"31098669\"' --dump - http://localhost:8529/_api/document/73482/31098670\n\nHTTP/1.1 412 Precondition Failed\ncontent-type: application/json; charset=utf-8\n\n{\n \"_rev\": \"31098670\",\n \"_id\": \"73482/31098670\",\n \"error\": true\n}\n