Skip to content
API documentation
View as MarkdownOpen in Claude

Guides

Wallet

The wallet is not self-service

You can't open a wallet through the API, and there is no sign-up for one. Main Team opens a wallet only after an agreement with you, and only when you ask for it. To ask, contact your Main Team contact or write to info@main-team.org. Main Team then opens your wallet and tells you how many credits you have for each olympiad (STEM, Neo and so on). One credit pays one application that has a price. To add credits later, ask the same way.

A credit is a convenience, not prepayment. The amount for the application is still due to Main Team and is settled afterwards by bank transfer.

Paying by bank transfer stays the default way to settle your students' applications (Settling payments). The wallet is an alternative for partners who have one. If you don't, nothing about your integration changes.

If you don't have a wallet

Every wallet operation answers 403 forbidden with error.details.reason set to wallet_not_enabled, and nothing is written:

{
  "success": false,
  "error": {
    "code": "forbidden",
    "message": "No wallet is enabled for your account. Ask your Main Team contact to open one.",
    "details": { "reason": "wallet_not_enabled" }
  }
}

The same answer comes when a wallet exists but was closed (the reads still work then, see below). Don't retry it: ask Main Team. Requests that don't use the wallet are not affected.

How the wallet works

Your wallet holds the credits Main Team gave you, counted separately for each olympiad. An application paid with a credit is marked paid at once, with a reference.

What a credit pays

  • One credit is one paid application. It doesn't matter what the exam costs: a 25 euro exam and a 60 euro exam each take one credit. The amount the payment is settled at is recorded in cents, with the olympiad's currency (USD for Neo, EUR for the others).
  • A free exam never takes a credit. Its payment is already paid with amount 0, and every wallet operation tells you so with charged: false and reason: "free".
  • Credits are counted per olympiad. A STEM credit pays a STEM application only.
  • On coding, the amount follows the bundle price. Once a student has paid a CodeCombat or Codementum exam this season, another exam of the same category costs 15, and one of the other category 30 (15 once one of that category is paid too), never more than the exam's own price. The credit is still one. With several coding exams for one student in the same call, they are priced in the order you send them: each one sees the earlier ones as paid.

Read your wallet

getWallet (GET /v1/wallet, permission wallet/read) returns, for each olympiad, granted, spent, remaining, spentAmount (cents) and currency, and credit totals. Olympiads you have no credits in are listed with zeros.

curl -s https://api.main-team.org/v1/wallet -H "Authorization: Bearer $TOKEN"
{
  "success": true,
  "message": "Wallet fetched successfully.",
  "data": {
    "enabled": true,
    "enabledAt": "2026-11-01T09:00:00.000Z",
    "organizations": [
      {
        "organization": "stem",
        "organizationId": "64b7f0c2a1d3e4f5a6b7c8d9",
        "currency": "EUR",
        "granted": 50,
        "spent": 9,
        "remaining": 41,
        "spentAmount": 45000
      }
    ],
    "totals": { "granted": 50, "spent": 9, "remaining": 41 }
  }
}

A wallet that has been closed still answers, with enabled: false, so you can read its history; it pays nothing. An account that never had a wallet answers 403 wallet_not_enabled (see above).

Read your credit history

listWalletEntries (GET /v1/wallet/entries) lists every credit added and spent, newest first, a page at a time. Entries are never changed or removed; a correction appears as a new entry.

typeMeaningcredits
grantMain Team added creditspositive
adjustMain Team corrected the balancepositive or negative
spendOne credit paid an application-1
reversalMain Team gave a spent credit back; reverses names the spend entry it undoes1

A spend entry carries the student (studentId), applicationId, paymentId, examId, the amount in cents, currency, the payment's reference and invoiceNo, and the operation that spent it in channel. Narrow the list with organizationId, type, studentId, applicationId, from and to; they combine, and an unreadable one is 400.

Pay when you create the application

Send "walletPay": true to createApplication:

curl -s -X POST "https://api.main-team.org/v1/<organizationId>/application" \
  -H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" \
  -d '{ "studentId": "<studentId>", "examId": "<examId>", "walletPay": true }'

The application, its payment and the credit taken happen together or not at all. If there are not enough credits you get 409, and no application is left behind waiting to be paid. data.wallet says what happened:

{
  "charged": true,
  "amount": 5000,
  "currency": "EUR",
  "reference": "stx-19a2c3d4e5f6a7b8c9",
  "entryId": "6650a1b2c3d4e5f6a7b8c9f2",
  "remaining": 40
}

walletPay: true needs the application/pay permission on that organization, besides application/create, and an enabled wallet even when the exam is free (nothing is taken, but the answer is the same 403 without a wallet).

A repeat of the same call is safe. If the application already exists and its payment is still pending, walletPay: true pays it; if this wallet already paid it, the answer is charged: false with reason: "already_paid".

Pay when you register students

registerStudent and createStudentImport take exams ({ organizationId, examId } entries) and walletPay. The student, their registration on each olympiad named, the applications and the payments are saved all together or not at all, and with walletPay: true the credits are taken in it:

  • One student: a wallet that can't cover the priced exams answers 409 insufficient_credits and creates nothing, not even the student. data.applications lists each application with its payment, data.wallet what was taken.
  • An import: the check when you submit is only a first check (409 with every organization the batch needs); the credits are taken when the import runs. If they are gone by then the import ends failed with failure.code insufficient_credits and nothing is registered or paid.
  • walletPay: true needs application/create and application/pay on every organization named, and an enabled wallet even when every exam is free.
  • On coding a student's exams of one request are priced in the order you send them.
  • Each spend is an entry in your wallet history with channel registerStudent or import; the entries of one import share one reference and one invoice number per olympiad.

Pay an application that already exists

payApplicationFromWallet pays one pending payment, with no body:

curl -s -X POST "https://api.main-team.org/v1/<organizationId>/application/<applicationId>/wallet-pay" \
  -H "Authorization: Bearer $TOKEN"

payApplicationsFromWallet pays up to 100 at once, all or nothing, under one reference and one invoice number:

curl -s -X POST "https://api.main-team.org/v1/<organizationId>/application/wallet-pay" \
  -H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" \
  -d '{ "applicationIds": ["<applicationId>", "<applicationId>"] }'

Each item comes back with charged, amount, currency, reference and entryId. Free and already paid items are charged: false, so a repeat is safe. An id that is not an application of your students fails the whole call with 404 and lists the ids in error.details.applicationIds.

When it is refused

Nothing is paid or written in any of these. The reason is in error.details.reason; branch on it, not on the message.

Statusdetails.reasonWhat to do
403wallet_not_enabledYour account has no wallet, or it is closed. A wallet is opened only by Main Team, after an agreement and on your request: ask your Main Team contact or info@main-team.org.
403permission_missingwalletPay: true without application/pay on this organization. Ask for the permission.
409insufficient_creditserror.details.organizations lists each organization the call needs, with needed, available and short. Ask for more credits, or pay fewer.
409already_paidThe payment was settled another way (a bank transfer, a card), so there is nothing to take.
409payment_canceledThe payment is canceled.
409payment_in_progressThe student has a card payment open for this application (opened in the last 25 hours). Wait for it to finish or expire.
409payment_changedThe payment changed while it was being paid. Read the application and try again.
503wallet_unavailableThe wallet isn't available yet. Try again later.

What you can't do here

A wallet can't be opened through the API. You can't grant yourself credits, open or close a wallet, or take a payment back. If a payment was made by mistake, ask your Main Team contact for a reversal: the payment returns to pending and the credit to your balance. The API never refunds money, and a paid application still can't be deleted (Applications).

Search the API documentation

Guides, endpoints by name, path or permission, and error codes such as not_found.