Skip to content

Commit 1c210e1

Browse files
committed
Initial commit of workflow invocation docs
1 parent 3fb007b commit 1c210e1

File tree

2 files changed

+46
-16
lines changed

2 files changed

+46
-16
lines changed

docs-v2/pages/connect/api.mdx

Lines changed: 45 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,25 @@ or a specific version:
4343

4444
## Authentication
4545

46+
### OAuth
47+
48+
TO DO
49+
50+
### Project keys
51+
52+
You authenticate to the Connect API using **Basic Auth**. Send your project public key as the username and the project secret key as the password. When you make API requests, pass an
53+
`Authorization` header of the following format:
54+
55+
```shell
56+
Authorization: Basic base_64(public_key:secret_key)
57+
```
58+
59+
Clients like `cURL` will often make this easy. For example, here's how you list all accounts on a project:
60+
61+
```shell
62+
curl 'https://api.pipedream.com/v1/connect/accounts' -u public_key:secret_key
63+
```
64+
4665
### TypeScript SDK (Server)
4766

4867
Most of your interactions with the Connect API will happen on the server, to protect API requests and user credentials. You'll use the SDK in [your frontend](#typescript-sdk-browser) to let users connect accounts. Once connected, you'll use the SDK on the server to retrieve credentials, invoke workflows on their behalf, and more.
@@ -102,21 +121,6 @@ export default function Home() {
102121
}
103122
```
104123

105-
### REST API
106-
107-
You authenticate to the Connect API using **Basic Auth**. Send your project public key as the username and the project secret key as the password. When you make API requests, pass an
108-
`Authorization` header of the following format:
109-
110-
```shell
111-
Authorization: Basic base_64(public_key:secret_key)
112-
```
113-
114-
Clients like `cURL` will often make this easy. For example, here's how you list all accounts on a project:
115-
116-
```shell
117-
curl 'https://api.pipedream.com/v1/connect/accounts' -u public_key:secret_key
118-
```
119-
120124
## External users
121125

122126
When you use the Connect API, you'll pass an `external_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.
@@ -136,6 +140,32 @@ If you need higher rate limits, please [reach out](https://pipedream.com/support
136140

137141
## API Reference
138142

143+
### Invoke workflows
144+
145+
You can use the SDK to invoke workflows on behalf of your users. Here's an example of invoking a workflow with the SDK:
146+
147+
```typescript
148+
import { createClient } from "@pipedream/sdk";
149+
150+
const pd = createClient({
151+
oauthClientId: "your-oauth-client-id",
152+
oauthClientSecret: "your-oauth-client-secret",
153+
});
154+
155+
const response = await pd.invokeWorkflow(
156+
"https://your-workflow-url.m.pipedream.net",
157+
{
158+
body: {
159+
foo: 123,
160+
bar: "abc",
161+
},
162+
// pass any other fetch options here
163+
},
164+
);
165+
```
166+
167+
`invokeWorkflow` uses Node's `fetch` API, so you can pass any standard options in that object.
168+
139169
### Tokens
140170

141171
Your app will initiate the account connection flow for your end users in your frontend. But you can't expose your project keys in the client, since they'd be accessible to anyone. Instead, on your server, **you exchange your project keys for a short-lived token that allows a specific user to connect a specific app**, and return that token to your frontend.

packages/sdk/src/server/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -643,7 +643,7 @@ class ServerClient {
643643
* @example
644644
* ```typescript
645645
* const response: JSON = await client.invokeWorkflow(
646-
* "https://eoy64t2rbte1u2p.m.pipedream.net",
646+
* "https://en-your-endpoint.m.pipedream.net",
647647
* {
648648
* body: {
649649
* foo: 123,

0 commit comments

Comments
 (0)