# Accounts

> Solarium docs. All requests are `POST https://api.trysolarium.com/graphql/` with `Authorization: Bearer <api key>` and a JSON body `{"query": ..., "variables": ...}`. Every query and mutation takes an `organizationId` (find it with `myOrganizations`). Index of all pages: https://trysolarium.com/llms.txt

## List Accounts

Returns a paginated list of accounts in the chart of accounts. Supports search by name and sorting.

### Arguments

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `organizationId` | `UUID!` | Yes | Organization ID |
| `limit` | `Int` | No | Page size (default 25, max 200) |
| `offset` | `Int` | No | Number of records to skip |
| `search` | `String` | No | Filter by name (case-insensitive) |
| `sortBy` | `String` | No | Field to sort by (e.g. name, currentBalance) |
| `sortDir` | `String` | No | asc or desc (default asc) |

### Request

```graphql
query {
  listAccounts(
    organizationId: "a1b2c3d4-..."
    limit: 10
    search: "expense"
  ) {
    items {
      id
      name
      accountType
      classification
      subType
      currentBalance
      active
    }
    totalCount
    pageSize
    offset
  }
}
```

### Response

```json
{
  "data": {
    "listAccounts": {
      "items": [
        {
          "id": "f7e6d5c4-...",
          "name": "Office Supplies",
          "accountType": "expense",
          "classification": "expense",
          "subType": "",
          "currentBalance": 1250.00,
          "active": true
        }
      ],
      "totalCount": 24,
      "pageSize": 10,
      "offset": 0
    }
  }
}
```

## Create an Account

Creates a new account in the chart of accounts.

### Arguments

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `organizationId` | `UUID!` | Yes | Organization ID |
| `name` | `String!` | Yes | Account name |
| `taxCodeId` | `UUID!` | Yes | CRA Tax Code code ID. Determines account type and classification. Use listTaxCodes to get available codes. |
| `lastFour` | `String` | No | Last 4 digits of card/account for payment matching |
| `parentId` | `UUID` | No | Parent account ID for hierarchical accounts |

### Request

```graphql
mutation {
  createAccount(
    organizationId: "a1b2c3d4-..."
    name: "Office Supplies"
    taxCodeId: "tax-code-uuid-for-8711"
  ) {
    account {
      id
      name
      accountType
      classification
      taxCode { code name }
    }
    success
    error
  }
}
```

### Response

```json
{
  "data": {
    "createAccount": {
      "account": {
        "id": "f7e6d5c4-...",
        "name": "Office Supplies",
        "accountType": "expense",
        "classification": "expense",
        "taxCode": {
          "code": "8711",
          "name": "Office stationery and supplies"
        }
      },
      "success": true,
      "error": null
    }
  }
}
```

## Add a Card Number

Remembers another last-4 for a card (e.g. its Apple Pay number or a reissued card), so receipts showing any of the card's numbers land on it. Any waiting receipts that show this number are filed to the card. A number can belong to only one account.

### Arguments

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `accountId` | `UUID!` | Yes | The card or bank account |
| `lastFour` | `String!` | Yes | Exactly 4 digits |

### Request

```graphql
mutation {
  addCardNumber(accountId: "c3d4e5f6-...", lastFour: "6659") {
    success
    error
    receiptsResolved
    account {
      name
      cardNumbers { lastFour source }
    }
  }
}
```

### Response

```json
{
  "data": {
    "addCardNumber": {
      "success": true,
      "error": null,
      "receiptsResolved": 1,
      "account": {
        "name": "Personal CC",
        "cardNumbers": [
          { "lastFour": "6859", "source": "account" },
          { "lastFour": "6659", "source": "manual" }
        ]
      }
    }
  }
}
```

## Remove a Card Number

Forgets a manually added card number. Numbers that come from a connected bank (Plaid) are managed by the bank connection and can't be removed here.

### Arguments

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `accountId` | `UUID!` | Yes | The card or bank account |
| `lastFour` | `String!` | Yes | The manually added number to remove |

### Request

```graphql
mutation {
  removeCardNumber(accountId: "c3d4e5f6-...", lastFour: "6659") {
    success
    error
  }
}
```

### Response

```json
{
  "data": {
    "removeCardNumber": { "success": true, "error": null }
  }
}
```
