API Reference

Create and manage dynamic web responses through our REST API.

Overview

The Khain API allows you to programmatically create web responses that can be accessed via unique URLs. All API requests must be made over HTTPS and include proper authentication headers.

POST https://api.khain.app/api/v1/web-response

Authentication

The Khain API uses Bearer token authentication. Include your API key in the Authorization header of every request.

Getting your API key

Visit api.khain.app, navigate to "New API Key", click "Generate Key", and copy your token.

Header format:
Authorization: Bearer YOUR_ACTIVE_TOKEN

Making requests

Send a POST request to the endpoint with your HTML content and an optional name for the web response.

Example request

curl -X POST "https://api.khain.app/api/v1/web-response" \
  -H "Authorization: Bearer YOUR_ACTIVE_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "body": "<h1>Hello World!</h1>",
    "name": "Example Web Response"
  }'

Request body

ParameterTypeDescription
bodystringHTML content to be rendered
namestringOptional name for the web response

Example response

{
  "message": "Web response saved successfully",
  "data": {
    "id": "abc123xyz",
    "create_at": "2025-11-06T09:05:48.000Z",
    "body": "<h1>Hello World!</h1>",
    "name": "Example Web Response",
    "user_id": "UidlHdFGEXc0UmWmbfRQ9yqO9Cf2",
    "status": "active"
  },
  "url": "https://api.khain.app/web/abc123xyz"
}

Response schema

The API returns a JSON object containing the operation status, saved data, and a public URL.

FieldTypeDescription
messagestringStatus message indicating success or failure
dataobjectWeb response object containing all saved data
data.idstringUnique identifier for the web response
data.create_atstringISO 8601 timestamp of creation time
data.bodystringHTML content stored in the web response
data.namestringUser-defined name for the web response
data.user_idstringUnique identifier of the user who created it
data.statusstringCurrent status of the web response (e.g., "active")
urlstringPublic URL where the web response can be accessed