Docs · API

Agent Studio API reference

Updated September 25, 2026 · by , founder of Agent Studio

One endpoint per agent. Send POST /v1/agents/{slug}/invoke with Authorization: Bearer <api key> and a JSON body containing either input or messages. You get back the answer, whether it was blocked, the deployed version, and a stage-by-stage trace.

Request

FieldTypeNotes
inputstringA single user message. Use this or messages, not both.
messagesarrayConversation as { role: "user" | "assistant", content: string }. The last item must be a user message.
curl -X POST https://create-your-agent.nishy.space/v1/agents/support-copilot/invoke \
  -H "Authorization: Bearer ak_…" \
  -H "Content-Type: application/json" \
  -d '{"messages": [
        {"role": "user", "content": "Hi, I ordered last week."},
        {"role": "assistant", "content": "Happy to help. What is the order number?"},
        {"role": "user", "content": "A1234"}
      ]}'

Response

{
  "agent": "support-copilot",
  "version": 3,
  "output": "Order A1234 shipped yesterday via UPS and arrives in 2 days.",
  "blocked": false,
  "blockedBy": null,
  "latencyMs": 1840,
  "trace": [
    { "stage": "shield", "name": "Injection shield", "status": "pass", "score": 0, "signals": [], "promptGuard": 0, "classifier": "safe", "ms": 412 },
    { "stage": "guardrail", "name": "Stay on topic", "phase": "input", "status": "pass", "reason": "Order status is on topic.", "ms": 380 },
    { "stage": "delegate", "tool": "delegate_to_order_tracker", "subagent": "Order Tracker", "task": "Look up order A1234", "result": "…", "ms": 630 },
    { "stage": "orchestrator", "steps": 2, "ms": 1100, "inputTokens": 938, "outputTokens": 71 }
  ]
}

When a stage blocks the request, blocked is true, blockedBy names it (for example shield:Injection shield or guardrail:Stay on topic), and output contains the blocked message you configured.

JavaScript and Python

// JavaScript (fetch)
const res = await fetch("https://create-your-agent.nishy.space/v1/agents/support-copilot/invoke", {
  method: "POST",
  headers: { Authorization: "Bearer " + process.env.AGENT_KEY, "Content-Type": "application/json" },
  body: JSON.stringify({ input: "Where is my order #A1234?" }),
});
const { output, blocked, trace } = await res.json();
# Python (requests)
import os, requests
r = requests.post(
    "https://create-your-agent.nishy.space/v1/agents/support-copilot/invoke",
    headers={"Authorization": f"Bearer {os.environ['AGENT_KEY']}"},
    json={"input": "Where is my order #A1234?"},
)
print(r.json()["output"])

Status and errors

CodeMeaning
200Run completed. Check blocked to see whether a guardrail or the shield intervened.
400Body was neither { input } nor { messages }, or the last message was not from the user.
401Missing or invalid API key.
402The agent's owner has no active plan; the agent is paused.
404No agent with that slug.
409The agent exists but has never been deployed.
500The run failed; the error field explains why.

A GET to the same URL returns the agent name, whether it is deployed, and the current version, without needing a key.

Versions and keys

  • Each Deploy creates an immutable version. The endpoint always serves the latest deployed version.
  • Rotating the API key takes effect immediately for all versions.
  • Runs are logged with input, output, trace, and latency and can be reviewed in the Runs tab.
  • Limits per plan are listed on the pricing page.

Frequently asked questions

Where do I find my agent's API key?+

In the builder, press Deploy. The dialog shows the endpoint, the API key, and a curl example. You can rotate the key from the same dialog; the old key stops working immediately.

Can I send a whole conversation?+

Yes. Instead of { "input" } send { "messages": [...] } with alternating user and assistant turns. The last message must be from the user.

Does the endpoint stream?+

Not yet. The endpoint returns one JSON document when the run completes, including the full trace. Streaming is on the roadmap.

What is in the trace?+

One entry per stage: shield (score, signals, classifier verdict), each guardrail (pass, block, or rewrite with a reason), each delegation (sub-agent, task, result, latency), and the orchestrator (steps and token usage).

Why did I get 402?+

The agent's owner has no active plan, for example a free trial that ended. Choosing a plan on the billing page resumes the agent immediately.