Skip to content

Commit 384daf7

Browse files
authored
Update source-functions.md
1 parent c1ee28e commit 384daf7

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

src/connections/functions/source-functions.md

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -299,17 +299,26 @@ The advantage of testing your source function with webhooks is that all incoming
299299

300300
Note that Segment has updated the webhook URL to `api.segmentapis.com/functions`. To use webhooks with your function:
301301
- You must [generate a public API token](https://docs.segmentapis.com/tag/Getting-Started/#section/Get-an-API-token){:target="_blank"}.
302-
- For POST calls, you'll need to use this API token in the header.
302+
- Navigate here to [create a Public API Token]([url](https://app.segment.com/goto-my-workspace/settings/access-management/tokens)), or follow these steps : In your Segment Workspace, navigate to Settings → Workspace settings → Access Management tab → Token tab. On the right, click the `+ Create Token` button. Create a description for the token and assign access. Click `Create` and make sure to save the access token before clicking `Done`.
303+
- For POST calls, you'll need to use this Public API token in the Authorization Header, as `Bearer Token : public_api_token`
303304

304305
### Testing source functions with a webhook
305306

306-
You can use webhooks to test the source function either by sending requests manually (using any HTTP client such as cURL or Insomnia) or by pasting the webhook into an external server that supports webhooks (such as Slack).
307+
You can use webhooks to test the source function either by sending requests manually (using any HTTP client such as cURL, Postman, or Insomnia) or by pasting the webhook into an external server that supports webhooks (such as Slack).
308+
_A common Segment use case is to connect a Segment [Webhooks destination](https://segment.com/docs/connections/destinations/catalog/webhooks/) or [Webhook Actions destination](https://segment.com/docs/connections/destinations/catalog/actions-webhook/) to a test source, where the Webhook URL/endpoint that is used corresponds to the provided source function's endpoint, then you can trigger test events to send directly to that source which would be routed through your Webhook destination and continue on to the source function : Source → Webhook destination → Source Function._
307309

308-
From the source function editor, copy the webhook URL from the "Auto-fill via Webhook" dialog. To trigger the source function, send the request using the `POST` method, with the `Content-Type` header set to `application/json` or `application/x-www-form-urlencoded`.
310+
From the source function editor, copy the provided webhook URL (endpoint) from the "Auto-fill via Webhook" dialog.
311+
_**Note** : When a new source is created that utilizes a source function, the new source's endpoint (webhook URL) will differ from the URL that is provided in the source function's test environment._
312+
313+
In order to test the source function, you must (1) send a `POST` request to the source function's provided endpoint (webhook URL), (2) include an event `body`, and (3) the request must include these Headers :
314+
- `Content-Type : application/json` or `Content-Type : application/x-www-form-urlencoded`
315+
- `Authorization : Bearer _your_public_api_token_`
309316

310317
### Testing source functions manually
311318

312319
You can also manually construct the headers and body of an HTTPS request right inside the editor and test with this data without using webhooks.
320+
The `Content-Type` Header is required when testing the function :
321+
- `Content-Type : application/json` or `Content-Type : application/x-www-form-urlencoded`
313322

314323
![Test HTTPS Request](images/test-manual.png){:width="500"}
315324

0 commit comments

Comments
 (0)