Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/Crypto-Project-ENSTA/back-end/llms.txt

Use this file to discover all available pages before exploring further.

All error responses from the Crypto E-Voting API follow FastAPI’s standard JSON error format. When a request fails, the response body contains a detail field that describes what went wrong. You can use this field to handle errors programmatically or surface a message to the user.

Error response format

Every error response from the API uses this structure:
{"detail": "Error message here"}
For example, attempting to submit a vote without completing the N1 verification step returns:
{"detail": "N1 not verified. Please verify your N1 first."}
Some endpoints — such as POST /voters/register — return a custom response body even for error cases. In those cases, the body follows the endpoint’s own response schema rather than the standard detail format.

HTTP status codes

The table below documents every HTTP status code used across the API and what it means in this system.
StatusMeaning in this API
200 OKThe request succeeded. The response body contains the requested data or a confirmation message.
201 CreatedA new voter was registered successfully (only returned by POST /voters/register).
400 Bad RequestThe request contained invalid input — for example, a malformed N2 fingerprint, an unrecognised vote choice, or a failed registration due to a DB error.
403 ForbiddenThe N1 code is not present in the session. You must call POST /voters/check_n1 before calling POST /voters/submit_vote.
404 Not FoundThe requested resource does not exist — for example, no voters are registered when starting a vote, or the voting configuration record is missing.
409 ConflictThe email address is already registered in the system. Each email can only be registered once.
500 Internal Server ErrorAn unexpected error occurred on the server. These are not caused by invalid input — check server logs for details.

Common error scenarios

The table below lists the most common error situations, where they occur, and how to resolve them.
ScenarioEndpointStatusResolution
Submitting a vote without verifying N1 firstPOST /voters/submit_vote403Call POST /voters/check_n1 with a valid N1 code first, then retry the vote submission within the 10-minute session window.
Registering a duplicate emailPOST /voters/register409The email is already in the system. If this is unexpected, check whether the voter previously registered under the same address.
Starting a vote when no voters are registeredPOST /voting/start-vote404Register at least one voter via POST /voters/register before calling start-vote.
Missing voting configurationGET /voting/vote-status404The voting configuration record does not exist in the database. Ensure the system is initialised correctly before querying status.
Session cookies expire after 10 minutes. If the session expires between calling /voters/check_n1 and /voters/submit_vote, the submit call returns 403. The voter must call /voters/check_n1 again to get a fresh session before resubmitting.
The POST /voters/check_n1 endpoint returns 200 regardless of whether the N1 code is valid — it does not return a 4xx error for an unrecognised code. Check the is_N1_exist field in the response body to determine whether the code was accepted.

Build docs developers (and LLMs) love