> ## Documentation Index
> Fetch the complete documentation index at: https://moengage-sdk-docs.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Get Subscription Preferences

> Fetches the subscription category preferences information for a specific user based on the encrypted User ID and Campaign ID found in the landing page URL.


### Rate Limit

The rate limit is 100 RPM and 360k per day.

### FAQs

**How do we fetch the parameters to be passed in the request?**

The `user_id` (MoEngage ID) and the `cid` (Campaign ID) fields should be fetched from the landing page URL.

For example, if the link to the custom landing page was `https://www.abc.com/managepreference`, when the user clicks the same from the email, the link will look like this:

```json
[https://www.abc.com/managepreference?user_id=7XvJW2dj3iS...&cid=5FGZGcA8FRv3...&app_key=UY_GHXBX](https://www.abc.com/managepreference?user_id=7XvJW2dj3iS...&cid=5FGZGcA8FRv3...&app_key=UY_GHXBX)...
```

You must parse this URL to extract the `user_id` and `cid` to pass to the API.


## OpenAPI

````yaml /api/subscription-categories/subscription-categories.yaml get /category-subscription/user-preferences
openapi: 3.0.3
info:
  title: MoEngage Subscription Categories API
  description: >
    Enables you to fetch and update email subscription preferences on your
    MoEngage dashboard.


    This API provides endpoints for:

    * **Get Preferences**: Fetches subscription preferences for a specific user.

    * **Update Preferences**: Updates preferences for a specific user (e.g.,
    from a landing page).

    * **Bulk Update Preferences**: Updates preferences for a batch of users.


    Authentication is handled via Basic Auth (Workspace ID as username, Data API
    Key as password) and the `MOE-APPKEY` header.
  version: '1.0'
servers:
  - url: https://api-{dc}.moengage.com/v1
    description: MoEngage API Server
    variables:
      dc:
        default: '01'
        description: The data center number for your account (e.g., 01, 02, 03).
        enum:
          - '01'
          - '02'
          - '03'
security:
  - basicAuth: []
tags:
  - name: Subscription Preferences
    description: Manage user email subscription preferences.
paths:
  /category-subscription/user-preferences:
    get:
      tags:
        - Subscription Preferences
      summary: Get Subscription Preferences
      description: >
        Fetches the subscription category preferences information for a specific
        user based on the encrypted User ID and Campaign ID found in the landing
        page URL.
      operationId: getSubscriptionPreferences
      parameters:
        - $ref: '#/components/parameters/AppKeyHeader'
        - name: user_id
          in: query
          required: true
          description: >
            This is the MoEngage ID that uniquely identifies the customer for
            whom the subscription preferences are being updated. 


            **Note:** MoEngage ID is encrypted using 16 bits DES and is encoded
            in the URL of the landing page. It must be sent as-is (encrypted).
          schema:
            type: string
        - name: cid
          in: query
          required: true
          description: >
            This is the campaign id of the email campaign. This field contains
            the information about the email campaign received by the customer.


            **Note:** The campaign ID is encrypted using 16-bit DES and is
            encoded within the landing page URL. You must fetch the encrypted
            `<campaign Id>` from the URL and send it directly to MoEngage; it is
            not necessary to perform any decryption.
          schema:
            type: string
        - name: Content-Type
          in: header
          required: true
          description: Set the Content-Type header to application/json.
          schema:
            type: string
            default: application/json
      responses:
        '200':
          description: >-
            Success. This response is returned when the request is processed
            successfully.
          content:
            application/json:
              schema:
                type: object
                properties:
                  categories:
                    $ref: '#/components/schemas/SubscriptionCategories'
              example:
                categories:
                  Promotional: true
                  Product Update: true
                  Newsletter: true
                  Conferences and Events: true
                  Special Offers: true
                  Recommended Music: true
                  New Music: true
                  Playlist Updates: false
                  Concert Notifications: true
                  Artist Updates: true
                  test: true
        '400':
          description: Bad Request. Returned when parameters are missing or invalid.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
              example:
                message: Invalid Params Received
        '401':
          $ref: '#/components/responses/Unauthorized'
        '409':
          $ref: '#/components/responses/Conflict'
        '429':
          $ref: '#/components/responses/TooManyRequests'
        '500':
          $ref: '#/components/responses/InternalServerError'
components:
  parameters:
    AppKeyHeader:
      name: MOE-APPKEY
      in: header
      required: true
      description: >
        This is your MoEngage account's APP ID that has to be passed along with
        the request. 

        You can find your MoEngage Workspace ID at **Settings** -> **Account**
        -> **APIs** -> **Workspace ID (earlier app id)**.
      schema:
        type: string
  schemas:
    SubscriptionCategories:
      type: object
      description: >
        A JSON Object that contains the subscription preferences of the
        customer.

        `category_name` is the unique category name in MoEngage.
      additionalProperties:
        type: boolean
      example:
        Promotions: true
        Updates: false
        Recommendations: true
        Newsletter: false
    ErrorResponse:
      type: object
      properties:
        title:
          type: string
          description: The error type.
        description:
          type: string
          description: The error description.
  responses:
    Unauthorized:
      description: >-
        Authorization Failure. Returned when authorization fails due to
        incorrect APP KEY/HTTP Auth Header.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          examples:
            auth_required:
              summary: Auth Failure
              value:
                title: Authentication required
                description: No identity information found.
            missing_header:
              summary: Missing Header
              value:
                title: Header required
                description: MOE-APPKEY missing in Header
    Conflict:
      description: >-
        API SECRET not configured. Returned when the authorization fails due to
        the APP SECRET key not being set on the Dashboard.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            title: API SECRET not configured
            description: >-
              This response is returned when the authorization fails due to the
              APP SECRET key not being set on the Dashboard.
    TooManyRequests:
      description: >-
        Rate Limit Breach. The number of requests per minute has exceeded the
        limit.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            title: Rate-Limit Reached
            description: Exceeded rate limit for this url
    InternalServerError:
      description: >-
        Internal Server Error. Returned when the system runs into an unexpected
        error.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            title: Internal Error
            description: Please Contact Moengage Team
  securitySchemes:
    basicAuth:
      type: http
      scheme: basic
      description: >
        This authentication parameter, used for access control, must be passed
        along with the request. To generate the authentication header, refer to
        Authentication.


        It uses **Workspace ID** as username and **Data API Key** as password.

````