Begin and commit a transaction in one request

1. Begin and commit request

If there is no need to keep a transaction open across multiple HTTP requests, you can begin a transaction, execute statements, and commit within a single HTTP request.

Example request

  • POST http://localhost:7474/db/neo4j/tx/commit

  • Accept: application/json;charset=UTF-8

  • Content-Type: application/json

{
  "statements": [
    {
      "statement": "MATCH (n) WHERE id(n) = $nodeId RETURN n",
      "parameters": {
        "nodeId": 7
      }
    }
  ]
}

Example response

  • 200: OK

  • Content-Type: application/json;charset=utf-8

{
  "results" : [ {
    "columns" : [ "n" ],
    "data" : [ {
      "row" : [ { } ],
      "meta" : [ {
        "id" : 7,
        "type" : "node",
        "deleted" : false
      } ]
    } ]
  } ],
  "errors" : [ ]
}

2. Legacy Endpoints Deprecated

The API described in this section of the manual has been deprecated and will be removed in Neo4j 5.0.

Starting with Neo4j version 4.3, statements submitted via these endpoints will be processed by the user’s respective home database. Previous versions rely on the the globally configured default database.

Example request

  • POST http://localhost:7474/db/neo4j/tx/commit

  • Accept: application/json;charset=UTF-8

  • Content-Type: application/json

{
  "statements": [
    {
      "statement": "MATCH (n) WHERE id(n) = $nodeId RETURN n",
      "parameters": {
        "nodeId": 2
      }
    }
  ]
}

Example response

  • 200: OK

  • Content-Type: application/json;charset=utf-8

{
  "results" : [ {
    "columns" : [ "n" ],
    "data" : [ {
      "row" : [ { } ],
      "meta" : [ {
        "id" : 2,
        "type" : "node",
        "deleted" : false
      } ]
    } ]
  } ],
  "errors" : [ ]
}