> ## 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.

# Add credit

> Starts an online payment to add credit to your balance. Send the user's browser to the returned `url`, using `method` and `params`, to complete the payment. When it succeeds, the amount is added to the balance.

The amount must be within the allowed minimum and maximum. If you have frozen mail servers, the amount must also cover reactivating them (see `GET /v1/payments/minimum-credit`). Your account must be verified. With `teamID`, this needs the `billing.manage` permission.

This endpoint is rate limited. Too many requests return `429`.



## OpenAPI

````yaml /spec/platform-billing.yaml post /v1/payments/pay
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/payments/pay:
    post:
      tags:
        - Payments
      summary: Add credit
      description: >-
        Starts an online payment to add credit to your balance. Send the user's
        browser to the returned `url`, using `method` and `params`, to complete
        the payment. When it succeeds, the amount is added to the balance.


        The amount must be within the allowed minimum and maximum. If you have
        frozen mail servers, the amount must also cover reactivating them (see
        `GET /v1/payments/minimum-credit`). Your account must be verified. With
        `teamID`, this needs the `billing.manage` permission.


        This endpoint is rate limited. Too many requests return `429`.
      operationId: createPayment
      parameters:
        - $ref: '#/components/parameters/TeamID'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - amount
              properties:
                amount:
                  type: integer
                  description: Amount to pay.
                gateway:
                  type: string
                  description: Payment gateway to use. Omit it to use the default gateway.
            example:
              amount: 1000000
      responses:
        '200':
          description: The payment was created. Send the browser to `url`.
          content:
            application/json:
              schema:
                type: object
                properties:
                  url:
                    type: string
                    format: uri
                    description: Payment page.
                  method:
                    type: string
                    description: HTTP method to open `url` with.
                  params:
                    type: object
                    description: Parameters to send to `url`, if any.
              example:
                url: https://payment-gateway.example.com/pay
                method: POST
                params:
                  token: <payment-token>
        '400':
          description: >-
            The amount is outside the allowed range, the amount doesn't cover
            your frozen mail servers (`minimum_credit_required`, with the
            required amount in `data.minimumCredit`), or the gateway rejected
            the payment.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              examples:
                belowMinimum:
                  summary: Amount below the minimum
                  value:
                    statusCode: 400
                    error: Bad Request
                    message: Minimum amount is <minimum-amount>.
                    data: null
                frozenMailServers:
                  summary: Amount doesn't cover frozen mail servers
                  value:
                    statusCode: 400
                    error: Bad Request
                    message: >-
                      You need to pay at least 1500000 to unfreeze your
                      mailservers.
                    data:
                      code: minimum_credit_required
                      minimumCredit: 1500000
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          description: >-
            Your account isn't verified (`account_verification_required`), or,
            with `teamID`, you aren't a member (`team_not_found`) or lack
            `billing.manage` (`no_permission`).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                statusCode: 403
                error: Forbidden
                message: You must verify your account, first.
                data:
                  code: account_verification_required
        '429':
          description: >-
            Too many payments in a short time (`too_many_payments_per_hour` or
            `too_many_payments_per_day`).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
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'
  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
  responses:
    Unauthorized:
      description: The API token is missing, invalid or expired.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/AuthError'
          example:
            error: Unauthorized.
  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.