Skip to content

Commit a802678

Browse files
DR-6257 Management API Docs Updates (#7389)
* usage endpoint * direct connection string documented * code rabbit comment applied
1 parent 980e2ec commit a802678

File tree

1 file changed

+89
-0
lines changed

1 file changed

+89
-0
lines changed

content/250-postgres/100-introduction/230-management-api.mdx

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,59 @@ Create a new project.
204204
"name": "My Project"
205205
}
206206
```
207+
- **Response body**:
208+
```json
209+
{
210+
"data": {
211+
"id": "proj_abc123",
212+
"type": "project",
213+
"name": "My Project",
214+
"createdAt": "2025-12-14T21:42:30.545Z",
215+
"workspace": {
216+
"id": "wksp_xyz789",
217+
"name": "My Workspace"
218+
},
219+
"database": {
220+
"id": "db_def456",
221+
"type": "database",
222+
"name": "My Project",
223+
"createdAt": "2025-12-14T21:42:30.545Z",
224+
"region": {
225+
"id": "us-east-1",
226+
"name": "US East (N. Virginia)"
227+
},
228+
"status": "ready",
229+
"connectionString": "prisma+postgres://accelerate.prisma-data.net/?api_key=...",
230+
"directConnection": {
231+
"host": "db.prisma.io:5432",
232+
"user": "your_user_id",
233+
"pass": "your_password"
234+
},
235+
"isDefault": true
236+
}
237+
}
238+
}
239+
```
240+
241+
The response includes a `directConnection` object with credentials for connecting directly to the underlying PostgreSQL database. Use these values to build your `DATABASE_URL`:
242+
243+
```
244+
postgresql://{user}:{pass}@{host}/postgres?sslmode=require
245+
```
246+
247+
For example, given the response above:
248+
```
249+
postgresql://your_user_id:[email protected]:5432/postgres?sslmode=require
250+
```
251+
252+
Set this as your `DATABASE_URL` environment variable in your `.env` file:
253+
254+
```env
255+
DATABASE_URL="postgresql://your_user_id:[email protected]:5432/postgres?sslmode=require"
256+
```
257+
258+
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.
259+
207260
- **Responses**:
208261
- `201 Created`: Project created
209262
- `401 Unauthorized`
@@ -314,6 +367,42 @@ Delete a database.
314367
- `403 Cannot delete default environment`
315368
- `404 Not Found`
316369

370+
#### `GET /databases/{databaseId}/usage`
371+
372+
Get usage metrics for a database.
373+
374+
- **Path parameters**:
375+
- `databaseId`: Database ID
376+
- **Query parameters**:
377+
- `startDate` (optional): Start date for the usage period
378+
- `endDate` (optional): End date for the usage period
379+
- **Response body**:
380+
```json
381+
{
382+
"period": {
383+
"start": "2025-12-01T00:00:00.000Z",
384+
"end": "2025-12-14T21:39:23.331Z"
385+
},
386+
"metrics": {
387+
"operations": {
388+
"used": 0,
389+
"unit": "ops"
390+
},
391+
"storage": {
392+
"used": 0,
393+
"unit": "GiB"
394+
}
395+
},
396+
"generatedAt": "2025-12-14T21:39:23.331Z"
397+
}
398+
```
399+
- **Responses**:
400+
- `200 OK`: Usage metrics returned
401+
- `400 Bad Request`: Invalid request parameters
402+
- `401 Unauthorized`
403+
- `404 Not Found`
404+
- `500 Internal Server Error`: Error occurred while fetching metrics
405+
317406
### Connection strings
318407

319408
#### `GET /databases/{databaseId}/connections`

0 commit comments

Comments
 (0)