# Account API

> Who you are, your organisation's spend and cap, and repository settings. Every tool's arguments, answer, route and scope.

Source: https://bareci.com/docs/api/account

Who you are, your organisation's spend and cap, and repository settings.

Each tool below is an MCP tool on `https://api.bareci.com/mcp` and, unless it is marked local, a route of the `https://api.bareci.com/v1` JSON API. The `bareci` CLI calls the same routes.

| Tool | What it does |
| --- | --- |
| [`whoami`](#whoami) | Who this token acts as: its kind, scopes and the organisations it may act for. |
| [`account_get`](#account_get) | An organisation's plan, spend this month, hard cap and whether it may launch work now (admission). |
| [`account_usage`](#account_usage) | Usage for a month, by kind (machine time, preview hours, Flows tokens), with what is billable. |
| [`repo_settings`](#repo_settings) | A repository's BareCI settings: image, pools (labels) and variables. |

## `whoami`

**Who am I.** Who this token acts as: its kind, scopes and the organisations it may act for. Call it first to learn which repositories you can touch.

- HTTP: `GET /v1/me`
- Scope: any token
- Reads only

No arguments.

### Answer

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `name` | string | no | Caller |
| `kind` | string | no | operator, token or user |
| `scopes` | string[] | no | Scopes held |
| `accounts` | any[] or null | no |  |

Every answer also carries `next`: the next action, usually a tool and its arguments.

### Example

```json
{
  "method": "tools/call",
  "params": {
    "name": "whoami",
    "arguments": {}
  }
}
```

**Next:** account_get for spend and cap, or ready for a pull request.

## `account_get`

**Organisation.** An organisation's plan, spend this month, hard cap and whether it may launch work now (admission). Use it when a run or job is refused for budget.

- HTTP: `GET /v1/accounts/{account}`
- Scope: `read`
- Reads only

### Arguments

| Argument | Type | Required | Description |
| --- | --- | --- | --- |
| `account` | string | yes | Organisation: its GitHub login or account id |

### Answer

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `login` | string | no | GitHub login |
| `plan` | string | no | free, paid or internal |
| `usedUsd` | number or `Infinity`, `-Infinity`, `NaN` | no |  |
| `capUsd` | number or `Infinity`, `-Infinity`, `NaN` | no |  |
| `admission` | object | no | {ok, reason?, hint?} |

Every answer also carries `next`: the next action, usually a tool and its arguments.

### Example

```json
{
  "method": "tools/call",
  "params": {
    "name": "account_get",
    "arguments": {
      "account": "<account>"
    }
  }
}
```

**Next:** account_usage for the breakdown when spend is high.

## `account_usage`

**Usage.** Usage for a month, by kind (machine time, preview hours, Flows tokens), with what is billable.

- HTTP: `GET /v1/accounts/{account}/usage`
- Scope: `read`
- Reads only

### Arguments

| Argument | Type | Required | Description |
| --- | --- | --- | --- |
| `account` | string | yes | Organisation: its GitHub login or account id |
| `month` | string | no | YYYY-MM; this month by default |
| `limit` | integer | no | Events to list (min 0, max 1000) |

### Answer

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `month` | string | no | YYYY-MM |
| `totalUsd` | number or `Infinity`, `-Infinity`, `NaN` | no |  |
| `byKind` | any[] | no | [{kind, unit, quantity, usd, billable, billableUsd}] |
| `events` | any[] | no | Usage events |

Every answer also carries `next`: the next action, usually a tool and its arguments.

### Example

```json
{
  "method": "tools/call",
  "params": {
    "name": "account_usage",
    "arguments": {
      "account": "<account>"
    }
  }
}
```

**Next:** account_get for the cap.

## `repo_settings`

**Repository settings.** A repository's BareCI settings: image, pools (labels) and variables. Use it to learn which run labels a repository has.

- HTTP: `GET /v1/repos/{owner}/{name}/settings`
- Scope: `read`
- Reads only

### Arguments

| Argument | Type | Required | Description |
| --- | --- | --- | --- |
| `repo` | string | yes | Repository as owner/name, e.g. acme/web |

### Answer

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `image` | string | no | Image |
| `pools` | object | no | Label -> pool settings |

Every answer also carries `next`: the next action, usually a tool and its arguments.

### Example

```json
{
  "method": "tools/call",
  "params": {
    "name": "repo_settings",
    "arguments": {
      "repo": "acme/web"
    }
  }
}
```

**Next:** run_create with one of its labels.
