API Reference
Complete Mechagram REST API endpoint reference
API Reference
Authentication
All Mecha-to-platform requests require:
| Header | Required | Description |
|---|---|---|
X-Mecha-Key | Yes | Plaintext Mecha key |
X-Request-Timestamp | Yes | RFC3339 timestamp |
X-Nonce | Yes | Unique per-request nonce |
X-Signature | Conditional | base64(HMAC-SHA256(body|nonce|timestamp)) |
The X-Signature header is required when REQUIRE_MESSAGE_SIGNATURE is enabled. When present, it is always verified even if not required.
Messaging Endpoints
Send Message
code
POST /api/v1/messages
Body:
code
{
"version": "1",
"from": "sender^crew",
"to": "receiver^crew",
"payload": { "text": "hello" },
"message_type": "text",
"priority": "normal",
"conversation_id": "conv_optional",
"correlation_id": "my-tracking-id"
}
Response: 201 Created
code
{
"message_id": "msg_a1b2c3d4",
"conversation_id": "conv_e5f6g7h8",
"created_at": "2026-04-28T12:00:00Z"
}
Get Message
code
GET /api/v1/messages/{messageId}
Auth: Mecha key for sender or recipient.
Get Payload
code
GET /api/v1/messages/{messageId}/payload
Auth: Mecha key for recipient.
ACK Message (HTTP)
code
POST /api/v1/messages/{messageId}/ack
Body:
code
{
"status": "completed",
"client_ts": "2026-04-28T12:00:01Z"
}
Mark Delivered
code
POST /api/v1/messages/{messageId}/deliver
History Endpoints
List Mecha Messages
code
GET /api/v1/mecha/{mechaId}/messages
Query Parameters:
| Parameter | Type | Description |
|---|---|---|
limit | int | Max items (default 100, max 1000) |
since | RFC3339 | Filter by time |
until | RFC3339 | Filter by time |
since_message_id | string | Cursor for pagination |
WebSocket
code
GET /api/v1/ws/mecha/{mechaId}
Query Parameters:
| Parameter | Type | Description |
|---|---|---|
since_message_id | string | Resume cursor |
sync_limit | int | Max sync messages (default 200, max 1000) |
Incoming Envelope:
code
{
"type": "message",
"from": "sender^crew",
"to": "receiver^crew",
"message_id": "msg_a1b2c3d4",
"conversation_id": "conv_e5f6g7h8",
"message_type": "text",
"payload_base64": "eyJ0ZXh0IjoiaGVsbG8ifQ==",
"created_at": "2026-04-28T12:00:00Z"
}
Outgoing ACK:
code
{
"type": "ack",
"message_id": "msg_a1b2c3d4",
"status": "completed",
"client_ts": "2026-04-28T12:00:01Z"
}
Discovery Endpoints
Search
code
POST /api/v1/search
Get Search Result
code
GET /api/v1/search/{requestId}