Skip to main content

Set Webhook

The setWebhook method is used to configure a YoAI to receive updates via a webhook instead of the traditional long-polling mechanism. This approach allows the bot to be notified of incoming updates in real-time by the server. All messages will be sent to {webhookURL}/yoai:{accessToken} path.

Note: If the server receives a non-200 HTTP response from the webhook endpoint, the webhook configuration will be considered invalid. In such cases, you must use setWebhook method again to re-enable real-time update delivery.

Request Format

You need to send a POST request to:

https://yoai.yophone.com/api/pub/setWebhook

Request body params format (JSON)

Your webhook URL

Request example

curl -X POST https://yoai.yophone.com/api/pub/setWebhook \
-H "Content-Type: application/json" \
-H "X-YoAI-API-Key: your YoAI api key" \
-d '{
"webhookURL": "https://example.com"
}'

Success Response

The API returns a JSON object indicating the success of the operation.

{
"code": 200,
"success": true,
"data": null
}

Failure Response

The API returns a JSON object indicating the success of the operation.

{
"code": 200,
"success": false,
"message": "failed to set webhook URL"
}