Documentation Index
Fetch the complete documentation index at: https://mintfax.com/docs/llms.txt
Use this file to discover all available pages before exploring further.
Outcome
You will wire mintfax into an LLM tool-use loop that sends faxes, handles errors deterministically, and retries safely with idempotency keys. You will also learn how mintfax’s agent-discoverable artifacts (OpenAPI spec,llms.txt, structured errors) plug into your agent’s tool definitions.
Prerequisites
- A mintfax sandbox API key (
fx_test_...). See Sandbox if you need one. - Node.js 18+ or Python 3.10+.
- Familiarity with your LLM provider’s function-calling or tool-use API (Claude tool use, OpenAI function calling, or similar).
Step 1: Define the fax-sending tool
Your agent needs a tool definition that maps toPOST /v1/fax. The mintfax OpenAPI spec at https://api.mintfax.com/v1/openapi.yaml (also at https://mintfax.com/.well-known/openapi.yaml) has the full request shape. Here is a minimal version:
idempotency_key a required parameter in your tool definition. Agents retry on transient failures, and without an idempotency key each retry creates a new fax. With one, mintfax returns the cached response for 24 hours. See Idempotency for the full behavior.
Step 2: Implement the tool handler
When the LLM invokes the tool, your handler calls the mintfax API and returns a structured result. Pass the full error shape back so the LLM can decide what to do next.action and docs alongside the error code gives the LLM enough context to act without guessing. See Errors for the complete catalog and the meaning of each action value.
Step 3: Handle errors in the agent loop
Every mintfax error response carries machine-readable fields that agents can branch on:| Field | Purpose | Example |
|---|---|---|
error | Stable error code for branching logic | insufficient_balance |
message | Human-readable explanation | "Balance too low to send fax" |
action | Deterministic next step | top_up_balance |
docs | Link to the relevant docs page | /errors/insufficient-balance |
error code and action field, not the message string. Message text can change between API versions; error codes and actions are stable. An agent that reads action: top_up_balance can surface a clear next step. An agent that parses prose will eventually break.
For retryable errors (HTTP 503 fax_busy, HTTP 429 rate limits), reuse the same idempotency key and respect the Retry-After header. Cap retries at five attempts with exponential backoff.
Step 4: Track fax status with events
After submitting a fax, your agent can either pollGET /v1/fax/{id} or receive webhook events. Polling is simpler for agent loops because it avoids spinning up an HTTP server inside the agent process.
Step 5: Use agent-discoverable artifacts
mintfax publishes three kinds of artifacts that LLM agents and developer tools can consume without human intervention: OpenAPI spec. The spec lives athttps://api.mintfax.com/v1/openapi.yaml and https://mintfax.com/.well-known/openapi.yaml. It is OpenAPI 3.1 with x-codeSamples on every endpoint and full error response schemas. Most agent frameworks include an OpenAPI-to-tool converter; feed the spec to it and skip writing tool definitions by hand.
llms.txt. Mintlify auto-generates llms.txt and llms-full.txt at the docs root (mintfax.com/docs/llms.txt and mintfax.com/docs/llms-full.txt). These follow the emerging llms.txt convention for service descriptions that LLMs can discover. Mintlify also sets Link and X-Llms-Txt HTTP headers on every docs page.
Structured errors. Every error response includes error, message, action, and docs fields. Your agent branches on the code, follows the action hint, and links the user to the relevant docs page if needed.
Prompt design tips
A few things worth putting in your agent’s system prompt:- Require the agent to generate a UUID idempotency key before every
send_faxcall. Reuse the same key on retry. - Instruct it to read
errorandactionfrom failed responses, notmessage. - Include the sandbox success number
+15005550001so the agent can test without touching real fax infrastructure. See Sandbox for the full magic number matrix. - Use a sandbox API key (
fx_test_...) during development. Sandbox keys cannot route to real destinations.
A note on MCP
MCP is one way to expose tools to LLM agents. A mintfax MCP server would wrap the API endpoints as MCP tools with the same send, poll, and error-handling flow described above. MCP server implementation is planned for a future release. The patterns in this guide apply whether you connect through MCP or through direct function calling.Verify
Send a test fax to the sandbox success number to confirm everything works:- Set your agent’s API key to a sandbox key (
fx_test_...). - Have the agent call
send_faxwithtoset to+15005550001. - Confirm the response contains a
fax_idandstatus: "queued". - Poll or wait for the fax to reach
deliveredstatus.
What to do next
- Idempotency for retry behavior, key expiration, and best practices in automated loops.
- Errors for the full error catalog with stable codes and action hints.
- Webhook signing to verify webhook payloads if your agent receives delivery events.
- Events for the complete list of event types and payload schemas.
- Sandbox for magic fax numbers and simulated failure scenarios.