openapi: 3.0.3
info:
  title: GetVerifyCode API
  version: 0.1.0
  description: >
    Public developer API at /api/v1. Money is integer USD cents. Client-sent
    prices are ignored. Create a bearer token under API keys. Cookie sessions
    on /api are for the website only. The v1 surface returns 503 when the
    public_api shop flag is off.
  contact:
    email: support@getverifycode.com
servers:
  - url: https://getverifycode.com/api/v1
security: []
tags:
  - name: Catalog
  - name: Account
  - name: Wallet
  - name: Activations
  - name: Keys
paths:
  /health:
    get:
      tags: [Catalog]
      summary: Liveness
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: string
                    example: ok
        "503":
          $ref: "#/components/responses/PublicApiOff"
  /catalog/services:
    get:
      tags: [Catalog]
      summary: List services
      responses:
        "200":
          description: Retail catalog. No wholesale.
          content:
            application/json:
              schema:
                type: object
                properties:
                  services:
                    type: array
                    items:
                      type: object
                      properties:
                        slug:
                          type: string
                        name:
                          type: string
                        from_cents:
                          type: integer
                          nullable: true
                        in_stock:
                          type: boolean
        "503":
          $ref: "#/components/responses/PublicApiOff"
  /catalog/services/{service}/countries:
    get:
      tags: [Catalog]
      summary: Countries for a service
      parameters:
        - $ref: "#/components/parameters/Service"
        - name: operator
          in: query
          schema:
            type: string
            default: any
      responses:
        "200":
          description: Countries with retail cents
        "503":
          $ref: "#/components/responses/PublicApiOff"
  /catalog/services/{service}/offers:
    get:
      tags: [Catalog]
      summary: Operator rows for a service
      parameters:
        - $ref: "#/components/parameters/Service"
        - name: fresh
          in: query
          schema:
            type: integer
            enum: [0, 1]
      responses:
        "200":
          description: Offers with retail cents and live stock
        "503":
          $ref: "#/components/responses/PublicApiOff"
  /catalog/quote:
    get:
      tags: [Catalog]
      summary: Live retail quote
      parameters:
        - name: service
          in: query
          required: true
          schema:
            type: string
            example: whatsapp
        - name: country
          in: query
          required: true
          schema:
            type: string
            example: US
        - name: operator
          in: query
          schema:
            type: string
            default: any
      responses:
        "200":
          description: Quote
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Quote"
        "503":
          $ref: "#/components/responses/PublicApiOff"
  /wallet/packages:
    get:
      tags: [Wallet]
      summary: Top-up packages
      responses:
        "200":
          description: Package cents and processor flags
          content:
            application/json:
              schema:
                type: object
                properties:
                  packages_cents:
                    type: array
                    items:
                      type: integer
                    example: [500, 1000, 2500, 5000, 10000]
                  currency:
                    type: string
                    example: USD
                  min_cents:
                    type: integer
                    example: 500
                  stripe_enabled:
                    type: boolean
                  crypto_enabled:
                    type: boolean
        "503":
          $ref: "#/components/responses/PublicApiOff"
  /me:
    get:
      tags: [Account]
      summary: Current user
      security:
        - bearerAuth: []
      responses:
        "200":
          description: Account plus wallet cents
        "401":
          description: Missing or invalid token
        "503":
          $ref: "#/components/responses/PublicApiOff"
  /wallet:
    get:
      tags: [Wallet]
      summary: Wallet balances
      security:
        - bearerAuth: []
      responses:
        "200":
          description: Available and held cents
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Wallet"
        "503":
          $ref: "#/components/responses/PublicApiOff"
  /wallet/ledger:
    get:
      tags: [Wallet]
      summary: Ledger
      security:
        - bearerAuth: []
      responses:
        "200":
          description: Paginated ledger rows
        "503":
          $ref: "#/components/responses/PublicApiOff"
  /wallet/top-ups/stripe:
    post:
      tags: [Wallet]
      summary: Start a card top-up
      security:
        - bearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/TopUpRequest"
      responses:
        "201":
          description: Checkout URL. Credits land after the webhook.
          content:
            application/json:
              schema:
                type: object
                properties:
                  top_up:
                    $ref: "#/components/schemas/TopUp"
        "422":
          $ref: "#/components/responses/ApiError"
        "503":
          $ref: "#/components/responses/PublicApiOff"
  /wallet/top-ups/cryptomus:
    post:
      tags: [Wallet]
      summary: Start a crypto top-up
      security:
        - bearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/TopUpRequest"
      responses:
        "201":
          description: Checkout URL. Credits land after the webhook.
        "422":
          $ref: "#/components/responses/ApiError"
        "503":
          $ref: "#/components/responses/PublicApiOff"
  /wallet/top-ups/{id}:
    get:
      tags: [Wallet]
      summary: Top-up status
      security:
        - bearerAuth: []
      parameters:
        - $ref: "#/components/parameters/NumericId"
      responses:
        "200":
          description: Owner only
        "404":
          description: Missing or another user
        "503":
          $ref: "#/components/responses/PublicApiOff"
  /activations:
    get:
      tags: [Activations]
      summary: Recent activations
      security:
        - bearerAuth: []
      responses:
        "200":
          description: Owner list
          content:
            application/json:
              schema:
                type: object
                properties:
                  activations:
                    type: array
                    items:
                      $ref: "#/components/schemas/Activation"
        "503":
          $ref: "#/components/responses/PublicApiOff"
    post:
      tags: [Activations]
      summary: Buy a number
      security:
        - bearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/BuyRequest"
      responses:
        "201":
          description: Number issued. Cents held.
          content:
            application/json:
              schema:
                type: object
                properties:
                  activation:
                    $ref: "#/components/schemas/Activation"
        "422":
          $ref: "#/components/responses/ApiError"
        "503":
          $ref: "#/components/responses/PublicApiOff"
  /activations/{id}:
    get:
      tags: [Activations]
      summary: Poll an activation
      description: Poll about every 2.5 seconds while status is pending.
      security:
        - bearerAuth: []
      parameters:
        - $ref: "#/components/parameters/NumericId"
      responses:
        "200":
          description: Owner only
          content:
            application/json:
              schema:
                type: object
                properties:
                  activation:
                    $ref: "#/components/schemas/Activation"
        "404":
          description: Missing or another user
        "503":
          $ref: "#/components/responses/PublicApiOff"
  /activations/{id}/cancel:
    post:
      tags: [Activations]
      summary: Cancel and release the hold
      security:
        - bearerAuth: []
      parameters:
        - $ref: "#/components/parameters/NumericId"
      responses:
        "200":
          description: Canceled if still pending
        "422":
          $ref: "#/components/responses/ApiError"
        "503":
          $ref: "#/components/responses/PublicApiOff"
  /api-keys:
    get:
      tags: [Keys]
      summary: List developer keys
      security:
        - bearerAuth: []
      responses:
        "200":
          description: Metadata only. No plaintext.
        "503":
          $ref: "#/components/responses/PublicApiOff"
    post:
      tags: [Keys]
      summary: Create a developer key
      description: Plaintext is shown once. Replaces any existing developer key.
      security:
        - bearerAuth: []
      responses:
        "201":
          description: Token returned once
        "503":
          $ref: "#/components/responses/PublicApiOff"
  /api-keys/{id}:
    delete:
      tags: [Keys]
      summary: Revoke a developer key
      security:
        - bearerAuth: []
      parameters:
        - $ref: "#/components/parameters/NumericId"
      responses:
        "200":
          description: Revoked
        "404":
          description: Missing or another user
        "503":
          $ref: "#/components/responses/PublicApiOff"
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
  parameters:
    Service:
      name: service
      in: path
      required: true
      schema:
        type: string
        example: whatsapp
    NumericId:
      name: id
      in: path
      required: true
      schema:
        type: integer
  schemas:
    Error:
      type: object
      properties:
        error:
          type: object
          properties:
            code:
              type: string
              example: insufficient_funds
            message:
              type: string
    Quote:
      type: object
      properties:
        service:
          type: string
        country:
          type: string
        operator:
          type: string
        retail_cents:
          type: integer
        in_stock:
          type: boolean
        currency:
          type: string
          example: USD
    Wallet:
      type: object
      properties:
        available_cents:
          type: integer
        held_cents:
          type: integer
        currency:
          type: string
          example: USD
    TopUpRequest:
      type: object
      required: [amount_cents, idempotency_key]
      properties:
        amount_cents:
          type: integer
          example: 500
        idempotency_key:
          type: string
          minLength: 8
    TopUp:
      type: object
      properties:
        id:
          type: integer
        provider:
          type: string
          enum: [stripe, cryptomus]
        status:
          type: string
          enum: [pending, paid, failed, reversed]
        amount_cents:
          type: integer
        credited_cents:
          type: integer
          nullable: true
        checkout_url:
          type: string
          format: uri
          nullable: true
    BuyRequest:
      type: object
      required: [service, country, idempotency_key]
      properties:
        service:
          type: string
          example: whatsapp
        country:
          type: string
          example: US
        operator:
          type: string
          default: any
        idempotency_key:
          type: string
          minLength: 8
    Activation:
      type: object
      properties:
        id:
          type: integer
        status:
          type: string
          enum: [pending, received, canceled, timeout, failed, refunded]
        service:
          type: string
        country:
          type: string
        operator:
          type: string
          nullable: true
        phone_number:
          type: string
          nullable: true
        retail_cents:
          type: integer
        currency:
          type: string
        expires_at:
          type: string
          format: date-time
          nullable: true
        completed_at:
          type: string
          format: date-time
          nullable: true
        sms:
          type: array
          items:
            type: object
            properties:
              sender:
                type: string
                nullable: true
              body:
                type: string
                nullable: true
              otp_code:
                type: string
                nullable: true
  responses:
    ApiError:
      description: Typed error
      content:
        application/json:
          schema:
            $ref: "#/components/schemas/Error"
    PublicApiOff:
      description: public_api flag is off
      content:
        application/json:
          schema:
            $ref: "#/components/schemas/Error"
          example:
            error:
              code: public_api_off
              message: The public API is paused.
