You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/ingest/transformations.mdx
+12Lines changed: 12 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -26,6 +26,8 @@ Svix expects a Transformation to declare a function named `handler`. Svix will p
26
26
-`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"`.
27
27
-`url`, a string representing the destination endpoint's URL. It can be changed to any valid URL.
28
28
-`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
29
31
30
32
The Transformation must return the same object, but may modify its properties as described above.
31
33
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) {
47
49
```
48
50
49
51
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