# Alfred API

## Alfred API

Alfred is a FATCA and CRS reporting platform API.

This reference is based on the current OpenAPI spec.

### Common response patterns

#### Validation errors

Most invalid requests return `422 Unprocessable Entity`.

```json
{
  "detail": [
    {
      "loc": ["body", "email"],
      "msg": "Field required",
      "type": "missing"
    }
  ]
}
```

#### Pagination

Paginated routes return:

```json
{
  "items": [],
  "total": 0,
  "page": 1,
  "page_size": 50
}
```

### Core workflow

{% stepper %}
{% step %}

### Create or access an organisation

Register with `POST /auth/register`, or sign in with `POST /auth/login`.
{% endstep %}

{% step %}

### Create a financial institution

Add the reporting entity with `POST /financial-institutions`.
{% endstep %}

{% step %}

### Create a report

Create a `FATCA`, `CRS`, or `CARF` report with `POST /reports`.
{% endstep %}

{% step %}

### Import account data

Preview the CSV, map columns, then import the data into the report.
{% endstep %}

{% step %}

### Validate and generate XML

Run `/validate`, then call `/generate` when the report is ready.
{% endstep %}
{% endstepper %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.stonemark.tech/alfred-api.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
