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 registration phase is the only window during which you can add voters to the election. Each voter is identified by a unique email address. Once the election starts — via POST /voting/start-vote — the system emails N1 and N2 credentials to every registered address. No registrations are accepted after that point.

Before you begin

Registration must happen while the election is still in the register state. Check the current state with GET /voting/vote-status before proceeding. If the status is already vote_started or vote_ended, voters can no longer be added.
1

Register a voter by email

Send a POST request to /voters/register with the voter’s email address in the request body.
curl -X POST https://your-api.example.com/voters/register \
  -H "Content-Type: application/json" \
  -d '{"email": "alice@example.com"}'
A successful registration returns HTTP 201:
{
  "status": "success",
  "message": "Voter registered successfully",
  "voter": "alice@example.com"
}
2

Handle duplicate email addresses

If the email address is already registered, the API returns HTTP 409 instead of 201. The response body uses the same shape as a success response:
{
  "status": "error",
  "message": "Email already exists",
  "voter": "alice@example.com"
}
Your registration script should treat a 409 as a no-op and continue with the next voter rather than aborting.
3

Repeat for all voters

Call POST /voters/register once for each voter. There is no bulk-registration endpoint, so iterate over your voter list and register each address individually.
for email in alice@example.com bob@example.com carol@example.com; do
  curl -s -X POST https://your-api.example.com/voters/register \
    -H "Content-Type: application/json" \
    -d "{\"email\": \"$email\"}"
  echo
done
Each email address must be unique in the system. Registering the same address twice returns 409 and does not create a duplicate record.

What happens next

When you call POST /voting/start-vote, the system immediately sends a credential email to every registered voter. Each email contains two one-time codes:
  • N1 — used to authenticate the voter’s session before casting a ballot. It is consumed after the first successful POST /voters/check_n1 call.
  • N2 — used as the voter’s unique fingerprint when submitting and later verifying a ballot.
Voters must have both codes available before they can vote. Make sure all voter addresses are registered and correct before starting the election, because there is no way to add voters or resend credentials once the vote is underway.

Build docs developers (and LLMs) love