You are looking at the docs for an older version of Dgraph (v21.03). The latest version is v23.1.
Ask a Question

Mutations Using cURL

Mutations can be done over HTTP by making a POST request to an Alpha’s /mutate endpoint. On the command line this can be done with curl. To commit the mutation, pass the parameter commitNow=true in the URL.

To run a set mutation:

curl -H "Content-Type: application/rdf" -X POST localhost:8080/mutate?commitNow=true -d $'
{
  set {
    _:alice <name> "Alice" .
    _:alice <dgraph.type> "Person" .
  }
}'

To run a delete mutation:

curl -H "Content-Type: application/rdf" -X POST localhost:8080/mutate?commitNow=true -d $'
{
  delete {
    # Example: The UID of Alice is 0x56f33
    <0x56f33> <name> * .
  }
}'

To run an RDF mutation stored in a file, use curl’s --data-binary option so that, unlike the -d option, the data is not URL encoded.

curl -H "Content-Type: application/rdf" -X POST localhost:8080/mutate?commitNow=true --data-binary @mutation.txt