Skip to content

Commit e30bfde

Browse files
updated docs
1 parent 4afe5e1 commit e30bfde

File tree

1 file changed

+48
-36
lines changed

1 file changed

+48
-36
lines changed

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

Lines changed: 48 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ We have three guides to help you use the Management API for common scenarios:
2020
- [Partner database provisioning & user claim flow](/guides/management-api)
2121
:::
2222

23-
2423
## Base URL
2524

2625
The base URL for a Prisma Postgres API request is:
@@ -37,52 +36,65 @@ https://api.prisma.io/v1/projects/{projectId}
3736

3837
## Authentication
3938

40-
### Bearer tokens
39+
The Prisma Postgres API supports two authentication methods:
40+
41+
- **Service tokens** — for accessing resources in your own workspace
42+
- **OAuth 2.0 access tokens** — for accessing or managing resources on behalf of users
43+
44+
### Service tokens
4145

42-
The Prisma Postgres API uses _Bearer Token Authentication_ and supports two kinds of tokens:
43-
- Service tokens (manually created in your [Prisma Console](https://console.prisma.io) workspace)
44-
- OAuth 2 access tokens
46+
Service tokens are manually created in your [Prisma Console](https://console.prisma.io) workspace. They're ideal for server-to-server integrations or provisioning databases in your own workspace.
4547

46-
To adhere to the Bearer Token Authentication, you need to format your `Authorization` header like this:
48+
To authenticate with a service token, include it in the `Authorization` header:
4749

4850
```
4951
Authorization: Bearer $TOKEN
5052
```
5153

5254
#### Creating a service token
5355

54-
You can create a service token to use the Management API like this:
55-
5656
1. Open the [Prisma Console](https://console.prisma.io/).
5757
2. Navigate to your workspace.
58-
3. Navigate to the **Settings** page of your workspace and select **Service Tokens**.
59-
4. Click **New Service Token**.
60-
5. Copy the generated token and store it in a safe location for future use.
58+
3. Go to the **Settings** page of your workspace and select **Service Tokens**.
59+
4. Click **New Service Token** and copy the generated token for future use.
60+
61+
### OAuth 2.0 authentication
62+
63+
Use OAuth 2.0 if you want to act on behalf of users and create or manage databases directly in their workspaces.
6164

6265
#### Creating OAuth credentials
6366

64-
To obtain a client ID and client secret, go through this flow:
67+
To obtain a client ID and client secret:
6568

6669
1. Open the [Prisma Console](https://console.prisma.io).
67-
1. Click the 🧩 **Integrations** tab in the sidenav.
68-
1. In the **Published Applications** section, click the **New Application** button to start creating a new OAuth app.
69-
1. Enter a **Name**, **Description**, and **Callback URL** for your OAuth app.
70-
1. Click **Continue**.
71-
72-
On the next screen, copy and store the client ID and client secret for your OAuth app in a secure location.
70+
2. Click the 🧩 **Integrations** tab.
71+
3. Under **Published Applications**, click **New Application**.
72+
4. Enter a **Name**, **Description**, and **Callback URL**.
73+
5. Click **Continue**, then copy and store your **Client ID** and **Client Secret**.
74+
75+
#### Example: exchange a code for an access token
76+
77+
```bash
78+
curl -X POST https://auth.prisma.io/token \
79+
-H "Content-Type: application/x-www-form-urlencoded" \
80+
-d "client_id=$CLIENT_ID" \
81+
-d "client_secret=$CLIENT_SECRET" \
82+
-d "code=$CODE" \
83+
-d "grant_type=authorization_code" \
84+
-d "redirect_uri=$REDIRECT_URI"
85+
```
7386

74-
### Example
87+
Once you have an access token, include it in requests to the Management API:
7588

76-
```terminal
89+
```bash
7790
curl --location "https://api.prisma.io/v1/projects" \
7891
-H "Accept: application/json" \
79-
-H "Authorization: Bearer $TOKEN" \
92+
-H "Authorization: Bearer $ACCESS_TOKEN" \
8093
-H "Content-Type: application/json" \
81-
--data \
82-
"{
83-
\"name\": \"my_project\",
84-
\"region\": \"us-east-1\"
85-
}"
94+
--data '{
95+
"name": "my_project",
96+
"region": "us-east-1"
97+
}'
8698
```
8799

88100
### Instructions
@@ -101,13 +113,14 @@ curl --location "https://api.prisma.io/v1/projects" \
101113

102114
1. In the **Authorization** tab, set type to **OAuth 2.0**.
103115
2. Click **Get New Access Token** and fill in the details:
104-
- **Token Name**: Any name
105-
- **Grant Type**: Authorization Code
106-
- **Callback URL**: `http://localhost:8789/swagger/oauth2-redirect.html`
107-
- **Auth URL** / **Access Token URL**: Your local OAuth URLs
108-
- **Client ID / Secret**: From the script output
109-
- **Scope**: (as needed)
110-
1. After completing the flow, use the token in your requests.
116+
- **Token Name**: Any name
117+
- **Grant Type**: Authorization Code
118+
- **Callback URL**: Your app’s redirect URI
119+
- **Auth URL**: `https://auth.prisma.io/authorize`
120+
- **Access Token URL**: `https://auth.prisma.io/token`
121+
- **Client ID / Secret**: From your OAuth app
122+
- **Scope**: `workspace:admin offline_access` (as needed)
123+
3. Complete the flow and use the token in your requests.
111124

112125
</details>
113126

@@ -360,7 +373,6 @@ Retrieve integrations for the given workspace.
360373
- `401 Unauthorized`: Missing or invalid authentication token
361374
- `404 Not Found`: Workspace not found
362375

363-
364376
#### `DELETE /workspaces/{workspaceId}/integrations/{clientId}`
365377

366378
Revokes the integration tokens with the given client ID.
@@ -383,7 +395,7 @@ Retrieve all available regions.
383395
- `200 OK`: Returns list of available/unsupported regions
384396
- `401 Unauthorized`
385397

386-
<!-- ## Management API playground
398+
{/* ## Management API playground
387399
388400
You can explore and interact with all endpoints in a live Swagger UI playground.
389401
@@ -401,4 +413,4 @@ Use your service token or OAuth 2.0 access token to authorize requests in the UI
401413
overflow: 'hidden'
402414
}}
403415
title="Prisma API Swagger Editor"
404-
></iframe> -->
416+
></iframe> */}

0 commit comments

Comments
 (0)