openapi: 3.0.0
info:
  title: MoEngage - Subscription Categories API
  description: >-
    Subscription Categories help your brand provide options to customers to
    choose the kind of communication they want to receive from you. For more
    information, refer to Subscription Categories.  

    The Preferences API enables you to fetch and update subscription preferences
    on your MoEngage dashboard.


    The following APIs are available:


    1. **Get User Preferences for a specified user :  
        **This API fetches the user preferences information for a specific user.  
        
    2. **Update preferences for a specified user :  
        **This API updates the user preferences information for a specific user who navigates to the custom landing page from the email notification sent to them and updates their preferences.  
          
        Note: Campaign ID information is required along with user ID in this case.  
        
    3. **Bulk update preferences :  
        **This API updates user preferences in bulk. Use this API for updating the user preferences to MoEngage in large volumes.
  version: 1.0.0
servers:
  - url: https://api-{{0x}}.moengage.com
components:
  securitySchemes:
    basicAuth:
      type: http
      scheme: basic
paths:
  /v1/category-subscription/user-preferences:
    get:
      tags:
        - General
      summary: User Preferences API
      security:
        - basicAuth: []
      parameters:
        - name: Content-Type
          in: header
          schema:
            type: string
          example: application/json
        - name: MOE-APPKEY
          in: header
          schema:
            type: string
          example: '{{DATA API ID}}'
        - name: user_id
          in: query
          schema:
            type: string
          description: MoEngage Id  - Encrypted and Encoded. Encrypted via DES 16 bits.
          example: '{{user_id}}'
        - name: cid
          in: query
          schema:
            type: string
          description: Campaign Id - Encrypted and Encoded. Encrypted via DES 16 bits
          example: '{{YourCampaignID}}'
      responses:
        '200':
          description: Successful response
          content:
            application/json: {}
    put:
      tags:
        - General
      summary: Update Preferences API
      requestBody:
        content:
          '*/*':
            schema:
              type: string
              example: >-
                "{\n    \"unsubscribe_all\": true,\n    \"categories\":
                {\n        \"Promotional\": true,\n        \"Transactional\":
                false,\n        \"Special Offers\": true,\n        \"Product
                Updates\": true,\n        \"New arrivals\": false,\n       
                \"Recommendations\": true,\n        \"Newsletter\": true\n   
                }\n}"
      security:
        - basicAuth: []
      parameters:
        - name: Content-Type
          in: header
          schema:
            type: string
          example: application/json
        - name: MOE-APPKEY
          in: header
          schema:
            type: string
          example: '{{DATA API ID}}'
        - name: user_id
          in: query
          schema:
            type: string
          description: MoEngage Id  - Encrypted and Encoded. Encrypted via DES 16 bits.
          example: '{{user_id}}'
        - name: cid
          in: query
          schema:
            type: string
          description: Campaign Id - Encrypted and Encoded. Encrypted via DES 16 bits
          example: '{{YourCampaignID}}'
      responses:
        '200':
          description: Successful response
          content:
            application/json: {}
    post:
      tags:
        - General
      summary: Bulk update API
      requestBody:
        content:
          application/json:
            schema:
              type: object
              example:
                channel: email
                user_preferences:
                  - customer_id: john@example.com
                    categories:
                      Promotional: false
                      Transactional: false
                      Special Offers: true
                    unsubscribe_all: false
                  - customer_id: mike@example.com
                    categories:
                      Transactional: true
                      Promotional: false
                      Special Offers: true
                    unsubscribe_all: false
                  - customer_id: doe@example.com
                    categories:
                      Product Updates: true
                      New arrivals: false
                      Recommendations: true
                    unsubscribe_all: false
      security:
        - basicAuth: []
      parameters:
        - name: Content-Type
          in: header
          schema:
            type: string
          example: application/json
        - name: MOE-APPKEY
          in: header
          schema:
            type: string
          example: '{{DATA API ID}}'
      responses:
        '200':
          description: Successful response
          content:
            application/json: {}
