# Delete and retention

How long BeeL. keeps customer replies, how to delete one to answer an erasure request, and what your webhook endpoint must do when it hears about it.

Customer replies hold personal data of people who are not your users. BeeL. stores them on behalf
of the company, which decides what to do with them and should tell its customers in its privacy
policy. Two mechanisms limit how long they last: a fixed retention and deletion on request.

## Retention

Twelve months after `received_at`, BeeL. empties the content of a reply: `text`, `excerpt`,
`subject`, `sender`, `attachments` and `external_id` become `null`. The identifiers, `channel`,
invoice, dates and `status` stay. A cleanup runs once a day, so it can take until the next one.

The same message still cannot be registered again after that, even though its `external_id` is gone.

## Delete a reply

To answer an erasure request, call
[`DELETE /v1/companies/{company_id}/invoice-replies/{reply_id}`](/invoice-replies/deleteCompanyInvoiceReply)
with `invoice-replies:write`.

- It erases the text, subject, sender, attachments, `external_id` and `connection_id` of the reply
  and delivers [`invoice.reply.deleted`](/webhook-events/onInvoiceReplyDeleted).
- It answers `204`. Repeating the call also answers `204` and delivers nothing.
- A reply that never existed, or belongs to another company or environment, answers
  `404` [`INVOICE_REPLY_NOT_FOUND`](/errors/INVOICE_REPLY_NOT_FOUND).
- The same `channel` and `external_id` can no longer be registered. A new attempt answers
  `409` [`INVOICE_REPLY_DUPLICATE`](/errors/INVOICE_REPLY_DUPLICATE) without `reply_id`, so a late retry of an integration
  does not bring back what was erased.

## What your endpoint must do

Webhooks already delivered cannot be recalled, so the copy you made is yours to erase. On
`invoice.reply.deleted`:

1. Erase what you stored about `reply_id` from earlier `invoice.reply.*` events. The event only carries
   `reply_id`, `invoice_id` and `deleted_at`.
2. Remember the `reply_id`, and discard any `invoice.reply.received` with that id that arrives afterwards.
   BeeL. stops sending it once the reply is deleted, but a retry that was already scheduled can still
   reach you.

## Delivery history

In the delivery history of your webhook subscriptions, the `payload` and `response_body` of an
`invoice.reply.received` delivery are no longer returned once the reply is past its 12 months, and shortly
after it is deleted.
Such a delivery can no longer be retried: it answers `404` [`DELIVERY_LOG_NOT_FOUND`](/errors/DELIVERY_LOG_NOT_FOUND).
The `invoice.reply.deleted` deliveries only carry identifiers and are kept, so the notice can be retried.

## Related

<Related>

- [Read customer replies](/guides/customer-replies): what is masked in the webhook and the list
- [Webhook retries](/webhooks/retries): how scheduled retries behave
- [Webhook deduplication](/webhooks/deduplication): handling the same event twice

</Related>

---

Full OpenAPI spec: https://docs.beel.es/api/openapi