# List your wallet history

- Endpoint: `GET /v1/wallet/entries`
- Production: `https://api.main-team.org/v1/wallet/entries`
- Sandbox: `https://apisnd.main-team.org/v1/wallet/entries`
- Operation: `listWalletEntries` (Wallet)
- Authentication: `Authorization: Bearer <token>`, a short-lived token you sign with your API key and secret
- Permission: `wallet/read:$org:$ID`

## Description

Needs a wallet, which Main Team opens only after an agreement and on your request (otherwise `403` `wallet_not_enabled`).

Your wallet history, newest first: credits Main Team added or corrected, the spend of every credit, and reversals. Entries are never changed; a correction is a new entry. Each spend entry carries the student, application, payment and exam it paid for, the amount in cents and its currency, and the `reference` the payment shows.

Narrow it with `organizationId`, `type`, `studentId`, `applicationId`, `from` and `to`; they combine, and one that cannot be read is `400`. The list is `limit` 20 a page by default and at most 100.

## Parameters

| Name | In | Required | Type | Description |
| --- | --- | --- | --- | --- |
| `organizationId` | query | no | string | Only the entries of this organization (its `_id`, from `listOrganizations`). |
| `type` | query | no | string one of `grant`, `adjust`, `spend`, `reversal` | Only entries of this type. |
| `studentId` | query | no | string | Only the entries for this student (the `_id` you registered them with). |
| `applicationId` | query | no | string | Only the entries for this application. |
| `from` | query | no | string | Only entries created at or after this moment (ISO 8601). |
| `to` | query | no | string | Only entries created at or before this moment (ISO 8601). |
| `page` | query | no | number | Page number. Defaults to 1. |
| `limit` | query | no | number | Items per page. Defaults to 20, max 100. |

## Response

`200` Success: `message` is "Wallet entries fetched successfully.".

```json
{
  "success": true,
  "message": "Wallet entries fetched successfully.",
  "pagination": {
    "page": 1,
    "limit": 20,
    "total": 57,
    "totalPages": 3
  },
  "data": [
    {
      "_id": "6650a1b2c3d4e5f6a7b8c9f2",
      "type": "spend",
      "organization": "stem",
      "organizationId": "64b7f0c2a1d3e4f5a6b7c8d9",
      "credits": -1,
      "amount": 5000,
      "currency": "EUR",
      "studentId": "6650a1b2c3d4e5f6a7b8c9d0",
      "applicationId": "6650a1b2c3d4e5f6a7b8c9e5",
      "paymentId": "6650a1b2c3d4e5f6a7b8c9e6",
      "examId": "6650a1b2c3d4e5f6a7b8c9e1",
      "reference": "stx-19a2c3d4e5f6a7b8c9",
      "invoiceNo": "2425-10042",
      "channel": "createApplication",
      "reverses": "6650a1b2c3d4e5f6a7b8c9f2",
      "createdAt": "2026-09-01T09:30:00.000Z"
    }
  ]
}
```

## Errors

| Status | Code | When |
| --- | --- | --- |
| 400 | [`bad_request`](https://hub.main-team.org/api/errors#bad_request) | A filter cannot be read: an id that is not 24 hexadecimal digits, an unknown `type`, an unreadable date, `from` after `to`, or an `organizationId` that is not an organization. |
| 401 | [`unauthorized`](https://hub.main-team.org/api/errors#unauthorized) | The token is missing or malformed, is not signed with your account’s `apiSecret`, breaks the `iat` and `exp` rules, has expired or been revoked, or its account is not active. All of these answer the same. |
| 403 | [`forbidden`](https://hub.main-team.org/api/errors#forbidden) | The token is valid, but no role on your account allows `wallet/read` on `mto` (the target of operations without `:organizationId` in their path), or a role denies it. |
| 403 | [`forbidden`](https://hub.main-team.org/api/errors#forbidden) | Your account has no wallet, or it is closed. A wallet is not self-service: Main Team opens it only after an agreement and on your request (ask your Main Team contact or info@main-team.org). `error.details.reason` is `wallet_not_enabled`. |
| 429 | [`too_many_requests`](https://hub.main-team.org/api/errors#too_many_requests) | Your account has made more than 100 requests to this operation in the current 60-second window. Wait the seconds in `Retry-After` before sending again. |
| 500 | [`internal_error`](https://hub.main-team.org/api/errors#internal_error) | Something failed on our side. Retry later, and quote `request_id` if it goes on. |

## Code samples

### curl

```bash
# $TOKEN: a short-lived token you minted with your API key and secret
curl -sS 'https://api.main-team.org/v1/wallet/entries?page=1&limit=20' \
  -H "Authorization: Bearer $TOKEN"
```

### Node.js

```js
const token = process.env.TOKEN; // a short-lived token you minted with your API key and secret

const res = await fetch('https://api.main-team.org/v1/wallet/entries?page=1&limit=20', {
  headers: {
    Authorization: `Bearer ${token}`,
  },
});
const body = await res.json();
if (!res.ok) throw new Error(`${res.status} ${body.error.code}: ${body.error.message}`);
console.log(body.data, body.pagination);
```

### PHP

```php
<?php
$token = getenv('TOKEN'); // a short-lived token you minted with your API key and secret

$ch = curl_init('https://api.main-team.org/v1/wallet/entries?page=1&limit=20');
curl_setopt_array($ch, [
    CURLOPT_HTTPHEADER => [
        'Authorization: Bearer ' . $token,
    ],
    CURLOPT_RETURNTRANSFER => true,
]);
$response = curl_exec($ch);
if ($response === false) {
    throw new RuntimeException(curl_error($ch));
}
$status = curl_getinfo($ch, CURLINFO_RESPONSE_CODE);
$body = json_decode($response, true);
if ($status >= 400) {
    $error = $body['error'];
    throw new RuntimeException("$status {$error['code']}: {$error['message']}");
}
print_r($body['data']);
print_r($body['pagination']);
```
