---
openapi: 3.0.3
info:
  title: Braze REST API – List user's subscription groups
  description: |
    ## Prerequisites

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

    ## Rate limit

    We apply the default Braze rate limit of 250,000 requests per hour to this endpoint, as documented in [API rate limits]({{site.baseurl}}/api/api_limits/).
  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/user/status":
    get:
      summary: List user's subscription groups
      operationId: get_subscription_user_status_get_list_user_subscription_groups
      parameters:
        - name: external_id
          in: query
          required: false
          description: |
            The `external_id` of the user (must include at least one and at most 50 `external_ids`).

            To query multiple users, repeat the parameter with brackets, as in this example request: `https://rest.iad-03.braze.com/subscription/user/status?external_id[]=1&external_id[]=2`
          schema:
            type: string
          example: external_identifier
        - name: email
          in: query
          required: false
          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).
          schema:
            type: string
          examples:
            email:
              summary: Email
              x-disabled: true
              value: example@example.com
        - name: phone
          in: query
          required: false
          description: The phone number of the user. Must include at least one phone number (with a maximum of 50). Use [E.164](https://en.wikipedia.org/wiki/E.164) format.
          schema:
            type: string
          examples:
            sms_and_whatsapp:
              summary: SMS and WhatsApp
              x-disabled: true
              value: "+15555550100"
        - name: limit
          in: query
          required: false
          description: The limit on the maximum number of results returned. Default (and maximum) `limit` is 100.
          schema:
            type: integer
            minimum: 1
            maximum: 100
            default: 100
          example: 100
        - name: offset
          in: query
          required: false
          description: Number of users to skip before returning the rest of the users that fit the search criteria.
          schema:
            type: integer
            minimum: 0
            default: 0
          example: 0
      responses:
        "200":
          description: |
            The request succeeded and the response body lists the user's subscription groups. No action needed.

            Only subscription groups that have had a subscription status update in a user's history will be included in a successful response. This means that newly created subscription groups will not be listed.

            **Tip:** If there are multiple users (multiple `external_ids`) who share the same email address, all users will be returned as a separate user (even if they have the same email address or subscription group).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ListUserSubscriptionGroupsResponse'
              examples:
                success:
                  summary: Subscription groups for one user
                  value:
                    users:
                      - email: test@example.com
                        phone: "+15555550100"
                        external_id: external_identifier
                        subscription_groups:
                          - id: ec2fcc919fca
                            name: ActivationGroup
                            channel: email
                            status: Subscribed
                          - id: 7d7af9dd5556
                            name: ReactivationGroup
                            channel: email
                            status: Subscribed
                          - id: a5e84fd16220
                            name: MarketingGroup
                            channel: sms
                            status: Unsubscribed
                          - id: 64d8cad9176c
                            name: TransactionalGroup
                            channel: sms
                            status: Unsubscribed
                          - id: b2134cd63942
                            name: BankerMarketingGroup
                            channel: sms
                            status: Subscribed
                    total_count: 1
                    message: success
        "400":
          description: |
            Bad request. To resolve it:

            - **No `email`, `phone`, or `external_id` was provided:** Include an `email`, `phone`, or `external_id`.
            - **Both an email address and a phone number were provided:** Include either an email address or a phone number, but not both.
            - **The `limit` is outside the allowed range:** Pass a `limit` between 1 and 100.
            - **The `offset` is negative:** Pass an `offset` of 0 or greater.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                no_identifier:
                  summary: No email, phone, or external_id
                  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.
                limit_out_of_range:
                  summary: Limit outside the allowed range
                  value:
                    message: Limit must be between 1 and 100
                negative_offset:
                  summary: Negative offset
                  value:
                    message: Offset must be greater than or equal to 0
        "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.groups.get` 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 250000 requests per hour. 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.groups.get` permission.
        Pass the key as `Authorization: Bearer YOUR_REST_API_KEY`.
  schemas:
    SubscriptionGroupStatus:
      title: Subscription group status
      type: object
      properties:
        id:
          type: string
          example: ec2fcc919fca
        name:
          type: string
          example: ActivationGroup
        channel:
          type: string
          example: email
        status:
          type: string
          example: Subscribed
    UserSubscriptionGroups:
      title: User subscription groups
      type: object
      properties:
        email:
          type: string
          example: test@example.com
        phone:
          type: string
          example: "+15555550100"
        external_id:
          type: string
          example: external_identifier
        subscription_groups:
          type: array
          items:
            $ref: '#/components/schemas/SubscriptionGroupStatus'
    ListUserSubscriptionGroupsResponse:
      title: List user's subscription groups response
      type: object
      properties:
        users:
          type: array
          items:
            $ref: '#/components/schemas/UserSubscriptionGroups'
        total_count:
          type: integer
          example: 1
        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.
