# Delete contacts

Source: https://kirora.io/docs/api/reference/deleteContacts

`POST /v1/contacts/delete`

Requires an API key with the `contacts:delete` scope. [About keys and scopes](https://kirora.io/docs/api/reference/authentication)

Works with integration and partner keys, not agent keys.

Safe to retry: a repeat sets the same values again. [About idempotency](https://kirora.io/docs/api/reference/idempotency)

Deletes up to 100 contacts, each named by `contactId`, `externalId` or `email`, and reports an outcome per contact. For each one deleted, its events, list memberships, consent changes and journey enrollments go with it. Journey messages go with the enrollments; campaign and transactional messages are kept for campaign totals but anonymised: the address, content and provider ids are removed and nothing links them to the person. Address suppressions are kept, so a deleted address that is imported again is still not mailed. `send_in_progress` means a message was being handed to the provider; retry that one shortly. Requires `contacts:delete`; agent keys are refused.

## Header parameters

- `Kirora-Workspace` (string, optional, pattern `^[A-Za-z0-9._:-]{1,128}$`) — Partner keys only: the child workspace to act in, by the external id the partner gave it. Without it, a partner key acts in its own workspace. Any other key that sends it is refused with 403, and an unknown workspace is 404.
- `Idempotency-Key` (string, optional, 8–255 characters) — Makes a retry safe: a repeat with the same key and body within 24 hours gets the first response again, with `Idempotency-Replay: true`. The same key with another request is 409 `IDEMPOTENCY_KEY_REUSED`; while the first is still running, 409 `IDEMPOTENCY_KEY_IN_USE`; after an `unsafe` first request failed or never returned, 409 `IDEMPOTENCY_KEY_OUTCOME_UNKNOWN`. Use a new key, such as a UUID, for each new request.

## Request body

- `contacts` (object[], required, at least 1 item, at most 100 items)
  - Any of: **By contact id**
    - `contactId` (string, required, uuid) — Kirora's id for the contact.
  - Any of: **By external id**
    - `externalId` (string, required, 1–255 characters) — Your own id for the contact, as set with identify.
  - Any of: **By email**
    - `email` (string, required) — The contact's email address, matched trimmed and without case.

## Returns

Returns `200 OK` with a `DeleteContactsResult` in `data`. It can also return `409 Conflict`, `413 Payload Too Large` or `415 Unsupported Media Type`; see the statuses below. Otherwise returns an error; [Errors](https://kirora.io/docs/api/reference/errors) lists every code and which to retry.

- `results` (object[], required)
  - `contact` (object, required) — The contact as named in the request.
    - Any of: **By contact id**
      - `contactId` (string, required, uuid) — Kirora's id for the contact.
    - Any of: **By external id**
      - `externalId` (string, required, 1–255 characters) — Your own id for the contact, as set with identify.
    - Any of: **By email**
      - `email` (string, required, email, up to 320 characters) — The contact's email address, matched trimmed and without case.
  - `outcome` (string, required, one of `deleted`, `not_found`, `send_in_progress`) — `send_in_progress`: a message is being handed to the provider; retry shortly.

Statuses:

- `200 OK`: One result per contact named, in request order.
- `409 Conflict`: The request conflicts with current state — a duplicate unique value, or a resource whose status does not allow this operation.
- `413 Payload Too Large`: The body is larger than this operation accepts (`PAYLOAD_TOO_LARGE`).
- `415 Unsupported Media Type`: The body is not JSON, or not the upload the operation takes (`UNSUPPORTED_MEDIA_TYPE`).

Headers on `200 OK`:

- `Idempotency-Replay` (string, optional, one of `true`) — `true` when this is the stored response to an earlier request with the same key.

## Example: Delete two contacts

```bash
curl -X POST https://api.kirora.io/v1/contacts/delete \
  -H "Authorization: Bearer $KIRORA_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "contacts": [
      {
        "email": "amaka@example.com"
      },
      {
        "externalId": "customer-0000"
      }
    ]
  }'
```

Response `200`:

```json
{
  "data": {
    "results": [
      {
        "contact": {
          "email": "amaka@example.com"
        },
        "outcome": "deleted"
      },
      {
        "contact": {
          "externalId": "customer-0000"
        },
        "outcome": "not_found"
      }
    ]
  }
}
```
