We’re overhauling Dgraph’s docs to make them clearer and more approachable. If you notice any issues during this transition or have suggestions, please let us know.

List backends

List backends that you have access to.

This API requires authentication, please see Authentication for instructions on issuing and passing a JWT token to the API.

Cloud endpoint

https://cerebro.cloud.dgraph.io/graphql

API command

{
  deployments {
    uid
    name
    zone
    url
    owner
    jwtToken
    deploymentMode
    deploymentType
    lambdaScript
  }
}

Example

  • <cerebro-jwt> is the JWT returned from Authentication.
  • <lambda-token> is a base64 string that’s non-empty if you have saved Lambdas on your backend
#!/usr/bin/env bash

CEREBRO_JWT="<cerebro-jwt>"

curl 'https://cerebro.cloud.dgraph.io/graphql' \
  -H 'Content-Type: application/json' \
  -H "Authorization: Bearer ${CEREBRO_JWT}" \
  --data-binary '{"query":"{\n deployments {\n uid\n name\n zone\n url\n owner\n jwtToken\n deploymentMode\n deploymentType\n lambdaScript\n }\n}","variables":{}}' \
  --compressed
For any /admin or /admin/slash requests to https://<deployment.url>, you must use the <deployment-jwt> in the X-Auth-Token header. The Cerebro JWT is only used in the Authorization header for requests to https://cerebro.cloud.dgraph.io/graphql.

Deploy backend

Launch a new backend.

This API requires authentication, please see Authentication for instructions on issuing and passing a JWT to the API.

Cloud endpoint

https://cerebro.cloud.dgraph.io/graphql

API command

mutation CreateDeployment($newDeployment: NewDeployment!) {
  createDeployment(input: $newDeployment) {
    uid
    name
    url
    jwtToken
  }
}

Arguments

  • newDeployment: parameter object for new deployment
  • newDeployment.name: name of the deployment
  • newDeployment.zone: region to launch
  • newDeployment.deploymentType: type of deployment (free|shared|dedicated)

Example

#!/usr/bin/env bash

CEREBRO_JWT="<cerebro-jwt>"

curl 'https://cerebro.cloud.dgraph.io/graphql' \
  -H 'Content-Type: application/json' \
  -H "Authorization: Bearer ${CEREBRO_JWT}" \
  --data-binary '{"query":"mutation CreateDeployment($deployment: NewDeployment!) {\n  createDeployment(input: $deployment) {\n    uid\n    name\n    url\n    jwtToken\n  }\n}","variables":{"deployment":{"name":"My New Deployment","zone":"us-east-1","deploymentType":"dedicated"}}}' \
  --compressed

Update Backend

Update backend.

This API requires authentication, please see Authentication for instructions on issuing and passing a JWT token to the API.

Cloud Endpoint

https://cerebro.cloud.dgraph.io/graphql

API Command

mutation UpdateDeployment($updateDeploymentInput: UpdateDeploymentInput!) {
  updateDeployment(input: $updateDeploymentInput)
}

Arguments

  • updateDeploymentInput: parameter object for update deployment
  • updateDeploymentInput.uid (required): deployment uid

Example

#!/usr/bin/env bash

CEREBRO_JWT="<cerebro-jwt>"

curl 'https://cerebro.cloud.dgraph.io/graphql' \
  -H 'Content-Type: application/json' \
  -H "Authorization: Bearer ${CEREBRO_JWT}" \
  --data-binary '{"query":"mutation UpdateDeployment($dep: UpdateDeploymentInput!) {\n updateDeployment(input: $dep)\n}","variables":{"dep":{"uid":"<deployment.uid>","name":"My Deployment!"}}}' \
  --compressed

Destroy Backend

Destroy (i.e., delete) a backend by id.

This API requires authentication, please see Authentication for instructions on issuing and passing a JWT token to the API.

Cloud Endpoint

https://cerebro.cloud.dgraph.io/graphql

API Command

mutation DeleteDeployment($deploymentID: String!) {
  deleteDeployment(deploymentID: $deploymentID)
}

Arguments

  • deploymentID (required): deployment uid returned from a List Backends request

Example

#!/usr/bin/env bash

CEREBRO_JWT="<cerebro-jwt>"

curl 'https://cerebro.cloud.dgraph.io/graphql' \
  -H 'Content-Type: application/json' \
  -H "Authorization: Bearer ${CEREBRO_JWT}" \
  --data-binary '{"query":"mutation DeleteDeployment($deploymentUid: String!) {\n  deleteDeployment(deploymentID: $deploymentUid)\n}","variables":{"deploymentUid":"<deployment.uid>"}}' \
  --compressed

Restore Backends

Restore into a backend by source backend ID.

Cloud Endpoint

https://${DEPLOYMENT_URL}/admin/slash

API Command

mutation ($uid: String!, $backupFolder: String, $backupNum: Int) {
  restore(uid: $uid, backupFolder: $backupFolder, backupNum: $backupNum) {
    response {
      code
      message
      restoreId
    }
    errors {
      message
    }
  }
}

Arguments

  • uid (required): the deployment uid from List Backends
  • backupFolder (required): TODO
  • backupNum (required): TODO

Example

#!/usr/bin/env bash

DEPLOYMENT_URL="polished-violet.us-east-1.aws.cloud.dgraph.io"
DEPLOYMENT_JWT="<deployment-jwt>"

curl "https://${DEPLOYMENT_URL}/admin/slash" \
  -H 'Content-Type: application/json' \
  -H "X-Auth-Token: ${DEPLOYMENT_JWT}" \
  --data-binary '{"query":"mutation($uid: String!, $backupFolder: String, $backupNum: Int) {\n restore(uid: $uid, backupFolder: $backupFolder, backupNum: $backupNum) {\n response {\n code\n message\n restoreId\n }, errors {\n message\n }\n}\n}","variables":{"uid":"<deployment-uid>","backupFolder":"<backup-folder>","backupNum":<backup-num>}}' \
  --compressed

Restore Backend Status

Retrieve the status of a restore operation.

Cloud Endpoint

https://${DEPLOYMENT_URL}/admin/slash

API Command

query ($restoreId: Int!) {
  restoreStatus(restoreId: $restoreId) {
    response {
      status
      errors
    }
  }
}

Arguments

  • restoreId (required): the id of the restore operation returned from Restore Backends request

Example

#!/usr/bin/env bash

DEPLOYMENT_URL="polished-violet.us-east-1.aws.cloud.dgraph.io"
DEPLOYMENT_JWT="<deployment-jwt>"

curl "https://${DEPLOYMENT_URL}/admin/slash" \
  -H 'Content-Type: application/json' \
  -H "X-Auth-Token: ${DEPLOYMENT_JWT}" \
  --data-binary '{"query":"query($restoreId: Int!) {\n restoreStatus(restoreId: $restoreId) {\n response {status errors}\n}\n}","variables":{"restoreId":1}}' \
  --compressed

Drop

Drop (i.e., delete) all data in your backend.

Cloud Endpoint

https://${DEPLOYMENT_URL}/admin/slash

API Command

Drop Data

mutation {
  dropData(allData: true) {
    response {
      code
      message
    }
  }
}

Drop Schema

mutation {
  dropData(allDataAndSchema: true) {
    response {
      code
      message
    }
  }
}

Drop Types

mutation ($types: [String!]) {
  dropData(types: $types) {
    response {
      code
      message
    }
  }
}

Arguments

  • types: string array containing type Names

Drop Fields

mutation ($fields: [String!]) {
  dropData(fields: $fields) {
    response {
      code
      message
    }
  }
}

Arguments

  • fields: string array containing field Names

Example

#!/usr/bin/env bash

DEPLOYMENT_URL="polished-violet.us-east-1.aws.cloud.dgraph.io"
DEPLOYMENT_JWT="<deployment-jwt>"

curl "https://${DEPLOYMENT_URL}/admin/slash" \
  -H 'Content-Type: application/json' \
  -H "X-Auth-Token: ${DEPLOYMENT_JWT}" \
  --data-binary '{"query":"mutation {\n dropData(allDataAndSchema: true) {\n response { code message }\n}\n}","variables":{}}' \
  --compressed