How to create and manage agents
Agents are living entities that connect your tools, follow your rules, and work on your behalf. Accumulate connections, credentials, memory, and rules — then apply them all at once. Use them when onboarding a new workspace or configuring Cadreen for a new use case.
When to use sessions vs. stateless setup
Cadreen has two ways to set up resources. The stateless /setup endpoint applies each resource immediately. Setup sessions let you stage changes, look them over, and apply them in one call.
Use stateless setup when
You're adding a single resource — one connection, one credential, one memory item. Quick and direct.
Use sessions when
You're setting up a whole use case — multiple connections, credentials, rules, and memory items that you want to look over before anything is created.
Create a session
Start by creating a session with an optional purpose. The session starts in draft status — you can add resources to it without anything taking effect yet.
# Create a session
curl -X POST \
-H "Authorization: Bearer sk_cadreen_..." \
-H "Content-Type: application/json" \
-d '{"purpose": "Set up ecommerce support"}' \
https://api.cadreen.com/api/v1/cadreen/setup/sessions{
"id": "sess_abc123",
"status": "draft",
"purpose": "Set up ecommerce support",
"connections": [],
"credentials": [],
"memory": [],
"policies": [],
"applied_count": 0,
"failed_count": 0,
"created_at": "2026-06-25T10:00:00Z"
}Add resources to the session
Add connections, credentials, memory items, and rules to the session. You can call this endpoint multiple times — resources accumulate.
# Add a connection and a memory item
curl -X POST \
-H "Authorization: Bearer sk_cadreen_..." \
-H "Content-Type: application/json" \
-d '{
"connections": [{"capability": "acme"}],
"memory": [
{
"type": "reference",
"content": {"text": "Refunds over $500 require manager approval"},
"domain": "finance"
}
],
"policies": [
{
"name": "refund-limit",
"rule": "amount > 500 requires approval",
"severity": "high",
"applies_to": "tools"
}
]
}' \
https://api.cadreen.com/api/v1/cadreen/setup/sessions/sess_abc123{
"id": "sess_abc123",
"status": "draft",
"connections": [{"capability": "acme"}],
"memory": [{"type": "reference", "content": {"text": "Refunds over $500 require manager approval"}}],
"policies": [{"name": "refund-limit", "rule": "amount > 500 requires approval", "applies_to": "tools"}]
}Review before applying
Fetch the session to see everything you've staged. Check the resource lists, verify the purpose, and make sure nothing unexpected snuck in.
curl -H "Authorization: Bearer sk_cadreen_..." \
https://api.cadreen.com/api/v1/cadreen/setup/sessions/sess_abc123The response includes connections, credentials, memory, and policies arrays showing exactly what will be applied. The session stays in draft until you explicitly apply. Policies in an applied session are saved as drafts, each with a reading of what it would do: a person turns each one on.
Apply the session
When you're ready, apply the session. The confirm: true flag is required — it's a safety mechanism to prevent accidental application.
curl -X POST \
-H "Authorization: Bearer sk_cadreen_..." \
-H "Content-Type: application/json" \
-d '{"confirm": true}' \
https://api.cadreen.com/api/v1/cadreen/setup/sessions/sess_abc123/apply{
"session_id": "sess_abc123",
"status": "applied",
"applied": 3,
"failed": 0
}applied and failed counts. Successfully applied resources stay — only the failures need retry.Session lifecycle
Sessions move through four statuses. Once applied or failed, a session is read-only — you can't add more resources to it.
Error handling
Sessions can fail partially. When you apply, some resources might succeed while others fail. The response tells you exactly what happened.
400 — missing_fields
The body must say confirm: true to apply. This prevents accidental application.
409 — invalid_request
The session is already applied or failed. Only draft sessions can be applied.
Partial failure
If failed > 0, inspect the session to see which resources failed. Successfully applied resources remain — only failures need retry.
{
"session_id": "sess_abc123",
"status": "applied",
"applied": 2,
"failed": 1
}failed in the apply response. If it's greater than zero, fetch the session to see which resources didn't apply and why.