Map user
POST
/consent/map-userWhen a user interacts with your application before logging in, truConsent records consent under a temporary anonymous or session-based ID. Once the user authenticates, call this endpoint to transfer all of those consent records to their permanent authenticated user ID. This preserves the full consent history across the login boundary.
A typical integration records consent with a session token as the userId, then calls this endpoint at login to reassign those records to the authenticated user ID from your identity provider.
Headers
| Header | Type | Required | Description |
|---|---|---|---|
X-API-Key | string | Yes | Your tenant API key |
Body
| Field | Type | Required | Description |
|---|---|---|---|
anonymousId | string | Yes | The anonymous or session-based user ID to transfer records from. All consent log entries where data_principal_id matches this value will be reassigned. |
authenticatedUserId | string | Yes | The authenticated user ID to transfer consent records to. |
metadata | object | No | Optional key-value pairs to attach to the mapping event. Merged into the metadata field of each transferred consent log entry. |
Response
200 OK
| Field | Type | Description |
|---|---|---|
success | boolean | true if the operation completed without error |
mapped_count | integer | Number of consent log entries transferred. A value of 0 means no records were found for the given anonymous ID — this is not an error. |
anonymous_id | string | The anonymous ID that was provided in the request |
authenticated_user_id | string | The authenticated user ID that records were transferred to |
message | string | A human-readable summary of the operation result |
Errors
| Status | Description |
|---|---|
422 | anonymousId or authenticatedUserId is missing or fails validation |
500 | Internal server error |
Example
curl --request POST \ --url 'https://{your-truConsent-endpoint}/consent/map-user' \ --header 'Content-Type: application/json' \ --header 'X-API-Key: tck_live_xxxxxxxxxxxx' \ --data '{ "anonymousId": "sess_a3f9b12c4d8e", "authenticatedUserId": "usr_7f3a9b21", "metadata": { "login_method": "google_oauth", "session_start": "2026-04-21T09:00:00Z" } }'{ "success": true, "mapped_count": 2, "anonymous_id": "sess_a3f9b12c4d8e", "authenticated_user_id": "usr_7f3a9b21", "message": "Successfully mapped 2 consent logs"}