# UserProfile

A UserProfile is usually [imported from an existing information system,](https://developer.mediarithmics.io/data-streams/data-ingestion/bulk-processing/imports/profiles) for example CRM, and login database. We usually see our customers using the profile to collect:

* Contact details
* User preferences
* Status in a loyalty program
* Subscription to a newsletter
* CRM information
* Scoring calculated outside the platform
* Aggregated Values
* *other details*

Each UserProfile is associated with a UserPoint by a [user identifier](https://developer.mediarithmics.io/user-points/..#user-identifiers). It can also be linked to a UserAccount.

## User profile object

| field                  | type               | description                                                                                      |
| ---------------------- | ------------------ | ------------------------------------------------------------------------------------------------ |
| $user\_account\_id     | String (Optional)  | The associated UserAccount ID. If none, the profile remains anonymous.                           |
| $compartment\_id       | Integer (Optional) | The compartment ID. If none, the profile is imported into the default compartment\_id.           |
| $last\_modified\_ts    | Timestamp          | The timestamp of the last edit operation for this user profile. Automatically set by the system. |
| $creation\_ts          | Timestamp          | The timestamp of the creation operation for this user profile. Automatically set by the system.  |
| \[any custom property] | Any                | The value of a custom property                                                                   |

{% hint style="warning" %}
When importing profiles it is recommended to complete the $user\_account\_id and the $compartment\_id event if the values are the same than the ones used as the identifier as the values are not inherited from the identifiers info. You can find more information about the [user profiles import](https://developer.mediarithmics.io/data-streams/data-ingestion/bulk-processing/imports/profiles).
{% endhint %}

### Example:

```javascript
# UserProfile object 
{
    "$compartment_id": 1606,
    "$user_account_id": "c9879698769OIUYOIY9879879",
    "$last_modified_ts": 5467987654613,
    "$creation_ts": 6579874654654654,
    "firstname": "David",
    "lastname": "Guetta",
    "gender": 1,
    "newsletter_options": {
        "subscribed": true,
        "preferred_periods": "MONTHLY"
    }
    
}
```

```javascript
# Complete payload when importing a profile 
{ 
    "operation": "UPSERT",
    "compartment_id": "1600", 
    "user_account_id": "identifier_account_id",
    "force_replace": true,
    "user_profile": {
        "$compartment_id": 1606,
        "$user_account_id": "c9879698769OIUYOIY9879879",
        "$last_modified_ts": 5467987654613,
        "$creation_ts": 6579874654654654,
        "firstname": "David",
        "lastname": "Guetta",
        "gender": 1,
        "newsletter_options": {
            "subscribed": true,
            "preferred_periods": "MONTHLY"
        }
    }
}
```

{% hint style="success" %}
You can have different compartment IDs and different UserAccount between the one in the profile wrapper, as the UserPoint identifier and the one into the UserProfile object.
{% endhint %}
