Documentation
Learn how to use Hook2TG webhooks with different message formats.
Message Formats
Hook2TG supports two message formats for displaying webhook payloads in Telegram. Choose the format that best fits your use case when creating or editing a webhook.
How it works
- JSON objects are automatically converted to YAML format
- Plain text strings are preserved as-is
- Supports MarkdownV2 formatting with automatic URL detection and linking
- Special characters are properly escaped for Telegram
Example
curl -X POST https://api.hook2tg.com/YOUR_WEBHOOK_ID \
-H "Content-Type: application/json" \
-d '{
"status": "success",
"message": "Deployment completed",
"url": "https://example.com",
"timestamp": "2024-01-15T10:30:00Z"
}'Telegram Output:
Use cases
- CI/CD deployment notifications
- Monitoring alerts with structured data
- Log messages and status updates
- Any payload where readability is important
How it works
- JSON payloads are displayed in code blocks
- Preserves exact JSON structure and formatting
- Syntax highlighting for better readability
- Ideal for debugging and inspecting raw payloads
Example
curl -X POST https://api.hook2tg.com/YOUR_WEBHOOK_ID \
-H "Content-Type: application/json" \
-d '{
"status": "success",
"message": "Deployment completed",
"url": "https://example.com",
"timestamp": "2024-01-15T10:30:00Z"
}'Telegram Output:
{
"status": "success",
"message": "Deployment completed",
"url": "https://example.com",
"timestamp": "2024-01-15T10:30:00Z"
}Use cases
- API response debugging
- Complex nested JSON structures
- When exact JSON formatting is required
- Development and testing workflows
When to use Text Format (Default)
Use text format for most use cases. It provides better readability, automatic YAML conversion for structured data, and MarkdownV2 support with URL auto-linking. This is the recommended format for production alerts, monitoring notifications, and general webhook integrations.
When to use JSON Format
Use JSON format when you need to preserve the exact JSON structure, such as when debugging API responses or working with complex nested objects. The code block formatting makes it easy to copy and inspect the raw payload.
Endpoint
POST https://api.hook2tg.com/{webhookId}Headers
Content-Type: application/json
Request Body
Send any JSON payload or plain text. The format is determined by your webhook configuration.
{
"key": "value",
"nested": {
"data": "example"
}
}Response
{
"ok": true
}