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

# Purchase a variant

> Buys `quantity` units of a variant. Your wallet is debited and, for allocated variants, your stock is consumed, in one transaction. Returns the order IDs; fetch the code with the retrieve endpoint. Include any `input_fields` listed in the catalog.



## OpenAPI

````yaml /openapi.json post /products/purchase/{variantId}
openapi: 3.0.3
info:
  title: Wasmou API
  version: 1.0.0
  description: >-
    Sell digital goods: catalog, purchase, delivery, game top-ups and per-client
    stock. All amounts are in DZD.
servers:
  - url: https://api.wasmou.net/api
    description: Production
security: []
paths:
  /products/purchase/{variantId}:
    post:
      tags:
        - Orders
      summary: Purchase a variant
      description: >-
        Buys `quantity` units of a variant. Your wallet is debited and, for
        allocated variants, your stock is consumed, in one transaction. Returns
        the order IDs; fetch the code with the retrieve endpoint. Include any
        `input_fields` listed in the catalog.
      operationId: purchase
      parameters:
        - name: variantId
          in: path
          required: true
          description: Variant ID
          schema:
            type: integer
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - quantity
              properties:
                quantity:
                  type: integer
                  minimum: 1
                  maximum: 50
                  example: 1
                key_id:
                  type: integer
                  description: >-
                    Optional. A specific key to buy; if omitted one is assigned
                    for you.
              additionalProperties: true
              description: Plus any product-specific input fields (for example player_id).
      responses:
        '200':
          description: Purchase accepted
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: string
                    example: success
                  message:
                    type: string
                  data:
                    type: object
                    properties:
                      order_ids:
                        type: array
                        items:
                          type: string
                      count:
                        type: integer
        '400':
          description: Validation error, out of stock or unavailable
        '401':
          description: Missing or invalid API key
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '403':
          description: Insufficient balance (or IP not allowed)
        '422':
          description: Not enough allocated stock for your account
        '429':
          description: Rate limit exceeded
      security:
        - ApiKey: []
components:
  schemas:
    Error:
      type: object
      properties:
        status:
          type: string
          example: error
        message:
          type: string
          example: Insufficient balance.
        data:
          nullable: true
  securitySchemes:
    ApiKey:
      type: apiKey
      in: header
      name: X-Api-Key
      description: Your API key from the Wasmou app (API access).

````

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