Skip to content

Commit 079a077

Browse files
dylburgerlcaresia
authored andcommitted
Fixing docs to reference X-PD-Environment
1 parent fd9047c commit 079a077

File tree

2 files changed

+60
-1
lines changed

2 files changed

+60
-1
lines changed

docs-v2/pages/connect/api.mdx

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,36 @@ export default function Home() {
102102
}
103103
```
104104

105+
## Environment
106+
107+
Some API endpoints accept an [environment](/connect/environments) parameter. This lets you specify the environment (`production` or `development`) where resources will live in your project.
108+
109+
You can set the environment when you create the SDK client:
110+
111+
```typescript
112+
import { createBackendClient } from "@pipedream/sdk";
113+
114+
const pd = createBackendClient({
115+
environment: "development", // change to production if running for a test production account, or in production
116+
credentials: {
117+
clientId: "your-oauth-client-id",
118+
clientSecret: "your-oauth-client-secret",
119+
}
120+
});
121+
```
122+
123+
or pass the `X-PD-Environment` header in HTTP requests:
124+
125+
```bash
126+
curl -X POST https://api.pipedream.com/v1/connect/{project_id}/tokens \
127+
-H "Content-Type: application/json" \
128+
-H "X-PD-Environment: development" \
129+
-H "Authorization: Bearer {access_token}" \
130+
-d '{
131+
"external_user_id": "your-external-user-id"
132+
}'
133+
```
134+
105135
## External users
106136

107137
When you use the Connect API, you'll pass an `external_user_id` parameter when initiating account connections and retrieving credentials. This is your user's ID, in your system — whatever you use to uniquely identify them.
@@ -245,6 +275,7 @@ import {
245275
} from "@pipedream/sdk";
246276

247277
const pd = createBackendClient({
278+
environment: "development", // change to production if running for a test production account, or in production
248279
credentials: {
249280
clientId: "your-oauth-client-id",
250281
clientSecret: "your-oauth-client-secret",
@@ -262,6 +293,7 @@ const { token, expires_at } = await pd.createConnectToken({
262293
import { createBackendClient } from "@pipedream/sdk";
263294

264295
const pd = createBackendClient({
296+
environment: "development", // change to production if running for a test production account, or in production
265297
credentials: {
266298
clientId: "your-oauth-client-id",
267299
clientSecret: "your-oauth-client-secret",
@@ -289,6 +321,7 @@ curl -X POST https://api.pipedream.com/v1/oauth/token \
289321

290322
curl -X POST https://api.pipedream.com/v1/connect/{project_id}/tokens \
291323
-H "Content-Type: application/json" \
324+
-H "X-PD-Environment: development" \
292325
-H "Authorization: Bearer {access_token}" \
293326
-d '{
294327
"external_user_id": "your-external-user-id"

docs-v2/pages/connect/environments.mdx

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,30 @@ Pipedream Connect projects support two environments: `development` and `producti
77

88
## How to specify environment
99

10-
You specify the environment when [creating a new Connect token](/connect/api/#create-a-new-token) with the Pipedream SDK or API. By default, the enviromment is set to `production`. When users succesfully connect their account, Pipedream saves it for that `external_user_id` in the specified `environment_name`.
10+
You specify the environment when [creating a new Connect token](/connect/api/#create-a-new-token) with the Pipedream SDK or API. By default, the enviromment is set to `production`. When users succesfully connect their account, Pipedream saves it for that `external_user_id` in the specified environment.
11+
12+
You can set the environment when you create the SDK client:
13+
14+
```typescript
15+
import { createBackendClient } from "@pipedream/sdk";
16+
17+
const pd = createBackendClient({
18+
environment: "development", // change to production if running for a test production account, or in production
19+
credentials: {
20+
clientId: "your-oauth-client-id",
21+
clientSecret: "your-oauth-client-secret",
22+
}
23+
});
24+
```
25+
26+
or pass the `X-PD-Environment` header in HTTP requests:
27+
28+
```bash
29+
curl -X POST https://api.pipedream.com/v1/connect/{project_id}/tokens \
30+
-H "Content-Type: application/json" \
31+
-H "X-PD-Environment: development" \
32+
-H "Authorization: Bearer {access_token}" \
33+
-d '{
34+
"external_user_id": "your-external-user-id"
35+
}'
36+
```

0 commit comments

Comments
 (0)