Getting Started
This guide walks you through making your first request to the Magisterium A2A endpoint, retrieving the resulting task, and reading the structured response.
Prerequisites
- A paid Magisterium plan (Pro, Organization, or Enterprise). Free accounts will receive a
PLAN_REQUIREDerror from A2A. - An OAuth 2.0 access token tied to your
magisterium.comaccount. A2A uses the same OAuth flow as the Magisterium MCP server; discover the authorization, token, and dynamic-registration endpoints from the OAuth metadata athttps://www.magisterium.com/.well-known/oauth-authorization-server. - The skills you want to call — see Skills for the full list.
Heads up: the long-lived API keys created in the API Console work for Chat Completions, Search, and News, but they are not valid for A2A — A2A only accepts OAuth-issued user tokens.
Export your access token as an environment variable so the examples below pick it up automatically:
export MAGISTERIUM_TOKEN=<your-access-token-here>Step 1: Discover the Agent
Before calling the endpoint, you can fetch the public Agent Card to see which skills are available and confirm the protocol version:
curl https://www.magisterium.com/.well-known/agent.jsonThe card requires no authentication. Orchestrators can cache it for an hour — the endpoint sets Cache-Control: public, max-age=3600.
Step 2: Send Your First Message
All A2A operations go through a single JSON-RPC endpoint: POST https://www.magisterium.com/api/v1/a2a. The example below calls message/send on the catholic_qa skill.
curl -X POST https://www.magisterium.com/api/v1/a2a \
-H "Authorization: Bearer $MAGISTERIUM_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "message/send",
"params": {
"message": {
"role": "user",
"messageId": "msg-001",
"kind": "message",
"parts": [{ "kind": "text", "text": "What does the Church teach about the Real Presence?" }],
"metadata": { "skillId": "catholic_qa" }
}
}
}'const accessToken = process.env.MAGISTERIUM_TOKEN!;
const response = await fetch("https://www.magisterium.com/api/v1/a2a", {
method: "POST",
headers: {
Authorization: `Bearer ${accessToken}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
jsonrpc: "2.0",
id: 1,
method: "message/send",
params: {
message: {
role: "user",
messageId: crypto.randomUUID(),
kind: "message",
parts: [
{ kind: "text", text: "What does the Church teach about the Real Presence?" },
],
metadata: { skillId: "catholic_qa" },
},
},
}),
});
const { result: task } = await response.json();
console.log(task.id, task.status.state);
for (const artifact of task.artifacts ?? []) {
for (const part of artifact.parts) {
if (part.kind === "text") console.log(part.text);
}
}import os
import uuid
import httpx
access_token = os.environ["MAGISTERIUM_TOKEN"]
payload = {
"jsonrpc": "2.0",
"id": 1,
"method": "message/send",
"params": {
"message": {
"role": "user",
"messageId": str(uuid.uuid4()),
"kind": "message",
"parts": [
{"kind": "text", "text": "What does the Church teach about the Real Presence?"}
],
"metadata": {"skillId": "catholic_qa"},
}
},
}
response = httpx.post(
"https://www.magisterium.com/api/v1/a2a",
headers={
"Authorization": f"Bearer {access_token}",
"Content-Type": "application/json",
},
json=payload,
timeout=60,
)
task = response.json()["result"]
print(task["id"], task["status"]["state"])
for artifact in task.get("artifacts", []):
for part in artifact["parts"]:
if part["kind"] == "text":
print(part["text"])Step 3: Read the Response
message/send returns a Task object with kind: "task". A synchronous skill call always ends in one of two terminal states:
status.state == "completed"— results live inresult.artifacts. Each artifact has anartifactId, an optionalname, and one or moreparts(text,data, orfile).status.state == "failed"— the failure reason is instatus.message.parts[0].text.
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"id": "task_abc123",
"contextId": "ctx_def456",
"kind": "task",
"status": { "state": "completed", "timestamp": "2026-04-20T12:00:00.000Z" },
"artifacts": [
{
"artifactId": "art_ghi789",
"name": "catholic_qa_response",
"parts": [
{ "kind": "text", "text": "The Catholic Church teaches..." },
{ "kind": "data", "data": { "citations": [] } }
]
}
]
}
}Step 4: Retrieve or Cancel a Task
Tasks are stored for 24 hours and can be refetched by ID using tasks/get:
curl -X POST https://www.magisterium.com/api/v1/a2a \
-H "Authorization: Bearer $MAGISTERIUM_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"id": 2,
"method": "tasks/get",
"params": { "id": "task_abc123" }
}'If you need to abort a task, call tasks/cancel with the same ID. Because all Magisterium skills resolve synchronously, cancelation is only useful in rare retry scenarios — a task that has already completed or failed cannot be canceled and will return INVALID_PARAMS.
Common Errors
| Code | Meaning | Fix |
|---|---|---|
-32004 | Unauthorized | Check the Authorization header and that the access token is valid and not expired. |
-32005 | Paid plan required | Upgrade your account at magisterium.com/plan. |
-32002 | Skill not found | Verify metadata.skillId matches an ID listed in the Agent Card. |
-32003 | Rate limit exceeded | Wait retryAfter seconds (present in the error data) before retrying. |
See the full API Reference for every method and error code.