---
openapi: 3.0.3
info:
  title: Braze REST API – Update user's subscription group status (V2)
  description: |
    ## Prerequisites

    To use this endpoint, you need an [API key]({{site.baseurl}}/api/basics#rest-api-key-permissions) with the `subscription.status.set` permission.

    **Note:**
    If you're interested in using this endpoint with [LINE subscription groups]({{site.baseurl}}/user_guide/channels/line/message_users/subscription_groups/), contact your customer success manager.

    For LINE subscription groups, we recommend using a custom attribute to track website or app consent separately, and then targeting campaigns using that custom attribute in combination with the LINE subscription state. This approach ensures your subscription state accurately reflects users who have actually subscribed in the LINE app. Manually adding users to LINE subscription groups using the API may lead to out-of-sync states and failed sends since Braze cannot re-subscribe users in the LINE app or send messages to users who have blocked an account in LINE.

    ## Rate limit

    This endpoint has a rate limit of 5,000 requests per minute shared across the `/subscription/status/set` and `/v2/subscription/status/set` endpoint as documented in [API rate limits]({{site.baseurl}}/api/api_limits/).

    ## How Braze handles orphaned subscription states

    An orphaned subscription state is a subscription state stored for a phone number or email address that isn't associated with any user profile. For SMS, email, WhatsApp, and LINE, Braze handles orphaned subscription states as follows:

    - If a user is deleted and is the only user associated with a given phone number or email address, the subscription state for that phone number or email address is deleted immediately.
    - If you call `/subscription/status/set` or `/v2/subscription/status/set` with a phone number or email address that is not currently associated with any user profile, Braze stores that subscription state for up to 30 days, after which it is automatically deleted.
        - If `use_double_opt_in_logic` is set to `true` and no user profile is associated with the provided phone number, the subscription state is not updated; a user must exist to enter the double opt-in workflow.
    - If a new user profile is created with a phone number or email address that has an orphaned subscription state stored for it, that user inherits the stored subscription state but only within the 30-day window. This 30-day grace period is intentional and exists to handle race conditions when creating a user and setting its channel identifier's subscription state happen in separate API calls. An example of this race condition is when a `/subscription/status/set` request is processed for a phone number before the `/users/track` request creating the corresponding user profile is processed.
  version: 1.0.0
  contact:
    name: Braze Support
    url: https://www.braze.com/docs/braze_support/
  license:
    name: Braze Documentation
    url: https://www.braze.com/docs/api/home/
servers:
  - url: https://rest.iad-01.braze.com
    description: US-01
  - url: https://rest.iad-02.braze.com
    description: US-02
  - url: https://rest.iad-03.braze.com
    description: US-03
  - url: https://rest.iad-04.braze.com
    description: US-04
  - url: https://rest.iad-05.braze.com
    description: US-05
  - url: https://rest.iad-06.braze.com
    description: US-06
  - url: https://rest.iad-07.braze.com
    description: US-07
  - url: https://rest.iad-08.braze.com
    description: US-08
  - url: https://rest.us-10.braze.com
    description: US-10
  - url: https://rest.fra-01.braze.eu
    description: EU-01
  - url: https://rest.fra-02.braze.eu
    description: EU-02
  - url: https://rest.au-01.braze.com
    description: AU-01
  - url: https://rest.id-01.braze.com
    description: ID-01
  - url: https://rest.jp-01.braze.com
    description: JP-01
  - url: https://rest.kr-01.braze.com
    description: KR-01
security:
- BearerAuth: []
paths:
  "/v2/subscription/status/set":
    post:
      summary: Update user's subscription group status (V2)
      operationId: post_v2_subscription_status_set_post_update_user_subscription_group_status_v2
      description: |
        ## Differences from V1

        The V2 endpoint differs from the [V1 endpoint]({{site.baseurl}}/api/endpoints/subscription_groups/post_update_user_subscription_group_status/) in the following ways:

        - **Multiple subscription groups**: V2 lets you update multiple subscription groups in a single API request, while V1 supports only one subscription group per request.
        - **Update both email and SMS in one call**: When using `external_ids`, you can update both email and SMS subscription groups for the same users in a single API call. With V1, you must make separate API calls for email and SMS subscription groups.
        - **Using email or phone identifiers**: If you use `emails` or `phones` instead of `external_ids`, you cannot update both email and SMS subscription groups in the same request. You must make separate API calls—one for email subscription groups and one for SMS subscription groups.

        **Important:**
        **Phone number format**: Phone numbers must be in [E.164 format](https://en.wikipedia.org/wiki/E.164) (for example, `+12223334444`). Phone numbers that are not in E.164 format are rejected.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UpdateUserSubscriptionGroupStatusV2Request'
            examples:
              external_ids:
                summary: Email and SMS subscription groups by external ID
                description: The following example uses `external_ids` to update both email and SMS subscription groups in a single API call. This is only possible when using `external_ids`—you cannot update both email and SMS subscription groups in one call when using `emails` or `phones`.
                value:
                  subscription_groups:
                    - subscription_group_id: subscription_group_identifier
                      subscription_state: subscribed
                      external_ids:
                        - example-user
                        - example1@example.com
                    - subscription_group_id: another_subscription_group_identifier
                      subscription_state: subscribed
                      external_ids:
                        - example-user
                        - example1@example.com
              email:
                summary: Email
                value:
                  subscription_groups:
                    - subscription_group_id: subscription_group_identifier
                      subscription_state: subscribed
                      emails:
                        - example1@example.com
                        - example2@example.com
              sms_and_whatsapp:
                summary: SMS and WhatsApp
                value:
                  subscription_groups:
                    - subscription_group_id: subscription_group_identifier
                      subscription_state: subscribed
                      phones:
                        - "+15555550100"
                        - "+15555550101"
      responses:
        "201":
          description: The request succeeded and the subscription group statuses were updated. No action needed.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UpdateUserSubscriptionGroupStatusV2Response'
              examples:
                success:
                  summary: Subscription group statuses updated
                  value:
                    message: success
        "400":
          description: |
            Bad request. To resolve it:

            - **More than 25 subscription groups were provided:** Send 25 or fewer subscription groups per request.
            - **Two subscription group objects share the same ID and state:** Remove duplicate subscription group objects.
            - **A user has conflicting states for the same subscription group:** Send one state per user per subscription group.
            - **The `emails` field isn't a valid array:** Pass `emails` as an array of email addresses.
            - **The `phones` field isn't a valid array:** Pass `phones` as an array of E.164 phone numbers.
            - **The `external_ids` field isn't a valid array:** Pass `external_ids` as an array of strings.
            - **No `emails`, `phones`, or `external_ids` was provided:** Include `emails`, `phones`, or `external_ids`.
            - **Both an email address and a phone number were provided:** Include either an email address or a phone number, but not both.
            - **More than 50 email addresses were provided:** Send 50 or fewer email addresses per request.
            - **More than 50 phone numbers were provided:** Send 50 or fewer phone numbers per request.
            - **More than 50 external IDs were provided:** Send 50 or fewer external IDs per request.
            - **The `subscription_group_id` isn't valid:** Pass a valid `subscription_group_id` from **Subscription Group** settings.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                too_many_subscription_groups:
                  summary: More than 25 subscription groups
                  value:
                    message: You can only pass in 1 to 25 subscription groups at a time.
                duplicate_subscription_groups:
                  summary: Duplicate subscription group objects
                  value:
                    message: Subscription group objects cannot have the same subscription_group_id and subscription_state.
                conflicting_states:
                  summary: Conflicting states for one user
                  value:
                    message: Users cannot have multiple states present for the same subscription group.
                invalid_emails_array:
                  summary: Invalid emails array
                  value:
                    message: The value provided for the email field is not a valid email array.
                invalid_phones_array:
                  summary: Invalid phones array
                  value:
                    message: The value provided for the phones field is not a valid phone number array.
                invalid_external_ids_array:
                  summary: Invalid external_ids array
                  value:
                    message: The value provided for the external_ids field is not a valid ID array.
                no_identifier:
                  summary: No emails, phones, or external_ids
                  value:
                    message: You must provide an email address, a phone number, or an external user id.
                email_and_phone:
                  summary: Both an email address and a phone number
                  value:
                    message: Either an email address or a phone number should be provided, but not both.
                too_many_emails:
                  summary: More than 50 email addresses
                  value:
                    message: You can only pass in 1 to 50 emails at a time.
                too_many_phones:
                  summary: More than 50 phone numbers
                  value:
                    message: You can only pass in 1 to 50 phone numbers at a time.
                too_many_external_ids:
                  summary: More than 50 external IDs
                  value:
                    message: You can only pass in 1 to 50 external ids at a time.
                invalid_subscription_group_id:
                  summary: Invalid subscription group ID
                  value:
                    message: Invalid subscription group ID
        "401":
          description: |
            Unauthorized. The REST API key is missing, malformed, or sent to the wrong REST endpoint. Send the key as `Authorization: Bearer YOUR_REST_API_KEY` to the correct [REST endpoint]({{site.baseurl}}/api/basics/#endpoints). For more causes, see [Errors and responses]({{site.baseurl}}/api/errors/#fatal-errors).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                invalid_api_key:
                  summary: Invalid API key
                  value:
                    message: 'Invalid API key: YOUR_REST_API_KEY'
        "403":
          description: Access denied. The REST API key doesn't have the required permission. Use a REST API key that has the `subscription.status.set` permission.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                access_denied:
                  summary: Missing permission
                  value:
                    message: Access Denied
        "429":
          description: |
            Rate limited. You exceeded the rate limit for this endpoint. Slow your request rate and retry with exponential backoff. See [API rate limits]({{site.baseurl}}/api/api_limits/).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                over_rate_limit:
                  summary: Over rate limit
                  value:
                    message: You have exceeded your limit of 5000 requests per minute. Please contact your account executive to increase your limit. If you do not have their info, you may contact Braze directly at https://www.braze.com/contact/.
        5XX:
          description: |
            Internal server error. An unexpected error occurred on the Braze server. Retry with exponential backoff. If the error persists, contact [Support]({{site.baseurl}}/braze_support/).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
components:
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: REST API key
      description: |
        REST API keys are created in the Braze dashboard at **Settings → APIs and
        Identifiers → API Keys**. The key must include the `subscription.status.set` permission.
        Pass the key as `Authorization: Bearer YOUR_REST_API_KEY`.
  schemas:
    SubscriptionGroupUpdate:
      title: Subscription group update
      type: object
      required: [subscription_group_id, subscription_state]
      properties:
        subscription_group_id:
          type: string
          description: The `id` of your subscription group. See [`subscription_group_id`]({{site.baseurl}}/api/identifier_types/?tab=subscription%20group%20ids).
          example: subscription_group_identifier
        subscription_state:
          type: string
          enum: [subscribed, unsubscribed]
          description: Available values are `unsubscribed` (not in subscription group) or `subscribed` (in subscription group).
          example: subscribed
        external_ids:
          type: array
          minItems: 1
          maxItems: 50
          items:
            type: string
          description: The `external_id` of the user or users, may include up to 50 `id`s.
          example:
            - example-user
            - example1@example.com
        emails:
          type: array
          minItems: 1
          maxItems: 50
          items:
            type: string
          description: |
            The email address of the user, can be passed as an array of strings. Must include at least one email address (with a maximum of 50).

            If multiple users (`external_id`) in the same workspace share the same email address, all users that share the email address are updated with the subscription group changes.
          example:
            - example1@example.com
            - example2@example.com
        phones:
          type: array
          minItems: 1
          maxItems: 50
          items:
            type: string
          description: |
            You can pass user phone numbers as an array of strings. Must include at least one phone number (up to 50). Phone numbers must be in E.164 format (for example, `+12223334444`).

            If multiple users (`external_id`) in the same workspace share the same phone number, then all users that share the phone number are updated with the same subscription group changes.
          example:
            - "+15555550100"
            - "+15555550101"
        use_double_opt_in_logic:
          type: boolean
          default: false
          description: Defaults to `false` if omitted. For SMS subscription groups, set to `true` to enter the user into the [SMS double opt-in]({{site.baseurl}}/user_guide/channels/sms_mms_and_rcs/message_features_and_optimization/keyword_processing/double_opt_in/) workflow when their subscription status is set to `subscribed`. Users entered into the double opt-in workflow in this way receive at most one opt-in prompt reply message per day, regardless of the number of times they are entered into the workflow. If this parameter is omitted or set to `false`, users are subscribed without entering the double opt-in workflow. This parameter is not applicable to email subscription groups.
          example: false
    UpdateUserSubscriptionGroupStatusV2Request:
      title: Update user's subscription group status (V2) request
      type: object
      required: [subscription_groups]
      description: |
        **Important:**
        **Identifier selection**:
        - To update both email and SMS subscription groups in a single API call, use `external_ids`. You cannot include both `emails` and `phones` in the same request.
        - If you use `emails` or `phones` instead of `external_ids`, make separate API calls—one for email subscription groups and one for SMS subscription groups.
        - You can send `emails`, `phones`, or `external_ids` individually.

        **Tip:**
        When creating new users using the [`/users/track` endpoint]({{site.baseurl}}/api/endpoints/user_data/post_user_track/), you can set subscription groups within the user attributes object, which allows you to create a user and set the subscription group state in one API call.
      properties:
        subscription_groups:
          type: array
          minItems: 1
          maxItems: 25
          items:
            $ref: '#/components/schemas/SubscriptionGroupUpdate'
          description: The subscription group updates to apply. You can pass 1 to 25 subscription group objects per request, each containing the fields below.
    UpdateUserSubscriptionGroupStatusV2Response:
      title: Update user's subscription group status (V2) response
      type: object
      properties:
        message:
          type: string
          description: Returns `success` when the request completes without errors.
          example: success
    ErrorResponse:
      title: Error
      type: object
      properties:
        message:
          type: string
          description: The error message describing why the request failed.
        errors:
          type: array
          description: Non-fatal errors encountered while processing the request. Data unaffected by these errors is still processed.
          items:
            type: object
            properties:
              type:
                type: string
                description: The error type.
