openapi: 3.1.0
info:
  title: owlchat-sms API
  version: 0.1.0
  description: SMS/MMS webhook and outbound messaging API for VoIP.ms and OpenRouter-backed replies.
  license:
    name: Proprietary
    identifier: LicenseRef-Proprietary
servers:
  - url: /
components:
  securitySchemes:
    WebhookSecret:
      type: apiKey
      in: header
      name: X-Webhook-Secret
      description: Optional header enforced when the server is configured with a webhook secret.
  schemas:
    HealthResponse:
      type: object
      additionalProperties: false
      required: [ok]
      properties:
        ok:
          type: boolean
    AcceptedResponse:
      type: object
      additionalProperties: false
      required: [ok]
      properties:
        ok:
          type: boolean
    ErrorResponse:
      type: object
      additionalProperties: false
      required: [error]
      properties:
        error:
          type: string
paths:
  /api/healthz:
    get:
      operationId: getHealthz
      summary: Health check
      security: []
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/HealthResponse"
        "405":
          description: Method not allowed
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "500":
          description: Unexpected server error
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /api/webhooks/voipms:
    post:
      operationId: postVoipmsWebhook
      summary: Receive an inbound VoIP.ms webhook
      security:
        - WebhookSecret: []
        - {}
      requestBody:
        required: true
        content:
          application/x-www-form-urlencoded:
            schema:
              type: object
              additionalProperties: true
      responses:
        "202":
          description: Accepted
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/AcceptedResponse"
        "400":
          description: Invalid webhook payload
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "401":
          description: Invalid webhook secret
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /api/messages:
    post:
      operationId: postMessage
      summary: Send an outbound SMS or MMS
      security: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              additionalProperties: false
              required: [to, body]
              properties:
                to:
                  type: string
                from:
                  type: string
                body:
                  type: string
                media_urls:
                  type: array
                  items:
                    type: string
      responses:
        "202":
          description: Accepted
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/AcceptedResponse"
        "400":
          description: Invalid JSON body or missing required fields
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "502":
          description: Upstream messaging provider error
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
