{
  "openapi": "3.1.0",
  "info": {
    "title": "Relaytiv API",
    "version": "0.1.0",
    "description": "API contract for the relaytiv.com/api server's payment and health endpoints; not the provider-backed messaging platform API. Relaytiv is an AI front desk for chat-led businesses. Currently connected: WhatsApp Web, SMS, Instagram, Messenger. WhatsApp Business API is supported subject to provider and account setup; web chat and custom channels are available depending on setup. Natural AI conversations use configured business context; optional visual automations can complement them. Features depend on plan and workspace setup. Facts verified 2026-09-23. For product API access and setup see https://relaytiv.com/docs and https://relaytiv.com/api. Authentication requirements vary by operation; see each endpoint."
  },
  "servers": [
    {
      "url": "https://relaytiv.com/api",
      "description": "Production"
    }
  ],
  "paths": {
    "/healthz": {
      "get": {
        "operationId": "healthCheck",
        "summary": "Health check",
        "description": "Returns server health and version status.",
        "tags": [
          "health"
        ],
        "responses": {
          "200": {
            "description": "Server is healthy",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HealthStatus"
                }
              }
            }
          }
        }
      }
    },
    "/payments/create-order": {
      "post": {
        "operationId": "createPaymentOrder",
        "summary": "Create a payment order",
        "description": "Creates a Razorpay subscription order for a Relaytiv plan. Returns an order ID and key for the Razorpay checkout SDK.",
        "tags": [
          "payments"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateOrderRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Order created — proceed to Razorpay checkout",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CreateOrderResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error"
          },
          "500": {
            "description": "Server error"
          }
        }
      }
    },
    "/payments/verify": {
      "post": {
        "operationId": "verifyPayment",
        "summary": "Verify a payment",
        "description": "Verifies the Razorpay payment signature and marks the subscriber as active.",
        "tags": [
          "payments"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/VerifyPaymentRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Payment verified"
          },
          "400": {
            "description": "Invalid signature or validation error"
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "HealthStatus": {
        "type": "object",
        "description": "API health status response",
        "properties": {
          "status": {
            "type": "string",
            "description": "Server health status — 'ok' when healthy"
          },
          "version": {
            "type": "string",
            "description": "API version string"
          }
        }
      },
      "CreateOrderRequest": {
        "type": "object",
        "required": [
          "plan",
          "currency",
          "phone"
        ],
        "description": "Request body to create a Razorpay subscription order",
        "properties": {
          "plan": {
            "type": "string",
            "enum": [
              "launch",
              "growth",
              "scale"
            ],
            "description": "Relaytiv subscription plan"
          },
          "currency": {
            "type": "string",
            "enum": [
              "INR",
              "USD",
              "AED"
            ],
            "description": "Billing currency"
          },
          "phone": {
            "type": "string",
            "description": "Subscriber's WhatsApp phone number in E.164 format"
          },
          "name": {
            "type": "string",
            "description": "Subscriber's full name"
          },
          "email": {
            "type": "string",
            "description": "Subscriber's email address"
          },
          "businessName": {
            "type": "string",
            "description": "Business or company name"
          }
        }
      },
      "CreateOrderResponse": {
        "type": "object",
        "description": "Razorpay order details for the checkout SDK",
        "properties": {
          "orderId": {
            "type": "string",
            "description": "Razorpay order ID — pass to the checkout SDK"
          },
          "amount": {
            "type": "number",
            "description": "Amount in the smallest currency unit (paise for INR, cents for USD)"
          },
          "currency": {
            "type": "string",
            "description": "Currency code"
          },
          "keyId": {
            "type": "string",
            "description": "Razorpay public key ID for the checkout SDK"
          }
        }
      },
      "VerifyPaymentRequest": {
        "type": "object",
        "required": [
          "orderId",
          "paymentId",
          "signature"
        ],
        "description": "Razorpay payment verification payload",
        "properties": {
          "orderId": {
            "type": "string",
            "description": "Razorpay order ID from the create-order step"
          },
          "paymentId": {
            "type": "string",
            "description": "Razorpay payment ID returned by the checkout SDK"
          },
          "signature": {
            "type": "string",
            "description": "HMAC-SHA256 signature from the checkout SDK for verification"
          }
        }
      }
    }
  }
}
