Skip to main content
Prisma Documentation Docs

Search documentation

Type to search this documentation.

Create database

POST/v1/databasesCreate database

Creates a new database in the specified project. logicalId cannot be combined with branchGitName; pass branchId instead.

Request body

application/json
object
branchGitNamenull | string

Git name of the Branch to attach the database to; the Branch is created when it does not exist. Mutually exclusive with branchId. Omit to attach to the project's default Branch. Every database belongs to a Branch, so null is rejected.

minLength 1

branchIdnull | string

ID of the Branch to attach the database to. Omit to attach the database to the project's default Branch. Every database belongs to a Branch, so null is rejected.

pattern ^(br_)?([cC][^\s-]{8,}|[a-z0-9]+)$

isDefaultboolean

Whether this is the default database

default false

logicalIdstring

Declared identity of the resource, unique within its branch. Set by the tool that declares the resource.

maxLength 255 · pattern ^[A-Za-z0-9][A-Za-z0-9._-]*$

namestring

Display name for the database

minLength 1

projectIdstringrequired

ID of the project to create the database in

pattern ^(proj_)?([cC][^\s-]{8,}|[a-z0-9]+)$

regionstring

Use "inherit" to use the project's default region (falls back to the default database's region for projects without one).

one of "us-east-1", "us-west-1", "eu-west-3", "eu-central-1", "ap-northeast-1", "ap-southeast-1", "inherit" · default "us-east-1"

sourcevalue

Source to create the database from. Omit to create an empty database.

Show child attributes
oneOf · 3 options
Option 1object
typestringrequired

const "empty"

Option 2object
backupIdstringrequired

ID of the backup to restore from

databaseIdstringrequired

ID of the database the backup belongs to

pattern ^(db_)?([cC][^\s-]{8,}|[a-z0-9]+)$

typestringrequired

const "backup"

Option 3object
databaseIdstringrequired

ID of the database to clone from

pattern ^(db_)?([cC][^\s-]{8,}|[a-z0-9]+)$

typestringrequired

const "database"

Example request
{
  "branchGitName": "string",
  "branchId": "string",
  "isDefault": false,
  "logicalId": "string",
  "name": "string",
  "projectId": "string",
  "region": "us-east-1",
  "source": {
    "databaseId": "string",
    "type": "database"
  }
}

Responses

201Created a new database.application/json
object
dataobjectrequired
Show child attributes
branchIdnull | stringrequired
connectionsarray of objectrequired
Show child attributes
Show array items
createdAtstring · date-timerequired
databaseobjectrequired
Show child attributes
idstringrequired
namestringrequired
urlstring · urirequired
directConnectionnull | object

Deprecated: use `endpoints.direct` instead.

Show child attributes
hoststringrequired
passstringrequired
userstringrequired
endpointsobjectrequired
Show child attributes
accelerateobject
Show child attributes
connectionStringstring
hoststringrequired
portnumberrequired
directobject
Show child attributes
connectionStringstring
hoststringrequired
portnumberrequired
pooledobject
Show child attributes
connectionStringstring
hoststringrequired
portnumberrequired
idstringrequired

pattern ^(con_)([cC][^\s-]{8,}|[a-z0-9]+)$

kindstringrequired

one of "postgres", "accelerate"

namestringrequired
typestringrequired

const "connection"

urlstring · urirequired
createdAtstring · date-timerequired
defaultConnectionIdnull | stringrequired

pattern ^(con_)([cC][^\s-]{8,}|[a-z0-9]+)$

idstringrequired
isDefaultbooleanrequired
logicalIdnull | stringrequired
namestringrequired
projectobjectrequired
Show child attributes
idstringrequired
namestringrequired
urlstring · urirequired
regionnull | objectrequired
Show child attributes
idstringrequired
namestringrequired
sourcevaluerequired
Show child attributes
oneOf · 4 options
Option 1object
typestringrequired

const "empty"

Option 2object
backupIdstringrequired

ID of the backup to restore from

databaseIdstringrequired
typestringrequired

const "backup"

Option 3object
databaseIdstringrequired
typestringrequired

const "database"

Option 4nullnullable
statusstringrequired

one of "failure", "provisioning", "ready", "recovering"

typestringrequired

const "database"

urlstring · urirequired
Example response
{
  "data": {
    "branchId": "string",
    "connections": [
      {
        "createdAt": "2026-06-09T00:00:00Z",
        "database": {
          "id": "string",
          "name": "string",
          "url": "https://example.com"
        },
        "directConnection": {
          "host": "string",
          "pass": "string",
          "user": "string"
        },
        "endpoints": {
          "accelerate": {
            "connectionString": "string",
            "host": "string",
            "port": 0
          },
          "direct": {
            "connectionString": "string",
            "host": "string",
            "port": 0
          },
          "pooled": {
            "connectionString": "string",
            "host": "string",
            "port": 0
          }
        },
        "id": "string",
        "kind": "accelerate",
        "name": "string",
        "type": "connection",
        "url": "https://example.com"
      }
    ],
    "createdAt": "2026-06-09T00:00:00Z",
    "defaultConnectionId": "string",
    "id": "string",
    "isDefault": true,
    "logicalId": "string",
    "name": "string",
    "project": {
      "id": "string",
      "name": "string",
      "url": "https://example.com"
    },
    "region": {
      "id": "string",
      "name": "string"
    },
    "source": {
      "backupId": "string",
      "databaseId": "string",
      "type": "backup"
    },
    "status": "failure",
    "type": "database",
    "url": "https://example.com"
  }
}
400Invalid request parameters.application/json
object
errorobjectrequired
Show child attributes
codestringrequired
hintstring
messagestringrequired
Example response
{
  "error": {
    "code": "string",
    "hint": "string",
    "message": "string"
  }
}
401Missing or invalid authorization token.application/json
object
errorobjectrequired
Show child attributes
codestringrequired
hintstring
messagestringrequired
Example response
{
  "error": {
    "code": "string",
    "hint": "string",
    "message": "string"
  }
}
403Actor does not have access to the specified project.application/json
object
errorobjectrequired
Show child attributes
codestringrequired
hintstring
messagestringrequired
Example response
{
  "error": {
    "code": "string",
    "hint": "string",
    "message": "string"
  }
}
404Project not found.application/json
object
errorobjectrequired
Show child attributes
codestringrequired
hintstring
messagestringrequired
Example response
{
  "error": {
    "code": "string",
    "hint": "string",
    "message": "string"
  }
}
409A database with the same `logicalId` already exists on the branch.application/json
object
errorobjectrequired
Show child attributes
codestringrequired
hintstring
messagestringrequired
Example response
{
  "error": {
    "code": "string",
    "hint": "string",
    "message": "string"
  }
}
413Request body exceeds this endpoint's size cap.application/json
object
errorobjectrequired
Show child attributes
codestringrequired
hintstring
messagestringrequired
Example response
{
  "error": {
    "code": "string",
    "hint": "string",
    "message": "string"
  }
}
Documentation menu