Votee — HTTP APIs
All services use snake_case JSON and the same error format:
{ "error": { "code": "QUOTA_EXCEEDED", "message": "the voting quota for this period is exhausted" } }
Gateway (:8000)
Clients, browsers and payment providers call one origin, http://localhost:8000 locally; the gateway forwards to
the service that owns the path. The paths and bodies below are the same through the gateway and on each service's own
port (development). GET /healthz answers {"status":"ok"} from the gateway itself.
| Public path | Service |
|---|---|
POST /v1/campaigns/{id}/votes, GET /v1/campaigns/{id}/ranking, GET /v1/campaigns/{id}/me/quota, GET /v1/me/votes, GET /v1/pow/challenge, GET /v1/audit/campaigns/{id}/{tallies,invalidations,cases} | voting-api |
POST /v1/accounts, POST /v1/accounts/email-verification[/resend], GET /v1/accounts/me, POST /v1/accounts/me/phone[/verification], DELETE /v1/accounts/me/phone, POST /v1/auth/{login,refresh,logout,guest} | identity-service |
POST /v1/orders, GET /v1/orders/{id}, GET /v1/accounts/me/debts, POST /v1/debts/{id}/settlement, POST /v1/webhooks/{provider} | payment-service |
GET /v1/campaigns/{id}/packages (the customer catalog, active packages only) | payment-service |
GET /v1/accounts/{account_id}/campaigns/{campaign_id}[/ledger] | credit-service |
GET /v1/public/campaigns, GET /v1/public/campaigns/{id} (no token) | campaign-service |
POST /v1/campaigns, GET /v1/campaigns/{id}[/transitions], POST /v1/campaigns/{id}/{schedule,pause,resume,end,cancel,candidates,packages}, PUT /v1/campaigns/{id}/{window,rules}, POST /v1/campaigns/{id}/candidates/{candidate_id}/withdraw, PUT /v1/campaigns/{id}/packages/{package_id} | campaign-service |
Everything else is 404 ROUTE_NOT_FOUND: every /internal/** path, the Swagger UI and OpenAPI endpoints, the actuator
and the JWKS. The administrator list of a campaign's packages (GET /v1/campaigns/{id}/packages on campaign-service)
is not reachable through the gateway, since the same path is the customer catalog there.
Behavior added by the gateway:
- CORS for the configured origins (
deploy/gateway/envoy.yaml;http://localhost:5173locally), with credentials so the guest cookie is sent.Idempotent-Replayed,Retry-AfterandX-Request-Idare readable by scripts. X-Request-Idon every response (generated when the request has none) and in the gateway access log.- Limits: 64 KiB request body (
413 PAYLOAD_TOO_LARGE; 1 MiB for webhooks), 100 requests per second per client with a burst of 200 (429 RATE_LIMITED,Retry-After: 1), and per-route timeouts (504 UPSTREAM_TIMEOUT): 10 s for a vote, 3 s for a ranking, 15 s otherwise. A client is an IPv4 address or an IPv6 /64. Smaller buckets per client on identity routes: registration 10 a minute; login, email verification and phone verification 30 a minute each; guest tokens 120 a minute (Retry-After: 60, or 30 for guests). The vote limit per actor in voting-api and the limits per account in identity-service are separate. - Retries: only
GET, once, on connection failure. The gateway never retries aPOST; retry a vote with the sameIdempotency-Key. 503 TEMPORARILY_UNAVAILABLEwhen a service is not reachable.- Tokens, cookies and bodies pass through unchanged; services still verify the token themselves.
API documentation
Every service serves its public API as OpenAPI with Swagger UI. Internal endpoints (/internal/**, or the
internal listener of voting-api) are not documented. The gateway never forwards these paths. Under make stack-up
the service ports are not published at all; the documentation is served by the gateway's second listener,
http://<service>.localhost:8001/swagger-ui/index.html with <service> one of voting, campaign, credit,
identity, payment (bound to 127.0.0.1, development only; "Try it out" goes back through the public gateway).
| Service | Base URL (local) | Swagger UI | OpenAPI description |
|---|---|---|---|
| voting-api | http://localhost:8080 | /swagger-ui/index.html | /v3/api-docs.yaml (hand-maintained, OpenAPI 3.0.3) |
| campaign-service | http://localhost:8081 | /swagger-ui/index.html | /v3/api-docs (JSON) or /v3/api-docs.yaml, generated from the code (OpenAPI 3.1) |
| credit-service | http://localhost:8082 | /swagger-ui/index.html | as above |
| identity-service | http://localhost:8083 | /swagger-ui/index.html | as above |
| payment-service | http://localhost:8084 | /swagger-ui/index.html | as above |
The documentation endpoints need no token. Operations that need one are marked with the bearer scheme in the
UI; Authorize accepts an access token from identity-service.
Authentication
Callers send Authorization: Bearer <access token>, a short-lived RS256 JWT issued by identity-service.
voting-api, campaign-service and the other services verify
it locally against identity-service's JWKS (/.well-known/jwks.json, cached, re-read when a token names an
unknown key id), so there is no call to identity per request. The verified sub is the actor; there are no
X-Actor-Id or X-Admin-Id headers any more.
Token claims: iss (votee-identity), aud (votee), sub, exp, iat, jti, actor_type (ACCOUNT or
GUEST), identity_level (GUEST, ACCOUNT or VERIFIED_ACCOUNT), roles (ADMIN for administrators,
AUDITOR for read-only auditors), and for accounts acct_created_at (seconds since the epoch, when the account
registered).
A guest is an anonymous actor issued by identity (sub = g_…, opaque id kept in an httpOnly cookie). Guests
vote free only where the campaign allows it; never in a campaign with paid_vote_price > 0.
Access policy: the campaign rule min_identity is GUEST | ACCOUNT | VERIFIED_ACCOUNT; unset it defaults to
ACCOUNT for a campaign with paid votes and GUEST otherwise, and GUEST is refused when
paid_vote_price > 0. A campaign may also require a minimum account age (min_account_age_seconds, never with
min_identity = GUEST); voting-api compares it with acct_created_at, and a token without that claim (issued before
it existed) counts as too new until it is refreshed. The policy is checked before quota and credit.
| Status | Code | When |
|---|---|---|
| 401 | UNAUTHENTICATED | no token, or a token that is malformed, expired, tampered with, or signed by an unknown key |
| 403 | ACCOUNT_REQUIRED | the campaign needs an account and the actor is a guest |
| 403 | VERIFICATION_REQUIRED | the campaign needs a verified account |
| 403 | ACCOUNT_TOO_NEW | the account is younger than the campaign's min_account_age_seconds; the message says from when it may vote |
| 403 | ADMIN_REQUIRED | an administrator endpoint was called without the ADMIN role (an AUDITOR may make GET requests to campaign-service) |
| 403 | AUDITOR_REQUIRED | an audit endpoint was called without the AUDITOR or ADMIN role |
The access-token lifetime is 15 minutes by default (votee.identity.access-token-ttl); the final value and the
revocation approach are still open. A change of level or role reaches existing tokens when they are
refreshed.
Voting Core (voting-api, public :8080)
Cast a vote
POST /v1/campaigns/{campaign_id}/votes — headers Authorization: Bearer <token>, Idempotency-Key
(1–128 printable ASCII characters). The actor is the token subject.
{ "candidate_id": "0b6c…", "vote_count": 1, "vote_type": "FREE" }
vote_count defaults to 1, vote_type to FREE. PAID votes reserve
paid_vote_price × vote_count credits from the actor's credit account (the balance of this
campaign). The access policy is checked before quota and credit.
201 Created, only after the vote is committed:
{
"status": "ACCEPTED", "vote_id": "019a…", "campaign_id": "…", "candidate_id": "…",
"vote_type": "PAID", "vote_count": 3, "points": 30, "accepted_at": "2026-12-01T10:00:00.123456Z",
"campaign_snapshot_version": 4, "rule_set_version": 1
}
| Status | Code | Stored for the key? | Retry with the same key? |
|---|---|---|---|
| 400 | INVALID_REQUEST, PAID_VOTING_UNAVAILABLE | no | after fixing the request |
| 401 | UNAUTHENTICATED (missing, expired or invalid token) | no | with a valid token |
| 403 | ACCOUNT_REQUIRED, VERIFICATION_REQUIRED (identity below the campaign's min_identity; guests in a paid campaign), ACCOUNT_TOO_NEW (account younger than min_account_age_seconds) | no | after signing in, verifying or waiting |
| 404 | CAMPAIGN_NOT_FOUND, CANDIDATE_NOT_FOUND | no | yes (the snapshot may not have arrived) |
| 409 | CAMPAIGN_NOT_ACCEPTING_VOTES, CANDIDATE_NOT_ELIGIBLE, VOTE_COUNT_EXCEEDS_LIMIT, QUOTA_EXCEEDED, PAID_VOTING_DISABLED, INSUFFICIENT_CREDIT, ATTEMPT_ABANDONED, ACCESS_DENIED (a paid vote whose access policy changed after the credit was reserved; the credit is released) | yes | replays the same rejection; use a new key |
| 422 | IDEMPOTENCY_KEY_REUSED | — | no: same key, different payload |
| 429 | RATE_LIMITED (+ Retry-After) | no | yes, after the delay |
| 503 | TEMPORARILY_UNAVAILABLE, CREDIT_UNAVAILABLE (paid vote only: credit-service keeps failing or is saturated; nothing was reserved; Retry-After: 5) | no | yes; a pending paid attempt is resumed |
Replays carry Idempotent-Replayed: true and the original status and body.
Proof of work
A vote from a hosting provider's network (needs VOTEE_ASN_DB), or from a network that sent more than
VOTEE_POW_NETWORK_VOTES_PER_MIN votes this minute, must carry a solved challenge. Otherwise the answer is
428 POW_REQUIRED, not stored under the idempotency key, with a fresh challenge:
{ "error": { "code": "POW_REQUIRED", "message": "…" },
"pow": { "challenge": "…", "difficulty": 18, "expires_at": "…" } }
Find a nonce (any string up to 64 characters) such that sha256(challenge + ":" + nonce) starts with difficulty
zero bits, then resend the vote with X-Pow-Challenge: <challenge> and X-Pow-Nonce: <nonce> and the same
Idempotency-Key. A challenge works once and expires after 2 minutes. GET /v1/pow/challenge (no token) returns
one ahead of time.
Vote history
GET /v1/me/votes?campaign_id={id}&limit={1..200}&cursor={next_cursor} — newest first, keyset
pagination: { "votes": [...], "next_cursor": "…" | null }.
Rankings
GET /v1/campaigns/{id}/ranking?kind=live&limit={1..200} (default)
{ "campaign_id": "…", "kind": "LIVE", "source": "redis",
"standings": [ { "rank": 1, "candidate_id": "…", "points": 120, "vote_count": 118, "updated_at": "…" } ] }
Eventually consistent (typically < 1 s); ties share a rank; source is redis or postgres.
Freeze. A campaign with ranking_freeze_seconds
stops showing changes that long before ends_at. From the freeze instant until the official final tally exists, kind=live
answers the ledger as it stood at frozen_at; votes are still accepted and counted:
{ "campaign_id": "…", "kind": "FROZEN", "frozen_at": "…", "computed_at": "…",
"standings": [ { "rank": 1, "candidate_id": "…", "name": "…", "points": 120, "vote_count": 118 } ] }
It is computed once, by the first read after the closing barrier (frozen_at + 10 s, longer than the 5 s vote
transaction timeout, so every vote accepted before frozen_at has committed). Until then the answer is
503 RANKING_FREEZING with Retry-After: 10. A token with the AUDITOR or ADMIN role still gets the live ranking.
Extending ends_at moves the freeze; a new frozen ranking is computed for the new instant.
GET /v1/campaigns/{id}/ranking?kind=final — latest final tally version, 404 NOT_FINALIZED
before finalization. With a review_period_seconds the result is provisional until the campaign is CERTIFIED: the
public then gets 409 RESULT_UNDER_REVIEW, and auditors and administrators get it with "official": false. A ranking
freeze lasts until the result is official.
{ "kind": "FINAL", "campaign_id": "…", "campaign_name": "…", "tally_version": 2, "ledger_watermark": 91234, "entry_count": 4120,
"checksum": "e2bb51a0…", "reason": "correction: vote … invalidated: chargeback", "computed_at": "…",
"standings": [ { "rank": 1, "candidate_id": "…", "name": "…", "points": 3, "vote_count": 3 } ] }
campaign_name and the name of each standing come from the campaign snapshot and are absent when the snapshot did not
carry one (a campaign whose last snapshot predates names). The live ranking has them too. A candidate without any
accepted vote is not in the live ranking: take the candidate list from GET /v1/public/campaigns/{id}.
Audit (AUDITOR or ADMIN)
| Endpoint | Returns |
|---|---|
GET /v1/audit/campaigns/{id}/tallies | { "campaign_id", "versions": [ { "tally_version", "ledger_watermark", "entry_count", "checksum", "reason", "computed_at" } ] }, oldest first: every correction is a version with its reason |
GET /v1/audit/campaigns/{id}/invalidations?after=&limit= | { "campaign_id", "invalidations": [ { "ledger_entry_id", "vote_id", "candidate_id", "points_delta", "reason", "invalidated_at" } ], "next_after" } in ledger order; limit 1–1000 (default 100); reason is absent for invalidations recorded before reasons were stored |
| GET /v1/audit/campaigns/{id}/cases?status= | the fraud review queue: { "campaign_id", "cases": [ { "case_id", "rule", "subject_key", "score", "evidence", "member_count", "status", "decided_by", "decision_reason", "decided_at", "invalidated_votes", … } ] }, highest score first; status is OPEN, CONFIRMED or DISMISSED |
401 UNAUTHENTICATED, 403 AUDITOR_REQUIRED. Auditors may also GET campaigns and their transitions on
campaign-service; they change nothing.
Remaining quota
GET /v1/campaigns/{id}/me/quota — Authorization: Bearer <token>. What the token subject may still vote, free and
paid, in the current quota period (the period is computed like a vote does it: the campaign timezone's local day, or the
whole campaign), and when it resets:
{ "campaign_id": "…", "status": "ACTIVE", "accepting_votes": true, "min_identity": "ACCOUNT", "identity_allowed": true,
"quota_period": "DAY", "period_start": "2026-12-01T17:00:00Z", "resets_at": "2026-12-02T17:00:00Z",
"max_votes_per_request": 5,
"free": { "limit": 10, "used": 4, "remaining": 6, "per_candidate_limit": 3,
"candidates": [ { "candidate_id": "…", "used": 3, "remaining": 0 } ] },
"paid": { "price": 100, "points_per_vote": 10, "limit": 50, "used": 0, "remaining": 50 } }
paid is present only when the campaign sells paid votes (limit and remaining are null without a cap);
per_candidate_limit and candidates only when the rules cap free votes per candidate. The numbers are advice, not a
reservation: a vote can still be rejected with QUOTA_EXCEEDED, counters never go down when a vote is invalidated, and
buying votes does not change the free allowance. 404 CAMPAIGN_NOT_FOUND for an unknown campaign.
Health
GET /healthz (process), GET /readyz (database).
Internal APIs and the internal token
Every /internal/** endpoint, on the Spring services and on voting-api's internal listener, requires the header
X-Votee-Internal-Token with the value of VOTEE_INTERNAL_TOKEN (votee.internal.token). A missing or wrong value is
401 INTERNAL_TOKEN_REQUIRED. A Spring service and voting-api refuse to start without the token. /healthz and
/metrics of voting-api's internal listener stay open for probes and scrapers; /actuator/** of the Spring services
is not behind the token. The gateway does not forward /internal/** and cannot add the header, so these calls come
from other services or from operators on the private network. make run-*, make stack-up and the smoke test use the
development value dev-internal-token-change-me unless VOTEE_INTERNAL_TOKEN is set; change it outside development.
Voting Core internal API (127.0.0.1:8090; 0.0.0.0:8090 on the private network of make stack-up)
| Endpoint | Caller | Purpose |
|---|---|---|
GET /internal/v1/vote-attempts/{attempt_id}/resolution | credit-service | { "outcome": "CAPTURE" | "RELEASE" | "PENDING", "reason": … } for an expired reservation |
POST /internal/v1/votes/{vote_id}/invalidate { "reason": … } | operators | correction; returns the ledger entry and, if finalized, the new tally version |
GET /internal/v1/integrity/campaigns/{campaign_id}/cases?status= | operators | the review queue |
POST /internal/v1/integrity/campaigns/{campaign_id}/scan | operators | run the detectors now; { "open_cases_touched" } |
GET /internal/v1/integrity/cases/{case_id} | operators | a case with its evidence and members |
POST /internal/v1/integrity/cases/{case_id}/decision { "decision": "CONFIRM" | "DISMISS", "reason", "decided_by" } | operators | CONFIRM invalidates every vote of the members in the campaign (one tally version per 500 votes; no credit refund) and closes the case; repeat a call that failed halfway; 409 CASE_ALREADY_DECIDED with the case once decided |
PUT /internal/v1/campaign-snapshots/{campaign_id} | development only (VOTEE_INTERNAL_API_ENABLED=true) | seed a snapshot without campaign-service (used by voting-load) |
GET /metrics | Prometheus |
campaign-service (:8081)
Public pages (no token)
What anyone may see of a campaign. A campaign still in DRAFT and a CANCELLED one do not exist here (404, and they
are never listed). Nothing of the administrator view (versions, checksums, audit actors) is exposed.
| Endpoint | Effect |
|---|---|
GET /v1/public/campaigns?status=&limit=&cursor= | newest start first, keyset-paged like GET /v1/me/votes: { "campaigns": [ … ], "next_cursor": "…" | null }. status may repeat (any of SCHEDULED, ACTIVE, PAUSED, ENDED, FINALIZING, FINALIZED, CERTIFIED); limit 1–200 (default 50). A summary has campaign_id, name, status, starts_at, ends_at, timezone, candidate_count, paid_voting, min_identity |
GET /v1/public/campaigns/{id} | campaign_id, name, status, window, timezone, rules (the rule set, min_identity included) and candidates (candidate_id, name, status, position) |
Administration (token with the ADMIN role)
| Endpoint | Effect |
|---|---|
POST /v1/campaigns | create a DRAFT: name, starts_at, ends_at, timezone, rules, candidates (names) |
GET /v1/campaigns/{id} | campaign with candidates, rules, versions, final tally version/checksum |
GET /v1/campaigns/{id}/transitions | audit trail |
POST /v1/campaigns/{id}/schedule · pause · resume | lifecycle commands |
POST /v1/campaigns/{id}/end { "reason" } | end voting now (audited) |
POST /v1/campaigns/{id}/cancel { "reason" } | DRAFT, or SCHEDULED before start |
PUT /v1/campaigns/{id}/window { "starts_at", "ends_at" } | reschedule before start; afterwards only extend ends_at |
PUT /v1/campaigns/{id}/rules { "rules" } | new rule set version |
POST /v1/campaigns/{id}/candidates { "name" } | before start only |
POST /v1/campaigns/{id}/candidates/{candidate_id}/withdraw | until voting closes |
Rules: free_votes_per_period, free_votes_per_candidate_per_period (optional), quota_period
(DAY in the campaign timezone or CAMPAIGN), max_votes_per_request, free_vote_points,
paid_vote_price (0 disables paid votes), paid_vote_points, paid_votes_per_period
(optional cap), min_identity (optional access policy), min_account_age_seconds (optional, 0–31536000: how old
an account must be to vote; needs min_identity above GUEST), ranking_freeze_seconds (optional, 0–2592000: the
public ranking freezes that long before ends_at), review_period_seconds (optional, 0–2592000: the final result
stays provisional that long after the first final tally, then the scheduler moves the campaign to CERTIFIED).
Every endpoint needs an access token with the ADMIN
role (401 UNAUTHENTICATED, 403 ADMIN_REQUIRED), except that a token with the AUDITOR role may make GET
requests; the token subject is recorded in the audit trail.
Errors: 400 INVALID_REQUEST, 409 INVALID_STATE, 409 CONCURRENT_MODIFICATION,
404 NOT_FOUND. ACTIVE/ENDED/FINALIZING transitions are driven by the scheduler.
min_identity is GUEST | ACCOUNT | VERIFIED_ACCOUNT. A rule set with paid_vote_price > 0 and
min_identity = GUEST is rejected with 400 INVALID_REQUEST; the default for paid campaigns is ACCOUNT.
Vote packages
Packages are campaign configuration; payment keeps no price catalogue of its own. Prices are minor currency units.
Only a campaign with paid_vote_price > 0 sells packages. The admin endpoints need the ADMIN role.
| Endpoint | Effect |
|---|---|
POST /v1/campaigns/{id}/packages { "name", "price", "currency", "credits" } | define a package; 201 { "package_id", "campaign_id", "name", "price", "currency", "credits", "active" }. price and credits are positive, currency is a 3-letter upper-case code, 400 INVALID_REQUEST otherwise |
PUT /v1/campaigns/{id}/packages/{package_id} { "name", "price", "currency", "credits", "active" } | change a package (active: false takes it off sale); orders already created keep the price they were created at |
GET /v1/campaigns/{id}/packages | all packages of the campaign |
GET /internal/v1/campaigns/{id}/packages[/{package_id}] | payment-service only: the package(s), with campaign_status for one package; network-restricted |
credit-service (:8082)
Balances are per (account, campaign); credit bought
for one campaign can never be spent in another. available >= 0 and reserved >= 0 always hold.
| Endpoint | Effect |
|---|---|
GET /v1/accounts/{account_id}/campaigns/{campaign_id} | { "account_id", "campaign_id", "available", "reserved" }; 404 if the account has no balance in that campaign |
GET /v1/accounts/{account_id}/campaigns/{campaign_id}/ledger | every balance change of that balance |
POST /internal/v1/reservations { "reservation_key", "account_id", "campaign_id", "amount", "ttl_seconds" } | Voting Core only; 201 new, 200 existing, 409 INSUFFICIENT_CREDIT, 422 RESERVATION_KEY_REUSED (same key, other account, campaign or amount), 400 without campaign_id |
GET /internal/v1/reservations/{id} | reservation state |
POST /internal/v1/refunds { "order_id" } | Refund of the unspent credit of a paid order (called by payment-service). 200 { "order_id", "account_id", "campaign_id", "granted", "refunded", "created" }; 404 GRANT_NOT_FOUND |
The account id is the voter's actor id.
Refunds
The order id is the payment reference of the grant (payment:<order_id>). The refund is
min(credits granted by the order, current available balance): reserved and spent credit is not
refundable, and the debit is one conditional statement, so the balance never goes negative. Each order has
one refund decision, recorded as a REFUND ledger entry with reference refund:<order_id>: repeating the
call (or a concurrent call) returns the same amount with created: false, and credit released later is not
refunded retroactively. refunded may be 0 when everything was spent. Which grant a spend is attributed to
(FIFO per account and campaign) is decided but not needed by the formula above, so no code attributes spends.
Grants
There is no public grant endpoint. credit-service consumes payment.PaymentConfirmed.v1 {order_id, account_id, campaign_id, credits, amount, currency} from votee.payment.payment-events.v1 and performs
a GRANT with reference payment:<order_id>. The ledger's unique (entry_type, reference) makes redelivery a
no-op. An event that cannot be applied (zero credits, or an order id already granted with different credit) goes to
the dead-letter topic votee.payment.payment-events.v1.dlq.
identity-service (:8083)
| Endpoint | Effect |
|---|---|
POST /v1/accounts { "email", "password" } | register an account at level ACCOUNT with an unverified email and mail it a six-digit code; 201 { "id", "email", "identity_level", "email_verified": false }, 409 EMAIL_TAKEN (also for another spelling of the same mailbox, e.g. Gmail dots and +tags), 400 EMAIL_DOMAIN_NOT_ALLOWED (disposable domain), 400 INVALID_REQUEST (password shorter than 10 characters or longer than 72 bytes, malformed email). A registration left unverified for 24 h is replaced by a new registration of the same mailbox |
POST /v1/accounts/email-verification { "email", "code" } | 204: the email is verified and the account can log in. 400 INVALID_VERIFICATION_CODE for a wrong, expired or used code, after 5 wrong guesses, and for an unknown email. Only the newest code counts |
POST /v1/accounts/email-verification/resend { "email" } | always 202 { "expires_in" }; sends a new code only if an unverified account exists and the limits allow it (60 s cooldown, 5 a day) |
POST /v1/auth/login { "email", "password" } | { "access_token", "token_type": "Bearer", "expires_in", "refresh_token", "actor_type", "identity_level" }; 401 INVALID_CREDENTIALS is the same for a wrong password, an unknown email and an account locked after 5 attempts without a success (15 min); 403 EMAIL_NOT_VERIFIED when the password is right but the email is not verified. Any spelling of the mailbox logs in |
POST /v1/auth/refresh { "refresh_token" } | a new token pair. Refresh tokens are single-use and rotate within a family; presenting a spent token revokes the family. 401 INVALID_REFRESH_TOKEN |
POST /v1/auth/logout { "refresh_token" } | revokes the refresh token's family (204) |
POST /v1/auth/guest | a guest access token (no refresh token) and a votee_guest httpOnly, SameSite=Lax cookie. Sending the cookie back returns the same guest; an id that was never issued is ignored |
GET /v1/accounts/me | the caller's subject, actor type, level, email, roles, email_verified and phone (masked, +84******678) (needs a token) |
POST /v1/accounts/me/phone { "phone" } | accounts only (403 ACCOUNT_REQUIRED for a guest): texts a code to a Vietnamese mobile number (0912345678, 84… or +84…); 202 { "expires_in" }. 409 PHONE_UNAVAILABLE if another account holds it or released it less than 30 days ago; 429 VERIFICATION_RATE_LIMITED with Retry-After (60 s cooldown, 5 a day per account, 5 a day per number, a daily SMS budget) |
POST /v1/accounts/me/phone/verification { "code" } | binds the number and raises the account to VERIFIED_ACCOUNT; returns the profile. Tokens carry the new level from the next refresh. 400 INVALID_VERIFICATION_CODE, 409 PHONE_UNAVAILABLE (lost a race for the number) |
DELETE /v1/accounts/me/phone | unbinds the number (it enters a 30-day quarantine for other accounts) and lowers the account to ACCOUNT; returns the profile |
GET /.well-known/jwks.json | public keys of the active key and of retired keys still inside their overlap window |
POST /internal/v1/keys/rotate | operators: new active key; the old one stays in the JWKS for key-overlap |
PUT /internal/v1/accounts/{id}/access { "identity_level", "roles" } | operators: set ACCOUNT / VERIFIED_ACCOUNT and roles (["ADMIN"], ["AUDITOR"]) |
/internal/** needs the internal token (see below). Passwords are
hashed with bcrypt, refresh tokens and verification codes are stored only as SHA-256 hashes. make run-identity creates the
development administrator admin@votee.local and sends mail to Mailpit (http://localhost:18025); without
votee.identity.mail.provider=smtp codes are written to the log. Text messages always go to the log (fake SMS
provider). The limits are configuration under votee.identity.{verification,login,registration}.
payment-service (:8084)
Buyer endpoints need an account-level token (401 UNAUTHENTICATED, guests get 403 ACCOUNT_REQUIRED); the token
subject is the account, and an order is visible only to its owner (404 ORDER_NOT_FOUND otherwise).
| Endpoint | Effect |
|---|---|
GET /v1/campaigns/{campaign_id}/packages | packages on sale: { "package_id", "name", "price", "currency", "credits" } |
POST /v1/orders { "campaign_id", "package_id" } | creates a PENDING order that snapshots the package price, currency and credits; 201 { "order_id", "campaign_id", "package_id", "kind": "PURCHASE", "state", "amount", "currency", "credits", "refunded_credits", "checkout_url", "checkout_method", "checkout_fields", "created_at" }. The buyer goes to checkout_url: with checkout_method GET (fake provider) by navigating, with POST (SePay) by submitting checkout_fields as a form in the order given (SePay verifies the signature over the fields in that order), which carries the provider's signature. 404 PACKAGE_NOT_FOUND, 409 PACKAGE_UNAVAILABLE (not on sale), 409 CAMPAIGN_CLOSED (ended, finalizing, finalized or cancelled), 409 PURCHASE_BLOCKED while a chargeback debt is open for the account and campaign (the error carries debt_id, amount, currency) |
GET /v1/orders/{order_id} | the order |
GET /v1/accounts/me/debts | the account's chargeback debts: { "debt_id", "campaign_id", "order_id", "amount", "currency", "state": "OPEN" | "SETTLED" } |
POST /v1/debts/{debt_id}/settlement | creates (or returns the pending) DEBT_SETTLEMENT order for the debt amount; it grants no credit, and when it is paid the debt is SETTLED and purchases are possible again. 404 DEBT_NOT_FOUND, 400 if already settled |
POST /v1/webhooks/{provider} | provider callback, authenticated by the provider's own check. Fake provider: header X-Fake-Signature: sha256=<hmac of the raw body>, body { "event_id", "type": "payment.succeeded" | "payment.failed" | "payment.disputed", "order_id", "occurred_at" }. SePay (provider = sepay): header X-Secret-Key equal to the IPN secret, body = SePay's IPN (ORDER_PAID, TRANSACTION_VOID). 200 { "status": "applied" | "duplicate" | "ignored" | "amount_mismatch" }; amount_mismatch records a payment for another amount and confirms nothing. 401 INVALID_SIGNATURE, 400 for a malformed body, 404 UNKNOWN_PROVIDER or ORDER_NOT_FOUND (the event id is not kept, so the provider's retry can succeed) |
POST /internal/v1/orders/{order_id}/refund | operators: refunds the unspent credit of a PAID purchase through credit-service (min(granted, available), idempotent) and marks the order REFUNDED with refunded_credits. 409 INVALID_STATE, 409 GRANT_PENDING while credit-service has not applied the grant |
POST /internal/v1/fake-provider/orders/{order_id}/{succeed|fail|dispute}[?eventId=…] | development only (votee.payment.fake-provider-enabled): plays the provider and delivers a signed webhook through the real intake |
Order states: PENDING → PAID | FAILED, PAID → REFUNDED | DISPUTED. Provider events are delivered at least once
and in any order; the order ends in the same state whatever the arrival order: a success after a failure repairs
it, a failure after a success is ignored, and a dispute that arrives before the success first confirms the payment,
then opens the debt. Every delivery is recorded by (provider, event_id), so a duplicate is a no-op, and
payment.PaymentConfirmed is written to the outbox in the same transaction that marks the order paid. The debt of
a chargeback equals the order amount; the credit that order granted stays, and votes already accepted stand.
Reconciliation (every minute) compares PENDING orders older than 15 minutes with what the provider reports and
applies the answer through the same path; an order the provider never heard of for 24 hours becomes FAILED.
Real settlement with a provider is not in scope.