Skip to content

API Reference

Base URL: https://api.astromesh.io/api/v1

Authentication: Authorization: Bearer <jwt> or X-API-Key: ask-<key> on all endpoints except auth routes.

Content-Type: application/json


Working

Create or retrieve a dev user and return a JWT. For development and testing only.

Terminal window
curl -X POST https://api.astromesh.io/api/v1/auth/dev/login \
-H "Content-Type: application/json" \
-d '{"email": "you@example.com", "name": "Your Name"}'

Response:

{
"access_token": "<jwt>",
"token_type": "bearer",
"expires_in": 86400,
"org_slug": "you-example-com"
}

Stub (501)

Exchange a Google ID token for an Astromesh JWT. Full OIDC flow coming in a future release.


Stub (501)

Exchange a GitHub OAuth code for an Astromesh JWT. Full OAuth flow coming in a future release.


Refresh an expired JWT using a refresh token.

Body: { "refresh_token": "..." }

Response: New access token.


Invalidate the current session token.

Response: 204 No Content


Return the org associated with the authenticated user.

Terminal window
curl https://api.astromesh.io/api/v1/orgs/me \
-H "Authorization: Bearer $TOKEN"

Response:

{
"slug": "my-org",
"display_name": "My Organization",
"plan": "free",
"limits": {
"max_agents": 5,
"requests_per_day": 1000,
"max_members": 3
}
}

Update org display name.

Body: { "display_name": "New Name" }


List org members with roles.


POST /orgs/{slug}/members/invite

Section titled “POST /orgs//members/invite”

Invite a user by email. Errors if the org is at the 3-member limit.

Body: { "email": "new@example.com", "role": "member" }


List all agents in the org.

Terminal window
curl https://api.astromesh.io/api/v1/orgs/my-org/agents \
-H "Authorization: Bearer $TOKEN"

Response:

{
"agents": [
{
"name": "support-bot",
"display_name": "Support Bot",
"status": "deployed",
"model": "openai/gpt-4o-mini",
"created_at": "2026-01-15T10:00:00Z"
}
]
}

Create an agent in draft state using a WizardConfig.

Terminal window
curl -X POST https://api.astromesh.io/api/v1/orgs/my-org/agents \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{
"name": "support-bot",
"display_name": "Support Bot",
"step1": {"model": "openai/gpt-4o-mini", "fallback_model": "ollama/llama3"},
"step2": {
"system_prompt": "You are a helpful support agent. Be concise.",
"persona": "Support Agent"
},
"step3": {"tools": ["web_search", "calculator"]},
"step4": {
"memory_type": "conversational",
"memory_strategy": "sliding_window",
"window_size": 20
},
"step5": {
"input_guardrails": ["pii_filter"],
"output_guardrails": ["content_safety"],
"max_tokens": 1000
}
}'

WizardConfig fields:

FieldDescription
step1.modelPrimary LLM — e.g. openai/gpt-4o-mini, anthropic/claude-3-haiku, ollama/llama3
step1.fallback_modelFallback if primary fails
step2.system_promptJinja2 system prompt (supports {{ session_id }}, {{ context }})
step2.personaShort label for Studio display
step3.toolsTool names from the platform catalog
step4.memory_typeconversational, semantic, or episodic
step4.memory_strategysliding_window, summary, or token_budget
step5.input_guardrailsList of input filter names
step5.output_guardrailsList of output filter names
step5.max_tokensMax tokens per response

GET /orgs/{slug}/agents/{name}

Section titled “GET /orgs//agents/”

Get a single agent’s full config and current status.


PUT /orgs/{slug}/agents/{name}

Section titled “PUT /orgs//agents/”

Update wizard config. Only allowed in draft or paused state.


DELETE /orgs/{slug}/agents/{name}

Section titled “DELETE /orgs//agents/”

Delete an agent. Pauses it first if deployed.

Response: 204 No Content


POST /orgs/{slug}/agents/{name}/deploy

Section titled “POST /orgs//agents//deploy”

Compile the wizard config to Astromesh runtime YAML and register the agent.

Transitions: draft → deployed or paused → deployed

Terminal window
curl -X POST https://api.astromesh.io/api/v1/orgs/my-org/agents/support-bot/deploy \
-H "Authorization: Bearer $TOKEN"

Response:

{
"status": "deployed",
"agent_id": "my-org__support-bot",
"deployed_at": "2026-03-17T12:00:00Z"
}

POST /orgs/{slug}/agents/{name}/pause

Section titled “POST /orgs//agents//pause”

Deregister the agent from the runtime. Transition: deployed → paused

Response: { "status": "paused" }


POST /orgs/{slug}/agents/{name}/test

Section titled “POST /orgs//agents//test”

Run a test query without incrementing usage counters. Agent must be deployed.

Body: { "query": "...", "session_id": "test-1" }


POST /orgs/{slug}/agents/{name}/run

Section titled “POST /orgs//agents//run”

Execute the agent. Accepts both JWT and API key auth.

Terminal window
curl -X POST https://api.astromesh.io/api/v1/orgs/my-org/agents/support-bot/run \
-H "X-API-Key: ask-your-key" \
-H "Content-Type: application/json" \
-d '{
"query": "What is the refund policy?",
"session_id": "user-session-abc",
"context": {"user_id": "usr_456", "channel": "web"}
}'

Body fields:

FieldRequiredDescription
queryYesUser message
session_idNoReuse to maintain conversational memory
contextNoKey-value metadata passed to the agent

Response:

{
"answer": "Our refund policy allows returns within 30 days...",
"session_id": "user-session-abc",
"tokens_used": 312,
"model": "openai/gpt-4o-mini",
"latency_ms": 1240,
"trace_id": "trc_789xyz"
}

WS /orgs/{slug}/agents/{name}/stream

Section titled “WS /orgs//agents//stream”

WebSocket endpoint for streaming responses token by token.

URL: wss://api.astromesh.io/api/v1/orgs/{'{slug}'}/agents/{'{name}'}/stream?token=<jwt>

Send:

{ "query": "Explain our pricing", "session_id": "sess-001" }

Receive:

{ "type": "token", "content": "Our" }
{ "type": "token", "content": " pricing" }
{ "type": "done", "answer": "Our pricing starts at...", "tokens_used": 89 }

List API keys (secrets masked).


Create a new API key. The full secret is returned once — store it securely.

Terminal window
curl -X POST https://api.astromesh.io/api/v1/orgs/my-org/keys \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{"name": "Production"}'

Response:

{
"id": "key_abc123",
"name": "Production",
"secret": "ask-prod-xxxxxxxxxxxxxxxxxxxxxxxx",
"created_at": "2026-03-17T12:00:00Z"
}

DELETE /orgs/{slug}/keys/{key_id}

Section titled “DELETE /orgs//keys/”

Revoke an API key. Takes effect immediately.

Response: 204 No Content


List configured provider keys (secrets masked).


Add or update a provider API key.

Terminal window
curl -X POST https://api.astromesh.io/api/v1/orgs/my-org/providers \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{"provider": "openai", "api_key": "sk-your-key"}'

Supported providers: openai, anthropic, groq, mistral, cohere, ollama


DELETE /orgs/{slug}/providers/{provider}

Section titled “DELETE /orgs//providers/”

Remove a provider key.

Response: 204 No Content


Get request and token usage statistics.

Query params: ?days=30 (default: 30, max: 90)

Terminal window
curl "https://api.astromesh.io/api/v1/orgs/my-org/usage?days=7" \
-H "Authorization: Bearer $TOKEN"

Response:

{
"period_days": 7,
"total_requests": 423,
"total_tokens": 189540,
"daily_limit": 1000,
"remaining_today": 577,
"by_agent": [
{ "agent": "support-bot", "requests": 310, "tokens": 142000 }
]
}

Rate limit headers are included on execution endpoints:

X-RateLimit-Limit: 1000
X-RateLimit-Remaining: 577
X-RateLimit-Reset: 1742256000
ResourceLimit
Agents per org5
Requests per day1,000
Members per org3

{
"error": "agent_not_deployed",
"message": "Agent 'support-bot' is in draft state. Deploy it first.",
"status": 400
}
StatusMeaning
401Missing or invalid token/key
403Valid auth but wrong org
404Resource not found
409Agent already in target state
429Daily limit reached
501Feature is a stub (Google/GitHub OAuth in v0.1.0)