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

# Assign subscription

> Assign a subscription to a user: deactivates current actives, creates a manual completed transaction + active subscription. billingCycle onetime requires a lifetime plan. Panel currency must be configured.

Authentication: API key via X-API-Key header (or Authorization: Bearer).
Permissions: User API key
Rate limit: api_admin_write — 20 requests/min per API user.



## OpenAPI

````yaml /api-reference/platform.openapi.json post /api/platform/v1/subscription/manage
openapi: 3.1.0
info:
  title: Platform API
  version: 1.0.0
  description: >-
    Manage platform users, subscriptions, add-ons, and support tickets across
    your platform. These endpoints require platform-level access on the account
    that owns the API key.


    Generate your API key in the Developer Portal (profile menu → Developer) and
    send it in the `X-API-Key` header, or as `Authorization: Bearer <key>`.
    Never put the key in the URL.


    Every endpoint accepts POST with a JSON body, and also accepts GET with the
    same parameters as query-string values. All responses use the envelope `{
    success, data?, message?, error? }`.
servers:
  - url: https://YOUR_DOMAIN
    description: Your deployment, for example https://app.example.com
security: []
tags:
  - name: Platform
  - name: Users
  - name: Subscriptions
  - name: Add-ons
  - name: Tickets
paths:
  /api/platform/v1/subscription/manage:
    post:
      tags:
        - Subscriptions
      summary: Assign subscription
      description: >-
        Assign a subscription to a user: deactivates current actives, creates a
        manual completed transaction + active subscription. billingCycle onetime
        requires a lifetime plan. Panel currency must be configured.


        Authentication: API key via X-API-Key header (or Authorization: Bearer).

        Permissions: User API key

        Rate limit: api_admin_write — 20 requests/min per API user.
      parameters:
        - name: platformId
          in: query
          required: false
          description: Your platform id.
          schema:
            type: string
            example: pf_1
        - name: userId
          in: query
          required: false
          description: Target user id (must belong to the platform).
          schema:
            type: string
            example: usr_123
        - name: planId
          in: query
          required: false
          description: Plan id with itemType=plan.
          schema:
            type: string
            example: plan_1
        - name: billingCycle
          in: query
          required: false
          description: >-
            monthly | quarterly | annual | onetime (aliases: one-time,
            lifetime).
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - platformId
                - userId
                - planId
              properties:
                platformId:
                  type: string
                  description: Your platform id.
                  example: pf_1
                userId:
                  type: string
                  description: Target user id (must belong to the platform).
                  example: usr_123
                planId:
                  type: string
                  description: Plan id with itemType=plan.
                  example: plan_1
                billingCycle:
                  type: string
                  description: >-
                    monthly | quarterly | annual | onetime (aliases: one-time,
                    lifetime).
            example:
              platformId: pf_1
              userId: usr_123
              planId: plan_1
              billingCycle: monthly
      responses:
        '200':
          description: 'Success. Envelope: { success:true, data, message? }.'
          content:
            application/json:
              schema:
                type: object
                required:
                  - success
                properties:
                  success:
                    type: boolean
                    example: true
                  data: {}
                  message:
                    type: string
                  pagination:
                    type: object
                  total:
                    type: number
              example:
                success: true
                message: Subscription assigned successfully
                data:
                  subscriptionId: sub_123
                  transactionId: txn_123
        '400':
          description: >-
            Missing/invalid parameters. Body has success:false plus error and
            message.
          content:
            application/json:
              schema:
                type: object
                required:
                  - success
                  - error
                properties:
                  success:
                    type: boolean
                    example: false
                  error:
                    type: string
                  message:
                    type: string
        '401':
          description: >-
            Missing or invalid API key (or session expired for session
            endpoints).
          content:
            application/json:
              schema:
                type: object
                required:
                  - success
                  - error
                properties:
                  success:
                    type: boolean
                    example: false
                  error:
                    type: string
                  message:
                    type: string
        '403':
          description: >-
            Authenticated but not authorized — wrong permissions or cross-tenant
            resource.
          content:
            application/json:
              schema:
                type: object
                required:
                  - success
                  - error
                properties:
                  success:
                    type: boolean
                    example: false
                  error:
                    type: string
                  message:
                    type: string
        '404':
          description: User or plan not found in this platform.
          content:
            application/json:
              schema:
                type: object
                required:
                  - success
                  - error
                properties:
                  success:
                    type: boolean
                    example: false
                  error:
                    type: string
                  message:
                    type: string
        '429':
          description: >-
            Rate limited. Retry after the Retry-After seconds; see RateLimit-*
            headers.
          content:
            application/json:
              schema:
                type: object
                required:
                  - success
                  - error
                properties:
                  success:
                    type: boolean
                    example: false
                  error:
                    type: string
                  message:
                    type: string
        '500':
          description: >-
            Unexpected server error. Body has success:false plus error and
            message.
          content:
            application/json:
              schema:
                type: object
                required:
                  - success
                  - error
                properties:
                  success:
                    type: boolean
                    example: false
                  error:
                    type: string
                  message:
                    type: string
      security:
        - apiKeyHeader: []
        - bearerAuth: []
components:
  securitySchemes:
    apiKeyHeader:
      type: apiKey
      in: header
      name: X-API-Key
      description: Preferred. API key value directly.
    bearerAuth:
      type: http
      scheme: bearer
      description: Alternative. API key as the bearer token.

````