apps/docs/content/docs.v6/postgres/introduction/management-api.mdx
This page covers the Prisma Management API which enables you to programmatically manage platform resources (e.g. projects or Prisma Postgres instances) in Prisma Console.
:::tip[TypeScript SDK]
The @prisma/management-api-sdk provides a typed TypeScript client with built-in OAuth authentication and automatic token refresh. It's the recommended way to interact with the Management API in TypeScript/JavaScript applications.
:::
:::tip[OpenAPI] An interactive OpenAPI 3.1 specification is available here, where you can explore endpoints, request/response bodies, and detailed examples. :::
:::tip[Guides] We have three guides to help you use the Management API for common scenarios:
The base URL for a Prisma Postgres API request is:
https://api.prisma.io/v1
Append an endpoint path to the base URL to construct the full URL for a request. For example:
https://api.prisma.io/v1/projects/{projectId}
The Prisma Postgres API supports two authentication methods:
Service tokens are manually created in your Prisma Console workspace. They're ideal for server-to-server integrations or provisioning databases in your own workspace.
To authenticate with a service token, include it in the Authorization header:
Authorization: Bearer $TOKEN
Use OAuth 2.0 if you want to act on behalf of users and create or manage databases directly in their workspaces.
To obtain a client ID and client secret:
To use OAuth 2.0, your application must:
Redirect users to the authorization URL with your client ID and redirect URI:
https://auth.prisma.io/authorize?client_id=$CLIENT_ID&redirect_uri=$REDIRECT_URI&response_type=code&scope=workspace:admin
Receive the authorization code: After the user authorizes your application, they'll be redirected to your redirect URI with a code parameter:
https://your-app.com/callback?code=abc123...
Exchange the code for an access token: Use the code from step 2 in the following request
curl -X POST https://auth.prisma.io/token \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "client_id=$CLIENT_ID" \
-d "client_secret=$CLIENT_SECRET" \
-d "code=$CODE" \
-d "grant_type=authorization_code" \
-d "redirect_uri=$REDIRECT_URI"
:::note
The $CODE is the authorization code received in step 2 above. The $REDIRECT_URI must match exactly what you configured when creating your OAuth credentials.
:::
Once you have an access token from the response, include it in requests to the Management API:
curl --location "https://api.prisma.io/v1/projects" \
-H "Accept: application/json" \
-H "Authorization: Bearer $ACCESS_TOKEN" \
-H "Content-Type: application/json" \
--data '{
"name": "my_project",
"region": "us-east-1"
}'
https://auth.prisma.io/authorizeworkspace:admin offline_access (as needed)The Swagger spec supports a Bearer token via the
Authorizationheader.
clientId, clientSecret, and redirect URI.GET /workspacesRetrieve information about the workspaces accessible by the current user.
cursor (optional): Cursor for paginationlimit (optional, default: 100): Limit number of results200 OK: List of workspaces401 Unauthorized: Invalid or missing authentication tokenGET /projectsRetrieve all projects.
cursor (optional): Cursor for paginationlimit (optional, default: 100): Limit number of results200 OK: List of projects401 UnauthorizedPOST /projectsCreate a new project.
Request body:
{
"region": "us-east-1",
"name": "My Project"
}
Response body:
{
"data": {
"id": "proj_abc123",
"type": "project",
"name": "My Project",
"createdAt": "2025-12-14T21:42:30.545Z",
"workspace": {
"id": "wksp_xyz789",
"name": "My Workspace"
},
"database": {
"id": "db_def456",
"type": "database",
"name": "My Project",
"createdAt": "2025-12-14T21:42:30.545Z",
"region": {
"id": "us-east-1",
"name": "US East (N. Virginia)"
},
"status": "ready",
"connectionString": "prisma+postgres://accelerate.prisma-data.net/?api_key=...",
"directConnection": {
"host": "db.prisma.io:5432",
"user": "your_user_id",
"pass": "your_password"
},
"isDefault": true
}
}
}
The response includes a directConnection object with credentials for connecting directly to the underlying PostgreSQL database. Use these values to build your DATABASE_URL:
postgresql://{user}:{pass}@{host}/postgres?sslmode=require
For example, given the response above:
postgresql://your_user_id:[email protected]:5432/postgres?sslmode=require
Set this as your DATABASE_URL environment variable in your .env file:
DATABASE_URL="postgresql://your_user_id:[email protected]:5432/postgres?sslmode=require"
This direct connection string is the recommended way to connect to your Prisma Postgres database for all use cases including Prisma Client, migrations, and direct database access.
Responses:
201 Created: Project created401 UnauthorizedGET /projects/{id}Retrieve a specific project by ID.
id: Project ID200 OK401 Unauthorized404 Not FoundDELETE /projects/{id}Deletes a project.
id: Project ID204 No Content400 Bad Request: Dependencies prevent deletion401 Unauthorized404 Not FoundPOST /projects/{id}/transferTransfer a project to a new workspace owner.
id: Project ID{
"recipientAccessToken": "string"
}
200 OK401 Unauthorized404 Not FoundGET /projects/{projectId}/databasesRetrieve all databases for a project.
projectId: Project IDcursor (optional): Cursor for paginationlimit (optional, default: 100): Limit number of results200 OK401 Unauthorized404 Not FoundPOST /projects/{projectId}/databasesCreate a new database.
projectId: Project ID{
"region": "us-east-1",
"name": "My Database",
"isDefault": false,
"fromDatabase": {
"id": "databaseId",
"backupId": "string"
}
}
fromDatabase only when creating the database from an existing one or a backup.
:::201 Created400 Default database already exists401 Unauthorized403 ForbiddenGET /databases/{databaseId}Retrieve a specific database.
databaseId: Database ID200 OK401 Unauthorized404 Not FoundDELETE /databases/{databaseId}Delete a database.
databaseId: Database ID200 OK401 Unauthorized403 Cannot delete default environment404 Not FoundGET /databases/{databaseId}/usageGet usage metrics for a database.
databaseId: Database IDstartDate (optional): Start date for the usage periodendDate (optional): End date for the usage period{
"period": {
"start": "2025-12-01T00:00:00.000Z",
"end": "2025-12-14T21:39:23.331Z"
},
"metrics": {
"operations": {
"used": 0,
"unit": "ops"
},
"storage": {
"used": 0,
"unit": "GiB"
}
},
"generatedAt": "2025-12-14T21:39:23.331Z"
}
200 OK: Usage metrics returned400 Bad Request: Invalid request parameters401 Unauthorized404 Not Found500 Internal Server Error: Error occurred while fetching metricsGET /databases/{databaseId}/connectionsRetrieve all database connection strings.
databaseId: Database IDcursor (optional): Cursor for paginationlimit (optional, default: 100): Limit number of results200 OK401 UnauthorizedPOST /databases/{databaseId}/connectionsCreate a new connection string.
Path parameters:
databaseId: Database IDRequest body:
{
"name": "Connection Name"
}
Responses:
200 OK401 Unauthorized404 Not FoundDELETE /connections/{id}Delete a connection string.
id: Connection ID204 No Content401 Unauthorized404 Not FoundGET /databases/{databaseId}/backupsRetrieve database backups.
databaseId: Database IDlimit (optional, default: 25): Limit number of results200 OK401 Unauthorized404 Not FoundGET /workspaces/{workspaceId}/integrationsRetrieve integrations for the given workspace.
workspaceId: Workspace IDcursor (optional): Cursor for paginationlimit (optional, default: 100): Limit number of results200 OK: List of integrations with details:
id: Integration IDcreatedAt: Creation timestampscopes: Array of granted scopesclient: Object containing id, name, createdAtcreatedByUser: Object containing id, email, displayName401 Unauthorized: Missing or invalid authentication token404 Not Found: Workspace not foundDELETE /workspaces/{workspaceId}/integrations/{clientId}Revokes the integration tokens with the given client ID.
workspaceId: Workspace ID (e.g. wksp_1234)clientId: Integration client ID (e.g. itgr_5678)204 No Content: Integration tokens revoked successfully401 Unauthorized: Missing or invalid authentication token404 Not Found: Workspace or integration not foundGET /regions/postgresRetrieve all available regions.
200 OK: Returns list of available/unsupported regions401 Unauthorized