You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
All endpoints are Next.js App Router API Routes located under app/api/.
Authentication Schemes
VeriHealth uses two authentication mechanisms depending on the endpoint:
Scheme
Mechanism
Details
Admin Cookie
admin_token HttpOnly cookie
Set by POST /api/admin/auth. Cookie value is base64(timestamp:ADMIN_SECRET). Validated at the Edge by proxy.ts.
Deploy Key
x-deploy-key request header
Must equal the DEPLOY_SECRET environment variable. Required only for contract deployment.
Wallet Address
Request body / query param
The caller's Midnight public key hex, used to look up issuer/patient records. No server-side signing verification — rely on on-chain assertions in the ZK circuit.
Public
None
Endpoint is open. Rate limiting or API key management may apply in production.
Important
All /admin routes and /api/admin/* routes (except /api/admin/auth) are additionally protected by the Edge Middleware in proxy.ts. Requests without a valid admin_token cookie will receive 401 Unauthorized before reaching the route handler.
Endpoints
Admin — Authentication
Method
Endpoint
Auth
Description
POST
/api/admin/auth
Public
Login to admin portal. Body: { password: string }. Sets admin_token HttpOnly cookie on success. Returns { ok: true }.
GET
/api/admin/auth
Cookie
Verify current admin session. Returns { authenticated: true } if the cookie is valid.
DELETE
/api/admin/auth
Cookie
Logout. Clears the admin_token cookie. Returns { ok: true }.
Admin — Issuer Management
Method
Endpoint
Auth
Description
GET
/api/admin/issuers
Admin Cookie
List all issuers in the database with their registryStatus (PENDING, APPROVED, REVOKED).
POST
/api/admin/approve-issuer/db
Admin Cookie
Approve a pending issuer. Body: { issuerId: string }. Updates DB status to APPROVED and calls register_issuer on-chain. Returns { txHash }.
Admin — Deployment
Method
Endpoint
Auth
Description
POST
/api/admin/deploy
Admin Cookie + x-deploy-key header
Deploy the verihealth-v2.compact ZK contract to Midnight PREPROD. Body: { userAddress: string }. Dynamically imports the Midnight JS SDK server-side to avoid bundling Node.js-only modules on the client. Returns { contractAddress: string }.
Caution
This endpoint performs an irreversible on-chain deployment. Protect DEPLOY_SECRET carefully — do not expose it in client-side code, logs, or public repositories.
Admin — Audit
Method
Endpoint
Auth
Description
GET
/api/admin/audit
Admin Cookie
Retrieve AuditLogEntry records in descending timestamp order. Supports optional query params: ?limit=<n>&actorType=<type>&actionType=<action>.
Contracts — On-Chain Interactions
Method
Endpoint
Auth
Description
POST
/api/contract/issue
Issuer wallet
Issue a health credential on-chain. Body: { issuerAddress: string, patientPublicKey: string, credentialTypeId: string, commitmentHash: string }. Calls issue_credential on the deployed contract. Returns { txHash, onChainTypeId }.
Credentials — Patient
Method
Endpoint
Auth
Description
GET
/api/credentials
Wallet address
Retrieve all IssuedCredential records for the authenticated patient. Query param: ?walletAddress=<hex>. Returns credential list with status, type, issue/expiry dates.
POST
/api/credentials/[id]/revoke
Issuer wallet
Revoke a specific credential by its DB id. Body: { issuerAddress: string }. Validates caller is the original issuer, calls revoke_credential on-chain, updates DB status to REVOKED. Returns { txHash }.
Credential Types — Catalogue
Method
Endpoint
Auth
Description
GET
/api/credential-types
Public
List all CredentialType records including their on-chain typeId (Uint<32>), name, and description.
Send a message to the AI support chatbot (Groq API, model: openai/gpt-oss-20b). Body: { messages: { role: string, content: string }[] }. Returns a streamed text response.