{
"basePath": "/",
"swaggerVersion": "1.1",
"apiVersion": "0.1",
"apis": [
{
"operations": [
{
"errorResponses": [
{
"reason": "If the transaction is fully executed and committed on the server, HTTP 200 will be returned.
",
"code": "200"
},
{
"reason": "If the transaction specification is either missing or malformed, the server will respond with HTTP 400.
",
"code": "400"
},
{
"reason": "If the transaction specification contains an unknown collection, the server will respond with HTTP 404.
",
"code": "404"
},
{
"reason": "Exceptions thrown by users will make the server respond with a return code of HTTP 500
",
"code": "500"
}
],
"parameters": [
{
"dataType": "String",
"paramType": "body",
"required": "true",
"name": "body",
"description": "Contains the collections and action.
"
}
],
"notes": "
The transaction description must be passed in the body of the POST request.
The following attributes must be specified inside the JSON object:
shell> curl -X POST --data-binary @- --dump - http://localhost:8529/_api/transaction\n{ \n \"collections\" : { \n \"write\" : \"products\" \n }, \n \"action\" : \"function () { var db = require('internal').db; db.products.save({}); return db.products.count(); }\" \n}\n\nHTTP/1.1 200 OK\ncontent-type: application/json; charset=utf-8\n\n{ \n \"result\" : 1, \n \"error\" : false, \n \"code\" : 200 \n}\n
shell> curl -X POST --data-binary @- --dump - http://localhost:8529/_api/transaction\n{ \n \"collections\" : { \n \"write\" : [ \n \"products\", \n \"materials\" \n ] \n }, \n \"action\" : \"function () { var db = require('internal').db; db.products.save({}); db.materials.save({}); return 'worked!'; }\" \n}\n\nHTTP/1.1 200 OK\ncontent-type: application/json; charset=utf-8\n\n{ \n \"result\" : \"worked!\", \n \"error\" : false, \n \"code\" : 200 \n}\n
shell> curl -X POST --data-binary @- --dump - http://localhost:8529/_api/transaction\n{ \n \"collections\" : { \n \"write\" : \"products\" \n }, \n \"action\" : \"function () { var db = require('internal').db; db.products.save({ _key: 'abc'}); db.products.save({ _key: 'abc'}); }\" \n}\n\nHTTP/1.1 400 Bad Request\ncontent-type: application/json; charset=utf-8\n\n{ \n \"error\" : true, \n \"code\" : 400, \n \"errorNum\" : 1210, \n \"errorMessage\" : \"unique constraint violated\" \n}\n
shell> curl -X POST --data-binary @- --dump - http://localhost:8529/_api/transaction\n{ \n \"collections\" : { \n \"read\" : \"products\" \n }, \n \"action\" : \"function () { throw 'doh!'; }\" \n}\n\nHTTP/1.1 500 Internal Error\ncontent-type: application/json; charset=utf-8\n\n{ \n \"error\" : true, \n \"code\" : 500, \n \"errorNum\" : 500, \n \"errorMessage\" : \"doh!\" \n}\n
shell> curl -X POST --data-binary @- --dump - http://localhost:8529/_api/transaction\n{ \n \"collections\" : { \n \"read\" : \"products\" \n }, \n \"action\" : \"function () { return true; }\" \n}\n\nHTTP/1.1 404 Not Found\ncontent-type: application/json; charset=utf-8\n\n{ \n \"error\" : true, \n \"code\" : 404, \n \"errorNum\" : 1203, \n \"errorMessage\" : \"collection not found\" \n}\n