Skip to content

Commit 36f7b42

Browse files
authored
Workspace webhook docs (windmill-labs#528)
* Workspace webhook docs * Workspace error handler sentence * title fix
1 parent 3b54f69 commit 36f7b42

File tree

6 files changed

+40
-28
lines changed

6 files changed

+40
-28
lines changed

docs/core_concepts/10_error_handling/index.mdx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,8 @@ You can pick the Slack pre-set schedule error handler or define your own.
9292

9393
## Workspace Error Handler
9494

95+
Define a script or flow to be executed automatically in case of error in the workspace.
96+
9597
### Workspace Error Handler on Slack
9698

9799
On [Cloud plans and Self-Hosted & Enterprise Edition](/pricing), you can [connect workspace to Slack](../../integrations/slack.mdx) and enable an automated error handler on a given channel.

docs/core_concepts/11_persistent_storage/index.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ Then from Windmill, just [fill the S3 resource type](../../integrations/s3.md).
252252

253253
4. [Integrate it to Windmill](../../integrations/microsoft-azure-blob.md) by filling the [resource type details](https://hub.windmill.dev/resource_types/137) for Azure Blob APIs.
254254

255-
### Connect your Windmill workspace to your S3 bucket or you Azure Blob storage
255+
### Connect your Windmill workspace to your S3 bucket or your Azure Blob storage
256256

257257
Once you've created an [S3 or Azure Blob resource](../../integrations/s3.md) in Windmill, go to the workspace settings > S3 Storage. Select the resource and click Save.
258258

docs/core_concepts/18_files_binary_data/index.mdx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@ Binary data, such as files, are not easy to handle. Windmill provides two option
1212

1313
## Windmill integration with S3 or Azure Blob Storage
1414

15-
The recommended way to store binary data is to upload it to S3 leveraging [Windmill's native S3 integrations](../11_persistent_storage/index.mdx#connect-your-windmill-workspace-to-your-s3-bucket-or-you-azure-blob-storage).
15+
The recommended way to store binary data is to upload it to S3 leveraging [Windmill's native S3 integrations](../11_persistent_storage/index.mdx#connect-your-windmill-workspace-to-your-s3-bucket-or-your-azure-blob-storage).
1616

1717
:::info
1818

1919
Windmill's integration with S3 and Azure Blob Storage works exactly the same and the features described below works in both cases. The only difference is that you need to select an `azure_blob` resource when setting up the S3 storage in the Workspace settings.
2020

2121
:::
2222

23-
By [setting a S3 resource for the workspace](../11_persistent_storage/index.mdx#connect-your-windmill-workspace-to-your-s3-bucket-or-you-azure-blob-storage), you can have an easy access to your bucket from the script editor. It becomes easy to consume S3 files as input, and write back to S3 anywhere in a script.
23+
By [setting a S3 resource for the workspace](../11_persistent_storage/index.mdx#connect-your-windmill-workspace-to-your-s3-bucket-or-your-azure-blob-storage), you can have an easy access to your bucket from the script editor. It becomes easy to consume S3 files as input, and write back to S3 anywhere in a script.
2424

2525
S3 files in Windmill are just pointers to the S3 object using its key. As such, they are represented by a simple JSON:
2626

@@ -45,8 +45,8 @@ Windmill provides helpers in its SDKs to consume and produce S3 file seamlessly.
4545
<div className="grid grid-cols-2 gap-6 mb-4">
4646
<DocCard
4747
title="Persistent Storage - S3 Integration"
48-
description="Connect your Windmill workspace to your S3 bucket or you Azure Blob storage."
49-
href="/docs/core_concepts/persistent_storage#connect-your-windmill-workspace-to-your-s3-bucket-or-you-azure-blob-storage"
48+
description="Connect your Windmill workspace to your S3 bucket or your Azure Blob storage."
49+
href="/docs/core_concepts/persistent_storage#connect-your-windmill-workspace-to-your-s3-bucket-or-your-azure-blob-storage"
5050
/>
5151
</div>
5252

@@ -303,7 +303,7 @@ def main(input_file: S3Object):
303303

304304
:::info
305305

306-
Polars and DuckDB needs to be configured to access S3 within the Windmill script. The job will need to accessed the S3 resources, which either needs to be accessible to the user running the job, or the S3 resource needs to be [set as public in the workspace settings](/docs/core_concepts/persistent_storage#connect-your-windmill-workspace-to-your-s3-bucket-or-you-azure-blob-storage).
306+
Polars and DuckDB needs to be configured to access S3 within the Windmill script. The job will need to accessed the S3 resources, which either needs to be accessible to the user running the job, or the S3 resource needs to be [set as public in the workspace settings](/docs/core_concepts/persistent_storage#connect-your-windmill-workspace-to-your-s3-bucket-or-your-azure-blob-storage).
307307

308308
:::
309309

docs/core_concepts/27_data_pipelines/index.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@ More details on S3 integration:
7272
<div className="grid grid-cols-2 gap-6 mb-4">
7373
<DocCard
7474
title="Persistent Storage - S3 Integration"
75-
description="Connect your Windmill workspace to your S3 bucket or you Azure Blob storage."
76-
href="/docs/core_concepts/persistent_storage#connect-your-windmill-workspace-to-your-s3-bucket-or-you-azure-blob-storage"
75+
description="Connect your Windmill workspace to your S3 bucket or your Azure Blob storage."
76+
href="/docs/core_concepts/persistent_storage#connect-your-windmill-workspace-to-your-s3-bucket-or-your-azure-blob-storage"
7777
/>
7878
</div>
7979

docs/core_concepts/4_webhooks/index.mdx

Lines changed: 30 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,11 @@ Some use cases include triggering scripts and flows from [Slack](/blog/handler-s
1515

1616
:::
1717

18+
## Webhooks for Scripts & Flows
19+
1820
Each Script and Flow created in Windmill gets autogenerated webhooks. The webhooks depend on how they are triggered, and what their return values are.
1921

20-
## Addresses
22+
### Addresses
2123

2224
![Webhook endpoints](./webhook_endpoints.png.webp)
2325

@@ -33,13 +35,13 @@ version of the Script/Flow and the other one with just a hash, i.e. `/h/<hash>`,
3335
hiding potentially sensitive information and always corresponding to that
3436
version of the script, even with overwrites.
3537

36-
### Asynchronous
38+
#### Asynchronous
3739

3840
Jobs can be triggered in asynchronous mode, meaning that the webhook is triggered, and the returning value is the uuid of the job assigned to execute the underlying code
3941

4042
These links are available in the "UUID/Async" tab.
4143

42-
### Synchronous
44+
#### Synchronous
4345

4446
The second type of autogenerated endpoint is the **synchronous** webhook. This
4547
webhook triggers the execution, automatically extracts the underlying code's
@@ -72,15 +74,15 @@ Be cautious with potentially long-running jobs in **synchronous** mode.
7274

7375
:::
7476

75-
### Asynchronous vs. Synchronous
77+
#### Asynchronous vs. Synchronous
7678

7779
It's always better to use asynchronous mode as it allows your client not to wait for the response and it avoids Windmill to have to maintain a connection to your client while the job is running. However, for short-running jobs where it's easier in your code to block until you get a response, then use the synchronous mode.
7880

7981
When using the **synchronous mode**, the webhook returns the result of the script directly. If the script returns an error, the endpoint still returns the `200` status code with the error as a JSON object.
8082

8183
When using the **asynchronous mode**, the webhook returns a `uuid` and you can poll the [get job](https://app.windmill.dev/openapi.html#/operations/getJob) API call to fetch the status and results once it is completed.
8284

83-
## User token
85+
### User token
8486

8587
To interact with Windmill you always need to use `Bearer` token authentication.
8688

@@ -99,15 +101,15 @@ securely!
99101

100102
![Create new tokens](./tokens.png.webp)
101103

102-
## Webhook specific tokens
104+
### Webhook specific tokens
103105

104106
Webhook specific tokens allow sharing tokens publicly without fear since the token will only be able to trigger a specific script/flow and not impersonate you for any other operations.
105107

106108
It also avoids the hassle of having to create an anonymous user and check their permissions. If you can run the script yourself, then the webhook specific token will still inherit your own permissions.
107109

108110
![Webhooks specific tokens](./webhooks_tokens.gif)
109111

110-
## Triggering
112+
### Triggering
111113

112114
Once you have a webhook URL and a user token, issue a request to the
113115
endpoint and you will get the appropriate return as response.
@@ -127,7 +129,7 @@ as a secret (for more context please check [OWASP ref.1] and [OWASP ref.2]).
127129
Examples using cURL for `POST` requests:
128130

129131
```bash
130-
# Request with Header
132+
## Request with Header
131133
curl -X POST \
132134
--data '{}' \
133135
-H "Content-Type: application/json" \
@@ -136,7 +138,7 @@ curl -X POST \
136138
```
137139

138140
```bash
139-
# Query parameter
141+
## Query parameter
140142
curl -X POST \
141143
--data '{}' \
142144
-H "Content-Type: application/json" \
@@ -146,7 +148,7 @@ curl -X POST \
146148
Examples using cURL for synchronous GET requests:
147149

148150
```bash
149-
# Request with Header".
151+
## Request with Header".
150152
curl -X GET \
151153
-H "Content-Type: application/json" \
152154
-H "Authorization: Bearer supersecret" \
@@ -161,13 +163,13 @@ encountered issues), by checking the [Runs menu][runs] on the app.
161163

162164
![Runs page](./runs.png.webp)
163165

164-
## Request headers
166+
### Request headers
165167

166168
It is possible for jobs to take request headers as arguments. To do so, either specify in the query args the headers to process at `include_header`, separated with `,`. e.g: `/api/w/admins/jobs/run_wait_result/p/u/user/undisputed_script?include_header=X-Sign,foo`
167169

168170
or use the env variable: `INCLUDE_HEADERS` with the same format so that all requests to any job will include the headers.
169171

170-
## Non Object payload / body
172+
### Non Object payload / body
171173

172174
If the payload is not an object, it will be wrapped in an object with the key `body` and the value will be the payload/body itself. e.g:
173175

@@ -182,11 +184,11 @@ def main(body: List[int]):
182184
print(body)
183185
```
184186

185-
## Raw payload / body
187+
### Raw payload / body
186188

187189
Similarly to request headers, if the query args contain `raw=true`, then an additional argument will be added: `raw_string` which contains the entire json payload as a string (without any parsing). This is useful to verify the signature of the payload for example (discord require the endpoints to verify the signature for instance).
188190

189-
## Custom Response Code
191+
### Custom Response Code
190192

191193
For all sync run jobs endpoints, if the response contains a key `windmill_status_code` with a number value, that value will be used as the status code. For example, if a script or flow returns:
192194

@@ -211,7 +213,7 @@ with a status code `201`.
211213

212214
Note that if the status code is invalid (w.r.t [RFC9110](https://httpwg.org/specs/rfc9110.html#overview.of.status.codes)), the endpoint will return an error.
213215

214-
## Custom Content Type
216+
### Custom Content Type
215217

216218
Similarly to the above, for all sync run jobs endpoints, if the response contains a key `windmill_content_type`, the associated value will be used as the content type header of the response. For example, if a script or flow returns:
217219

@@ -230,7 +232,7 @@ the synchronous endpoint will return:
230232

231233
with the response header: "Content-Type: text/csv".
232234

233-
## Return early for flows
235+
### Return early for flows
234236

235237
It is possible to define a node at which the flow will return at for sync endpoints. The rest of the flow will continue asynchronously.
236238

@@ -244,20 +246,20 @@ Useful when some webhooks need to return extremely fast but not just the uuid (d
244246
/>
245247
</div>
246248

247-
## Exposing a webhook URL
249+
### Exposing a webhook URL
248250

249251
Single port proxy can be leveraged to expose a webhook with a custom URL. In its docker-compose, Windmill uses Caddy but the logic can be adapted for others.
250252

251-
In the Caddyfile, the (`handle_path`)[https://caddyserver.com/docs/caddyfile/directives/handle_path#handle-path] and (`rewrite`)[https://caddyserver.com/docs/caddyfile/directives/rewrite#rewrite] directive can be used:
253+
In the Caddyfile, the [`handle_path`](https://caddyserver.com/docs/caddyfile/directives/handle_path#handle-path) and [`rewrite`](https://caddyserver.com/docs/caddyfile/directives/rewrite#rewrite) directive can be used:
252254

253255
```
254256
{$BASE_URL} {
255257
bind {$ADDRESS}
256258
257259
handle_path /mywebhook {
258260
rewrite * /api/w/demo/jobs/run_wait_result/p/u/bot/hello_world_deno"
259-
# You can optionally inject the token in Caddy to have the endpoint exposed publicly
260-
# request_header Authorization "Bearer <WINDMILL_GENERATED_TOKEN>"
261+
## You can optionally inject the token in Caddy to have the endpoint exposed publicly
262+
## request_header Authorization "Bearer <WINDMILL_GENERATED_TOKEN>"
261263
}
262264
263265
...
@@ -274,6 +276,14 @@ curl -X POST \
274276
".../mywebhook?payload=<URL_SAFE_BASE64_ENCODED_JSON>"
275277
```
276278

279+
## Workspace Webhook
280+
281+
Connect your Windmill workspace to an external service to sync or get notified about any change.
282+
283+
From workspace settings, go to the "Webhooks" tab and fill an URL under "URL to send requests to".
284+
285+
![Workspace Webhook](./workspace_webhook.png "Workspace Webhook")
286+
277287
<!-- Resources -->
278288

279289
[runs]: ../5_monitor_past_and_future_runs/index.mdx
Loading

0 commit comments

Comments
 (0)