API

API Request examples

This article shows some examples of how to automate operations like Create database, Pause and Resume database, Clone database, disaster recovery, and more, using our API.

Create database

The below example will guide you through the steps needed to deploy a new database (with chosen plan, version, name, edition, and extras) in the desired Environment.

Step 1: Get Access token

curl https://api.db.graphenedb.com/organizations/oauth/token \
-d "client_secret"="SECRET" \
-d "client_id"="ID" \
-d "grant_type"="client_credentials" 

Step 2: Get Environments (to get environmentId)

curl https://api.db.graphenedb.com/deployments/environments \
-H "authorization: Bearer ACCESS_TOKEN" \
-H "content-type: application/json" 

Step 3: Create database

  • environmentId: the ID of the Environment you want a new database to be deployed into.
curl -X POST https://api.db.graphenedb.com/deployments/databases/graphneo \
-H "content-type: application/json" \
-H "authorization: Bearer ACCESS_TOKEN" \
-d '{"environmentId":"{environmentId}","name":"string","plan":"string","version":"string","edition":"string","enabledExtrasKinds":["string"]}'

Restart database

The example below will guide you through the steps needed to restart the specific database in the respective Environment.

Step 1: Get Access token

curl https://api.db.graphenedb.com/organizations/oauth/token \
-d "client_secret"="SECRET" \
-d "client_id"="ID" \
-d "grant_type"="client_credentials" 

Step 2: Get Environments (to get environmentId)

curl https://api.db.graphenedb.com/deployments/environments \
-H "authorization: Bearer ACCESS_TOKEN" \
-H "content-type: application/json" 

Step 3: Get database ID

curl https://api.db.graphenedb.com/deployments/environments/{environmentId}/databases \
-H "authorization: Bearer ACCESS_TOKEN" \
-H "Content-Type: application/json" 

Step 4: Restart database

  • stationIds: please leave it empty
curl -X POST https://api.db.graphenedb.com/deployments/databases/graphneo/{databaseId}/restart \
-H "Content-Type: application/json" \
-H "authorization: Bearer ACCESS_TOKEN" \
-d '{"stationIds":[],"reset":true}'

Pause database

The example below will guide you through the steps needed to pause the database of your choice in the respective Environment, and save costs when the database is not in use.

Step 1: Get Access token

curl https://api.db.graphenedb.com/organizations/oauth/token \
-d "client_secret"="SECRET" \
-d "client_id"="ID" \
-d "grant_type"="client_credentials" 

Step 2: Get Environments (to get environmentId)

curl https://api.db.graphenedb.com/deployments/environments \
-H "authorization: Bearer ACCESS_TOKEN" \
-H "content-type: application/json" 

Step 3: Get database ID

curl https://api.db.graphenedb.com/deployments/environments/{environmentId}/databases \
-H "authorization: Bearer ACCESS_TOKEN" \
-H "Content-Type: application/json" 

Step 4: Pause database

curl -X POST https://api.db.graphenedb.com/deployments/databases/graphneo/{databaseId}/pause \
-H "authorization: Bearer ACCESS_TOKEN" \
-H "Content-Type: application/json"

Resume database

The example below will guide you through the steps needed to resume the paused database.

Step 1: Get Access token

curl https://api.db.graphenedb.com/organizations/oauth/token \
-d "client_secret"="SECRET" \
-d "client_id"="ID" \
-d "grant_type"="client_credentials" 

Step 2: Get Environments

curl https://api.db.graphenedb.com/deployments/environments \
-H "authorization: Bearer ACCESS_TOKEN" \
-H "content-type: application/json" 

Step 3: Get database ID

curl https://api.db.graphenedb.com/deployments/environments/{environmentId}/databases \
-H "authorization: Bearer ACCESS_TOKEN" \
-H "Content-Type: application/json" 

Step 4: Resume database

curl -X POST https://api.db.graphenedb.com/deployments/databases/graphneo/{databaseId}/start \
-H "authorization: Bearer ACCESS_TOKEN" \
-H "Content-Type: application/json" 

Clone database

The example below will guide you through the steps needed to clone the specific database into the Environment of your choice.

Step 1: Get Access token

curl https://api.db.graphenedb.com/organizations/oauth/token \
-d "client_secret"="SECRET" \
-d "client_id"="ID" \
-d "grant_type"="client_credentials" 

Step 2: Get Environments (to get environmentId)

curl https://api.db.graphenedb.com/deployments/environments \
-H "authorization: Bearer ACCESS_TOKEN" \
-H "content-type: application/json" 

Step 3: Get database ID

curl https://api.db.graphenedb.com/deployments/environments/{environmentId}/databases \
-H "authorization: Bearer ACCESS_TOKEN" \
-H "Content-Type: application/json" 

Step 4: Clone database

  • environmentId: the ID of the Environment you want the cloned database to be deployed into.
curl -X POST https://api.db.graphenedb.com/deployments/databases/graphneo/{databaseId}/clone \
-H "Content-Type: application/json" \
-H "authorization: Bearer ACCESS_TOKEN" \
-d '{"name": "string", "environmentId": "{environmentId}"}'

Create database from Snapshot

The example below will guide you through the steps needed to deploy a new database from a Snapshot taken from another database.

Step 1: Get Access token

curl https://api.db.graphenedb.com/organizations/oauth/token \
-d "client_secret"="SECRET" \
-d "client_id"="ID" \
-d "grant_type"="client_credentials" 

Step 2: Get Environments (to get environmentId)

curl https://api.db.graphenedb.com/deployments/environments \
-H "authorization: Bearer ACCESS_TOKEN" \
-H "content-type: application/json" 

Step 3: Get database ID

curl https://api.db.graphenedb.com/deployments/environments/{environmentId}/databases \
-H "authorization: Bearer ACCESS_TOKEN" \
-H "Content-Type: application/json" 

Step 4: Get Snapshot ID

curl https://api.db.graphenedb.com/deployments/databases/graphneo/{databaseId}/snapshots/manual \
-H "authorization: Bearer ACCESS_TOKEN" \
-H "Content-Type: application/json" 

Step 5: Create database from Snapshot

  • snapshotEnvironmentID: The ID of the Environment, where the database is deployed from which the snapshot was taken.
  • environmentID: The ID of the Environment where the new database will get deployed.
curl -X POST https://api.db.graphenedb.com/deployments/databases/graphneo/restore \
-H "authorization: Bearer ACCESS_TOKEN" \
-H "content-type: application/json" \
-d '{"snapshotId": "string", "snapshotEnvironmentId": "{environmentId}", "environmentId": "{environmentId}", "name": "string"}'

All other configuration for the database like plan, version, etc. will be retrieved from the Snapshot itself, and cannot be changed.

Restore database from Snapshot

The example below will guide you through the steps needed to restore Snapshot into the target database (same or different database).

Step 1: Get Access token

curl https://api.db.graphenedb.com/organizations/oauth/token \
-d "client_secret"="SECRET" \
-d "client_id"="ID" \
-d "grant_type"="client_credentials" 

Step 2: Get Environments (to get environmentId)

curl https://api.db.graphenedb.com/deployments/environments \
-H "authorization: Bearer ACCESS_TOKEN" \
-H "content-type: application/json" 

Step 3: Get database ID

curl https://api.db.graphenedb.com/deployments/environments/{environmentId}/databases \
-H "authorization: Bearer ACCESS_TOKEN" \
-H "Content-Type: application/json" 

Step 4: Get Snapshot ID

curl https://api.db.graphenedb.com/deployments/databases/graphneo/{databaseId}/snapshots/manual \
-H "authorization: Bearer ACCESS_TOKEN" \
-H "Content-Type: application/json" 

Step 5: Restore database from Snapshot

  • databaseId: The ID of the target database
  • snapshotEnvironmentID: The ID of the Environment, where the database is deployed from which the snapshot was taken.
curl -X POST https://api.db.graphenedb.com/deployments/databases/graphneo/{databaseId}/restore \
-H "Content-Type: application/json" \
-H "authorization: Bearer ACCESS_TOKEN" \
-d '{"snapshotId": "string","snapshotEnvironmentId": "{environmentId}"}'

Delete database

The example below will guide you through the steps needed to terminate the specific database.

Step 1: Get Access token

curl https://api.db.graphenedb.com/organizations/oauth/token \
-d "client_secret"="SECRET" \
-d "client_id"="ID" \
-d "grant_type"="client_credentials" 

Step 2: Get Environments

curl https://api.db.graphenedb.com/deployments/environments \
-H "authorization: Bearer ACCESS_TOKEN" \
-H "content-type: application/json" 

Step 3: Get database ID

curl https://api.db.graphenedb.com/deployments/environments/{environmentId}/databases \
-H "authorization: Bearer ACCESS_TOKEN" \
-H "Content-Type: application/json" 

Step 4: Terminate database

curl -X DELETE https://api.db.graphenedb.com/deployments/databases/graphneo/{databaseId} \
-H "authorization: Bearer ACCESS_TOKEN" \
-H "Content-Type: application/json"

Disaster recovery

This disaster recovery example includes Cloning database (which will create a snapshot and a clone) and Switching DNS from origin database to a cloned database.

Step 1: Get Access token

curl https://api.db.graphenedb.com/organizations/oauth/token \
-d "client_secret"="SECRET" \
-d "client_id"="ID" \
-d "grant_type"="client_credentials" 

Step 2: Get Environments (to get environmentId)

curl https://api.db.graphenedb.com/deployments/environments \
-H "authorization: Bearer ACCESS_TOKEN" \
-H "content-type: application/json" 

Step 3: Get database ID

curl https://api.db.graphenedb.com/deployments/environments/{environmentId}/databases \
-H "authorization: Bearer ACCESS_TOKEN" \
-H "Content-Type: application/json" 

Step 4. Clone database

  • environmentId: the ID of the Environment you want the cloned database to be deployed into.
curl -X POST https://api.db.graphenedb.com/deployments/databases/graphneo/{databaseId}/clone \
-H "Content-Type: application/json" \
-H "authorization: Bearer ACCESS_TOKEN" \
-d '{"name": "string", "environmentId": "{environmentId}"}'

Step 5: Switch DNS

  • databaseId: The ID of the origin database. Its connection urls will be switched to the target database.
  • target database (databaseId): The ID of the target database.
curl -X POST https://api.db.graphenedb.com/deployments/databases/graphneo/{databaseId}/connections/switch \
-H "Content-Type: application/json" \
-H "authorization: Bearer ACCESS_TOKEN" \
-d '{"targetDatabase": "{databaseId}"}'
Try out today and get $50 in CreditsTry out today and get $50
Check
Evaluate for free
Check
Pay as you go
Check
No hidden costs