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

# Subscribe or change plan

> Subscribes the account to a plan, or changes its current plan. With `teamID`, it applies to the team and needs the `team.operate` or `team.manage` permission.

- **No current plan:** the plan starts now and its price plus tax is
  charged from the balance.

- **More expensive plan:** the change happens now and the new price
  plus tax is charged from the balance.

- **Same or cheaper plan:** the change is scheduled for when the
  current plan expires, and the response is `{"reservation": true}`.
  You can cancel it with `DELETE /v1/subscription/reservation`.


Monthly plans last 30 days and yearly plans 1 year.



## OpenAPI

````yaml /spec/platform-billing.yaml post /v1/subscription
openapi: 3.0.1
info:
  title: Billing & Subscription
  version: 1.0.0
  description: |
    Check your balance and costs, add credit, download invoices and receipts,
    manage your subscription plan, and apply discount codes.

    All amounts are in Toman (IRT).

    With `teamID`, these endpoints work on the team's billing. Most of them
    need the `billing.manage` permission in the team; the description of each
    endpoint says which permission it needs.
servers:
  - url: https://api.liara.ir
security:
  - bearerAuth: []
tags:
  - name: Balance & Usage
    description: Balance, current costs and service counts.
  - name: Payments
    description: Add credit and list past payments.
  - name: Invoices & Receipts
    description: Monthly billing invoices and payment receipts.
  - name: Subscription
    description: View and change the account's subscription plan.
  - name: Discount Codes
    description: Check and apply discount codes.
paths:
  /v1/subscription:
    post:
      tags:
        - Subscription
      summary: Subscribe or change plan
      description: >-
        Subscribes the account to a plan, or changes its current plan. With
        `teamID`, it applies to the team and needs the `team.operate` or
        `team.manage` permission.


        - **No current plan:** the plan starts now and its price plus tax is
          charged from the balance.

        - **More expensive plan:** the change happens now and the new price
          plus tax is charged from the balance.

        - **Same or cheaper plan:** the change is scheduled for when the
          current plan expires, and the response is `{"reservation": true}`.
          You can cancel it with `DELETE /v1/subscription/reservation`.


        Monthly plans last 30 days and yearly plans 1 year.
      operationId: changeSubscription
      parameters:
        - $ref: '#/components/parameters/TeamID'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - subscriptionPlanID
              properties:
                subscriptionPlanID:
                  type: string
                  enum:
                    - free
                    - standard
                    - enterprise
                durationType:
                  type: string
                  enum:
                    - monthly
                    - yearly
                  default: monthly
            example:
              subscriptionPlanID: standard
              durationType: monthly
      responses:
        '201':
          description: >-
            The plan was applied (empty body), or a plan change was scheduled
            (`{"reservation": true}`).
          content:
            application/json:
              schema:
                type: object
                properties:
                  reservation:
                    type: boolean
              example:
                reservation: true
        '400':
          $ref: '#/components/responses/ValidationOrTeamIDError'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '402':
          description: The balance doesn't cover the plan's price plus tax.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                statusCode: 402
                error: Payment Required
                message: Not enough balance.
                data: null
        '403':
          $ref: '#/components/responses/TeamForbidden'
        '428':
          description: >-
            You already have this plan and duration
            (`already_have_subscription_plan`), or a plan change is already
            scheduled (`already_have_subscription_plan_reservation`).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                statusCode: 428
                error: Precondition Required
                message: You already have a subscription plan reservation.
                data:
                  code: already_have_subscription_plan_reservation
components:
  parameters:
    TeamID:
      name: teamID
      in: query
      required: false
      description: >-
        Run the request in the context of a team you belong to, instead of your
        personal account.
      schema:
        $ref: '#/components/schemas/ObjectID'
      example: '000000000000000000000002'
  responses:
    ValidationOrTeamIDError:
      description: >-
        A parameter or the body is invalid (`message` says which), or `teamID`
        isn't a valid ID.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          examples:
            validation:
              summary: Invalid parameter
              value:
                statusCode: 400
                error: Bad Request
                message: '"count" must be greater than or equal to 1'
            invalidTeamID:
              summary: Invalid team ID
              value:
                statusCode: 400
                error: Bad Request
                message: Invalid team ID.
                data: null
    Unauthorized:
      description: The API token is missing, invalid or expired.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/AuthError'
          example:
            error: Unauthorized.
    TeamForbidden:
      description: >-
        With `teamID`: you aren't a member of the team (`team_not_found`), or
        your role doesn't have the required permission (`no_permission`).
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          examples:
            teamNotFound:
              summary: Not a team member
              value:
                statusCode: 403
                error: Forbidden
                message: Team not found
                data:
                  code: team_not_found
            noPermission:
              summary: Missing permission
              value:
                statusCode: 403
                error: Forbidden
                message: You do not have permission to access this resource.
                data:
                  code: no_permission
  schemas:
    Error:
      type: object
      description: Standard error body.
      properties:
        statusCode:
          type: integer
        error:
          type: string
          description: HTTP status text.
        message:
          type: string
          description: What went wrong.
        data:
          type: object
          nullable: true
          description: >-
            Extra details. When present, `code` is a stable, machine-readable
            error code.
          properties:
            code:
              type: string
    ObjectID:
      type: string
      pattern: ^[0-9a-fA-F]{24}$
      description: 24-character hexadecimal ID.
    AuthError:
      type: object
      description: Error body returned when the API token is rejected.
      properties:
        error:
          type: string
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: 'Send your API token as `Authorization: Bearer <api-token>`.'

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.