openapi: 3.0.3
info:
  title: CryptoXTS Merchant API
  version: "1.0"
  description: >
    Public invoice API for plugins and gateways. Authenticate with domain API key + secret.
    Does not include withdrawals, wallets, or admin operations.
servers:
  - url: https://cryptoxts.com/api/v1
    description: Production
security:
  - ApiKeyHeader: []
    ApiSecretHeader: []
paths:
  /ping:
    get:
      summary: Health check
      responses:
        "200":
          description: OK
  /stats:
    get:
      summary: Domain stats
      responses:
        "200":
          description: Stats snapshot
  /invoices:
    get:
      summary: List invoices
      parameters:
        - in: query
          name: status
          schema: { type: string }
        - in: query
          name: from
          schema: { type: string, format: date }
        - in: query
          name: to
          schema: { type: string, format: date }
        - in: query
          name: external_invoice_id
          schema: { type: string }
        - in: query
          name: client_email
          schema: { type: string, format: email }
        - in: query
          name: per_page
          schema: { type: integer, minimum: 1, maximum: 100, default: 25 }
      responses:
        "200":
          description: Paginated invoices
    post:
      summary: Create invoice
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [amount_usd]
              properties:
                amount_usd: { type: number, minimum: 0.01 }
                external_invoice_id: { type: string, maxLength: 100 }
                callback_url: { type: string, format: uri }
                success_url: { type: string, format: uri }
                cancel_url: { type: string, format: uri }
                meta: { type: object, additionalProperties: true }
      responses:
        "201":
          description: Invoice created
  /invoices/{uuid}:
    get:
      summary: Get invoice
      parameters:
        - in: path
          name: uuid
          required: true
          schema: { type: string }
      responses:
        "200":
          description: Invoice
        "404":
          description: Not found
components:
  securitySchemes:
    ApiKeyHeader:
      type: apiKey
      in: header
      name: X-API-KEY
    ApiSecretHeader:
      type: apiKey
      in: header
      name: X-API-SECRET
