Sendmux token-efficient usage
Use this skill to choose the lowest-cost Sendmux route that still answers the task correctly.
Boundaries
- Do not ask the user to paste an API key.
- Use send-capable
smx_mbx_* keys or owner-approved Sending-resource smx_agent_* tokens for Sending calls, and smx_mbx_* keys for normal Mailbox calls.
- Use scoped
smx_agent_* only for the calls its scopes and resource allow. Pre-claim agent tokens cannot send.
- Use
smx_root_* for Management calls.
- Do not default to MCP for every task. MCP is best when the required tool is curated; CLI and SDK cover broader surfaces.
- Do not pipe real attachments through model context as base64. Route attachment transfer to
sendmux-attachments; prefer file_path, presigned URLs, CLI --attach, or SDK file helpers. Mailbox uploads cap each attachment at 7,500,000 bytes; Sending uploads cap each file at 18 MiB; MCP inline base64 caps at 32 KiB decoded.
- Do not read full mailbox bodies, every message, or every log row unless the user asks for full content and narrower calls cannot answer.
Surface choice
| Situation |
Use |
Why |
| Connected agent and curated tool exists |
MCP tool |
Small schema and no SDK boilerplate. |
| One-off terminal task |
sendmux CLI with --json |
Direct, scriptable, exposes the full generated operation set. |
| Application code or repeated workflow |
SDK for the project already in use |
Reuses client setup, pagination, headers, and retry helpers. |
| MCP lacks the needed operation |
CLI for terminal work, SDK for code |
Do not invent uncurated MCP tools. |
| No package/tooling available |
Direct HTTP |
Keep request bodies and headers aligned to OpenAPI. |
Cheapest-call map
| Task |
Cheapest correct default |
| Send one outbound email |
sending_send_email, CLI sending:send, SDK sendingSendEmail; include Idempotency-Key. |
| Send multiple outbound emails |
sending_send_email_batch, CLI sending:send:batch, SDK sendingSendEmailBatch; do not loop single sends. |
| Send or read attachments |
sendmux-attachments; use file_path, presigned upload/download URLs, CLI --attach, SDK file helpers, blob_id for mailbox sends, and attachment_id for Sending sends instead of inline base64. |
| Count matching mailbox messages |
mailbox_count_messages, CLI mailbox:count-messages, SDK mailboxCountMessages. |
| Search mailbox text |
mailbox_search_message_snippets, CLI mailbox:search-message-snippets, SDK mailboxSearchMessageSnippets; then fetch selected IDs. |
| Read several known messages |
mailbox_batch_get_messages, CLI mailbox:batch-get-messages, SDK mailboxBatchGetMessages. |
| Update/delete several messages |
Batch update/delete after explicit confirmation. |
| Resume broad mailbox sync |
mailbox_get_changes, CLI mailbox:get-changes, SDK mailboxGetChanges. |
| Resume filtered mailbox sync |
CLI/SDK mailbox:query-message-changes / mailboxQueryMessageChanges; MCP does not curate it yet. |
| Watch live mailbox events |
CLI/SDK mailbox:stream-events / mailboxStreamEvents; MCP does not curate it yet. |
| Scan threads |
List threads, then fetch one thread or its messages. |
| Manage domains/mailboxes/keys |
Management MCP for curated create/list/get/update/suspend/resume/key tools; CLI/SDK for uncovered lifecycle work. |
| Manage sending accounts |
CLI/SDK; MCP does not curate provider tools yet. |
| Manage webhooks |
MCP for list/create/test; CLI/SDK for get/update/delete/rotate/delivery payloads. |
| Inspect spend, logs, metrics |
Summary/metrics first; filter log lists with small limit, then fetch one selected row. |
Read less
For mailbox questions, reduce the result set before reading content:
- Count when the user asks "how many" or when the query may be broad.
- Search snippets with a small
limit when the user needs examples.
- Batch-get only selected message IDs.
- Request clean body/content only when message text affects the answer.
CLI:
sendmux mailbox:count-messages \
--query q=invoice \
--query is_unread=true \
--json
sendmux mailbox:search-message-snippets \
--query q=invoice \
--query is_unread=true \
--query limit=10 \
--json
sendmux mailbox:batch-get-messages \
--body '{
"ids": ["eml_abc", "eml_def"],
"body_mode": "clean_json",
"max_body_chars": 4000,
"strip_quotes": true,
"strip_signature": true,
"include_attachments": "metadata"
}' \
--json
Write fewer requests
Batch when there is more than one target.
sendmux sending:send:batch \
--idempotency-key "$IDEMPOTENCY_KEY" \
--body-file ./messages.json \
--json
sendmux mailbox:batch-update-messages \
--body '{
"ids": ["eml_abc", "eml_def"],
"seen": true,
"if_in_state": "state_from_prior_read"
}' \
--json
For batch sends, inspect every per-message result before reporting success. Batch can contain mixed outcomes.
Sync by delta
Use sync endpoints instead of re-listing stable data.
Broad mailbox sync:
sendmux mailbox:get-changes \
--query messages_since_state="$MESSAGES_STATE" \
--query folders_since_state="$FOLDERS_STATE" \
--query threads_since_state="$THREADS_STATE" \
--query limit=100 \
--json
Filtered message sync:
sendmux mailbox:query-message-changes \
--query since_query_state="$QUERY_STATE" \
--query q=invoice \
--query is_unread=true \
--query limit=100 \
--json
Store the returned state token. Continue with the same filters only while has_more is true and the next page is needed.
Transfer less
- Use small
limit values on list calls.
- Follow
pagination.next_cursor only until enough evidence has been gathered.
- Prefer summary or metrics endpoints before log lists.
- Use
If-None-Match for repeated detail reads that previously returned an ETag.
- Use
If-Match for updates when the prior read returned an ETag.
- For inbound attachments, fetch metadata and use the short-lived
download_url; if it expires, re-fetch metadata instead of building URLs manually.
- For outbound attachments, a file path or presigned URL is usually under 100 tokens, while base64 can burn thousands of tokens and corrupt large files.
CLI conditional examples:
sendmux management:get-email-log \
--path public_id=dlog_abc \
--if-none-match "$ETAG" \
--json
sendmux management:update-mailbox \
--path public_id=mbx_abc \
--if-match "$ETAG" \
--body '{"display_name":"Agent Inbox"}' \
--json
SDK helpers:
import {
conditionalHeaders,
idempotencyHeaders,
paginate,
responseEtag,
} from "@sendmux/core";
const headers = conditionalHeaders({ ifNoneMatch: priorEtag });
const writeHeaders = {
...conditionalHeaders({ etag: priorEtag }),
...idempotencyHeaders(operationKey),
};
Retry safely
Use Idempotency-Key on supported mutations so retrying does not create duplicate work.
Good candidates:
sending:send and sending:send:batch.
mailbox:send-message.
- Management creates, mailbox key creation, suspend/resume, provider mutations, webhook create/rotate/test.
When retrying application code, prefer SDK retry helpers only for safe reads or idempotent writes. Non-idempotent writes should fail rather than risk duplicate side effects.
Routing
- Setup, key scopes, first call:
sendmux-getting-started.
- Email send bodies and SMTP-vs-HTTP choice:
sendmux-send-email.
- Attachment upload/download mechanics:
sendmux-attachments.
- Mailbox read/search/sync/triage/reply details:
sendmux-mailbox-agent.
- Management domains, mailboxes, webhooks, billing, logs:
sendmux-management.
- CLI syntax and profiles:
sendmux-cli.
- MCP installation and client config:
sendmux-mcp-setup.
1---2name: sendmux-token-efficient-usage3description: Choose the cheapest correct Sendmux surface and call. Use whenever a Sendmux task could be done through MCP, the sendmux CLI, an SDK, or direct HTTP and the user needs low-token, low-round-trip usage: batch sends, mailbox search/count/batch reads, sync deltas, cursor pagination, ETags, conditional requests, idempotency keys, attachment file transfer, or avoiding broad mailbox/log fetches.4license: Apache-2.05---67# Sendmux token-efficient usage89Use this skill to choose the lowest-cost Sendmux route that still answers the task correctly.1011## Boundaries1213- Do not ask the user to paste an API key.14- Use send-capable `smx_mbx_*` keys or owner-approved Sending-resource `smx_agent_*` tokens for Sending calls, and `smx_mbx_*` keys for normal Mailbox calls.15- Use scoped `smx_agent_*` only for the calls its scopes and resource allow. Pre-claim agent tokens cannot send.16- Use `smx_root_*` for Management calls.17- Do not default to MCP for every task. MCP is best when the required tool is curated; CLI and SDK cover broader surfaces.18- Do not pipe real attachments through model context as base64. Route attachment transfer to `sendmux-attachments`; prefer `file_path`, presigned URLs, CLI `--attach`, or SDK file helpers. Mailbox uploads cap each attachment at 7,500,000 bytes; Sending uploads cap each file at 18 MiB; MCP inline base64 caps at 32 KiB decoded.19- Do not read full mailbox bodies, every message, or every log row unless the user asks for full content and narrower calls cannot answer.2021## Surface choice2223| Situation | Use | Why |24| --------------------------------------- | ----------------------------------- | ------------------------------------------------------------- |25| Connected agent and curated tool exists | MCP tool | Small schema and no SDK boilerplate. |26| One-off terminal task | `sendmux` CLI with `--json` | Direct, scriptable, exposes the full generated operation set. |27| Application code or repeated workflow | SDK for the project already in use | Reuses client setup, pagination, headers, and retry helpers. |28| MCP lacks the needed operation | CLI for terminal work, SDK for code | Do not invent uncurated MCP tools. |29| No package/tooling available | Direct HTTP | Keep request bodies and headers aligned to OpenAPI. |3031## Cheapest-call map3233| Task | Cheapest correct default |34| ------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------- |35| Send one outbound email | `sending_send_email`, CLI `sending:send`, SDK `sendingSendEmail`; include `Idempotency-Key`. |36| Send multiple outbound emails | `sending_send_email_batch`, CLI `sending:send:batch`, SDK `sendingSendEmailBatch`; do not loop single sends. |37| Send or read attachments | `sendmux-attachments`; use `file_path`, presigned upload/download URLs, CLI `--attach`, SDK file helpers, `blob_id` for mailbox sends, and `attachment_id` for Sending sends instead of inline base64. |38| Count matching mailbox messages | `mailbox_count_messages`, CLI `mailbox:count-messages`, SDK `mailboxCountMessages`. |39| Search mailbox text | `mailbox_search_message_snippets`, CLI `mailbox:search-message-snippets`, SDK `mailboxSearchMessageSnippets`; then fetch selected IDs. |40| Read several known messages | `mailbox_batch_get_messages`, CLI `mailbox:batch-get-messages`, SDK `mailboxBatchGetMessages`. |41| Update/delete several messages | Batch update/delete after explicit confirmation. |42| Resume broad mailbox sync | `mailbox_get_changes`, CLI `mailbox:get-changes`, SDK `mailboxGetChanges`. |43| Resume filtered mailbox sync | CLI/SDK `mailbox:query-message-changes` / `mailboxQueryMessageChanges`; MCP does not curate it yet. |44| Watch live mailbox events | CLI/SDK `mailbox:stream-events` / `mailboxStreamEvents`; MCP does not curate it yet. |45| Scan threads | List threads, then fetch one thread or its messages. |46| Manage domains/mailboxes/keys | Management MCP for curated create/list/get/update/suspend/resume/key tools; CLI/SDK for uncovered lifecycle work. |47| Manage sending accounts | CLI/SDK; MCP does not curate provider tools yet. |48| Manage webhooks | MCP for list/create/test; CLI/SDK for get/update/delete/rotate/delivery payloads. |49| Inspect spend, logs, metrics | Summary/metrics first; filter log lists with small `limit`, then fetch one selected row. |5051## Read less5253For mailbox questions, reduce the result set before reading content:54551. Count when the user asks "how many" or when the query may be broad.562. Search snippets with a small `limit` when the user needs examples.573. Batch-get only selected message IDs.584. Request clean body/content only when message text affects the answer.5960CLI:6162```bash63sendmux mailbox:count-messages \64 --query q=invoice \65 --query is_unread=true \66 --json6768sendmux mailbox:search-message-snippets \69 --query q=invoice \70 --query is_unread=true \71 --query limit=10 \72 --json7374sendmux mailbox:batch-get-messages \75 --body '{76 "ids": ["eml_abc", "eml_def"],77 "body_mode": "clean_json",78 "max_body_chars": 4000,79 "strip_quotes": true,80 "strip_signature": true,81 "include_attachments": "metadata"82 }' \83 --json84```8586## Write fewer requests8788Batch when there is more than one target.8990```bash91sendmux sending:send:batch \92 --idempotency-key "$IDEMPOTENCY_KEY" \93 --body-file ./messages.json \94 --json9596sendmux mailbox:batch-update-messages \97 --body '{98 "ids": ["eml_abc", "eml_def"],99 "seen": true,100 "if_in_state": "state_from_prior_read"101 }' \102 --json103```104105For batch sends, inspect every per-message result before reporting success. Batch can contain mixed outcomes.106107## Sync by delta108109Use sync endpoints instead of re-listing stable data.110111Broad mailbox sync:112113```bash114sendmux mailbox:get-changes \115 --query messages_since_state="$MESSAGES_STATE" \116 --query folders_since_state="$FOLDERS_STATE" \117 --query threads_since_state="$THREADS_STATE" \118 --query limit=100 \119 --json120```121122Filtered message sync:123124```bash125sendmux mailbox:query-message-changes \126 --query since_query_state="$QUERY_STATE" \127 --query q=invoice \128 --query is_unread=true \129 --query limit=100 \130 --json131```132133Store the returned state token. Continue with the same filters only while `has_more` is true and the next page is needed.134135## Transfer less136137- Use small `limit` values on list calls.138- Follow `pagination.next_cursor` only until enough evidence has been gathered.139- Prefer summary or metrics endpoints before log lists.140- Use `If-None-Match` for repeated detail reads that previously returned an `ETag`.141- Use `If-Match` for updates when the prior read returned an `ETag`.142- For inbound attachments, fetch metadata and use the short-lived `download_url`; if it expires, re-fetch metadata instead of building URLs manually.143- For outbound attachments, a file path or presigned URL is usually under 100 tokens, while base64 can burn thousands of tokens and corrupt large files.144145CLI conditional examples:146147```bash148sendmux management:get-email-log \149 --path public_id=dlog_abc \150 --if-none-match "$ETAG" \151 --json152153sendmux management:update-mailbox \154 --path public_id=mbx_abc \155 --if-match "$ETAG" \156 --body '{"display_name":"Agent Inbox"}' \157 --json158```159160SDK helpers:161162```163import {164 conditionalHeaders,165 idempotencyHeaders,166 paginate,167 responseEtag,168} from "@sendmux/core";169170const headers = conditionalHeaders({ ifNoneMatch: priorEtag });171const writeHeaders = {172 ...conditionalHeaders({ etag: priorEtag }),173 ...idempotencyHeaders(operationKey),174};175```176177## Retry safely178179Use `Idempotency-Key` on supported mutations so retrying does not create duplicate work.180181Good candidates:182183- `sending:send` and `sending:send:batch`.184- `mailbox:send-message`.185- Management creates, mailbox key creation, suspend/resume, provider mutations, webhook create/rotate/test.186187When retrying application code, prefer SDK retry helpers only for safe reads or idempotent writes. Non-idempotent writes should fail rather than risk duplicate side effects.188189## Routing190191- Setup, key scopes, first call: `sendmux-getting-started`.192- Email send bodies and SMTP-vs-HTTP choice: `sendmux-send-email`.193- Attachment upload/download mechanics: `sendmux-attachments`.194- Mailbox read/search/sync/triage/reply details: `sendmux-mailbox-agent`.195- Management domains, mailboxes, webhooks, billing, logs: `sendmux-management`.196- CLI syntax and profiles: `sendmux-cli`.197- MCP installation and client config: `sendmux-mcp-setup`.