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

# Create Subscription

> Creates a new subscription for a user against a given plan.



## OpenAPI

````yaml api-reference/openapi.json post /subscriptions
openapi: 3.0.3
info:
  title: AscendOTT Aggregator Plans API
  description: API description for aggregators to interact with AscendOTT Sites
  version: 1.0.0
  license:
    name: MIT
servers:
  - url: '{scheme}://{domain}/api/v1/aggregator'
    variables:
      scheme:
        enum:
          - https
          - http
        default: https
        description: Protocol
      domain:
        default: api.example.com
        description: Client API host (e.g., api.client.com)
security:
  - ApiKeyAuth: []
tags:
  - name: Plans
  - name: Subscriptions
  - name: Catalogs
paths:
  /subscriptions:
    post:
      tags:
        - Subscriptions
      summary: Create Subscription
      description: Creates a new subscription for a user against a given plan.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SubscriptionCreateRequest'
            examples:
              basic:
                value:
                  externalUserId: abcd123
                  planCode: 68b74fd80e51671c21e46913
                  startDate: '2025-09-03T11:30:00.000Z'
                  endDate: '2025-12-02T11:30:00.000Z'
                  device: android_phone
              minimal:
                summary: >-
                  Rely on defaults (start now, device = web_browser, end = plan
                  duration)
                value:
                  externalUserId: abcd123
                  planCode: 68b74fd80e51671c21e46913
      responses:
        '201':
          description: Created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Subscription'
              examples:
                success:
                  value:
                    subscriptionId: sub_01J8Z3Z2Y6M3X4
                    externalUserId: aysgte536d8sgh
                    planCode: configuredPlanCode
                    startDate: '2020-09-04T11:23:42.958Z'
                    endDate: '2020-10-04T11:22:23.958Z'
                    device: android_phone
                    status: completed
        '400':
          description: Bad Request — invalid body or field types
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              examples:
                invalidDate:
                  value:
                    error: startDate must be an ISO 8601 UTC string
        '403':
          description: Forbidden — missing or invalid API key
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              examples:
                missing:
                  value:
                    error: x-api-key missing
                incorrect:
                  value:
                    error: x-api-key is incorrect
        '409':
          description: Conflict — subscription already exists or plan constraints violated
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              examples:
                exists:
                  value:
                    error: Subscription already exists for user and plan
        '422':
          description: Unprocessable Entity — plan/user not found or business rule failed
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              examples:
                notFound:
                  value:
                    error: planCode not found
        '500':
          description: Internal Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              examples:
                error:
                  value:
                    error: Internal Server Error
      security:
        - ApiKeyAuth: []
components:
  schemas:
    SubscriptionCreateRequest:
      type: object
      required:
        - externalUserId
        - planCode
      properties:
        externalUserId:
          type: string
          description: Aggregator's user identifier (stable across calls).
        planCode:
          type: string
          description: AscendOTT planCode to subscribe to.
        startDate:
          type: string
          format: date-time
          description: UTC ISO8601. Optional. Defaults to current date/time.
        endDate:
          type: string
          format: date-time
          description: UTC ISO8601. Optional. Defaults to plan duration.
        device:
          type: string
          description: Origin device of the purchase. Optional.
          default: web_browser
          enum:
            - web_browser
            - android_phone
            - ios_phone
            - android_tablet
            - ios_tablet
            - android_tv
            - smart_tv
            - roku
            - fire_tv
            - apple_tv
            - jio_stb
            - other
    Subscription:
      type: object
      required:
        - subscriptionId
        - externalUserId
        - planCode
        - startDate
        - endDate
        - status
      properties:
        subscriptionId:
          type: string
        externalUserId:
          type: string
        planCode:
          type: string
        startDate:
          type: string
          format: date-time
        endDate:
          type: string
          format: date-time
        device:
          type: string
          enum:
            - web_browser
            - android_phone
            - ios_phone
            - android_tablet
            - ios_tablet
            - android_tv
            - smart_tv
            - roku
            - fire_tv
            - apple_tv
            - jio_stb
            - other
        status:
          type: string
          enum:
            - completed
            - pending
            - cancelled
            - expired
    Error:
      type: object
      required:
        - error
      properties:
        error:
          type: string
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: x-api-key

````