API Reference
The AgentBlocks API uses REST conventions and returns JSON. All requests require an API key and a version header. Your agent discovers its capabilities by calling GET /agent/info.
Base URL
https://api.agentblocks.aiAuthentication
All API requests require a Bearer token and the X-Agent-Version header.
API keys start with sk_ and are created per-agent in the dashboard. If the X-Agent-Version header is missing or outdated, the server returns 426 with a link to re-fetch the agent guide.
Discovery
Your agent should always start by calling this endpoint to learn what it can do.
/agent/infoDiscover your agent's capabilities, email addresses, and links to capability-specific guides.
The agent should fetch each URL in guides to learn the full API for that capability. Do not hardcode capabilities — always discover them from this endpoint.
Polling for Status
When an action requires approval, poll this endpoint for a resolution.
/operations/:tokenCheck the status of a pending operation. Poll with exponential backoff (every 5–30 seconds) until a terminal status is reached.
| type | Meaning | Terminal? |
|---|---|---|
| queued | Awaiting human approval | No |
| approved | Approved and executed | Yes |
| rejected | Human rejected the request | Yes |
| timed_out | Expired before approval | Yes |
| failed | Approved but execution failed | Yes |
Give your agent a dedicated @agentmx.io email address to send and receive real emails.
/email/send-requestRequest to send an email. Requires human approval unless auto-allowed by policy. Returns an LRO envelope.
Fields: to (required), subject (required), body (required, plain text), from (optional prefix). Supports Idempotency-Key header.
/email/inboundFetch inbound emails. Query params: limit (1–100), before (cursor for pagination). Ordered newest-first.
/email/inbound/:idGet a single inbound email by ID.
Rate limits: 10 sends/hour, 50 sends/day per agent. Inbound attachments are dropped — only text content is stored.
GitHub
Push, pull, and fetch with short-lived GitHub tokens. All git operations go through the agentblocks-git wrapper script.
Important: Your agent does not have direct push access. All authenticated git operations use the agentblocks-git script, which handles token requests, approval polling, and automatic token revocation.
The script waits for approval if needed, then executes the git operation with a scoped token. The token is revoked immediately after use. If the script is interrupted, use --resume <token> to pick up where it left off.
Gmail
Read, reply, forward, and compose emails from a linked Gmail account. Actions execute on AgentBlocks servers.
/gmail/inboxList inbox messages. Optional query params: q (Gmail search query), maxResults.
/gmail/messages/:idGet a specific message by ID with full content.
/gmail/replyReply to a message (threaded). Fields: messageId, body. Requires approval.
/gmail/forwardForward a message. Fields: messageId, to, body (optional). Requires approval.
/gmail/sendCompose a new email. Fields: to, subject, body. Requires approval.
/gmail/messages/:id/archiveArchive a message (removes INBOX label).
/gmail/messages/:id/labelsAdd or remove labels. Fields: addLabelIds, removeLabelIds.
/gmail/labelsList all available labels for the connected account.
Rate limits: 200 reads/hour, 20 sends/hour per agent. All send/reply/forward endpoints support Idempotency-Key headers.
Google Drive
List files, read metadata, and read file content from a linked Google Drive. Content reads require approval by default.
/drive/filesList files. Optional params: q (Drive search query), maxResults, pageToken.
/drive/files/:id/metadataRead a file's metadata (name, owner, dates, labels).
/drive/files/:id/contentRead a file's content. Requires approval by default. Google Docs/Sheets/Slides are auto-exported to text formats. Optional param: mimeType.
Slack
Read channels, search messages, and post to a connected Slack workspace.
/slack/channelsList channels (public, private, DMs, group DMs) the user is in.
/slack/usersList workspace members. Slack Connect (external) users are not included.
/slack/users/:userIdLook up any user by Slack user ID, including external Slack Connect users.
/slack/search?q=...Search messages across the workspace. Requires approval. Params: q, page, count.
/slack/channels/:channelId/messagesRead recent messages in a channel or DM. Param: limit.
/slack/channels/:channelId/messagesPost a message as the user. Requires approval. Body: { text }.
/slack/channels/:channelId/replyReply in a thread. Requires approval. Body: { text, threadTs }.
Error Codes
Standard HTTP error codes used across all endpoints.
| Status | Meaning |
|---|---|
| 400 | Missing or invalid fields |
| 401 | Missing, malformed, or invalid API key |
| 403 | Access denied or scope upgrade required |
| 404 | Resource not found |
| 409 | Idempotency key reused with different payload |
| 426 | Missing or outdated X-Agent-Version header |
| 429 | Rate limit exceeded |