Transaction Configuration

For any transaction-initiating request (such as /tx or tx/commit), you can provide configuration options that apply for the duration of the whole transaction.

1. Access Mode

To ensure efficient load balancing across a cluster, it is important to label transactions that only contain READ statements with a READ access mode.

This can be done by adding an access-mode header to the request, with a value of READ.

If an access-mode configuration has not been provided, the default value is WRITE.

However, if you have clusters with Server-side routing disabled, the default value is READ.

  • Please note that access-mode is not required for a Neo4j single instance.

  • This feature was introduced in Neo4j version 4.4.4.

Example request

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

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

  • Content-Type: application/json

  • Access-Mode: WRITE

{
  "statements": [
    {
      "statement": "CREATE (n) RETURN n"
    }
  ]
}

Example response

  • 200: OK

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

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