Skip to content

Commit 6bbc1fa

Browse files
authored
add documentation for svix-ingest-query and svix-ingest-trailing-path-segments (#310)
part of svix/monorepo-private#12827 depends on svix/svix-webhooks-private#6660
2 parents a3cf04a + 278e940 commit 6bbc1fa

2 files changed

Lines changed: 21 additions & 1 deletion

File tree

content/ingest/receiving-with-ingest.mdx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,15 @@ The Ingest URL is also listed on the [Ingest Dashboard] for each `Source`.
199199

200200
The `IngestSourceOut` response from the API will include an `ingestUrl` which is
201201
the endpoint you give to your provider, telling them where to send their
202-
webhooks.
202+
webhooks. Given an ingest URL of the format
203+
`https://api.svix.com/ingest/api/v1/source/src_abcdefghijklmnop/in/token1234567`,
204+
providers can actually send requests to any trailing path, and with any query parameter; e.g.,
205+
`https://api.svix.com/ingest/api/v1/source/src_abcdefghijklmnop/in/token1234567/foo/bar/baz?qux=duck`.
206+
207+
Trailing path segments will be forwarded along to the eventual destination under the `svix-ingest-trailing-path-segments` header;
208+
query parameters will be forwarded under the `svix-ingest-query` header. Both
209+
are and are also available as [transformations](./transformations.mdx)
210+
parameters.
203211

204212
For GitHub, as is used in this example, this is referred to as the
205213
_"Payload URL"_.

content/ingest/transformations.mdx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ Svix expects a Transformation to declare a function named `handler`. Svix will p
2626
- `method`, a string representing the HTTP method the webhook will be sent with. It is always `"POST"` by default, and its only valid values are `"POST"` or `"PUT"`.
2727
- `url`, a string representing the destination endpoint's URL. It can be changed to any valid URL.
2828
- `payload`, which contains the webhook's payload as a JSON object. It can be changed as needed.
29+
- `eventType`, a string representing the event type. Changes to it are ignored. This will always have the value `svix.in` for ingest events
30+
- `transformationsParams`, additional parameters made available in ingest; see below for details
2931

3032
The Transformation must return the same object, but may modify its properties as described above.
3133
In addition to the ones listed above, it can also set the following properties on the returned object:
@@ -47,3 +49,13 @@ function handler(webhook) {
4749
```
4850

4951
Great, the webhook is redirected to the custom URL if the `customUrl` property exists on the payload. Otherwise, it is sent to the endpoint's defined URL.
52+
53+
### Ingest-Specific Transformations Params
54+
55+
Transformations called from an Ingest request will receive additional parameters under the `transformationsParams` property. Specifically:
56+
57+
- `transformationsParams.headers` will be a string/string key-value map containing the headers of the input request. If a header is duplicated on the input request, the values will be concatenated with ", ", as per [RFC 9110 § 5.2](https://www.rfc-editor.org/info/rfc9110/#section-5.2).
58+
- `transformationsParams.headers.svix-ingest-query` contains the un-parsed query string (the part after the `?` on the request URL)
59+
- `transformationsParams.headers.svix-ingest-trailing-path-segments` contains any parts of the URL after the token, not including the first `/`.
60+
61+
If your source URL is `https://api.svix.com/ingest/api/v1/source/src_abcdefghijklmnop/in/token1234567` and your provider makes a request to `https://api.svix.com/ingest/api/v1/source/src_abcdefghijklmnop/in/token1234567/foo/bar/baz?qux=duck`, `transformationsParams.headers["svix-ingest-query"]` will contain the string `qux=duck` and `transformationsParams.headers["svix-ingest-trailing-path-segments"]` will contain the string `foo/bar/baz`.

0 commit comments

Comments
 (0)