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

    To use this endpoint, you'll 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.

    ## 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:
  "/subscription/status/set":
    post:
      summary: Update user's subscription group status
      operationId: post_subscription_status_set_post_update_user_subscription_group_status
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UpdateUserSubscriptionGroupStatusRequest'
            examples:
              email:
                summary: Email
                value:
                  subscription_group_id: subscription_group_identifier
                  subscription_state: unsubscribed
                  external_id: external_identifier
                  email:
                    - example1@example.com
                    - example2@example.com
              sms_and_rcs:
                summary: SMS and RCS
                value:
                  subscription_group_id: subscription_group_identifier
                  subscription_state: unsubscribed
                  external_id: external_identifier
                  phone:
                    - "+15555550100"
                    - "+15555550101"
      responses:
        "201":
          description: |
            The request succeeded and the subscription group status was updated. No action needed.

            The status code `201` could return the following response body.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UpdateUserSubscriptionGroupStatusResponse'
              examples:
                success:
                  summary: Subscription group status updated
                  value:
                    message: success
        "400":
          description: |
            Bad request. To resolve it:

            - **The `subscription_group_id` isn't valid:** Pass a valid `subscription_group_id` from **Subscription Group** settings.
            - **The `subscription_state` isn't `subscribed` or `unsubscribed`:** Set `subscription_state` to `subscribed` or `unsubscribed`.
            - **A phone number was sent for an email subscription group:** Send an email address or `external_id` for email subscription groups.
            - **An email address was sent for an SMS subscription group:** Send a phone number or `external_id` for SMS subscription groups.
            - **An email address was sent for a WhatsApp subscription group:** Send a phone number or `external_id` for WhatsApp subscription groups.
            - **The subscription group is a Kakao group, which the API can't update:** Update Kakao subscription groups from the dashboard.
            - **Both an email address and a phone number were provided:** Include either an email address or a phone number, but not both.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                invalid_subscription_group_id:
                  summary: Invalid subscription group ID
                  value:
                    message: Invalid subscription group ID
                invalid_subscription_state:
                  summary: Invalid subscription state
                  value:
                    message: You must provide a subscription state that is either subscribed or unsubscribed.
                phone_for_email_group:
                  summary: Phone number sent for an email subscription group
                  value:
                    message: An email address or an external user id is required to update this email subscription group.
                email_for_sms_group:
                  summary: Email address sent for an SMS subscription group
                  value:
                    message: A phone number or an external user id is required to update this SMS subscription group.
                email_for_whatsapp_group:
                  summary: Email address sent for a WhatsApp subscription group
                  value:
                    message: A phone number or an external user id is required to update this WhatsApp subscription group.
                kakao_group:
                  summary: Kakao subscription group
                  value:
                    message: Updating Kakao subscription groups is not supported.
                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.
        "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:
    UpdateUserSubscriptionGroupStatusRequest:
      title: Update user's subscription group status request
      type: object
      required: [subscription_group_id, subscription_state]
      description: |
        - **SMS and RCS subscription groups:** Braze accepts only `external_id` or `phone`.
        - **Email subscription groups:** You must include either `email` or `external_id`.

        This property should not be used for updating a user's profile information. Use the [/users/track]({{site.baseurl}}/api/endpoints/user_data/post_user_track) property instead.

        **Tip:**
        **Adding existing users to a subscription group:** This endpoint is the recommended way to backfill or bulk-update subscription group membership for existing users. You can pass up to 50 `external_id`s, email addresses, or phone numbers per request. Users can also update their own subscription status through an [email preference center]({{site.baseurl}}/user_guide/channels/email/subscriptions) link.

        **Creating new users with a subscription group:** When creating new users using the [`/users/track`]({{site.baseurl}}/api/endpoints/user_data/post_user_track) endpoint, 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_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: unsubscribed
        external_id:
          description: The `external_id` of the user or users, may include up to 50 IDs.
          oneOf:
            - title: Single external ID
              type: string
            - title: Single numeric external ID
              type: integer
            - title: Array of external IDs
              type: array
              maxItems: 50
              items:
                type: string
          example: external_identifier
        email:
          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, then Braze updates all users that share the email address with the subscription group changes.
          oneOf:
            - title: Single email address
              type: string
            - title: Array of email addresses
              type: array
              minItems: 1
              maxItems: 50
              items:
                type: string
          example:
            - example1@example.com
            - example2@example.com
        phone:
          description: |
            The phone number of the user, can be passed as an array of strings. Must include at least one phone number (up to 50).

            If multiple users (`external_id`) in the same workspace share the same phone number, then Braze updates all users that share the phone number with the same subscription group changes.

            Use [E.164](https://en.wikipedia.org/wiki/E.164) format.
          oneOf:
            - title: Single phone number
              type: string
            - title: Array of phone numbers
              type: array
              minItems: 1
              maxItems: 50
              items:
                type: string
          example:
            - "+15555550100"
            - "+15555550101"
        use_double_opt_in_logic:
          type: boolean
          default: false
          description: Applies only to SMS subscription groups; ignored for email and other subscription group types. 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.
          example: false
    UpdateUserSubscriptionGroupStatusResponse:
      title: Update user's subscription group status response
      type: object
      properties:
        message:
          type: string
          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.
