Skip to main content

Developer API

Base URL: https://ayts-api.jerquinbayudo.workers.dev Auth: Authorization: Bearer kap_live_... Availability: Pro plan only Rate limit: 60 requests/minute per API key

The Developer API lets you talk to your own AI agent — the same one answering your Facebook Page — from your own website, app, or automation. It's useful if you want a chat widget on your website, or want to build your own order-capture workflow on top of the same AI.

Getting an API key

API keys are created from the API Keys tab in your dashboard (Pro plan required). Give the key a name (e.g. "My Website"), and the full key is shown once — copy it immediately, as it can't be viewed again after you close that screen. If you lose it, revoke it and create a new one.

Every request must include your key in the Authorization header:

Authorization: Bearer kap_live_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

POST /v1/chat

Send a customer message to your AI agent and get a reply back — with an order object if the customer just confirmed a complete order.

Request:

{
"message": "Magkano ang lechon manok?",
"session_id": "customer-123"
}

session_id identifies the conversation — use a stable ID per customer/session (e.g. a visitor ID, phone number, or chat widget session) so the AI remembers context across messages.

Response:

{
"success": true,
"data": {
"reply": "₱280 per whole, ₱150 per half po! Gusto ka mo-order?",
"order": null
}
}

When a customer has just confirmed a complete order, order is populated instead of null:

{
"success": true,
"data": {
"reply": "Salamat! ✅ Na-confirm na imong order.",
"order": {
"customer_name": "Ana Cruz",
"items": [{ "name": "Lechon Manok (Whole)", "qty": 1, "price": 280 }],
"total": 280,
"delivery_address": "Pickup 6:00 PM",
"contact_number": "09171234567",
"notes": null
}
}
}

Captured orders through the API also appear in your dashboard Orders tab, same as Messenger orders.

curl example:

curl -X POST https://ayts-api.jerquinbayudo.workers.dev/v1/chat \
-H "Authorization: Bearer kap_live_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" \
-H "Content-Type: application/json" \
-d '{
"message": "Magkano ang lechon manok?",
"session_id": "customer-123"
}'

GET /v1/orders

Fetch orders your AI agent has captured. Supports optional filtering and a result limit.

Query paramDescription
statusFilter by new, confirmed, fulfilled, or cancelled
limitMax results to return (default 20, max 100)

curl example:

curl "https://ayts-api.jerquinbayudo.workers.dev/v1/orders?status=new&limit=20" \
-H "Authorization: Bearer kap_live_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"

Response:

{
"success": true,
"data": [
{
"id": "b7e2...",
"customer_name": "Ana Cruz",
"items": [{ "name": "Lechon Manok (Whole)", "qty": 1, "price": 280 }],
"total": 280,
"delivery_address": "Pickup 6:00 PM",
"contact_number": "09171234567",
"status": "new",
"created_at": "2026-07-17T10:15:00.000Z"
}
]
}

GET /v1/health

An unauthenticated liveness check — useful for confirming the API is reachable before you debug your integration.

curl https://ayts-api.jerquinbayudo.workers.dev/v1/health
{ "ok": true }

Rate limits

Each API key is limited to 60 requests per minute. Every response includes rate-limit headers:

X-RateLimit-Limit: 60
X-RateLimit-Remaining: 47
X-RateLimit-Reset: 1721212800

If you exceed the limit, you'll get an HTTP 429:

{
"error": "Rate limit exceeded",
"message": "Too many requests. Try again in 12 seconds.",
"retryAfter": 12
}

Errors

StatusMeaning
401Missing, invalid, or revoked API key
403Your plan no longer includes API access (downgrade from Pro)
429Monthly AI reply limit reached, or per-minute rate limit exceeded

Monthly limit responses look like:

{
"error": "Monthly AI message limit reached for your plan.",
"used": 8000,
"limit": 8000
}