> For the complete documentation index, see [llms.txt](https://user.netmera.com/netmera-developer-guide/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://user.netmera.com/netmera-developer-guide/api-documentation/recipes/registering-users-and-profiles.md).

# Registering Users and Building a Profile

Register users from your backend with tags and profile attributes, then update and read the profile.

This recipe shows how to register users and their devices from your backend, set their tags and profile attributes in the same request, update the profile later, and read it back. A complete profile is the basis for targeting and personalization in every other recipe.

## When to Use

This recipe fits flows where your own system is the source of truth for user data, such as a sign-up flow, a CRM sync, or a migration of existing users into Netmera.

## Prerequisites

* REST API key of the application
* The external ID (`extId`) that identifies each user in your system
* Profile attributes defined in the Netmera panel. Keys in a `profile` object must match attributes defined for the application.

## Step 1: Look Up the Profile Attribute Definitions

List the attributes of the application with `app/profile-attributes`. Use the returned `code` values as keys in `profile` objects.

```bash
curl https://restapi.netmera.com/rest/3.0/app/profile-attributes \
  --header 'X-netmera-api-key: <API_KEY>'
```

`standardProfileAttributes` contains the built-in attributes in use and `customProfileAttributes` contains the attributes created in the panel. Each entry shows its `dataType` and whether it is an `array` attribute, which decides if it can be changed with the push and pull endpoints in Step 3.

**Expected result:** The attributes you plan to set are listed with their codes and data types.

## Step 2: Register the Users

Send one entry per registration to `registerUsers`. An entry is a device, identified by `platform` and `deviceToken`, or an SMS-only user, identified by `msisdn`. `tags` and `profile` are applied to the user in the same request.

```bash
curl https://restapi.netmera.com/rest/3.0/registerUsers \
  --request POST \
  --header 'Content-Type: application/json' \
  --header 'X-netmera-api-key: <API_KEY>' \
  --data '[
  {
    "extId": "user_1001",
    "platform": "IOS",
    "deviceToken": "<DEVICE_TOKEN>",
    "email": "john.brown@example.com",
    "tags": ["Sport"],
    "profile": {
      "name": "John",
      "age": 34
    }
  }
]'
```

{% hint style="info" %}
`platform` is required unless `msisdn` is sent. A registration with only `msisdn` is stored as an SMS user. `extId` is optional, but it is needed to target the user in other endpoints.
{% endhint %}

Registrations are processed asynchronously. An entry that fails validation is skipped without affecting the others. The request is rejected only when every entry is invalid or when no registration is sent.

**Expected result:** The users are registered with their tags and profile attributes.

## Step 3: Update the Profile

Use `setProfileAttributes` to set or change attributes of existing users. The body is an array with one entry per user.

```bash
curl https://restapi.netmera.com/rest/3.0/setProfileAttributes \
  --request POST \
  --header 'Content-Type: application/json' \
  --header 'X-netmera-api-key: <API_KEY>' \
  --data '[
  {
    "extId": "user_1001",
    "profile": { "age": 35 }
  }
]'
```

For attributes of the array type, `pushProfileAttributes` appends values and `pullProfileAttributes` removes values. The attribute must be an array attribute.

```bash
curl https://restapi.netmera.com/rest/3.0/pushProfileAttributes \
  --request POST \
  --header 'Content-Type: application/json' \
  --header 'X-netmera-api-key: <API_KEY>' \
  --data '[
  {
    "extId": "user_1001",
    "profile": {
      "lastVisitedCategories": ["shopping"]
    }
  }
]'
```

To remove attributes from a user, send the attribute keys to `unsetProfileAttributes`, for example `"profile": ["age"]`.

**Expected result:** The attributes of the user reflect the new values.

## Step 4: Read the Profile Back

Verify the stored state with `getProfileAttributes`.

```bash
curl 'https://restapi.netmera.com/rest/3.0/getProfileAttributes?extId=user_1001' \
  --header 'X-netmera-api-key: <API_KEY>'
```

The response contains the `extId` and a `profile` object with the current attributes of the user:

```json
{
  "extId": "user_1001",
  "profile": {
    "name": "John",
    "email": "john.brown@example.com",
    "age": 35
  }
}
```

**Expected result:** The profile shows the values sent in Step 2 and Step 3.

## Verification Checklist

* Keys in `profile` match the attribute codes returned by `app/profile-attributes`
* `extId` is set on every registration that will be targeted later
* `platform` is sent for device registrations, and `msisdn` for SMS-only users
* Each request contains at most 1000 unique external IDs
* `pushProfileAttributes` and `pullProfileAttributes` are used only on array attributes
* Registrations are processed asynchronously, so `getProfileAttributes` is called after they are accepted

## Related Pages

For all registration parameters and the full list of profile attribute endpoints, see [User & Device Management](/netmera-developer-guide/api-documentation/rest-api/user-and-device-management.md) in the REST API documentation. For the attribute definitions endpoint, see [Application Data](/netmera-developer-guide/api-documentation/rest-api/application-data.md). To target users by these attributes, see [Targeting a Push Campaign by Segment or Profile Attribute](/netmera-developer-guide/api-documentation/recipes/targeting-by-segment-or-profile.md).


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://user.netmera.com/netmera-developer-guide/api-documentation/recipes/registering-users-and-profiles.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
