# Export a profile's data

> POST /api/v0/profiles/exports: e-mail a download link with everything Releva holds about one person (profile, devices, events, attribution), for a data access request.

`POST https://releva.ai/api/v0/profiles/exports` collects everything Releva holds about one person and e-mails a download link to the address you give.

## When to use it

GDPR gives users the right to access the personal data held about them. Call it from your server to fulfil such a data subject access request in an automated way. The export holds the profile, its devices, its events and its attribution records, including those of profiles merged into it. To read only the profile fields, [Get a profile](https://releva.ai/documentation/reference/profiles/get-a-profile/) is faster.

## Authentication

Send your shop’s Secret Key as a bearer token, from your server only:

```plaintext
authorization: Bearer $RELEVA_SECRET_KEY
```

Find the key under **Settings › Shop & Integration**; see [Find your Access Token and Secret Key](https://releva.ai/documentation/guides/shop-settings/find-your-api-keys/). Authentication failures answer `400`, not `401` (see [Errors](https://releva.ai/documentation/reference/profiles/export-a-profiles-data/#errors)).

## Request

`POST /api/v0/profiles/exports` with `content-type: application/json`.

| Field         | Type   | Required                                           | Notes                                                        |
| ------------- | ------ | -------------------------------------------------- | ------------------------------------------------------------ |
| `sendToEmail` | string | yes                                                | Where the download link goes, for example your privacy team. |
| `email`       | string | exactly one of `email`, `profileId`, `phoneNumber` | The person’s email address.                                  |
| `profileId`   | string |                                                    | Your customer id.                                            |
| `phoneNumber` | string |                                                    | International form only: `+` and digits.                     |

```plaintext
curl -X POST 'https://releva.ai/api/v0/profiles/exports' \
  -H "authorization: Bearer $RELEVA_SECRET_KEY" \
  -H 'content-type: application/json' \
  -d '{ "email": "maria@example.com", "sendToEmail": "privacy@demo-store.example.com" }'
```

To find the person by your customer id or phone number instead, replace `email` in the body:

```plaintext
curl -X POST 'https://releva.ai/api/v0/profiles/exports' \
  -H "authorization: Bearer $RELEVA_SECRET_KEY" \
  -H 'content-type: application/json' \
  -d '{ "profileId": "DEMO-1001", "sendToEmail": "privacy@demo-store.example.com" }'


curl -X POST 'https://releva.ai/api/v0/profiles/exports' \
  -H "authorization: Bearer $RELEVA_SECRET_KEY" \
  -H 'content-type: application/json' \
  -d '{ "phoneNumber": "+15555550199", "sendToEmail": "privacy@demo-store.example.com" }'
```

## Response

`202 Accepted` with the body `{}`. The export runs in the background after the response. When it is ready, `sendToEmail` gets an e-mail with the subject `<your shop URL> - Data request result ready to download` and a **Download Data Dump** button. The e-mail says the link is valid for 7 days.

The file is JSON Lines: one JSON object per line, each with one key that names the record type: `profile`, `device`, `event`, `attribution` or `productAttribution`.

## Errors

Errors have one shape, `{ "message": "..." }`.

| Status | When                               | Message                                                                                                                 |
| ------ | ---------------------------------- | ----------------------------------------------------------------------------------------------------------------------- |
| `400`  | No `authorization` header          | `Authorization header is missing.`                                                                                      |
| `400`  | The header is not `Bearer <token>` | ``Authorization header is malformed. It should look like `Bearer <string>`.``                                           |
| `400`  | The token is not a UUID            | `Authorization header contains an invalid Bearer token.`                                                                |
| `400`  | No shop has this key               | `Domain with the provided secret key cannot be found.`                                                                  |
| `400`  | Missing `sendToEmail`              | `The 'sendToEmail' field is required.`                                                                                  |
| `400`  | No identifier, or more than one    | `Exactly one of (profileId, phoneNumber, email) is required.`                                                           |
| `400`  | Unknown key, for example `format`  | `The object '' contains forbidden keys: 'format'.`                                                                      |
| `400`  | National phone number              | `phoneNumber must be a valid telephone number starting with + and international code, e.g. +1. Got 0888000111 instead.` |
| `402`  | The shop is disabled               | `Domain is disabled. Please reach out to support@releva.ai to enable it.`                                               |
| `413`  | Body larger than 800 KB            | `request entity too large`                                                                                              |
| `500`  | Unexpected error                   | `An internal error occurred.` Retry later.                                                                              |

## Limits

* One person per request.
* Rate limits: none on this endpoint.
* The `202` means the export was queued, not that a profile matched.

## Next steps

* [Delete a profile](https://releva.ai/documentation/reference/profiles/delete-a-profile/): Erase the person’s data once they have their copy.
* [Get a profile](https://releva.ai/documentation/reference/profiles/get-a-profile/): Read only the profile fields, without events.
* [How customer profiles work](https://releva.ai/documentation/learn/profiles/how-profiles-work/): Learn which merged profiles the export includes.