---
title: "Update User Email Opt-in Preferences"
method: PUT
path: "/v1.0/opt-in-management/user-preferences"
tags: ["Opt-in Management"]
---

# Update User Email Opt-in Preferences

`PUT /v1.0/opt-in-management/user-preferences`

## Request

- Base URL: `https://api-01.moengage.com`
- URL: `https://api-01.moengage.com/v1.0/opt-in-management/user-preferences`
- Auth: HTTP basic
- TypeScript: <https://skmtc.dev/moengage/apis/moengage-email-subscription-management-apis/docs/v1.0/opt-in-management/user-preferences/put.ts> (a function with typed inputs; its response is checked against the schema)

This API updates a user's overall email opt-in status and/or category-level subscription preferences within MoEngage. This API is typically used after a user submits the second confirmation through MoEngage consent-seeking emails (Double Opt-in).

## Headers

- `MOE-APPKEY` string, required
- `MOE-PROJECT-CODE` string

## Request body

- OptinRequest: The main wrapper object for the user preferences payload.
  - `user_preferences` UserPreferences, required: Contains the user's opt-in preferences. Must contain either `customer_id` or `email_id`.
    - `customer_id` string: Unique identifier for the user in MoEngage. Optional, if `email_id` is passed. To avoid error, make sure you pass either `customer_id` or `email_id`. If you are passing `customer_id`, `email_id` is not mandatory. If you pass only `customer_id`, MoEngage finds the user with this `customer_id` and updates the opt-in status accordingly. Generally, when `email_id` is passed, MoEngage finds all users with this `email_id` and updates the opt-in status accordingly. But if you don't want all the users with this `email_id` to be updated, you can contact the MoEngage team. `customer_id` is mandatory if you don't want to pass the opt-in status update to all users with the same email ID.
    - `email_id` string, email: Email ID of the user. Optional if `customer_id` is provided. If only `email_id` is provided, all users with this email may be updated (contact MoEngage support to configure behavior). To avoid error, make sure you pass `customer_id` or `email_id`. If you are passing `email_id`, `customer_id` is not mandatory. If you pass only `email_id`, MoEngage finds all the users with this `email_id` and updates the opt-in status accordingly. You can also pass both `customer_id` and `email_id`. In this case, `email_id` is given the highest priority, and MoEngage finds all users with this `email_id` and updates the opt-in status accordingly. You can contact the MoEngage team if you don't want to update the opt-in status of all users with the same email ID.
    - `categories` object: Subscription status for defined categories in your dashboard. Keys are category names, values are boolean (`true`=subscribed). If even one category is invalid/inactive, the entire request will fail. **Note**: If this is passed and all category values are `false`, the overall `opt_in_status` will be overridden to **OPTED_OUT** even if `DOUBLE_OPTED_IN` is passed.
    - `opt_in_status` 'DOUBLE_OPTED_IN' | 'OPTED_OUT' | 'OPT_IN_PENDING', required: The user's overall email opt-in status. Note: This field is case-insensitive, but ensure that you follow the same format as in the example. You can pass both `categories` and `opt_in_status`. In this case, if all category values are `false` and `opt_in_status` is `DOUBLE_OPTED_IN`, MoEngage gives high priority to category-level information and the opt-in status is updated as `OPTED_OUT`.
    - `channel` 'email', required: The channel for which the opt-in status applies. Currently, only **email** is supported.

## Response `200`

The request has been processed successfully.

- OptinSuccessResponse: Success response body for the Opt-in Management API (200 OK).
  - `message` string: The success message denoting the request was processed successfully.

## Other responses

- `400`: Bad Request. Returned when required parameters are missing, incorrect data types are used, invalid values are passed (e.g., invalid `opt_in_status`), the user is not found, or project code missing for Portfolio enabled workspaces.
- `401`: Unauthorized. Authentication failed (e.g., missing Authorization header, wrong Workspace ID, or wrong Data API Key).
- `403`: Forbidden. Returned when the Email Opt-in Management feature is not enabled for the workspace.
- `429`: Too Many Requests. The request rate has exceeded the limit of 1000 RPM or 360K per day.
- `500`: Internal Server Error.

---

[API](https://skmtc.dev/moengage/apis/moengage-email-subscription-management-apis.md) - [All operations](https://skmtc.dev/moengage/apis/moengage-email-subscription-management-apis/llms.txt) - [OpenAPI document](https://skmtc.dev/moengage/apis/moengage-email-subscription-management-apis/revisions/d430419491a1?raw)
