---
title: Payload Retention
---

# Payload Retention

Svix retains all message payloads (content) for a period of 90 days, after which they are deleted. This ensures that potentially sensitive and private information is not held indefinitely.

## Modifying the retention period

While 90 days is a good default for most use-cases, in some cases, a shorter retention period is preferred. Since different messages may require different retention periods, Svix lets you control the wanted retention on a message by message basis.

To change the retention period just pass the wanted retention period when creating the message by setting the `payload_retention_period` parameter to the wanted number of days.

Here are a few examples for setting the retention to `14` days:

<CodeTabs items={["JavaScript","Python","Go","Rust","Java","Kotlin","Ruby","C#","CLI","PHP","cURL"]}>
<TabItem value="JavaScript">

```js
const svix = new Svix("AUTH_TOKEN");
await svix.message.create("app_Xzx8bQeOB1D1XEYmAJaRGoj0", {
  eventType: "invoice.paid",
  eventId: "evt_Wqb1k73rXprtTm7Qdlr38G",
  payloadRetentionPeriod: 14,
  payload: {
    id: "invoice_WF7WtCLFFtd8ubcTgboSFNql",
    status: "paid",
    attempt: 2,
  },
});
```

</TabItem>
<TabItem value="Python">

```python
svix = Svix("AUTH_TOKEN")
svix.message.create(
    "app_Xzx8bQeOB1D1XEYmAJaRGoj0",
    MessageIn(
        event_type="invoice.paid",
        event_id="evt_Wqb1k73rXprtTm7Qdlr38G",
        payload_retention_period=14,
        payload={
            "id": "invoice_WF7WtCLFFtd8ubcTgboSFNql",
            "status": "paid",
            "attempt": 2
        }
    )
)
```

</TabItem>
<TabItem value="Go">

```go
svixClient := svix.New("AUTH_TOKEN", nil)
svixClient.Message.Create(ctx, "app_Xzx8bQeOB1D1XEYmAJaRGoj0", &svix.MessageIn{
    EventType:              "invoice.paid",
    EventId:                svix.NullableString("evt_Wqb1k73rXprtTm7Qdlr38G"),
    PayloadRetentionPeriod: 14,
    Payload:                map[string]interface{}{
        "id":      "invoice_WF7WtCLFFtd8ubcTgboSFNql",
        "status":  "paid",
        "attempt": 2,
    },
})
```

</TabItem>
<TabItem value="Rust">

```rust
let svix = Svix::new("AUTH_TOKEN".to_string(), None);
svix.message()
    .create(
        "app_Xzx8bQeOB1D1XEYmAJaRGoj0".to_string(),
        MessageIn {
            event_type: "invoice.paid".to_string(),
            event_id: Some("evt_Wqb1k73rXprtTm7Qdlr38G".to_string()),
            payload: json!({
                "id": "invoice_WF7WtCLFFtd8ubcTgboSFNql",
                "status": "paid",
                "attempt": 2
            }),
            ..MessageIn::default()
        },
        None,
    )
    .await?;
```

</TabItem>
<TabItem value="Java">

```java
Svix svix = new Svix("AUTH_TOKEN");
svix.getMessage().create("app_Xzx8bQeOB1D1XEYmAJaRGoj0",
  new MessageIn()
    .eventType("invoice.paid")
    .eventId("evt_Wqb1k73rXprtTm7Qdlr38G")
    .payloadRetentionPeriod(14)
    .payload("{" +
       "\"id\": \"invoice_WF7WtCLFFtd8ubcTgboSFNql\"," +
       "\"status\":  \"paid\"," +
       "\"attempt\": 2" +
      "}"));
```

</TabItem>
<TabItem value="Kotlin">

```kotlin
val svix = Svix("AUTH_TOKEN")
svix.message.create("app_Xzx8bQeOB1D1XEYmAJaRGoj0",
        MessageIn(
            eventType = "invoice.paid",
            eventId = "evt_Wqb1k73rXprtTm7Qdlr38G")),
            payloadRetentionPeriod = 14,
            payload = mapOf<String, Any>(
                "id" to "invoice_WF7WtCLFFtd8ubcTgboSFNql",
                "status" to "paid",
                "attempt" to 2
            )
```

</TabItem>
<TabItem value="Ruby">

```ruby
svix = Svix::Client.new("AUTH_TOKEN")
svix.message.create("app_Xzx8bQeOB1D1XEYmAJaRGoj0",
    Svix::MessageIn.new({
        "event_type" => "invoice.paid",
        "event_id" => "evt_Wqb1k73rXprtTm7Qdlr38G"})),
        "payload" => {
            "id" => "invoice_WF7WtCLFFtd8ubcTgboSFNql",
            "status" => "paid",
            "attempt" => 2
        },
        "payload_retention_period" => 14
    })
)
```

</TabItem>
<TabItem value="C#">

```csharp
var svix = new SvixClient("AUTH_TOKEN", new SvixOptions("https://api.us.svix.com"));
await svix.Message.CreateAsync("app_Xzx8bQeOB1D1XEYmAJaRGoj0", new MessageIn(
    eventType: "invoice.paid",
    eventId: "evt_Wqb1k73rXprtTm7Qdlr38G",
    payloadRetentionPeriod: 14,
    payload: new {
        id: "invoice_WF7WtCLFFtd8ubcTgboSFNql",
        status: "paid",
        attempt: 2,
    },
));
```

</TabItem>
<TabItem value="CLI">

```shell
export SVIX_AUTH_TOKEN="AUTH_TOKEN"
svix message create app_Xzx8bQeOB1D1XEYmAJaRGoj0 '{ "eventType": "invoice.paid", "eventId": "evt_Wqb1k73rXprtTm7Qdlr38G", "payloadRetentionPeriod": 14, "payload": { "id": "invoice_WF7WtCLFFtd8ubcTgboSFNql", "status": "paid", "attempt": 2 } }'
```

</TabItem>
<TabItem value="PHP">

```php
$svix = new Svix('AUTH_TOKEN');


$svix->message->create(
  'app_Xzx8bQeOB1D1XEYmAJaRGoj0',
  MessageIn::create(
    eventType: 'invoice.paid',
    payload: [
      'id' => 'invoice_WF7WtCLFFtd8ubcTgboSFNql',
      'status' => 'paid',
      'attempt' => 2
    ]
  )->withPayloadRetentionPeriod(14)->withEventId('evt_Wqb1k73rXprtTm7Qdlr38G')
);
```

</TabItem>
<TabItem value="cURL">

```shell
curl -X POST "https://api.us.svix.com/api/v1/app/app_Xzx8bQeOB1D1XEYmAJaRGoj0/msg/" \
    -H  "Accept: application/json" \
    -H  "Content-Type: application/json" \
    -H  "Authorization: Bearer AUTH_TOKEN" \
    -d '{"eventType": "invoice.paid", "eventId": "evt_Wqb1k73rXprtTm7Qdlr38G", "payloadRetentionPeriod": 14, "payload": {"id": "invoice_WF7WtCLFFtd8ubcTgboSFNql", "status": "paid", "attempt": 2}}'
```

</TabItem>
</CodeTabs>

## Delete payloads on successful delivery

As part of the enhanced compliance controls available in the Enterprise tier, Svix supports deleting payloads automatically upon successful delivery or the expiry of the retention period. Whichever comes first.

This is useful for when you want to have the lowest retention required due to compliance reasons; as it ensures that the payload is deleted the moment it's no longer required and no longer than the defined retention period.

While it may be useful in some scenarios, we recommend not using this setting unless you absolutely have to. The reason is that having the payload retained even after successful delivery is often useful for debugging and recovering from errors. While the payload is only deleted on successful delivery, we have seen scenarios where the receiver reported a success, but they actually failed to process the event and wanted to redrive it. If the payload is deleted, they won't be able to do that.

This is a per-environment setting which can be enabled from the [environment settings page](https://dashboard.svix.com/settings) on the dashboard.
