Skip to content
API documentation
View as MarkdownOpen in Claude

Students

Check a registration without registering the student

POST
/v1/student/check

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.sameAccount is true when one of your students already has this email address, and data.duplicate.studentId is that student’s _id: registerStudent would answer 409. Nothing else is looked up then, as registration does not look further either.
  • data.problems lists every country, grade, city and school that would be refused, each as { field, message } with the message registerStudent would answer 400 with, where registration names only the first. A country whose students cannot be given a username is listed as well. A city or school name that is not in our list yet is not a problem: see data.willCreate.
  • data.willCreate is { city, school }: true for 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.resolved has the _id each of the four resolved to, what registration would store, or null.

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

application/jsonrequired

  • firstNamestringrequired

    The student’s first name. Printed on certificates and reports, followed by lastName.

    exampleJane

  • lastNamestringrequired

    The student’s surname. Printed on certificates and reports after firstName. It cannot be empty.

    exampleDoe

  • birthstringrequired

    Date of birth as DD/MM/YYYY, and a date that exists: 31/02/2008 is refused. An ISO date such as 2008-05-14 is refused.

    pattern^(0[1-9]|[12]\d|3[01])\/(0[1-9]|1[0-2])\/\d{4}$example14/05/2008

  • sexstringrequired

    One of m, f or n.

    one ofmfn

    examplef

  • emailstringrequired

    The 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.

    formatemailexamplejane.doe@example.com

  • email2string

    Leave this out. Any value but an empty one is refused with 400.

  • phonestring

    A phone number, stored as you send it. No format is checked. On an update, "" clears it.

    example+1 555 0100

  • countrystringrequired

    The _id of a country, from listCountries (GET /v1/country). An id only: a name or an ISO code is refused. Its two-letter code starts the student’s username.

    pattern^[0-9a-fA-F]{24}$example6650a1b2c3d4e5f6a7b8c9d1

  • subdivisionstring

    The _id of a subdivision (a state) of country, from listCountrySubdivisions, or its full ISO 3166-2 code such as US-CA. Required for a country whose students must have one: a United States student needs a state, and registration without it is refused with 400 subdivision_required. Optional for every other country. A subdivision of another country is refused with 400. It never changes the username.

    example6650a1b2c3d4e5f6a7b8c9f2

  • gradestringrequired

    The _id of a grade, from listGrades (GET /v1/grade), or its name, 1 to 12. Either way the grade’s _id is 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.

    example10

  • schoolstringrequired

    The _id of 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 with checkStudentRegistration (willCreate.school) to catch a typo. A new name may be at most 120 characters, without < or >. An _id that matches no school is refused with 400.

    exampleSpringfield High School

  • citystringrequired

    The _id of 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 with checkStudentRegistration (willCreate.city). A new name may be at most 80 characters, without < or >. An _id that matches no city is refused with 400.

    exampleSpringfield

  • activatedPlatformsThisSeasonarray of string

    The organizations the student takes part in this season, by slug (as listOrganizations gives it, or mto, which every student is on), or common for every organization. Registration sets ["common"] when you leave it out; null is refused with 400. At most 6 entries.

    each one ofcommonstemhilinguaneogmathcoding

    max items6example["common"]

  • examsarray of StudentExamChoice

    Exams to enter the new student for, at most 10. Each one is checked by the rules createApplication applies, and the application is created in the same all-or-nothing write as the student. Pending (unpaid) unless walletPay is true.

    max items10

    2 fields of each item
    • organizationIdstringrequired

      The _id of the organization the exam belongs to, from listOrganizations. Not its name or slug.

      example64b7f0c2a1d3e4f5a6b7c8d9

    • examIdstringrequired

      The exam’s _id: a leaf examId of listAvailableExams, or an _id from listExams. It must be an exam the student could be entered for.

      example6650a1b2c3d4e5f6a7b8c9e1

  • walletPayboolean

    Pay every priced exam in exams from 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 the application/pay permission on each organization, even when no credit ends up being needed. Leave it out, or false, and the applications are created unpaid. The check only reports whether the wallet would cover it.

    examplefalse

Responses

200 OK

Success: message is "Registration checked. Nothing was created.".

Body

  • successbooleanrequired

    Always true on a success.

    one oftrue

  • messagestringrequired

    exampleRegistration checked. Nothing was created.

  • dataobject · RegistrationCheckResponserequired

    What checkStudentRegistration found: whether registerStudent with the same body would pass the checks it makes before it writes, and why not.

    7 fields of data
    • validbooleanrequired

      true when no student of yours has the email address and every reference resolved, or is a city or school name that would be added (willCreate).

      examplefalse

    • problemsarray of RegistrationProblemResponserequired

      Every reference field that matched nothing and would be refused, in the order country, subdivision, grade, city, school, a missing subdivision when 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 in willCreate. Empty when the email address is one of your students’.

      2 fields of each item
      • fieldstringrequired

        The field: country, subdivision, grade, city or school.

        one ofcountrysubdivisiongradecityschool

        examplegrade

      • messagestringrequired

        The message registerStudent answers 400 bad_request with for this field.

        examplegrade is not a known grade. This API does not create reference data.

    • resolvedobject · ResolvedReferencesResponserequired

      The _id each reference resolved to. All five are null when the email address is one of your students’: nothing is looked up then.

      5 fields of resolved
      • countrystringnullablerequired

        The country’s _id; null if it matched nothing or was not looked up.

        example6650a1b2c3d4e5f6a7b8c9d1

      • subdivisionstringnullablerequired

        The subdivision’s _id, also when you sent its code; null if you sent none, it matched nothing or was not looked up.

        example6650a1b2c3d4e5f6a7b8c9f2

      • gradestringnullablerequired

        The grade’s _id, also when you sent its name; null if it matched nothing or was not looked up.

        examplenull

      • citystringnullablerequired

        The city’s _id, also when you sent its name; null if it matched nothing or is a new city that registerStudent would add (see willCreate).

        example6650a1b2c3d4e5f6a7b8c9d2

      • schoolstringnullablerequired

        The school’s _id, also when you sent its name; null if it matched nothing or is a new school that registerStudent would add (see willCreate).

        examplenull

    • willCreateobject · NewReferencesResponserequired

      Which of city and school are not in our list yet and would be added when you register. resolved holds null for each. The check adds nothing; look here before you register, because a misspelt name becomes a new school. All false when the email address is one of your students’.

      2 fields of willCreate
      • citybooleanrequired

        true when 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.

        examplefalse

      • schoolbooleanrequired

        true when 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. Always false for an _id.

        exampletrue

    • duplicateobject · RegistrationDuplicateResponserequired

      Whether one of your students already has the address.

      2 fields of duplicate
      • sameAccountbooleanrequired

        true when one of your students already has this email address, so registerStudent would answer 409 conflict.

        examplefalse

      • studentIdstring

        That student’s _id, only when sameAccount is true: the student to use instead of registering a second one.

        example6650a1b2c3d4e5f6a7b8c9d0

    • examsarray of CheckedExamResponse

      Only when you sent exams: one entry per exam, in your order.

      9 fields of each item
      • organizationIdstringrequired

        The organizationId you sent.

        example64b7f0c2a1d3e4f5a6b7c8d9

      • organizationstring

        Present for an organization that resolved.

        examplestem

      • examIdstringrequired

        The examId you sent.

        example6650a1b2c3d4e5f6a7b8c9e1

      • validbooleanrequired

        true when the student could be entered for this exam.

        exampletrue

      • pricenumber

        Cents, after any Coding bundle price. Only on a valid exam.

        example5000

      • currencystring

        USD for neo, EUR otherwise. Only on a valid exam.

        exampleEUR

      • freeboolean

        true when the price is 0. Only on a valid exam.

        examplefalse

      • creditsnumber

        Wallet credits it would take: 1 for a priced exam, 0 for a free one.

        example1

      • problemobject

        Why valid is false: unknown_reference, exam_not_offered, exam_conflict, or student_not_checked when 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 · CheckedWalletResponse

      Only when you sent walletPay.

      5 fields of wallet
      • walletPaybooleanrequired

        Echoes that the check was asked about the wallet.

        exampletrue

      • enabledbooleanrequired

        Whether your account has an enabled wallet.

        exampletrue

      • neededobjectrequired

        Credits the valid exams would take, per organization slug.

        example{"stem":1}

      • availableobjectrequired

        Credits left, per organization the exams need.

        example{"stem":40}

      • sufficientbooleanrequired

        true when the wallet is enabled and covers every needed.

        exampletrue

Headers

X-RateLimit-Limit integer

Requests your account may make to this operation per window (100).

X-RateLimit-Remaining integer

Requests left in the current window.

X-RateLimit-Reset integer

Seconds 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
    }
  }
}

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/student/check' \
  -H "Authorization: Bearer $TOKEN" \
  -H 'Content-Type: application/json' \
  --data-binary @- <<'JSON'
{
  "firstName": "Jane",
  "lastName": "Doe",
  "birth": "14/05/2008",
  "sex": "f",
  "email": "jane.doe@example.com",
  "email2": "<email2>",
  "phone": "+1 555 0100",
  "country": "6650a1b2c3d4e5f6a7b8c9d1",
  "subdivision": "6650a1b2c3d4e5f6a7b8c9f2",
  "grade": "10",
  "school": "Springfield High School",
  "city": "Springfield",
  "activatedPlatformsThisSeason": [
    "common"
  ],
  "exams": [
    {
      "organizationId": "64b7f0c2a1d3e4f5a6b7c8d9",
      "examId": "6650a1b2c3d4e5f6a7b8c9e1"
    }
  ],
  "walletPay": false
}
JSON

Search the API documentation

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