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.

The Crypto E-Voting API is a FastAPI-based REST API that handles voter registration, encrypted ballot submission, vote tallying, and system configuration. Every request and response uses JSON. All paths documented here are relative to the server’s base URL.

Base URL

The server runs at a configurable host. All endpoint paths listed in this reference are relative to that host. For example, if your server runs at https://api.example.com, the health check endpoint is:
https://api.example.com/health
No versioning prefix is applied — paths start directly from the root.

Content type

All requests that include a body must set the Content-Type header to application/json. All responses from the API are returned as application/json.
Content-Type: application/json
Accept: application/json

Session authentication

This API uses HTTP session cookies for authentication, not API keys or JWTs. The session cookie is set automatically by the server when you call /voters/check_n1. The voting flow requires two sequential calls:
  1. POST /voters/check_n1 — submit your N1 code. If the code is valid, the server stores it in your session.
  2. POST /voters/submit_vote — submit your encrypted ballot. The server reads the N1 code from your session automatically and clears it after the vote is accepted.
If you call /voters/submit_vote without first calling /voters/check_n1 in the same session, the API returns 403 Forbidden. The session also expires after 10 minutes of inactivity — if the session expires between the two calls, you must call /voters/check_n1 again.
The session cookie is configured with SameSite=None, which requires the API to be served over HTTPS. Calls over plain HTTP will not work.

All endpoints

The table below lists every endpoint available in the API.
MethodPathDescription
GET/healthReturns {"status": "ok"} to confirm the server is running
GET/Root endpoint — returns a message confirming the API is running
POST/voters/registerRegister a new voter by email address
POST/voters/check_n1Validate a voter’s N1 code and store it in the session
POST/voters/submit_voteSubmit an encrypted ballot (requires N1 verified in session)
POST/voting/start-voteStart the election and send credentials to all registered voters
POST/voting/end-voteEnd the election and trigger the vote counting pipeline
GET/voting/vote-statusGet the current voting status (register, vote_started, or vote_ended)
GET/results/tallyRetrieve vote counts and percentages for all candidates
POST/results/verify-voteVerify whether a ballot was received and counted, using an N2 fingerprint
GET/config/voting-system-configRetrieve the current voting system configuration
PATCH/config/voting-system-configUpdate one or more voting configuration fields

Explore by group

Voters

Register voters, verify N1 codes, and submit encrypted ballots.

Voting session

Start and end the election, and check the current voting status.

Results

Retrieve the vote tally and verify individual ballots by N2 fingerprint.

Configuration

Read and update the voting system configuration, including candidates and ballot theme.

Build docs developers (and LLMs) love