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

# Automatically Buy Subscription Plan

> This endpoint allows you to buy subscription for a particular api key automatically

<Warning>
  Before calling this endpoint, make sure that you have enabled **[Subscription Auto Payment](https://modelslab.com/dashboard/subscription)** on your dashboard.
</Warning>

## Request

Send a `POST` request to below endpoint and pass the desired **plan\_name** to buy in the request body.

```curl curl theme={null}
--request POST 'https://modelslab.com/api/v3/buy_subscription' \
```

## Body

```json json theme={null}
{  
  "key":"your-default-api-key",  
  "plan_name":"basic_monthly"
}
```


## OpenAPI

````yaml POST /buy_subscription
openapi: 3.1.0
info:
  title: ModelsLab General API
  description: >-
    General utility endpoints for ModelsLab API including subscription
    management, content moderation, and file handling
  license:
    name: MIT
  version: 6.0.0
servers:
  - url: https://modelslab.com/api
    description: Main API server (for endpoints without version prefix)
  - url: https://modelslab.com/api/v3
    description: API v3 server
  - url: https://modelslab.com/api/v5
    description: API v5 server
  - url: https://modelslab.com/api/v6
    description: API v6 server
security: []
paths:
  /buy_subscription:
    post:
      summary: Buy subscription plan
      description: >-
        This endpoint allows you to buy an API key with a subscription plan
        automatically
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/BuySubscriptionRequest'
      responses:
        '200':
          description: Buy subscription response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BuySubscriptionResponse'
        '400':
          description: Bad request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
      servers:
        - url: https://modelslab.com/api/v3
components:
  schemas:
    BuySubscriptionRequest:
      type: object
      required:
        - key
        - plan_name
      properties:
        key:
          type: string
          description: Your default API Key used for request authorization
        plan_name:
          type: string
          enum:
            - basic_monthly
            - basic_yearly
            - standard_monthly
            - standard_yearly
            - premium_monthly
            - premium_yearly
          description: The name of the plan you want to buy
    BuySubscriptionResponse:
      type: object
      properties:
        status:
          type: string
          enum:
            - success
        messege:
          type: string
          example: You have just bought a custom api with basic plan
        data:
          type: object
          properties:
            key:
              type: string
              description: The purchased API key
            plan:
              type: string
              description: The purchased plan name
    Error:
      type: object
      required:
        - status
        - message
      properties:
        status:
          type: string
          enum:
            - error
        message:
          type: string
          description: Error message

````