Skip to content
API documentation
View as MarkdownOpen in Claude

Applications

Pay several applications from your wallet

POST
/v1/{organizationId}/application/wallet-pay

Pays the pending payments of up to 100 applications of your students in this organization from your wallet, one credit each, all or nothing, under one reference and one invoice number.

Per application. A free exam never takes a credit (charged: false, reason: free). A payment this wallet already paid, or one settled another way, comes back charged: false, reason: already_paid, so a repeat is safe. A pending payment is paid at its amount, or the coding bundle price when that is lower, the student’s applications taken in the order you send them.

All or nothing. An id that is not an application of your students (unknown and another account’s look the same) fails the whole call with 404 and the ids in error.details.applicationIds. A canceled payment, a card payment still open, or too few credits fails it too, and nothing is paid.

Needs an enabled wallet, which Main Team opens only after an agreement and on your request (otherwise 403 wallet_not_enabled), and the application/pay permission on this organization. At most 30 requests per minute.

Parameters

Path parameters

NameTypeDescription
organizationIdrequiredstringpattern ^[0-9a-f]{24}$

The organization’s _id: 24 hexadecimal digits, as listOrganizations (GET /v1/organization) lists it.

Example 64b7f0c2a1d3e4f5a6b7c8d9

Request body

application/jsonrequired

  • applicationIdsarray of stringrequired

    The applications’ _ids, 24 hexadecimal digits each, from createApplication or the application lists. No duplicates.

    min items1max items100example["6650a1b2c3d4e5f6a7b8c9e5"]

Responses

200 OK

Success: message is "Applications paid from wallet.".

Or message is "Nothing was taken from the wallet.": Every application was free or already paid.

Body

  • successbooleanrequired

    Always true on a success.

    one oftrue

  • messagestringrequired

    exampleApplications paid from wallet.

  • dataobject · PayApplicationsResponserequired

    The answer of payApplicationsFromWallet.

    5 fields of data
    • referencestring

      The one reference every payment of this call carries. Absent when nothing was charged.

      examplestx-19a2c3d4e5f6a7b8c9

    • invoiceNostring

      The one invoice number of this call. Absent when nothing was charged.

      example2425-10042

    • chargednumberrequired

      How many credits this call took.

      example3

    • itemsarray of PayApplicationsItemResponserequired

      One entry per application, in the order you sent them.

      8 fields of each item
      • applicationIdstringrequired

        The application.

        example6650a1b2c3d4e5f6a7b8c9e5

      • paymentIdstringrequired

        Its payment.

        example6650a1b2c3d4e5f6a7b8c9e6

      • chargedbooleanrequired

        true when a credit was taken by this call. false when there was nothing to take: see reason.

        exampletrue

      • reasonstring

        Why nothing was taken, only when charged is false. free: the exam costs nothing, and a free exam never uses a credit. already_paid: this wallet already paid it, in an earlier call; reference and entryId are that payment’s.

        one offreealready_paid

        examplefree

      • amountnumberrequired

        The amount the payment was settled at, in cents: the exam’s price, or the coding bundle price when it is lower. 0 for a free exam.

        example5000

      • currencystringrequired

        The currency of amount: USD for neo, EUR otherwise.

        one ofEURUSD

        exampleEUR

      • referencestring

        The transaction code of the payment (stx-...), the same reference the application reads show on a settled payment.

        examplestx-19a2c3d4e5f6a7b8c9

      • entryIdstring

        The _id of the wallet entry (listWalletEntries).

        example6650a1b2c3d4e5f6a7b8c9f2

    • walletobject · WalletBalanceViewResponserequired

      The organization’s balance after the call.

      4 fields of wallet
      • organizationstringrequired

        The organization’s slug.

        examplestem

      • grantednumberrequired

        Credits granted to you in total.

        example50

      • spentnumberrequired

        Credits spent in total.

        example9

      • remainingnumberrequired

        granted minus spent.

        example41

Headers

X-RateLimit-Limit integer

Requests your account may make to this operation per window (30 per 60 seconds).

X-RateLimit-Remaining integer

Requests left in the current window.

X-RateLimit-Reset integer

Seconds until the current window ends.

Example

{
  "data": {
    "charged": 3,
    "invoiceNo": "2425-10042",
    "items": [
      {
        "amount": 5000,
        "applicationId": "6650a1b2c3d4e5f6a7b8c9e5",
        "charged": true,
        "currency": "EUR",
        "entryId": "6650a1b2c3d4e5f6a7b8c9f2",
        "paymentId": "6650a1b2c3d4e5f6a7b8c9e6",
        "reason": "free",
        "reference": "stx-19a2c3d4e5f6a7b8c9"
      }
    ],
    "reference": "stx-19a2c3d4e5f6a7b8c9",
    "wallet": {
      "granted": 50,
      "organization": "stem",
      "remaining": 41,
      "spent": 9
    }
  },
  "message": "Nothing was taken from the wallet.",
  "success": true
}

Example request

# $TOKEN: a short-lived token you minted with your API key and secret
curl -sS -X POST 'https://api.main-team.org/v1/<organizationId>/application/wallet-pay' \
  -H "Authorization: Bearer $TOKEN" \
  -H 'Content-Type: application/json' \
  --data-binary @- <<'JSON'
{
  "applicationIds": [
    "6650a1b2c3d4e5f6a7b8c9e5"
  ]
}
JSON

Search the API documentation

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