For the complete documentation index, see llms.txt. This page is also available as Markdown.

Import profiles

Load CRM data and scoring into user profiles, and choose how existing profiles are overwritten.

Your goal

Bring the timeless information you hold about your users - CRM fields, preferences, loyalty status, externally calculated scores - into the datamart as user profiles.

Expected outcome

Profiles attached to the right UserPoints, in the right compartments, updated according to a strategy you chose deliberately.

What a profile import does

The import performs UPSERT or DELETE operations on user profiles. A profile is a summary of information about a user, typically imported from an existing information system such as a CRM or a login database.

Run a profile import

1

Create the document import

Document type USER_PROFILE, mime type APPLICATION_X_NDJSON. Only ndjson is supported for user profiles.

curl -X POST \
  https://api.mediarithmics.com/v1/datamarts/<DATAMART_ID>/document_imports \
  -H 'Authorization: <YOUR_API_TOKEN>' \
  -H 'Content-Type: application/json' \
  -d '{
    "document_type": "USER_PROFILE",
    "mime_type": "APPLICATION_X_NDJSON",
    "encoding": "utf-8",
    "name": "<YOUR_DOCUMENT_IMPORT_NAME>"
}'
2

Create an execution with your profile commands

curl -X POST \
  https://api.mediarithmics.com/v1/datamarts/<DATAMART_ID>/document_imports/<DOCUMENT_IMPORT_ID>/executions \
  -H 'Authorization: <API_TOKEN>' \
  -H 'Content-Type: application/x-ndjson' \
  -d '{
        "operation": "UPSERT",
        "compartment_id": "<COMPARTMENT_ID>",
        "user_account_id": "<USER_ACCOUNT_ID>",
        "user_profile": {
              "firstname": "David",
              "lastname": "Guetta"
        }
      }'
3

Read the result

Check total_success, total_failure, and the error file. See reading the result.

The profile import command

Property
Type
Description

operation

Enum

UPSERT or DELETE.

compartment_id

String, optional

The compartment ID, acting as an identifier together with user_account_id.

user_account_id

String, optional

The account ID, acting as an identifier together with compartment_id.

email_hash

String, optional

The email hash, acting as an identifier.

user_agent_id

String, optional

The user agent ID, acting as an identifier.

update_strategy

Enum, optional

Only considered when the operation is UPSERT. PARTIAL_UPDATE, PARTIAL_DELETE, or FORCE_REPLACE.

user_profile

JSON object

Mandatory when the operation is UPSERT. The profile object.

Choosing an update strategy

update_strategy decides what happens to the profile already stored.

Strategy
What it does
Use it when

FORCE_REPLACE

The profile is completely replaced by the object you pass.

Your source system is authoritative and sends the whole profile every time.

PARTIAL_UPDATE

Targeted updates, without overwriting the whole profile.

You send deltas - a new loyalty card, a changed field. See Enrich user profiles.

PARTIAL_DELETE

Targeted deletion inside the profile.

You need to remove one object from an array rather than the whole profile. See Enrich user profiles.

FORCE_REPLACE, worked through

Stored profile:

Import command:

Resulting profile - the previous card is gone, not merged:

Legacy parameters

force_replace and merge_objects are legacy. Use update_strategy instead. They are documented here because existing integrations still use them.

Property
Type
Description

force_replace

Boolean

If true, the profile is completely replaced by the object in user_profile. If false, that object is merged with the existing profile.

merge_objects

Boolean

Only considered when force_replace is false. Controls what happens between two objects sharing a property. false - the default - means the new object overrides the existing one. true means the new object is deep-merged into the existing one.

What merge_objects: true does

Stored profile:

Imported with force_replace: false and merge_objects: true:

Result - scalars are overridden, arrays are appended to, objects are merged:

Note that arrays grow rather than being replaced, which is rarely what a nightly full export intends.

Verify

  • The execution reports the success count you expected, and the error file is empty.

  • A known profile shows the fields you sent, in the compartment you targeted.

  • A second import of the same file produces the result your strategy implies - replaced, merged, or appended.

Troubleshooting

Symptom
Likely cause

The whole request fails

A property in the payload is not declared in the schema, or its type does not match the schema.

Profiles are created but empty

$user_account_id and $compartment_id were not filled inside the profile object.

Arrays keep growing

merge_objects: true merges arrays. Use FORCE_REPLACE, or a partial update with a key.

"No profile id found while upserting a user profile"

The line does not carry a usable identifier.

Last updated

Was this helpful?