# Record a registration

> POST /api/v0/register: tell Releva that a customer created an account in your shop, from your server. Creates or updates the profile and stamps the registration time.

`POST https://releva.ai/api/v0/register` creates or updates a profile and sets its registration time to the moment of the call.

## When to use it

Call it from your server at the time a user completes their registration in your shop. Unlike [Create or update profiles](https://releva.ai/documentation/reference/profiles/create-or-update-profiles/), which is meant for backfill and bulk sync, this call is made for the sign-up moment. To load past registrations with their original dates, use Create or update profiles with `registeredAt`.

> **Marketing checkbox at sign-up**
>
> This call does not change marketing consent. If your registration page has a “subscribe to marketing” checkbox, also call [Subscribe a customer](https://releva.ai/documentation/reference/consent/subscribe-a-customer/) to mark the new user as subscribed. Alternatively, call [Create or update profiles](https://releva.ai/documentation/reference/profiles/create-or-update-profiles/) to send a subscribe date and a registration date in a single request.

## 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/record-a-registration/#errors)).

## Request

`POST /api/v0/register` with `content-type: application/json`. Send your customer `id`, with `email` or `phoneNumber` when you have them. Releva also accepts a request with only `email` or only `phoneNumber`; it answers `400` only when all three are missing.

| Field                   | Type             | Notes                                                                                                                                                                   |
| ----------------------- | ---------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `id`                    | string           | The user’s unique identifier in your database.                                                                                                                          |
| `email`                 | string           | A valid email address.                                                                                                                                                  |
| `phoneNumber`           | string           | Must start with `+` followed by digits only, for example `+49875345976`. A national number is converted with your shop’s country code, but send the international form. |
| `firstName`, `lastName` | string           |                                                                                                                                                                         |
| `birthday`              | string           | `YYYY-MM-DD` only.                                                                                                                                                      |
| `tags`                  | array of strings | Tags to apply to the user. **Replaces** the profile’s tags. Leave it out to keep the existing tags.                                                                     |

Unknown keys are ignored on this endpoint. There is no field for the registration date: every call sets it to now, also for a customer who registered before.

```plaintext
curl -X POST 'https://releva.ai/api/v0/register' \
  -H "authorization: Bearer $RELEVA_SECRET_KEY" \
  -H 'content-type: application/json' \
  -d '{
    "id": "DEMO-1001",
    "email": "maria@example.com",
    "firstName": "Maria",
    "lastName": "Example",
    "phoneNumber": "+15555550199",
    "tags": ["registered-online"],
    "birthday": "1990-05-12"
  }'
```

## Response

`202 Accepted` with the body `{}`. The profile is written when the response returns.

## 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`  | No identifier                                            | `At least one of (id, email, phoneNumber) is required!`                                                                                                                |
| `400`  | Bad email                                                | `The 'email' field must be a valid e-mail.`                                                                                                                            |
| `400`  | `tags` is not an array                                   | `The 'tags' field must be an array.`                                                                                                                                   |
| `400`  | `birthday` with a time part                              | `birthday must be a valid ISO-8601 date such as 2020-01-01 with optional time ... Got 1990-05-12T00:00:00Z instead.` (despite the text, only `YYYY-MM-DD` is accepted) |
| `400`  | Phone number that is not `+` and digits after conversion | `phoneNumber must be a valid telephone number starting with + and international code, e.g. +1. Got abc 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 profile per request.
* Rate limits: none on this endpoint.

## Next steps

* [Create or update profiles](https://releva.ai/documentation/reference/profiles/create-or-update-profiles/): Load past registrations in bulk with their own dates.
* [Consent API overview](https://releva.ai/documentation/reference/consent/overview/): Record a newsletter opt-in made at sign-up.
* [Connect your custom website](https://releva.ai/documentation/integrations/custom-website/connect-your-custom-website/): See where registration fits in a custom integration.