Using this API from an AI agent

This API was built with agentic tools in mind. Claude Code, Codex, and similar tools work well against it because the responses are small, typed, and self-describing.

The fastest setup

Give your agent the key as an environment variable:

export LEADMAGNET_API_KEY="lmb_live_..."

Then point it at the spec:

Read https://resources.ashwanth.dev/api/v1/openapi.json for the contract.
Authenticate with Authorization: Bearer $LEADMAGNET_API_KEY.

The spec is public and unauthenticated, so the agent can read the contract before it ever holds a credential.

Prompts that work

A weekly review:

Pull /api/v1/dashboard?range=7d and /api/v1/unibox.
Tell me what moved this week and what did not, and name the one
thing worth fixing first.

Finding the leads worth a call:

Get /api/v1/subscribers?temperature=hot&order=score.
For each, tell me which magnet brought them in and what they
engaged with.

Campaign triage:

List /api/v1/campaigns?status=active. For each, fetch
/api/v1/campaigns/{id}/metrics and flag any whose bounce_rate is
above 3 or whose reply_rate is below 2.

Give the agent a read-only key

Create a key with only the :read scopes for anything running unattended. Version 1 has no destructive endpoints at all, but a narrow key stays narrow as the API grows, which is the entire reason scopes exist.

Practical notes

total_matching on the subscribers endpoint is the size of the whole filtered set, so an agent can decide whether paging is worth it without fetching everything first.

Filter on the server. ?temperature=hot&min_score=60 is one small response. Pulling every subscriber and filtering inside the agent is slower and wastes context.

Error codes are stable, so an agent can branch on insufficient_scope and tell you exactly which scope to add rather than guessing at the problem.