Grade a student's answer to a problem you fetched. The token binds the call to that exact problem; the answer key is loaded and compared server-side by a computer algebra system.
curl -X POST "https://api.locusmath.org/public/grade" \
-H "x-api-key: <your-key>" \
-H "Content-Type: application/json" \
-d '{"submission_token": "<from the problem>", "user_input": "2x + 3"}'| Field | Description |
|---|---|
submission_token | The token from the fetched problem. Valid for 31 days, and the problem stays gradeable that whole window even if the corpus rotates underneath. Expired or malformed tokens return 400 - refetch the problem for a fresh one. |
user_input | The student's answer in the normalized string form the widget emits (for plain math entry: the expression, e.g. 2x+3 or x = 4). Max 10 KB; larger returns 400. |
{ "is_correct": true }Equivalent forms count: 0.5x and x/2 grade the same. There is no partial credit signal - grading is boolean per problem (multi-part problems grade all parts together).
Because the answer never crosses the wire, a student inspecting your site's network traffic finds nothing to leak - and you never store or sync answer keys. A client can only grade problems it was actually served. Grading is included with the problem serve - grade calls do not count against your quota.