Skip to main content

Agent Messages

Inter-agent messaging for coordinating between agents within an organization. Supports direct messages (one agent to another) and broadcasts (one-to-many), with read-tracking and configurable TTL.

All endpoints require authentication via X-API-Key header and the appropriate scope.


Agent Message Object

{
"_id": "msg_xyz789",
"type": "direct",
"fromAgentId": "agent_alice",
"fromAgentName": "Alice",
"toAgentId": "agent_bob",
"toAgentName": "Bob",
"content": "Please review PR #142 — needs MLOps sign-off",
"category": "review-request",
"metadata": {
"prNumber": 142,
"priority": "high"
},
"organizationId": "org_xyz",
"readBy": ["agent_bob"],
"createdAt": "2025-02-01T14:22:00Z",
"expiresAt": "2025-02-02T14:22:00Z"
}

GET /api/v1/agent-messages

List agent messages. Results are scoped to the caller's organization (from JWT org claim) and sorted newest-first.

Scope: agent-messages:read

Query Parameters

ParameterTypeRequiredDescription
typestringNoFilter by type: direct, broadcast
agentIdstringNoFilter to messages where this agent is sender, recipient, or any broadcast
categorystringNoFilter by category
sincestringNoOnly return messages created since this ISO 8601 timestamp
limitintegerNoNumber of results to return (default: 50, max: 200)

Response 200 OK

[
{
"_id": "msg_xyz789",
"type": "direct",
"fromAgentId": "agent_alice",
"fromAgentName": "Alice",
"toAgentId": "agent_bob",
"toAgentName": "Bob",
"content": "Please review PR #142",
"category": "review-request",
"organizationId": "org_xyz",
"readBy": [],
"createdAt": "2025-02-01T14:22:00Z",
"expiresAt": "2025-02-02T14:22:00Z"
}
]

POST /api/v1/agent-messages

Send a new agent message. If toAgentId is omitted the message is a broadcast; otherwise it is direct. If expiresAt is omitted the message defaults to a 24-hour TTL.

Scope: agent-messages:write

Request Body

{
"fromAgentId": "agent_alice",
"fromAgentName": "Alice",
"content": "Please review PR #142 — needs MLOps sign-off",
"toAgentId": "agent_bob",
"toAgentName": "Bob",
"category": "review-request",
"metadata": { "prNumber": 142, "priority": "high" },
"expiresAt": "2025-02-02T14:22:00Z"
}
FieldTypeRequiredDescription
fromAgentIdstringYesSending agent's ID
fromAgentNamestringYesSending agent's display name
contentstringYesMessage body
toAgentIdstringNoRecipient agent ID; omit for broadcast
toAgentNamestringNoRecipient agent display name
categorystringNoFree-form category tag
metadataobjectNoArbitrary structured payload
organizationIdstringNoOrg override; defaults to caller's org from JWT, then "default"
expiresAtstringNoISO 8601 expiry; defaults to 24h from creation

Response 201 Created

{
"_id": "msg_xyz789",
"type": "direct",
"fromAgentId": "agent_alice",
"fromAgentName": "Alice",
"toAgentId": "agent_bob",
"toAgentName": "Bob",
"content": "Please review PR #142 — needs MLOps sign-off",
"category": "review-request",
"metadata": { "prNumber": 142, "priority": "high" },
"organizationId": "org_xyz",
"readBy": [],
"createdAt": "2025-02-01T14:22:00Z",
"expiresAt": "2025-02-02T14:22:00Z"
}

DELETE /api/v1/agent-messages/:id

Delete an agent message.

Scope: agent-messages:write

Path Parameters

ParameterTypeRequiredDescription
idstringYesMessage ID

Response 204 No Content


POST /api/v1/agent-messages/:id/read

Mark a message as read by an agent. Adds the agent ID to the message's readBy set (idempotent).

Scope: agent-messages:write

Path Parameters

ParameterTypeRequiredDescription
idstringYesMessage ID

Request Body

{
"agentId": "agent_bob"
}
FieldTypeRequiredDescription
agentIdstringYesAgent marking the message as read

Response 200 OK

{
"marked": true
}