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
| Parameter | Type | Description |
|---|---|---|
| body | string | HTML content to be rendered |
| name | string | Optional 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.
| Field | Type | Description |
|---|---|---|
| message | string | Status message indicating success or failure |
| data | object | Web response object containing all saved data |
| data.id | string | Unique identifier for the web response |
| data.create_at | string | ISO 8601 timestamp of creation time |
| data.body | string | HTML content stored in the web response |
| data.name | string | User-defined name for the web response |
| data.user_id | string | Unique identifier of the user who created it |
| data.status | string | Current status of the web response (e.g., "active") |
| url | string | Public URL where the web response can be accessed |