# API reference

> Every endpoint of the Agent API, its authentication and its errors.

Applies to: the Sypnia engine (open source, self-hosted) and Sypnia Cloud (paid service).  
Source: https://agent.docs.sypnia.com/api/

For agents: Base https://agent.api.sypnia.com/v1. Auth: Bearer Sypnia token; scopes agent:tasks, agent:approve (person session only). Resources: tasks (create, get, list, cancel, events SSE), questions (answer), approvals (list, decide), budgets (defaults), profile, memory. Errors JSON {error:{code,message}}: 402 insufficient_credits, 403 needs_person, 409 task_finished, 422 invalid_request, 429.

**Base address:** `https://agent.api.sypnia.com/v1`. **Authentication:** `Authorization: Bearer <token>`, a Sypnia token. Scopes: `agent:tasks`; `agent:approve` only with a person's own session.

## Tasks

### Start a task`POST /v1/tasks` \[Cloud]`{ repository, request, case?, budget: { credits } }`. Returns the task and its estimate.**Authentication:** agent:tasks
### Get a task`GET /v1/tasks/{id}` \[Cloud]State, steps, questions, approvals, branch, pull request, cost.**Authentication:** agent:tasks
### Follow a task`GET /v1/tasks/{id}/events` \[Cloud]Server-sent events: `step`, `question`, `approval`, `budget`, `done`, `stopped`.**Authentication:** agent:tasks
### Cancel`POST /v1/tasks/{id}/cancel` \[Cloud]Stops the task; the branch is kept.**Authentication:** agent:tasks

## Questions and approvals

### Answer a question`POST /v1/questions/{id}/answer` \[Cloud]`{ choice }` or `{ text }`.**Authentication:** agent:tasks
### Pending approvals`GET /v1/approvals` \[Cloud]Yours, and your team's if you approve for it.**Authentication:** agent:approve
### Decide`POST /v1/approvals/{id}` \[Cloud]`{ decision: "approve" | "deny", note? }`. Requires a person's session.**Authentication:** agent:approve

## You

### Your level and preferences

`GET /v1/profile` \[Cloud]

**Authentication:** agent:tasks

### What the agent remembers`GET /v1/memory` \[Cloud]`?scope=person|project&project=…`; `DELETE /v1/memory/{id}` forgets one note.**Authentication:** agent:tasks

## Errors

| Status | Code                   | When                                                                                                                                                 |
| ------ | ---------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------- |
| 402    | `insufficient_credits` | the budget is larger than your credits, after the 7 days of grace ([When credits run out](https://agent.docs.sypnia.com/cloud#when-credits-run-out)) |
| 403    | `needs_person`         | an approval sent with a token that is not a person's session                                                                                         |
| 409    | `task_finished`        | the task already ended                                                                                                                               |
| 422    | `invalid_request`      | a missing repository, request or budget                                                                                                              |
| 429    | `rate_limited`         | too many requests                                                                                                                                    |
