xAPI statements API

Base path: /api/statements

Ingests xAPI (Experience API) statements — the learning records emitted when a learner interacts with exercises and assignments. The route resolves the referenced content and assignment and hands the statement to the statements repository for persistence.

Endpoint

  • POST /api/statements/:ref_id/:assignment_id? — record one xAPI statement.
    • Path: ref_id (required) — the content reference the statement is about; assignment_id (optional) — the assignment the statement belongs to.
    • Body: a standard xAPI statement (actor, verb, object, and optional context / result), sent as JSON. verb.id is required, and timestamp must be an ISO 8601 datetime carrying a timezone — either Z or a ±hh:mm offset, which is what Date.prototype.toISOString() produces.
    • Response: 200 OK with { "ok": true } on success.

Errors

  • 400 Bad Request — missing ref_id, or a body that is not a valid statement (missing verb.id, a timestamp without a timezone, and so on). The response body carries a message naming the offending field.
  • 404 Not Found — the ref_id (or the given assignment_id) does not exist.