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

# Airtime

> Buy airtime



## OpenAPI

````yaml POST /airtime/buy
openapi: 3.0.1
info:
  title: OpenAPI Simpu API
  description: Simpu API Documentation
  license:
    name: MIT
  version: 1.0.0
servers:
  - url: https://api.simpu.co
security:
  - apiKeyAuth: []
paths:
  /airtime/buy:
    post:
      description: Buy airtime
      requestBody:
        description: Buy airtime object
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/BuyAirtimeRequest'
        required: true
      responses:
        '200':
          description: Buy airtime response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BuyAirtime'
        '400':
          description: unexpected error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
components:
  schemas:
    BuyAirtimeRequest:
      type: object
      required:
        - network
        - amount
        - recipient
      properties:
        network:
          description: The network carrier of the airtime
          type: string
          example: Airtel
          enum:
            - Airtel
            - MTN
            - Glo
            - 9mobile
            - NTEL
        amount:
          description: ' The airtime amount to be recharged'
          type: number
          example: 1500
        recipient:
          description: The recipient of the airtime
          type: string
          example: '2348023456789'
        callback:
          description: This is the URL to receive delivery reports for the message
          type: string
          example: https://example.com/airtime/delivery_report
        external_ref:
          description: This is a reference to the message in your system
          type: string
          example: 674535b2b39158b9aae90188fcec23eb
    BuyAirtime:
      type: object
      properties:
        id:
          description: Unique ID of the SMS message
          type: string
          example: 674535b2b39158b9aae90188fcec23eb
        recipient:
          description: The recipient of the airtime
          type: string
          example: '2348023456789'
        external_ref:
          description: This is a reference to the airtime in your system
          type: string
          example: 674535b2b39158b9aae90188fcec23eb
        callback:
          description: This is the URL to receive delivery reports for the message
          type: string
          example: https://example.com/airtime/delivery_report
        status:
          description: 'The status of the airtime '
          type: string
          example: pending
          enum:
            - pending
            - sent
            - failed
            - error
            - success
            - duplicate
        created_datetime:
          description: Date and time the airtime was created
          type: string
          example: '2024-06-28T23:56:38.128604+00:00'
        network:
          description: The network carrier of the airtime
          type: string
          example: Airtel
          enum:
            - Airtel
            - MTN
            - Glo
            - 9mobile
            - NTEL
        meta:
          $ref: '#/components/schemas/MetaAirtime'
    Error:
      required:
        - status
        - message
      type: object
      properties:
        status:
          type: integer
          format: int32
          example: 200
        message:
          type: string
          example: Invalid request
        errors:
          type: array
          items:
            type: object
            properties:
              field:
                type: string
                example: name
              message:
                type: string
                example: 'Error in field: ''name'' Field required.'
              type:
                type: string
                example: missing
    MetaAirtime:
      required:
        - method
        - resource
      type: object
      properties:
        method:
          description: The HTTP method used to make the request
          type: string
          example: POST
        resource:
          description: The resource requested
          type: string
          example: /airtime/buy
        charge:
          $ref: '#/components/schemas/ChargeAirtime'
    ChargeAirtime:
      required:
        - amount
        - available_balance
        - balance_before
        - refunded
      type: object
      properties:
        amount:
          description: Amount of the airtime to be recharged
          type: number
          example: 1500
        available_balance:
          description: Available balance of the recipient
          type: number
          example: 2000
        balance_before:
          description: Balance before recharge
          type: number
          example: 500
        refunded:
          description: Airtime refund
          type: boolean
          example: false
  securitySchemes:
    apiKeyAuth:
      type: apiKey
      in: header
      name: Authorization
      description: An API key to authenticate requests

````