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

# Add Subscription

> API to add subscribers (users/child objects) to a given object, to notify subscribers when workflow is triggered on the parent object.



## OpenAPI

````yaml POST /v1/object/{object_type}/{id}/subscription/
openapi: 3.1.1
info:
  title: SuprSend API
  description: APIs supported on suprsend platform
  version: 1.2.2
servers:
  - url: https://hub.suprsend.com
security:
  - sec0: []
  - BearerAuth: []
paths:
  /v1/object/{object_type}/{id}/subscription/:
    post:
      summary: Add Subscription
      description: >-
        API to add subscribers (users/child objects) to a given object, to
        notify subscribers when workflow is triggered on the parent object.
      operationId: add-object-subscription
      parameters:
        - name: id
          in: path
          description: Unique identifier of the object in your system
          schema:
            type: string
          required: true
        - name: object_type
          in: path
          description: >-
            Used to group similar objects together. Give plural namespace like
            teams, organizations, and roles.
          schema:
            type: string
          required: true
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                recipients:
                  type: array
                  description: >-
                    List of recipients to be notified. You can either add
                    recipient as array of distinct_ids or array of recipient
                    objects. You can add up to 100 recipients in a single API.
                  items:
                    oneOf:
                      - type: object
                        title: Add user
                        description: >-
                          **Option 1: Add user subscription** - Add user
                          subscription by passing user json. You can pass user
                          distinct_ids in array as `["id1","id2"]` or as user
                          object to identify recipient inline.
                        required:
                          - distinct_id
                        properties:
                          distinct_id:
                            type: string
                            description: unique identifier of the user
                            default: id1
                          $email:
                            type: array
                            description: List of email addresses.
                            items:
                              type: string
                          $sms:
                            type: array
                            description: List of SMS numbers.
                            items:
                              type: string
                          $whatsapp:
                            type: array
                            description: List of WhatsApp numbers.
                            items:
                              type: string
                          $inbox:
                            type: array
                            description: List of Inbox numbers.
                            items:
                              type: string
                          $androidpush:
                            type: array
                            description: List of Android Push tokens.
                            items:
                              type: string
                          $iospush:
                            type: array
                            description: List of iOS Push tokens.
                            items:
                              type: string
                          $slack:
                            type: array
                            description: Slack channel configuration
                            items:
                              oneOf:
                                - type: object
                                  title: Slack using email
                                  required:
                                    - email
                                    - access_token
                                  properties:
                                    email:
                                      type: string
                                      format: email
                                      description: User email address
                                      example: user@example.com
                                    access_token:
                                      type: string
                                      description: Slack bot access token
                                      example: xoxb-XXXXXXXX
                                - type: object
                                  title: Slack using member ID
                                  required:
                                    - user_id
                                    - access_token
                                  properties:
                                    user_id:
                                      type: string
                                      description: Slack user ID (U/WXXXXXXXX format)
                                      example: U/WXXXXXXXX
                                    access_token:
                                      type: string
                                      description: Slack bot access token
                                      example: xoxb-XXXXXX
                                - type: object
                                  title: Slack using channel
                                  required:
                                    - channel
                                    - access_token
                                  properties:
                                    channel:
                                      type: string
                                      description: Slack channel ID (CXXXXXXXX format)
                                      example: CXXXXXXXX
                                    access_token:
                                      type: string
                                      description: Slack bot access token
                                      example: xoxb-XXXXXX
                                - type: object
                                  title: Slack using incoming webhook
                                  required:
                                    - incoming_webhook
                                  properties:
                                    incoming_webhook:
                                      type: object
                                      required:
                                        - url
                                      properties:
                                        url:
                                          type: string
                                          format: uri
                                          description: Slack incoming webhook URL
                                          example: >-
                                            https://hooks.slack.com/services/TXXXX/BXXXX/XXXXXXX
                          $ms_teams:
                            type: array
                            description: Microsoft Teams channel configuration
                            items:
                              oneOf:
                                - type: object
                                  title: MS Teams using conversation ID
                                  required:
                                    - tenant_id
                                    - service_url
                                    - conversation_id
                                  properties:
                                    tenant_id:
                                      type: string
                                      description: Microsoft Teams tenant ID
                                      example: c1981ab2-9aaf-xxxx-xxxx
                                    service_url:
                                      type: string
                                      format: uri
                                      description: Microsoft Teams service URL
                                      example: https://smba.trafficmanager.net/amer
                                    conversation_id:
                                      type: string
                                      description: Microsoft Teams conversation ID
                                      example: 19:c1524d7c-a06f-456f-8abe-xxxx
                                - type: object
                                  title: MS Teams using user ID
                                  required:
                                    - tenant_id
                                    - service_url
                                    - user_id
                                  properties:
                                    tenant_id:
                                      type: string
                                      description: Microsoft Teams tenant ID
                                      example: c1981ab2-9aaf-xxxx-xxxx
                                    service_url:
                                      type: string
                                      format: uri
                                      description: Microsoft Teams service URL
                                      example: https://smba.trafficmanager.net/amer
                                    user_id:
                                      type: string
                                      description: Microsoft Teams user ID
                                      example: 29:1nsLcmJ2RKtYH6Cxxxx-xxxx
                                - type: object
                                  title: MS Teams using incoming webhook
                                  required:
                                    - incoming_webhook
                                  properties:
                                    incoming_webhook:
                                      type: object
                                      required:
                                        - url
                                      properties:
                                        url:
                                          type: string
                                          format: uri
                                          description: Microsoft Teams incoming webhook URL
                                          example: >-
                                            https://wnk1z.webhook.office.com/webhookb2/XXXXXXXXX
                          $locale:
                            type: string
                            description: >-
                              User's locale for
                              [translating](https://suprsend.com/docs/translations)
                              template content in SuprSend.
                            example: en_GB
                          $timezone:
                            type: string
                            description: in IANA timezone format e.g. 'America/Los_Angeles'
                        additionalProperties:
                          type: string
                          description: >-
                            You can pass other user properties to render dynamic
                            template content in key-value pair as
                            "user_prop1":"value1" . Extra properties will be set
                            in subscriber profile (as subscriber properties)
                            which can then be used in the template as
                            $recipient.<property>.
                      - type: object
                        title: Add child object
                        description: >-
                          **Option 2: Add object subscription** - Add other
                          object as child subscriber to the parent object
                        required:
                          - id
                          - object_type
                        properties:
                          id:
                            type: string
                            description: Unique identifier of the object
                            example: frontend
                          object_type:
                            type: string
                        additionalProperties:
                          type: string
                          description: >-
                            You can pass other user properties similar to
                            recipient payload. It will be used when notification
                            is sent to object channels as $recipient.<property>.
                properties:
                  type: object
                  description: >-
                    properties defining the relation between object and its
                    subscribers. Can be referenced as
                    `recipient.subscription.<key>` in workflow and template.
                  example:
                    role: developer
      responses:
        '200':
          description: '200'
          content:
            application/json:
              examples:
                Result:
                  value:
                    results:
                      - properties:
                          department: frontend
                        user:
                          distinct_id: _distinct_id_
                          updated_at: '2025-04-05T10:33:33.629736+00:00'
                        object:
                          id: _object_id_
                          object_type: _object_type_
                          subscriptions_count: 10
                          updated_at: '2025-04-06T11:00:24.257046+00:00'
                        created_at: '2025-04-06T10:59:07.726336+00:00'
                        updated_at: '2025-04-06T10:59:07.726336+00:00'
              schema:
                type: object
                properties:
                  user:
                    type: object
                    properties:
                      distinct_id:
                        type: string
                        description: unique identifier of the user
                        example: _distinct_id_
                      updated_at:
                        type: string
                        format: date-time
                        description: time when user was subscribed to this list
                        example: '2025-04-04T09:55:12.422Z'
                  object:
                    type: object
                    properties:
                      id:
                        type: string
                        description: unique identifier of the object
                        example: frontend
                      object_type:
                        type: string
                        description: >-
                          type of object like teams, organizations, and roles.
                          Used to group similar objects together.
                        example: frontend
                      subscriptions_count:
                        type: integer
                        description: >-
                          number of users/child objects subscribed to this
                          object
                      updated_at:
                        type: string
                        format: date-time
                        description: timestamp when subscription was first created
                        example: '2025-04-04T09:55:12.422Z'
                  properties:
                    type: object
                    description: >-
                      object subscription properties, referred as
                      `$recipient.subscription.<key>` in template or workflow.
                  created_at:
                    type: string
                    format: date-time
                    example: '2025-04-04T09:55:12.397Z'
                  updated_at:
                    type: string
                    format: date-time
                    example: '2025-04-04T09:55:12.422Z'
        '404':
          description: 404 - Not Found
          content:
            application/json:
              examples:
                Result:
                  value:
                    code: 404
                    message: object 'object_type/id' not found
              schema:
                type: object
                properties:
                  code:
                    type: integer
                    example: 404
                  message:
                    type: string
                    description: >-
                      Error message indicating object_id and type combination is
                      not found
      deprecated: false
      security:
        - BearerAuth: []
      x-codeSamples:
        - lang: cURL
          source: >
            curl -X POST
            "https://hub.suprsend.com/v1/object/{object_type}/{id}/subscription/"
            \
              --header 'Authorization: Bearer __YOUR_API_KEY__' \
              --header 'Content-Type: application/json' \
              --data '{
                "recipients": ["user123","user456"],
                "properties": {
                  "role": "developer"
                }
              }'
components:
  securitySchemes:
    sec0:
      type: apiKey
      in: header
      name: Authorization
      x-bearer-format: bearer
      description: >-
        Bearer authentication header of the form `Bearer <token>`, where <token>
        is your auth token.
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: API_Key
      description: >-
        Pass as `Bearer <API_KEY>`. Get API Key from SuprSend dashboard
        Developers -> API Keys section.

````