{
"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": "Json",
"paramType": "body",
"required": "true",
"name": "document",
"description": "A JSON representation of document. "
},
{
"dataType": "String",
"paramType": "query",
"required": "True",
"name": "collection",
"description": "The collection name. "
},
{
"dataType": "Boolean",
"paramType": "query",
"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",
"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: \"210709724\"\nlocation: /_api/document/products/210709724\n\n{ \n \"error\" : false, \n \"_id\" : \"products/210709724\", \n \"_rev\" : \"210709724\", \n \"_key\" : \"210709724\" \n}\n\n
unix> curl -X POST --data @- --dump - http://localhost:8529/_api/document?collection=products\n{ \"Hello\": \"World\" }\n\nHTTP/1.1 202 Accepted\ncontent-type: application/json; charset=utf-8\netag: \"24849628\"\nlocation: /_api/document/products/24849628\n\n{ \n \"error\" : false, \n \"_id\" : \"products/24849628\", \n \"_rev\" : \"24849628\", \n \"_key\" : \"24849628\" \n}\n\n
unix> curl -X POST --data @- --dump - http://localhost:8529/_api/document?collection=products&waitForSync=true\n{ \"Hello\": \"World\" }\n\nHTTP/1.1 201 Created\ncontent-type: application/json; charset=utf-8\netag: \"158805212\"\nlocation: /_api/document/products/158805212\n\n{ \n \"error\" : false, \n \"_id\" : \"products/158805212\", \n \"_rev\" : \"158805212\", \n \"_key\" : \"158805212\" \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: \"211823836\"\nlocation: /_api/document/products/211823836\n\n{ \n \"error\" : false, \n \"_id\" : \"products/211823836\", \n \"_rev\" : \"211823836\", \n \"_key\" : \"211823836\" \n}\n\n
unix> curl -X POST --data @- --dump - http://localhost:8529/_api/document?collection=products\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/products 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/products/162147548\n\nHTTP/1.1 200 OK\ncontent-type: application/json; charset=utf-8\netag: \"162147548\"\n\n{ \n \"hello\" : \"world\", \n \"_id\" : \"products/162147548\", \n \"_rev\" : \"162147548\", \n \"_key\" : \"162147548\" \n}\n\n
unix> curl --header 'If-None-Match:\"149302492\"' --dump - http://localhost:8529/_api/document/products/149302492\n\nHTTP/1.1 304 Not Modified\ncontent-type: text/plain; charset=utf-8\netag: \"149302492\"\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\" : \"collection /_api/collection/products not found\", \n \"code\" : 404, \n \"errorNum\" : 1203 \n}\n\n
unix> 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/37891292\", \n \"/_api/document/products/37301468\", \n \"/_api/document/products/37629148\" \n ] \n}\n\n
unix> 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 /_api/collection/doesnotexist not found\", \n \"code\" : 404, \n \"errorNum\" : 1203 \n}\n\n
unix> curl -X HEAD --dump - http://localhost:8529/_api/document/products/216739036\n\nHTTP/1.1 200 OK\ncontent-type: application/json; charset=utf-8\netag: \"216739036\"\n\n
unix> curl -X PUT --data @- --dump - http://localhost:8529/_api/document/products/97922268\n{\"Hello\": \"you\"}\n\nHTTP/1.1 202 Accepted\ncontent-type: application/json; charset=utf-8\netag: \"98381020\"\nlocation: /_api/document/products/97922268\n\n{ \n \"error\" : false, \n \"_id\" : \"products/97922268\", \n \"_rev\" : \"98381020\", \n \"_key\" : \"97922268\" \n}\n\n
unix> curl -X PUT --data @- --dump - http://localhost:8529/_api/document/products/201534684\n{}\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/201534684 not found\", \n \"code\" : 404, \n \"errorNum\" : 1202 \n}\n\n
unix> curl -X PUT --header 'If-Match:\"29699292\"' --data @- --dump - http://localhost:8529/_api/document/products/29240540\n{\"other\":\"content\"}\n\nHTTP/1.1 412 Precondition Failed\ncontent-type: application/json; charset=utf-8\n\n{ \n \"error\" : true, \n \"code\" : 412, \n \"errorNum\" : 1200, \n \"errorMessage\" : \"precondition failed\", \n \"_id\" : \"products/29240540\", \n \"_rev\" : \"29240540\", \n \"_key\" : \"29240540\" \n}\n\n
unix> curl -X PUT --header 'If-Match:\"95038684\"' --data @- --dump - http://localhost:8529/_api/document/products/94711004?policy=last\n{}\n\nHTTP/1.1 202 Accepted\ncontent-type: application/json; charset=utf-8\netag: \"95235292\"\nlocation: /_api/document/products/94711004\n\n{ \n \"error\" : false, \n \"_id\" : \"products/94711004\", \n \"_rev\" : \"95235292\", \n \"_key\" : \"94711004\" \n}\n\n
unix> curl -X PUT --data @- --dump - http://localhost:8529/_api/document/products/150613212?rev=150940892\n{\"other\":\"content\"}\n\nHTTP/1.1 412 Precondition Failed\ncontent-type: application/json; charset=utf-8\n\n{ \n \"error\" : true, \n \"code\" : 412, \n \"errorNum\" : 1200, \n \"errorMessage\" : \"precondition failed\", \n \"_id\" : \"products/150613212\", \n \"_rev\" : \"150613212\", \n \"_key\" : \"150613212\" \n}\n\n
unix> curl -X PATCH --data @- --dump - http://localhost:8529/_api/document/products/92089564\n{\"hello\":\"world\"}\n\nHTTP/1.1 202 Accepted\ncontent-type: application/json; charset=utf-8\netag: \"92548316\"\nlocation: /_api/document/products/92089564\n\n{ \n \"error\" : false, \n \"_id\" : \"products/92089564\", \n \"_rev\" : \"92548316\", \n \"_key\" : \"92089564\" \n}\n\nunix> curl -X PATCH --data @- --dump - http://localhost:8529/_api/document/products/92089564\n{\"numbers\":{\"one\":1,\"two\":2,\"three\":3,\"empty\":null}}\n\nHTTP/1.1 202 Accepted\ncontent-type: application/json; charset=utf-8\netag: \"93072604\"\nlocation: /_api/document/products/92089564\n\n{ \n \"error\" : false, \n \"_id\" : \"products/92089564\", \n \"_rev\" : \"93072604\", \n \"_key\" : \"92089564\" \n}\n\nunix> curl --dump - http://localhost:8529/_api/document/products/92089564\n\nHTTP/1.1 200 OK\ncontent-type: application/json; charset=utf-8\netag: \"93072604\"\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/92089564\", \n \"_rev\" : \"93072604\", \n \"_key\" : \"92089564\" \n}\n\nunix> curl -X PATCH --data @- --dump - http://localhost:8529/_api/document/products/92089564?keepNull=false\n{\"hello\":null,\"numbers\":{\"four\":4}}\n\nHTTP/1.1 202 Accepted\ncontent-type: application/json; charset=utf-8\netag: \"93465820\"\nlocation: /_api/document/products/92089564\n\n{ \n \"error\" : false, \n \"_id\" : \"products/92089564\", \n \"_rev\" : \"93465820\", \n \"_key\" : \"92089564\" \n}\n\nunix> curl --dump - http://localhost:8529/_api/document/products/92089564\n\nHTTP/1.1 200 OK\ncontent-type: application/json; charset=utf-8\netag: \"93465820\"\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/92089564\", \n \"_rev\" : \"93465820\", \n \"_key\" : \"92089564\" \n}\n\n
unix> curl -X DELETE --dump - http://localhost:8529/_api/document/products/53554396\n\nHTTP/1.1 200 OK\ncontent-type: application/json; charset=utf-8\n\n{ \n \"error\" : false, \n \"_id\" : \"products/53554396\", \n \"_rev\" : \"53554396\", \n \"_key\" : \"53554396\" \n}\n\n
unix> curl -X DELETE --dump - http://localhost:8529/_api/document/products/78589148\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/78589148 not found\", \n \"code\" : 404, \n \"errorNum\" : 1202 \n}\n\n
unix> curl -X DELETE --header 'If-Match:\"96742620\"' --dump - http://localhost:8529/_api/document/products/96414940\n\nHTTP/1.1 412 Precondition Failed\ncontent-type: application/json; charset=utf-8\n\n{ \n \"error\" : true, \n \"code\" : 412, \n \"errorNum\" : 1200, \n \"errorMessage\" : \"precondition failed\", \n \"_id\" : \"products/96414940\", \n \"_rev\" : \"96414940\", \n \"_key\" : \"96414940\" \n}\n\n