Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
89 changes: 89 additions & 0 deletions content/250-postgres/100-introduction/230-management-api.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,59 @@ Create a new project.
"name": "My Project"
}
```
- **Response body**:
```json
{
"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:

```env
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 created
- `401 Unauthorized`
Expand Down Expand Up @@ -314,6 +367,42 @@ Delete a database.
- `403 Cannot delete default environment`
- `404 Not Found`

#### `GET /databases/{databaseId}/usage`

Get usage metrics for a database.

- **Path parameters**:
- `databaseId`: Database ID
- **Query parameters**:
- `startDate` (optional): Start date for the usage period
- `endDate` (optional): End date for the usage period
- **Response body**:
```json
{
"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"
}
```
- **Responses**:
- `200 OK`: Usage metrics returned
- `400 Bad Request`: Invalid request parameters
- `401 Unauthorized`
- `404 Not Found`
- `500 Internal Server Error`: Error occurred while fetching metrics

### Connection strings

#### `GET /databases/{databaseId}/connections`
Expand Down
Loading