@@ -38,13 +38,68 @@ You can skip steps 1 and 2 if you already know the component you want to use or
3838
3939<Steps >
4040
41+ ### Authenticate to the Pipedream API  
42+ 
43+ Before sending requests to the API, make sure to [ authenticate using a Pipedream OAuth client] ( /rest-api/auth#oauth ) :
44+ 
45+ <Tabs  items = { [' Node.js' ' HTTP (cURL)' } >
46+ <Tabs.Tab >
47+ ``` javascript 
48+ //  Initialize the Pipedream client with the SDK
49+ 
50+ import  { createBackendClient  } from  " @pipedream/sdk/server" 
51+ 
52+ const  pd  =  createBackendClient ({
53+   environment:  " development | production" 
54+   credentials:  {
55+     clientId:  " {oauth_client_id}" 
56+     clientSecret:  " {oauth_client_secret}" 
57+   },
58+   projectId:  " {your_project_id}" 
59+ });
60+ ``` 
61+ </Tabs.Tab >
62+ <Tabs.Tab >
63+ ``` bash 
64+ #  Get an access token for the REST API
65+ 
66+ curl -X POST https://api.pipedream.com/v1/oauth/token \
67+   -H " Content-Type: application/json" 
68+   -d ' {
69+     "grant_type": "client_credentials", 
70+     "client_id": "{your_oauth_client_id}", 
71+     "client_secret": "{your_oauth_client_secret}" 
72+   }'  
73+ ``` 
74+ </Tabs.Tab >
75+ </Tabs >
76+ 
77+ <Callout  type = " info" 
78+ All subsequent examples assume that you've either initialized the SDK client or have a valid access token.
79+ </Callout >
80+ 
4181### Find the app you want to use  
4282
43- In order to  find the right trigger or action to configure and run, you  first need to  find the app. In this example, we'll search for ` gitlab ` .
83+ To  find the right trigger or action to configure and run, first find the app. In this example, we'll search for ` gitlab ` .
4484
45- ``` text 
46- GET /v1/connect/apps?q=gitlab 
85+ <Tabs  items = { [' Node.js' ' HTTP (cURL)' } >
86+ <Tabs.Tab >
87+ ``` javascript 
88+ const  apps  =  await  pd .getApps ({ q:  " gitlab" 
89+ 
90+ //  Parse and return the data you need
91+ ``` 
92+ </Tabs.Tab >
93+ <Tabs.Tab >
94+ ``` bash 
95+ curl -X https://api.pipedream.com/v1/apps? q=gitlab \
96+   -H " Content-Type: application/json" 
97+   -H " Authorization: Bearer {access_token}" 
98+ 
99+ #  Parse and return the data you need
47100``` 
101+ </Tabs.Tab >
102+ </Tabs >
48103
49104Here's the response:
50105
@@ -77,9 +132,25 @@ Here's the response:
77132
78133Once you have the app you want to use, now you can list the triggers and/or actions for that app. We'll list the actions for Gitlab and we'll pass the ` name_slug `  ` gitlab `  as the ` app ` .
79134
80- ``` text 
81- GET /actions?app=gitlab 
135+ <Tabs  items = { [' Node.js' ' HTTP (cURL)' } >
136+ <Tabs.Tab >
137+ ``` javascript 
138+ const  components  =  await  pd .getComponents ({ q:  " gitlab" 
139+ 
140+ //  Parse and return the data you need
82141``` 
142+ </Tabs.Tab >
143+ <Tabs.Tab >
144+ ``` bash 
145+ curl -X https://api.pipedream.com/v1/connect/{project_id}/actions? app=gitlab \
146+   -H " Content-Type: application/json" 
147+   -H " X-PD-Environment: development" 
148+   -H " Authorization: Bearer {access_token}" 
149+ 
150+ #  Parse and return the data you need
151+ ``` 
152+ </Tabs.Tab >
153+ </Tabs >
83154
84155Here's the response:
85156
@@ -156,9 +227,25 @@ details.
156227As an example, the following API call will return the structure of the ** List
157228Commits**  action for Gitlab:
158229
159- ``` text 
160- GET /v1/connect/components/gitlab-list-commits 
230+ <Tabs  items = { [' Node.js' ' HTTP (cURL)' } >
231+ <Tabs.Tab >
232+ ``` javascript 
233+ const  component  =  await  pd .getComponent ({ key:  " gitlab-list-commits" 
234+ 
235+ //  Parse and return the data you need
236+ ``` 
237+ </Tabs.Tab >
238+ <Tabs.Tab >
239+ ``` bash 
240+ curl -X https://api.pipedream.com/v1/connect/{project_id}/components/gitlab-list-commits \
241+   -H " Content-Type: application/json" 
242+   -H " X-PD-Environment: development" 
243+   -H " Authorization: Bearer {access_token}" 
244+ 
245+ #  Parse and return the data you need
161246``` 
247+ </Tabs.Tab >
248+ </Tabs >
162249
163250The response will contain the component's structure, including its user-friendly name,
164251version, and most importantly, the configuration options the component accepts
@@ -217,10 +304,6 @@ steps, focused on getting the right input parameters (aka
217304Configuring each prop for a component often involves an API call to retrieve the possible values,
218305unless the values that a prop can take are static or free-form. The endpoint is accessible at:
219306
220- ``` text 
221- POST /v1/connect/components/configure 
222- ``` 
223- 
224307Typically, the options for a prop are linked to a specific user's account. Each
225308of these props implements an ` options `  method that retrieves the necessary
226309options from the third-party API, formats them, and sends them back in the
@@ -232,31 +315,56 @@ The payload for the configuration API call must contain the following fields:
2323152 .  ` id ` : the component's unique ID (aka ** key** )
2333163 .  ` prop_name ` : the name of the prop you want to configure
2343174 .  ` configured_props ` : an object containing the props that have already been
235-    configured. The initial configuration call must contain the ID of the account
236-    (aka ` authProvisionId ` ) that your user has connected to the target app (see
237-    [ this section] ( workflows#configure-accounts-to-use-your-end-users-auth )  for
238-    more details on how to create these accounts).
318+      configured. The initial configuration call must contain the ID of the account
319+      (aka ` authProvisionId ` ) that your user has connected to the target app (see
320+      [ this section] ( workflows#configure-accounts-to-use-your-end-users-auth )  for
321+      more details on how to create these accounts).
239322
240323We'll use the [ ** List Commits**  component for
241324Gitlab] ( https://github.com/PipedreamHQ/pipedream/blob/master/components/gitlab/actions/list-commits/list-commits.mjs#L4 ) 
242325as an example, to illustrate a call that retrieves the options for the
243- ` projectId `  prop of that component. The payload sent to the configuration API
244- would look like this:
245- 
246- ``` json 
247- {
248-   "external_user_id" : " demo-34c13d13-a31e-4a3d-8b63-0ac954671095" 
249-   "id" : " gitlab-list-commits" 
250-   "prop_name" : " projectId" 
251-   "configured_props" : {
252-     "gitlab" : {
253-       "authProvisionId" : " apn_oOhaBlD" 
326+ ` projectId `  prop of that component:
327+ 
328+ <Tabs  items = { [' Node.js' ' HTTP (cURL)' } >
329+ <Tabs.Tab >
330+ ``` javascript 
331+ const  { options  } =  await  pd .configureComponent ({
332+   externalUserId:  " abc-123" 
333+   id:  " gitlab-list-commits" 
334+   propName:  " projectId" 
335+   configuredProps:  {
336+     gitlab:  {
337+       authProvisionId:  " apn_kVh9AoD" 
254338    }
255339  }
256- }
340+ });
341+ 
342+ //  Parse and return the data you need
343+ ``` 
344+ </Tabs.Tab >
345+ <Tabs.Tab >
346+ ``` bash 
347+ curl -X POST https://api.pipedream.com/v1/connect/{project_id}/components/configure \
348+   -H " Content-Type: application/json" 
349+   -H " X-PD-Environment: development" 
350+   -H " Authorization: Bearer {access_token}" 
351+   -d ' {
352+     "external_user_id": "abc-123", 
353+     "id": "gitlab-list-commits", 
354+     "prop_name": "projectId", 
355+     "configured_props": { 
356+       "gitlab": { 
357+         "authProvisionId": "apn_kVh9AoD" 
358+       } 
359+     } 
360+   }'  
361+ #  Parse and return the data you need
257362``` 
363+ </Tabs.Tab >
364+ </Tabs >
365+ 
258366
259- The response will contain  the possible values (and their human-readable labels
367+ The response contains  the possible values (and their human-readable labels
260368when applicable) for the prop, as well as any possible errors that might have
261369occurred. The response for the request above would look like this:
262370
@@ -348,7 +456,7 @@ The set of props that a component can accept might not be static, and may change
348456depending on the values of prior props. Props that behave this way are called
349457[ dynamic props] ( /components/api#dynamic-props ) , and they need to be configured
350458in a different way. Props that are dynamic will have a ` reloadProps `  attribute
351- set to ` true `  in the component's code .
459+ set to ` true `  in the component's definition .
352460
353461After configuring a dynamic prop, the set of subsequent props must be recomputed
354462(or reloaded), which is possible using the following API call:
@@ -452,8 +560,8 @@ supports two types of components: [actions](/components#actions) and
452560
453561Actions are components that perform a task by taking an input either during
454562[ configuration] ( #configure-the-component )  and/or during invocation (usually both), and
455- produce  a result. Sources are very similar, but the difference is that they are
456- not invoked directly by Pipedream  users, but rather by events that happen on a
563+ produces  a result. Sources are very similar, but the difference is that they are
564+ not invoked directly by end  users directly , but rather by events that happen on a
457565third-party service. For example, the "New File" source for Google Drive will be
458566triggered every time a new file is created in a specific folder in Google Drive,
459567then will emit an event for you to consume.
@@ -472,11 +580,11 @@ used for configuring a prop, with the exception of the `prop_name` attribute
472580``` json 
473581{
474582  "async_handle" : " xFfBakdTGTkI" 
475-   "external_user_id" : " demo-20a1b80e-23a5-4d4d-a8ef-c91cdbd0dad9 " 
583+   "external_user_id" : " abc-123 " 
476584  "id" : " gitlab-list-commits" 
477585  "configured_props" : {
478586    "gitlab" : {
479-       "authProvisionId" : " apn_JjhWOl0 " 
587+       "authProvisionId" : " apn_kVh9AoD " 
480588    },
481589    "projectId" : 45672541 ,
482590    "refName" : " main" 
@@ -487,9 +595,45 @@ used for configuring a prop, with the exception of the `prop_name` attribute
487595To run the action with this configuration, simply send it as the request payload
488596to the following endpoint:
489597
490- ``` text 
491- POST /v1/connect/actions/run 
598+ <Tabs  items = { [' Node.js' ' HTTP (cURL)' } >
599+ <Tabs.Tab >
600+ ``` javascript 
601+ const  resp  =  await  pd .runAction ({
602+   externalUserId:  " abc-123" 
603+   id:  " gitlab-list-commits" 
604+   configuredProps:  {
605+     gitlab:  {
606+       authProvisionId:  " apn_kVh9AoD" 
607+     },
608+     projectId:  45672541 ,
609+     refName:  " main" 
610+   }
611+ });
612+ 
613+ //  Parse and return the data you need
614+ ``` 
615+ </Tabs.Tab >
616+ <Tabs.Tab >
617+ ``` bash 
618+ curl -X POST https://api.pipedream.com/v1/connect/{project_id}/actions/run \
619+   -H " Content-Type: application/json" 
620+   -H " X-PD-Environment: development" 
621+   -H " Authorization: Bearer {access_token}" 
622+   -d ' {
623+     "external_user_id": "abc-123", 
624+     "id": "gitlab-list-commits", 
625+     "prop_name": "projectId", 
626+     "configured_props": { 
627+       "gitlab": { 
628+         "authProvisionId": "apn_kVh9AoD" 
629+       } 
630+     } 
631+   }'  
632+ 
633+ #  Parse and return the data you need
492634``` 
635+ </Tabs.Tab >
636+ </Tabs >
493637
494638The output of executing the action will be a JSON object containing the
495639following fields:
@@ -532,21 +676,19 @@ above:
532676
533677#### Deploying a source  
534678
535- Because sources are exercised by events that happen on a third-party service,
536- their semantics are different from actions. Once a source is configured, it must
537- be deployed in order to start listening for events. You might be asking where do
538- those events go, and you'd be right to ask. That's the reason why when deploying
539- a source you must provide a URL where the source will send these events, similar
540- to how a webhook works.
679+ Because sources are exercised by events that happen on a third-party service, 
680+ their semantics are different from actions. Once a source is configured, it must 
681+ be deployed to start listening for events. When deploying a source, you 
682+ can define either a webhook URL or a Pipedream workflow ID to consume those events.
541683
542684Deploying a source is done by sending a payload similar to the one used for
543- running an action, with the addition of the webhook URL mentioned above . Using
685+ running an action, with the addition of the webhook URL or workflow ID . Using
544686the ** New Issue (Instant)**  source for Gitlab as an example, the payload would
545687look something like this:
546688
547689``` json 
548690{
549-   "external_user_id" : " demo-20a1b80e-23a5-4d4d-a8ef-c91cdbd0dad9 " 
691+   "external_user_id" : " abc-123 " 
550692  "id" : " gitlab-new-issue" 
551693  "prop_name" : " http" 
552694  "configured_props" : {
@@ -559,11 +701,53 @@ look something like this:
559701}
560702``` 
561703
562- The endpoint to deploy a source is:
704+ Deploy a source for your users:
705+ 
706+ <Tabs  items = { [' Node.js' ' HTTP (cURL)' } >
707+ <Tabs.Tab >
708+ ``` javascript 
709+ const  { data:  deployedTrigger  } =  await  pd .deployTrigger ({
710+   externalUserId:  " abc-123" 
711+   id:  " gitlab-new-issue" 
712+   propName:  " projectId" 
713+   configuredProps:  {
714+     gitlab:  {
715+       authProvisionId:  " apn_kVh9AoD" 
716+     }
717+   },
718+   webhookUrl:  " https://events.example.com/gitlab-new-issue" 
719+ });
563720
564- ``` text 
565- POST /v1/connect/triggers/deploy 
721+ const  {
722+   id:  triggerId ,      //  The unique ID of the deployed trigger
723+   name:  triggerName,  //  The name of the deployed trigger
724+   owner_id:  userId,   //  The unique ID in Pipedream of your user
725+ } =  deployedTrigger;
726+ 
727+ //  Parse and return the data you need
566728``` 
729+ </Tabs.Tab >
730+ <Tabs.Tab >
731+ ``` bash 
732+ curl -X POST https://api.pipedream.com/v1/connect/{project_id}/components/triggers/deploy \
733+   -H " Content-Type: application/json" 
734+   -H " X-PD-Environment: development" 
735+   -H " Authorization: Bearer {access_token}" 
736+   -d ' {
737+     "external_user_id": "abc-123", 
738+     "id": "gitlab-new-issue", 
739+     "prop_name": "projectId", 
740+     "configured_props": { 
741+       "gitlab": { 
742+         "authProvisionId": "apn_kVh9AoD" 
743+       } 
744+     }, 
745+     "webhook_url": "https://events.example.com/gitlab-new-issue" 
746+   }'  
747+ #  Parse and return the data you need
748+ ``` 
749+ </Tabs.Tab >
750+ </Tabs >
567751
568752If the source deployment succeeds, the response will contain the information
569753regarding the state of the source, including all the component's props metadata,
@@ -622,11 +806,9 @@ this:
622806}
623807``` 
624808
625- In the example above, the source ID is ` dc_dAuGmW7 ` , which can be used to delete
626- the source in the future: 
809+ In the example above, the source ID is ` dc_dAuGmW7 ` , which can be used to delete, 
810+ retrieve, or update  the source in the future. 
627811
628- ``` text 
629- DELETE /v1/connect/deployed-triggers/dc_dAuGmW7?external_user_id=demo-20a1b80e-23a5-4d4d-a8ef-c91cdbd0dad9 
630- ``` 
812+ Refer to the [ full Connect API reference] ( /connect/api#components )  for questions and additional examples.
631813
632814</Steps >
0 commit comments