Pay one application from your wallet
- Bearer token
- Permission
application/pay - Per organization
Pays the pending payment of one application of one of your students from your wallet: one credit of this organization, the payment marked paid, and an entry in your wallet history (listWalletEntries). No body.
A free exam takes no credit, and an application this wallet already paid answers 200 with charged: false, so a retry is safe. A payment settled another way is 409 already_paid; a canceled one 409 payment_canceled; a card payment the student still has open 409 payment_in_progress. On coding the price is the bundle price when the student has already paid a bundle exam.
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. To pay several at once use payApplicationsFromWallet.
Parameters
Path parameters
| Name | Type | Description |
|---|---|---|
organizationIdrequired | stringpattern ^[0-9a-f]{24}$ | The organization’s Example |
applicationIdrequired | string | The application’s |
Responses
200 OK
Success: message is "Application paid from wallet.".
Or message is "Nothing was taken from the wallet.": The exam is free, or this wallet already paid it.
Body
successbooleanrequiredAlways
trueon a success.one of
truemessagestringrequiredexample
Application paid from wallet.dataobject · PayApplicationResponserequiredThe answer of
payApplicationFromWallet.9 fields of data
applicationIdstringrequiredThe application that was paid.
example
6650a1b2c3d4e5f6a7b8c9e5paymentIdstringrequiredIts payment.
example
6650a1b2c3d4e5f6a7b8c9e6chargedbooleanrequiredtruewhen a credit was taken by this call.falsewhen there was nothing to take: seereason.example
truereasonstringWhy nothing was taken, only when
chargedisfalse.free: the exam costs nothing, and a free exam never uses a credit.already_paid: this wallet already paid it, in an earlier call;referenceandentryIdare that payment’s.one of
freealready_paidexample
freeamountnumberrequiredThe amount the payment was settled at, in cents: the exam’s price, or the coding bundle price when it is lower.
0for a free exam.example
5000currencystringrequiredThe currency of
amount:USDfor neo,EURotherwise.one of
EURUSDexample
EURreferencestringThe transaction code of the payment (
stx-...), the samereferencethe application reads show on a settled payment.example
stx-19a2c3d4e5f6a7b8c9entryIdstringThe
_idof the wallet entry (listWalletEntries).example
6650a1b2c3d4e5f6a7b8c9f2walletobject · WalletBalanceViewResponserequiredThe organization’s balance after the call.
4 fields of wallet
organizationstringrequiredThe organization’s slug.
example
stemgrantednumberrequiredCredits granted to you in total.
example
50spentnumberrequiredCredits spent in total.
example
9remainingnumberrequiredgrantedminusspent.example
41
Headers
X-RateLimit-LimitintegerRequests your account may make to this operation per window (100).
X-RateLimit-RemainingintegerRequests left in the current window.
X-RateLimit-ResetintegerSeconds until the current window ends.
Example
{
"data": {
"amount": 5000,
"applicationId": "6650a1b2c3d4e5f6a7b8c9e5",
"charged": true,
"currency": "EUR",
"entryId": "6650a1b2c3d4e5f6a7b8c9f2",
"paymentId": "6650a1b2c3d4e5f6a7b8c9e6",
"reason": "free",
"reference": "stx-19a2c3d4e5f6a7b8c9",
"wallet": {
"granted": 50,
"organization": "stem",
"remaining": 41,
"spent": 9
}
},
"message": "Nothing was taken from the wallet.",
"success": true
}400 Bad request
bad_request: applicationId is not 24 hexadecimal digits.
When
bad_requestapplicationIdis not 24 hexadecimal digits.
Example
{
"error": {
"code": "bad_request",
"documentation_url": "https://hub.main-team.org/api/errors#bad_request",
"message": "Invalid value for '_id': expected ObjectId.",
"request_id": "0b5c6d0e-8f7a-4b1c-9d2e-3f4a5b6c7d8e"
}
}Fields of the error body
errorobject · ErrorDetailrequiredWhat went wrong.
5 fields of error
codestringrequiredA stable machine code: branch on this. Each one is explained at
documentation_url.one of
invalid_emailbad_requestsubdivision_requiredunauthorizedforbiddennot_foundconflictpayload_too_largeunsupported_media_typeunprocessable_entitytoo_many_requestsinternal_errorservice_unavailableexample
not_foundmessagestringrequiredWritten for a person, and may change: never branch on it.
example
Not found!documentation_urlstringrequiredWhere this code is explained.
format
uriexamplehttps://hub.main-team.org/api/errors#not_foundrequest_idstringrequiredThis request’s id, also sent as the
X-Request-Idresponse header: the one you sent, when it was acceptable, or else one the API made. Quote it when you report a problem.example
0b5c6d0e-8f7a-4b1c-9d2e-3f4a5b6c7d8edetailsobjectPresent only where an operation says so, and then with the shape that operation documents — the rows it could not accept, say. Treat it as absent everywhere else, and ignore a
detailsyou do not recognise.
401 Unauthorized
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.
When
unauthorizedThe token is missing or malformed, is not signed with your account’s
apiSecret, breaks theiatandexprules, has expired or been revoked, or its account is not active. All of these answer the same.
Example
{
"error": {
"code": "unauthorized",
"documentation_url": "https://hub.main-team.org/api/errors#unauthorized",
"message": "Authentication is required or the provided credentials are invalid.",
"request_id": "0b5c6d0e-8f7a-4b1c-9d2e-3f4a5b6c7d8e"
}
}Fields of the error body
errorobject · ErrorDetailrequiredWhat went wrong.
5 fields of error
codestringrequiredA stable machine code: branch on this. Each one is explained at
documentation_url.one of
invalid_emailbad_requestsubdivision_requiredunauthorizedforbiddennot_foundconflictpayload_too_largeunsupported_media_typeunprocessable_entitytoo_many_requestsinternal_errorservice_unavailableexample
not_foundmessagestringrequiredWritten for a person, and may change: never branch on it.
example
Not found!documentation_urlstringrequiredWhere this code is explained.
format
uriexamplehttps://hub.main-team.org/api/errors#not_foundrequest_idstringrequiredThis request’s id, also sent as the
X-Request-Idresponse header: the one you sent, when it was acceptable, or else one the API made. Quote it when you report a problem.example
0b5c6d0e-8f7a-4b1c-9d2e-3f4a5b6c7d8edetailsobjectPresent only where an operation says so, and then with the shape that operation documents — the rows it could not accept, say. Treat it as absent everywhere else, and ignore a
detailsyou do not recognise.
403 Forbidden
forbidden: The token is valid, but no role on your account allowsapplication/payon the organization in the path, or a role denies it.forbidden: Your 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). Asked for bywalletPay: trueeven when no credit would be taken.error.details.reasoniswallet_not_enabled.
When
forbiddenThe token is valid, but no role on your account allows
application/payon the organization in the path, or a role denies it.forbiddenYour 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). Asked for by
walletPay: trueeven when no credit would be taken.error.details.reasoniswallet_not_enabled.
Example
{
"error": {
"code": "forbidden",
"documentation_url": "https://hub.main-team.org/api/errors#forbidden",
"message": "Insufficient role permissions",
"request_id": "0b5c6d0e-8f7a-4b1c-9d2e-3f4a5b6c7d8e"
}
}Fields of the error body
errorobject · ErrorDetailrequiredWhat went wrong.
5 fields of error
codestringrequiredA stable machine code: branch on this. Each one is explained at
documentation_url.one of
invalid_emailbad_requestsubdivision_requiredunauthorizedforbiddennot_foundconflictpayload_too_largeunsupported_media_typeunprocessable_entitytoo_many_requestsinternal_errorservice_unavailableexample
not_foundmessagestringrequiredWritten for a person, and may change: never branch on it.
example
Not found!documentation_urlstringrequiredWhere this code is explained.
format
uriexamplehttps://hub.main-team.org/api/errors#not_foundrequest_idstringrequiredThis request’s id, also sent as the
X-Request-Idresponse header: the one you sent, when it was acceptable, or else one the API made. Quote it when you report a problem.example
0b5c6d0e-8f7a-4b1c-9d2e-3f4a5b6c7d8edetailsobjectPresent only where an operation says so, and then with the shape that operation documents — the rows it could not accept, say. Treat it as absent everywhere else, and ignore a
detailsyou do not recognise.
404 Not found
not_found:organizationIdis not the_idof an organization.not_found: No application of your students has this id: it matches nothing, or the application belongs to another account’s student. Both get the same answer.
When
Example
{
"error": {
"code": "not_found",
"documentation_url": "https://hub.main-team.org/api/errors#not_found",
"message": "Organization not found!",
"request_id": "0b5c6d0e-8f7a-4b1c-9d2e-3f4a5b6c7d8e"
}
}Fields of the error body
errorobject · ErrorDetailrequiredWhat went wrong.
5 fields of error
codestringrequiredA stable machine code: branch on this. Each one is explained at
documentation_url.one of
invalid_emailbad_requestsubdivision_requiredunauthorizedforbiddennot_foundconflictpayload_too_largeunsupported_media_typeunprocessable_entitytoo_many_requestsinternal_errorservice_unavailableexample
not_foundmessagestringrequiredWritten for a person, and may change: never branch on it.
example
Not found!documentation_urlstringrequiredWhere this code is explained.
format
uriexamplehttps://hub.main-team.org/api/errors#not_foundrequest_idstringrequiredThis request’s id, also sent as the
X-Request-Idresponse header: the one you sent, when it was acceptable, or else one the API made. Quote it when you report a problem.example
0b5c6d0e-8f7a-4b1c-9d2e-3f4a5b6c7d8edetailsobjectPresent only where an operation says so, and then with the shape that operation documents — the rows it could not accept, say. Treat it as absent everywhere else, and ignore a
detailsyou do not recognise.
409 Conflict
conflict: The wallet holds fewer credits than the call needs. Nothing was paid or written.error.details.reasonisinsufficient_credits, anderror.details.organizationslistsorganizationId,organization,needed,availableandshort.conflict: The payment was settled another way (a bank transfer, a card), so there is nothing to take.error.details.reasonisalready_paid.conflict: The payment is canceled.error.details.reasonispayment_canceled.conflict: The student has a card payment open for this application (opened in the last 25 hours).error.details.reasonispayment_in_progress; try again once it has finished or expired.conflict: The payment changed while it was being paid and the call could not settle it after retrying. Nothing was taken.error.details.reasonispayment_changed; read the application and try again.
When
conflictThe wallet holds fewer credits than the call needs. Nothing was paid or written.
error.details.reasonisinsufficient_credits, anderror.details.organizationslistsorganizationId,organization,needed,availableandshort.conflictThe payment was settled another way (a bank transfer, a card), so there is nothing to take.
error.details.reasonisalready_paid.conflictThe payment is canceled.
error.details.reasonispayment_canceled.conflictThe student has a card payment open for this application (opened in the last 25 hours).
error.details.reasonispayment_in_progress; try again once it has finished or expired.conflictThe payment changed while it was being paid and the call could not settle it after retrying. Nothing was taken.
error.details.reasonispayment_changed; read the application and try again.
Example
{
"error": {
"code": "conflict",
"details": {
"organizations": [
{
"available": 1,
"needed": 3,
"organization": "stem",
"organizationId": "64b7f0c2a1d3e4f5a6b7c8d9",
"short": 2
}
],
"reason": "insufficient_credits"
},
"documentation_url": "https://hub.main-team.org/api/errors#conflict",
"message": "The request conflicts with the current state of the resource.",
"request_id": "0b5c6d0e-8f7a-4b1c-9d2e-3f4a5b6c7d8e"
}
}Fields of the error body
errorobject · ErrorDetailrequiredWhat went wrong.
5 fields of error
codestringrequiredA stable machine code: branch on this. Each one is explained at
documentation_url.one of
invalid_emailbad_requestsubdivision_requiredunauthorizedforbiddennot_foundconflictpayload_too_largeunsupported_media_typeunprocessable_entitytoo_many_requestsinternal_errorservice_unavailableexample
not_foundmessagestringrequiredWritten for a person, and may change: never branch on it.
example
Not found!documentation_urlstringrequiredWhere this code is explained.
format
uriexamplehttps://hub.main-team.org/api/errors#not_foundrequest_idstringrequiredThis request’s id, also sent as the
X-Request-Idresponse header: the one you sent, when it was acceptable, or else one the API made. Quote it when you report a problem.example
0b5c6d0e-8f7a-4b1c-9d2e-3f4a5b6c7d8edetailsobjectPresent only where an operation says so, and then with the shape that operation documents — the rows it could not accept, say. Treat it as absent everywhere else, and ignore a
detailsyou do not recognise.
429 Too many requests
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.
When
too_many_requestsYour account has made more than 100 requests to this operation in the current 60-second window. Wait the seconds in
Retry-Afterbefore sending again.
Headers
Retry-AfterintegerSeconds to wait before sending again; a request sent sooner is refused too.
Example
{
"error": {
"code": "too_many_requests",
"documentation_url": "https://hub.main-team.org/api/errors#too_many_requests",
"message": "Too many requests to this operation. Wait the number of seconds in Retry-After, then try again.",
"request_id": "0b5c6d0e-8f7a-4b1c-9d2e-3f4a5b6c7d8e"
}
}Fields of the error body
errorobject · ErrorDetailrequiredWhat went wrong.
5 fields of error
codestringrequiredA stable machine code: branch on this. Each one is explained at
documentation_url.one of
invalid_emailbad_requestsubdivision_requiredunauthorizedforbiddennot_foundconflictpayload_too_largeunsupported_media_typeunprocessable_entitytoo_many_requestsinternal_errorservice_unavailableexample
not_foundmessagestringrequiredWritten for a person, and may change: never branch on it.
example
Not found!documentation_urlstringrequiredWhere this code is explained.
format
uriexamplehttps://hub.main-team.org/api/errors#not_foundrequest_idstringrequiredThis request’s id, also sent as the
X-Request-Idresponse header: the one you sent, when it was acceptable, or else one the API made. Quote it when you report a problem.example
0b5c6d0e-8f7a-4b1c-9d2e-3f4a5b6c7d8edetailsobjectPresent only where an operation says so, and then with the shape that operation documents — the rows it could not accept, say. Treat it as absent everywhere else, and ignore a
detailsyou do not recognise.
500 Internal error
internal_error: Something failed on our side. Retry later, and quote request_id if it goes on.
When
internal_errorSomething failed on our side. Retry later, and quote
request_idif it goes on.
Example
{
"error": {
"code": "internal_error",
"documentation_url": "https://hub.main-team.org/api/errors#internal_error",
"message": "An unexpected error occurred.",
"request_id": "0b5c6d0e-8f7a-4b1c-9d2e-3f4a5b6c7d8e"
}
}Fields of the error body
errorobject · ErrorDetailrequiredWhat went wrong.
5 fields of error
codestringrequiredA stable machine code: branch on this. Each one is explained at
documentation_url.one of
invalid_emailbad_requestsubdivision_requiredunauthorizedforbiddennot_foundconflictpayload_too_largeunsupported_media_typeunprocessable_entitytoo_many_requestsinternal_errorservice_unavailableexample
not_foundmessagestringrequiredWritten for a person, and may change: never branch on it.
example
Not found!documentation_urlstringrequiredWhere this code is explained.
format
uriexamplehttps://hub.main-team.org/api/errors#not_foundrequest_idstringrequiredThis request’s id, also sent as the
X-Request-Idresponse header: the one you sent, when it was acceptable, or else one the API made. Quote it when you report a problem.example
0b5c6d0e-8f7a-4b1c-9d2e-3f4a5b6c7d8edetailsobjectPresent only where an operation says so, and then with the shape that operation documents — the rows it could not accept, say. Treat it as absent everywhere else, and ignore a
detailsyou do not recognise.
503 Service unavailable
service_unavailable: The wallet is not available in this environment yet. Nothing was paid or written. error.details.reason is wallet_unavailable.
When
service_unavailableThe wallet is not available in this environment yet. Nothing was paid or written.
error.details.reasoniswallet_unavailable.
Headers
Retry-AfterintegerSeconds to wait before sending again; a request sent sooner is refused too.
Example
{
"error": {
"code": "service_unavailable",
"details": {
"reason": "wallet_unavailable"
},
"documentation_url": "https://hub.main-team.org/api/errors#service_unavailable",
"message": "Not ready.",
"request_id": "0b5c6d0e-8f7a-4b1c-9d2e-3f4a5b6c7d8e"
}
}Fields of the error body
errorobject · ErrorDetailrequiredWhat went wrong.
5 fields of error
codestringrequiredA stable machine code: branch on this. Each one is explained at
documentation_url.one of
invalid_emailbad_requestsubdivision_requiredunauthorizedforbiddennot_foundconflictpayload_too_largeunsupported_media_typeunprocessable_entitytoo_many_requestsinternal_errorservice_unavailableexample
not_foundmessagestringrequiredWritten for a person, and may change: never branch on it.
example
Not found!documentation_urlstringrequiredWhere this code is explained.
format
uriexamplehttps://hub.main-team.org/api/errors#not_foundrequest_idstringrequiredThis request’s id, also sent as the
X-Request-Idresponse header: the one you sent, when it was acceptable, or else one the API made. Quote it when you report a problem.example
0b5c6d0e-8f7a-4b1c-9d2e-3f4a5b6c7d8edetailsobjectPresent only where an operation says so, and then with the shape that operation documents — the rows it could not accept, say. Treat it as absent everywhere else, and ignore a
detailsyou do not recognise.