Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion docs/advanced-endpoints/intro.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ Svix supports multiple types of endpoints in addition to regular webhook endpoin
- [Polling Endpoints](/advanced-endpoints/polling-endpoints)
- [FIFO Endpoints](/advanced-endpoints/fifo-endpoints)
- [Object Storage](/advanced-endpoints/object-storage)
- [SQS](/advanced-endpoints/sqs)
- [SNS](/advanced-endpoints/sns)

## Enabling Advanced Endpoint Types

Expand All @@ -18,4 +20,4 @@ Advanced Endpoint Types can be enabled at the environment level in the [Svix Das

When you enable Advanced Endpoint Types, your users will be able to create them in the [App Portal](/app-portal).

![Advanced Endpoint Types](../img/advanced-endpoints/object-storage-endpoints.png)
![Advanced Endpoint Types](../img/advanced-endpoints/advanced-endpoints.png)
136 changes: 136 additions & 0 deletions docs/advanced-endpoints/sns.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
---
title: SNS endpoints
---

# SNS (Simple Notification Service) endpoints

SNS endpoints allow you to send webhook events to AWS SNS topics instead of HTTP endpoints.

This is useful for publishing events to notification topics without your customers having to set up any listener endpoint or write any glue code. SNS endpoints are ideal for:

- **Fan-out messaging**: Deliver events to multiple subscribers
- **Multi-protocol delivery**: Support email, SMS, HTTP, and other protocols
- **Reliability**: Leverage SNS's durability and retry mechanisms
- **Scalability**: Handle high-throughput event publishing

## Configuration

Create an SNS endpoint by providing your SNS topic ARN and AWS credentials. Events will be published to your topic as individual messages.

```bash
curl -X 'POST' \
'https://api.eu.svix.com/api/v1/stream/{your_sink_id}/sink' \
-H 'Authorization: Bearer AUTH_TOKEN' \
-H 'Accept: application/json' \
-H 'Content-Type: application/json' \
-d '{
"config": {
"topicArn": "arn:aws:sns:us-east-1:123456789012:my-topic",
"region": "us-east-1",
"accessKeyId": "xxx",
"secretAccessKey": "xxx"
},
"type": "sns"
}'
```

## Transformation

SNS endpoints use transformations to format events for the target topic. Here's the transformation function for SNS:

```javascript
/**
* @param input - The input object
* @param input.events - The array of events in the batch. The number of events in the batch is capped by the Sink's batch size.
* @param input.events[].payload - The message payload (string or JSON).
* @param input.events[].eventType - The message event type (string).
*
* @returns Object containing the response.
* @returns returns.messages - The array of SNS messages to send to the SNS topic.
* @returns returns.messages[].payload - The content of the message (string).
* @returns returns.messages[].subject - An optional subject of the message (string).
*/
function handler(input) {
const messages = input.events.map((event) => ({
payload: event,
}));

return {
messages,
};
}
```

For example, if the endpoint receives the following events:

```json
{
"eventType": "user.created",
"payload": "{\"email\": \"[email protected]\"}"
}
```

```json
{
"eventType": "user.login",
"payload": "{\"id\": 12, \"timestamp\": \"2025-07-21T14:23:17.861Z\"}"
}
```

Using the same example events, the default SNS transformation would produce:

```json
{
"messages": [
{
"payload": {
"eventType": "user.created",
"payload": "{\"email\": \"[email protected]\"}"
}
},
{
"payload": {
"eventType": "user.login",
"payload": "{\"id\": 12, \"timestamp\": \"2025-07-21T14:23:17.861Z\"}"
}
}
]
}
```

To add a custom subject:
```javascript
function handler(input) {
const messages = input.events.map((event) => ({
payload: event,
subject: `Webhook: ${event.eventType}`,
}));

return {
messages,
};
}
```

This would produce:

```json
{
"messages": [
{
"payload": {
"eventType": "user.created",
"payload": "{\"email\": \"[email protected]\"}"
},
"subject": "Webhook: user.created"
},
{
"payload": {
"eventType": "user.login",
"payload": "{\"id\": 12, \"timestamp\": \"2025-07-21T14:23:17.861Z\"}"
},
"subject": "Webhook: user.login"
}
]
}
```
126 changes: 126 additions & 0 deletions docs/advanced-endpoints/sqs.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
---
title: SQS endpoints
---

# SQS (Simple Queue Service) endpoints

SQS endpoints allow you to send webhook events to AWS SQS queues instead of HTTP endpoints.

This is useful for queuing payloads in a message queue without your customers having to set up any listener endpoint or write any glue code. SQS endpoints are ideal for:

- **Asynchronous processing**: Decouple event delivery from processing
- **High throughput**: Handle large volumes of events with built-in batching
- **Reliability**: Leverage SQS's durability and retry mechanisms
- **Scalability**: Auto-scale consumers based on queue depth

## Configuration

Create an SQS endpoint by providing your SQS queue URL and AWS credentials. Events will be batched and sent to your queue according to your sink's batch configuration.

```bash
curl -X 'POST' \
'https://api.eu.svix.com/api/v1/stream/{your_sink_id}/sink' \
-H 'Authorization: Bearer AUTH_TOKEN' \
-H 'Accept: application/json' \
-H 'Content-Type: application/json' \
-d '{
"config": {
"queueUrl": "https://sqs.us-east-1.amazonaws.com/123456789012/my-queue",
"region": "us-east-1",
"accessKeyId": "xxx",
"secretAccessKey": "xxx"
},
"type": "sqs"
}'
```

## Transformation

SQS endpoints use transformations to format events for the target queue. Here's the transformation function for SQS:

```javascript
/**
* @param input - The input object
* @param input.events - The array of events in the batch. The number of events in the batch is capped by the Sink's batch size.
* @param input.events[].payload - The message payload (string or JSON).
* @param input.events[].eventType - The message event type (string).
*
* @returns Object containing the response.
* @returns returns.messages - The array of SQS messages to send to the SQS queue.
* @returns returns.messages[].payload - The payload of the message (string).
*/
function handler(input) {
const messages = input.events.map((event) => ({
payload: event,
}));

return {
messages,
};
}
```

For example, if the endpoint receives the following events:

```json
{
"eventType": "user.created",
"payload": "{\"email\": \"[email protected]\"}"
}
```

```json
{
"eventType": "user.login",
"payload": "{\"id\": 12, \"timestamp\": \"2025-07-21T14:23:17.861Z\"}"
}
```

The default transformation would produce these SQS messages:

```json
{
"messages": [
{
"payload": {
"eventType": "user.created",
"payload": "{\"email\": \"[email protected]\"}"
}
},
{
"payload": {
"eventType": "user.login",
"payload": "{\"id\": 12, \"timestamp\": \"2025-07-21T14:23:17.861Z\"}"
}
}
]
}
```

To send only the payload data:
```javascript
function handler(input) {
const messages = input.events.map((event) => ({
payload: event.payload,
}));

return {
messages,
};
}
```

This would produce:

```json
{
"messages": [
{
"payload": "{\"email\": \"[email protected]\"}"
},
{
"payload": "{\"id\": 12, \"timestamp\": \"2025-07-21T14:23:17.861Z\"}"
}
]
}
```
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/img/stream/sns-create.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/img/stream/sqs-create.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 3 additions & 1 deletion docs/stream/sinks/introduction.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ The following sink types are supported by Svix Stream:
* [HTTP Endpoints](./http)
* [OpenTelemetry Trace Collector](./otel_trace)
* [Amazon S3](./s3)
* [Amazon SQS](./sqs)
* [Amazon SNS](./sns)
* [Google Cloud Storage](./gcs)
* [Azure Blob Storage](./azure_blob)
* [Polling Endpoint](./poller)
Expand Down Expand Up @@ -149,4 +151,4 @@ If dispatch fails because the sink is misconfigured, or the retry schedule was e

While a sink is disabled, events can still be written to the Stream without interruption.

In the UI, you can still alter the sink's configuration, and re-enable the sink once you're sure the error is resolved. Once a sink is re-enabled, it will resume dispatching events from where it left off.
In the UI, you can still alter the sink's configuration, and re-enable the sink once you're sure the error is resolved. Once a sink is re-enabled, it will resume dispatching events from where it left off.
Loading