Check a registration without registering the student
- Bearer token
- Permission
student/create - Core record
Runs the checks registerStudent makes before it creates anything, on the same body without password, and tells you what they found. Nothing is created or changed and no username is issued, so sending it any number of times has no effect. Use it to validate a batch before you register it.
The body follows registerStudent’s rules, and one that breaks a rule is refused the same way, with 400: a missing or malformed field, null for phone or activatedPlatformsThisSeason, or a property the operation does not accept, password included.
The answer is 200 whatever the lookups found. data.valid is true when the registration would pass every check made here:
data.duplicate.sameAccountistruewhen one of your students already has this email address, anddata.duplicate.studentIdis that student’s_id:registerStudentwould answer409. Nothing else is looked up then, as registration does not look further either.data.problemslists everycountry,grade,cityandschoolthat would be refused, each as{ field, message }with the messageregisterStudentwould answer400with, where registration names only the first. A country whose students cannot be given a username is listed as well. Acityorschoolname that is not in our list yet is not a problem: seedata.willCreate.data.willCreateis{ city, school }:truefor a name that is not in our list yet and would be added when you register. Look at it before you register: a misspelt school name becomes a new school. The check adds nothing.data.resolvedhas the_ideach of the four resolved to, what registration would store, ornull.
exams and walletPay (both optional) are checked too. data.exams has one entry per exam you sent, with valid, the price in cents after any Coding bundle price, the currency, free, the credits it would take (1, or 0 for a free exam) and, when it would be refused, a problem with a code and a message. With walletPay: true, data.wallet says whether the wallet is enabled, what is needed and available per organization, and whether it is sufficient; valid is false when it is not. A check needs the same application/create (and application/pay) grants registration does. It tells you nothing about students on other accounts.
Only your own students are checked for the email address. An address a student on another account holds is not looked for and not reported, so valid: true is not a promise: registerStudent still answers 409 for such an address, without saying whose it is. Nor can the check foresee a student registered, or reference data changed, between the check and the registration.
Request body
firstNamestringrequiredThe student’s first name. Printed on certificates and reports, followed by
lastName.example
JanelastNamestringrequiredThe student’s surname. Printed on certificates and reports after
firstName. It cannot be empty.example
DoebirthstringrequiredDate of birth as
DD/MM/YYYY, and a date that exists:31/02/2008is refused. An ISO date such as2008-05-14is refused.pattern
^(0[1-9]|[12]\d|3[01])\/(0[1-9]|1[0-2])\/\d{4}$example14/05/2008sexstringrequiredOne of
m,forn.one of
mfnexample
femailstringrequiredThe student’s email address, stored in lower case. An address belongs to one student on the whole platform, so one already registered, by your account or another, is refused with 409.
format
emailexamplejane.doe@example.comemail2stringLeave this out. Any value but an empty one is refused with 400.
phonestringA phone number, stored as you send it. No format is checked. On an update,
""clears it.example
+1 555 0100countrystringrequiredThe
_idof a country, fromlistCountries(GET /v1/country). An id only: a name or an ISO code is refused. Its two-letter code starts the student’susername.pattern
^[0-9a-fA-F]{24}$example6650a1b2c3d4e5f6a7b8c9d1subdivisionstringThe
_idof a subdivision (a state) ofcountry, fromlistCountrySubdivisions, or its full ISO 3166-2 code such asUS-CA. Required for a country whose students must have one: a United States student needs a state, and registration without it is refused with 400subdivision_required. Optional for every other country. A subdivision of another country is refused with 400. It never changes theusername.example
6650a1b2c3d4e5f6a7b8c9f2gradestringrequiredThe
_idof a grade, fromlistGrades(GET /v1/grade), or its name,1to12. Either way the grade’s_idis what is stored. One that matches no grade is refused with 400, and so is the Graduated grade (GRADUATED), which no partner may set unless the student already holds it. The grade decides which exams the student is offered.example
10schoolstringrequiredThe
_idof a school, or its name. There is no list of schools: send the name your records hold. A school name that is not in our list yet is added automatically; check first withcheckStudentRegistration(willCreate.school) to catch a typo. A new name may be at most 120 characters, without<or>. An_idthat matches no school is refused with 400.example
Springfield High SchoolcitystringrequiredThe
_idof a city, or its name. There is no list of cities: send the name your records hold. A city name that is not in our list yet is added automatically; check first withcheckStudentRegistration(willCreate.city). A new name may be at most 80 characters, without<or>. An_idthat matches no city is refused with 400.example
SpringfieldactivatedPlatformsThisSeasonarray of stringThe organizations the student takes part in this season, by
slug(aslistOrganizationsgives it, ormto, which every student is on), orcommonfor every organization. Registration sets["common"]when you leave it out;nullis refused with 400. At most 6 entries.each one of
commonstemhilinguaneogmathcodingmax items
6example["common"]examsarray of StudentExamChoiceExams to enter the new student for, at most 10. Each one is checked by the rules
createApplicationapplies, and the application is created in the same all-or-nothing write as the student. Pending (unpaid) unlesswalletPayistrue.max items
102 fields of each item
organizationIdstringrequiredThe
_idof the organization the exam belongs to, fromlistOrganizations. Not its name or slug.example
64b7f0c2a1d3e4f5a6b7c8d9examIdstringrequiredThe exam’s
_id: a leafexamIdoflistAvailableExams, or an_idfromlistExams. It must be an exam the student could be entered for.example
6650a1b2c3d4e5f6a7b8c9e1
walletPaybooleanPay every priced exam in
examsfrom your wallet, one credit each, in the same all-or-nothing write. Needs an enabled wallet (opened by Main Team only after an agreement and on your request, never through the API) and theapplication/paypermission on each organization, even when no credit ends up being needed. Leave it out, orfalse, and the applications are created unpaid. The check only reports whether the wallet would cover it.example
false
Responses
200 OK
Success: message is "Registration checked. Nothing was created.".
Body
successbooleanrequiredAlways
trueon a success.one of
truemessagestringrequiredexample
Registration checked. Nothing was created.dataobject · RegistrationCheckResponserequiredWhat
checkStudentRegistrationfound: whetherregisterStudentwith the same body would pass the checks it makes before it writes, and why not.7 fields of data
validbooleanrequiredtruewhen no student of yours has the email address and every reference resolved, or is a city or school name that would be added (willCreate).example
falseproblemsarray of RegistrationProblemResponserequiredEvery reference field that matched nothing and would be refused, in the order
country,subdivision,grade,city,school, a missingsubdivisionwhen the country needs one, and the country again when its students cannot be given a username. A city or school name that is not in our list yet is not a problem: it is listed inwillCreate. Empty when the email address is one of your students’.2 fields of each item
fieldstringrequiredThe field:
country,subdivision,grade,cityorschool.one of
countrysubdivisiongradecityschoolexample
grademessagestringrequiredThe message
registerStudentanswers400 bad_requestwith for this field.example
grade is not a known grade. This API does not create reference data.
resolvedobject · ResolvedReferencesResponserequiredThe
_ideach reference resolved to. All five arenullwhen the email address is one of your students’: nothing is looked up then.5 fields of resolved
countrystringnullablerequiredThe country’s
_id;nullif it matched nothing or was not looked up.example
6650a1b2c3d4e5f6a7b8c9d1subdivisionstringnullablerequiredThe subdivision’s
_id, also when you sent its code;nullif you sent none, it matched nothing or was not looked up.example
6650a1b2c3d4e5f6a7b8c9f2gradestringnullablerequiredThe grade’s
_id, also when you sent its name;nullif it matched nothing or was not looked up.example
nullcitystringnullablerequiredThe city’s
_id, also when you sent its name;nullif it matched nothing or is a new city thatregisterStudentwould add (seewillCreate).example
6650a1b2c3d4e5f6a7b8c9d2schoolstringnullablerequiredThe school’s
_id, also when you sent its name;nullif it matched nothing or is a new school thatregisterStudentwould add (seewillCreate).example
null
willCreateobject · NewReferencesResponserequiredWhich of
cityandschoolare not in our list yet and would be added when you register.resolvedholdsnullfor each. The check adds nothing; look here before you register, because a misspelt name becomes a new school. Allfalsewhen the email address is one of your students’.2 fields of willCreate
citybooleanrequiredtruewhen the city name you sent is not in our list yet and would be added when you register. Check the spelling: a misspelt name becomes a new city.example
falseschoolbooleanrequiredtruewhen the school name you sent is not in our list yet and would be added when you register. Check the spelling: a misspelt name becomes a new school. Alwaysfalsefor an_id.example
true
duplicateobject · RegistrationDuplicateResponserequiredWhether one of your students already has the address.
2 fields of duplicate
sameAccountbooleanrequiredtruewhen one of your students already has this email address, soregisterStudentwould answer409 conflict.example
falsestudentIdstringThat student’s
_id, only whensameAccountistrue: the student to use instead of registering a second one.example
6650a1b2c3d4e5f6a7b8c9d0
examsarray of CheckedExamResponseOnly when you sent
exams: one entry per exam, in your order.9 fields of each item
organizationIdstringrequiredThe
organizationIdyou sent.example
64b7f0c2a1d3e4f5a6b7c8d9organizationstringPresent for an organization that resolved.
example
stemexamIdstringrequiredThe
examIdyou sent.example
6650a1b2c3d4e5f6a7b8c9e1validbooleanrequiredtruewhen the student could be entered for this exam.example
truepricenumberCents, after any Coding bundle price. Only on a valid exam.
example
5000currencystringUSDfor neo,EURotherwise. Only on a valid exam.example
EURfreebooleantruewhen the price is 0. Only on a valid exam.example
falsecreditsnumberWallet credits it would take: 1 for a priced exam, 0 for a free one.
example
1problemobjectWhy
validisfalse:unknown_reference,exam_not_offered,exam_conflict, orstudent_not_checkedwhen the student’s own fields have a problem and the exam was not looked at.example
{"code":"exam_not_offered","message":"Exam is not open for application."}
walletobject · CheckedWalletResponseOnly when you sent
walletPay.5 fields of wallet
walletPaybooleanrequiredEchoes that the check was asked about the wallet.
example
trueenabledbooleanrequiredWhether your account has an enabled wallet.
example
trueneededobjectrequiredCredits the valid exams would take, per organization slug.
example
{"stem":1}availableobjectrequiredCredits left, per organization the exams need.
example
{"stem":40}sufficientbooleanrequiredtruewhen the wallet is enabled and covers everyneeded.example
true
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
{
"success": true,
"message": "Registration checked. Nothing was created.",
"data": {
"valid": false,
"problems": [
{
"field": "grade",
"message": "grade is not a known grade. This API does not create reference data."
}
],
"resolved": {
"city": "6650a1b2c3d4e5f6a7b8c9d2",
"country": "6650a1b2c3d4e5f6a7b8c9d1",
"grade": null,
"school": null,
"subdivision": "6650a1b2c3d4e5f6a7b8c9f2"
},
"willCreate": {
"city": false,
"school": true
},
"duplicate": {
"sameAccount": false
},
"exams": [
{
"organizationId": "64b7f0c2a1d3e4f5a6b7c8d9",
"organization": "stem",
"examId": "6650a1b2c3d4e5f6a7b8c9e1",
"valid": true,
"price": 5000,
"currency": "EUR",
"free": false,
"credits": 1,
"problem": {
"code": "exam_not_offered",
"message": "Exam is not open for application."
}
}
],
"wallet": {
"walletPay": true,
"enabled": true,
"needed": {
"stem": 1
},
"available": {
"stem": 40
},
"sufficient": true
}
}
}400 Bad request
bad_request: The body is not valid JSON, breaks a field’s rules, or has a field this operation does not accept ("property <name> should not exist").bad_request:passwordwas sent. The check never takes one: leave it out, and send it withregisterStudentonly.bad_request:lastNameis missing or empty.bad_request:birthis notDD/MM/YYYY, or is not a date that exists, such as31/02/2008.
When
bad_requestThe body is not valid JSON, breaks a field’s rules, or has a field this operation does not accept ("property <name> should not exist").
bad_requestpasswordwas sent. The check never takes one: leave it out, and send it withregisterStudentonly.bad_requestlastNameis missing or empty.bad_requestbirthis notDD/MM/YYYY, or is not a date that exists, such as31/02/2008.
Example
{
"error": {
"code": "bad_request",
"documentation_url": "https://hub.main-team.org/api/errors#bad_request",
"message": "The request was malformed or contained invalid parameters.",
"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 allows student/create on mto (the target of operations without :organizationId in their path), or a role denies it.
When
forbiddenThe token is valid, but no role on your account allows
student/createonmto(the target of operations without:organizationIdin their path), or a role denies it.
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.
413 Payload too large
payload_too_large: The body is larger than 100 kB.
When
payload_too_largeThe body is larger than 100 kB.
Example
{
"error": {
"code": "payload_too_large",
"documentation_url": "https://hub.main-team.org/api/errors#payload_too_large",
"message": "request entity too large",
"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.
415 Unsupported media type
unsupported_media_type: The body declares a charset that is not a UTF one (send UTF-8), or a Content-Encoding other than gzip, deflate or br.
When
unsupported_media_typeThe body declares a charset that is not a UTF one (send UTF-8), or a
Content-Encodingother than gzip, deflate or br.
Example
{
"error": {
"code": "unsupported_media_type",
"documentation_url": "https://hub.main-team.org/api/errors#unsupported_media_type",
"message": "unsupported charset \"ISO-8859-1\"",
"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.