Version 1.0.0
Initial release of the v1 partner API, with 35 operations for students, sign-in links, exams, applications, certificates and reports.
Added
- Health:
getHealth. - API account:
getCurrentApiAccount,revokeToken. - Reference data:
listCountries,getCountry,listGrades,getGrade,listOrganizations,getOrganization. - Students:
listStudents,getStudent,registerStudent,updateStudent,setStudentPassword,listOrgStudents,getOrgStudent,updateOrgStudent,linkStudentSupervisor. - Sign-in links:
createSigninLink. - Exams:
listExamCategories,getExamCategory,listExams,listAvailableExams,getExam. - Applications:
listApplications,listExamApplications,listStudentApplications,getApplication,createApplication,moveApplication,deleteApplication. - Documents:
listStudentCertificates,downloadCertificate,listStudentReports,downloadReport. - Authentication with self-signed HS256 tokens, where
kidandsubare the apiKey, andiatandexpare required with a lifetime of at most 3600 seconds and 30 seconds of clock tolerance. Every authentication failure answers the same401 unauthorized. - Permissions by role, checked against the organization each request acts on. An operation with no permission granted answers
403 forbidden. - Response envelopes:
{ success, message, data, pagination? }on success, and{ error: { code, message, documentation_url, request_id } }on failure, with anX-Request-Idheader on every response.documentation_urlis the code's entry on the partner documentation,https://hub.main-team.org/api/errors#<code>. - Pagination with
page(default 1) andlimit(default 20, at most 100). - A rate limit of 100 requests per 60 seconds for each account and each operation, with
Retry-AfterandX-RateLimit-*headers. Each operation has its own budget. Going over answers429 too_many_requestswith the message "Too many requests to this operation. Wait the number of seconds in Retry-After, then try again." createSigninLink: sign-in links that are valid for 120 seconds and work once, for a student with access to that organization.getStudent,getOrgStudent,getCountry,getGrade,getOrganizationandgetExamCategoryanswer404 not_foundfor an id they cannot show, as every single read does. A student of another account answers like a missing one.getApplication,moveApplicationanddeleteApplicationanswer404with "Application not found!" alike for a missing application and one of another account's student.listOrganizationsandgetOrganizationserve the five organizations that run exams:stem,hilingua,neo,gmathandcoding. On every operation withorganizationIdin its path, the id of any other organization,mto's included, answers404 not_foundwith "Organization not found!", as an id that names no organization does.getCurrentApiAccountreturns the account'sroles, each witheffect,action,targetand, when set,authorized, to compare with an operation'sx-permission.registerStudentrequiresfirstName,lastName,email,birth,sex,country,grade,cityandschool, withbirtha date that exists, as DD/MM/YYYY, and names a missing field in its400("lastName should not be empty").updateStudentandupdateOrgStudenthold the fields they are sent to the same rules, and refusenullforfirstName,lastName,birth,sexandphone.registerStudentrefuses anullphonetoo.activatedPlatformsThisSeasononregisterStudent,updateStudentandupdateOrgStudenttakescommon,stem,hilingua,neo,gmathandcoding. The two updates add to the student's list and never remove from it.updateOrgStudentwithout the field, even with an empty body, adds its own organization, unless the list already holdscommon. All three refusenullfor it with400;registerStudentwithout it stores["common"].- Passwords: a
passwordatregisterStudent, andsetStudentPassword, needauth/signinonmto. A password is 5 characters to 72 bytes and contains none of the student's own details.setStudentPasswordanswers409once the student has confirmed their email address. linkStudentSupervisoranswers every refusal with the same404"Not found!".createApplicationis safe to repeat: the same student and exam answer200with the existing application.
Release notes
The first release of the Main Team API. Every path is under https://api.main-team.org/v1. Nothing here replaces an earlier version: each behavior below is how the API works from day one, listed so you can see the rules your integration will meet in one place. Each item links to the page that explains it.
Operations
35 operations in eight groups:
| Group | Operations |
|---|---|
| Health | getHealth |
| API account | getCurrentApiAccount, revokeToken |
| Reference data | listCountries, getCountry, listGrades, getGrade, listOrganizations, getOrganization |
| Students | listStudents, getStudent, registerStudent, updateStudent, setStudentPassword, listOrgStudents, getOrgStudent, updateOrgStudent, linkStudentSupervisor |
| Sign-in links | createSigninLink |
| Exams | listExamCategories, getExamCategory, listExams, listAvailableExams, getExam |
| Applications | listApplications, listExamApplications, listStudentApplications, getApplication, createApplication, moveApplication, deleteApplication |
| Documents | listStudentCertificates, downloadCertificate, listStudentReports, downloadReport |
Notable behaviors
Authentication and access
- You sign your own tokens: HS256 with your
apiSecret,kidandsubset to yourapiKey,iatandexprequired, at most 3600 seconds apart, with 30 seconds of clock tolerance. Every authentication failure answers the same401 unauthorized. See Authentication. - revokeToken ends one token early. Role changes and deactivation of your account take effect within 60 seconds.
- Every operation except the health check needs a permission from your roles, checked against the organization the request acts on; operations without an organization in their path act on
mto. Setting a password needsauth/signinonmto. See Permissions. {organizationId}in a path is the organization's_idfrom listOrganizations, never its slug. An unknown id answers404withOrganization not found!, after the token is checked. See Organizations.- listOrganizations lists the five organizations that run exams: stem, hilingua, neo, gmath and coding.
mto, the core record, is not listed: the operations without an organization in their path act on it. - Your account sees only the students it registered and the records reached through them. Another account's record answers like a missing one.
Requests and responses
- JSON bodies in UTF-8, at most 100 kB (
413above that). A field the operation does not accept is refused with400naming it. See Requests and responses. - Success responses use
{ success, message, data, pagination? }; errors use{ error: { code, message, documentation_url, request_id } }, wheredocumentation_urlis the code's entry on the errors page,https://hub.main-team.org/api/errors#<code>. getCurrentApiAccount returns the account without the envelope, and the downloads return the file itself. - Every single read answers
404 not_foundfor a record it cannot show, including getStudent, getOrgStudent, getCountry, getGrade, getOrganization and getExamCategory. - Every response carries
X-Request-Id. Quote it when you contact support. - Lists take
page(default 1) andlimit(default 20, at most 100; larger values are clamped). See Pagination. - Two catalog codes,
invalid_emailandunprocessable_entity, are reserved: no operation returns them in 1.0.0. See Errors.
Rate limits
- 100 requests per 60 seconds per account and per operation, whichever organization is in the path. Each operation is counted on its own. See Rate limits.
- Going over answers
429withRetry-Afterand the message "Too many requests to this operation. Wait the number of seconds in Retry-After, then try again.", and blocks that operation for 60 seconds. Counted responses carryX-RateLimit-Limit,X-RateLimit-RemainingandX-RateLimit-Reset.
Students
- Registration is not idempotent. An email address already registered to your account answers
409with that student's id; one held by anyone else answers409without an id. See Students. - Every student gets a username at registration, which the API never changes.
- Registration requires
firstName,lastName,email,birth,sex,country,grade,cityandschool, andbirthmust be a date that exists, asDD/MM/YYYY. Both updates hold the fields you send to the same rules, and refusenullfor a field a student can't be without. - A student can use every organization by default (
activatedPlatformsThisSeason: ["common"]). The list takescommonand the slugsstem,hilingua,neo,gmathandcoding. Updates only add to it and never remove anything. Updating a student through an organization without the field, even with an empty body, gives the student access to that organization. - Changing a student's email address withdraws its confirmation until the student confirms the new address.
- Passwords are at least 5 characters and at most 72 bytes, may not contain the student's name, username or email address, and can no longer be set once the student has confirmed their email address (
409). See Passwords.
Sign-in links and organization copies
- A sign-in link works once and for 120 seconds. Its optional
redirectmust be a path on the organization's site that starts with a single/. See Sign-in links. - A student without access to the organization gets
403. An unconfirmed email address does not block a link; the panel asks the student to confirm it and lets them choose to do it later. - An organization creates its own copy of a student at their first sign-in there. Until then, applications, the student's application, certificate and report lists on that organization answer
409, and a supervisor link answers404.
Exams and applications
- Only open exams are listed or can be read by id. The exam picker, listAvailableExams, offers one student exactly what they may apply for. See Exams.
- Creating the same application again answers
200withApplication already exists.and the existing application. See Applications. - A move is refused once the exam has started, and checked against the same rules as a new application. A paid application moves only to an exam with the same price. An AI Challenge application cannot be moved once the student has used part of their image quota.
- An application with a settled payment cannot be deleted (
409). The API records payments but never charges or refunds anyone. - getApplication, moveApplication and deleteApplication answer
404withApplication not found!alike for an application that does not exist and one of another account's student.
Certificates and reports
- Only released documents are listed or downloaded. A download by
_idorshortIdanswers one404for a document that is missing, not released, not yours or has no file. See Certificates and reports.