manicanldes-backend/docs/b2b-business-verification-a...

2.8 KiB

B2B business verification (Phase 3A)

Business accounts belong to a merchant organization. Staff manage profiles and manually review submissions. A business account is not a staff user or a separate tenant. A decision records a staff attestation based on the submitted details; this phase does not check a government registry or collect evidence documents.

All routes require a bearer session and are available in Swagger UI under /api/v1/b2b/accounts.

Method Route Permission Purpose
GET /api/v1/b2b/accounts b2b.read List profiles, with limit, offset, and optional search
POST /api/v1/b2b/accounts b2b.manage Create a draft profile
GET /api/v1/b2b/accounts/:id b2b.read Read a profile and its current state
PATCH /api/v1/b2b/accounts/:id b2b.manage Update draft or rejected profile fields
GET /api/v1/b2b/accounts/:id/events b2b.read Read immutable review history
POST /api/v1/b2b/accounts/:id/submit b2b.manage Submit a profile snapshot for review
POST /api/v1/b2b/accounts/:id/decision b2b.verify Approve or reject a pending submission

Create requires code, legalName, tradingName (nullable), registrationNumber, taxIdentifier (nullable), countryCode, contactEmail, contactPhone (nullable), billingLine1, billingCity, billingRegion, and billingPostalCode. Codes and country codes normalize to uppercase; email normalizes to lowercase. The code cannot change after creation. Country plus registration number is unique within an organization.

Submit takes { "idempotencyKey": "<UUID>" }. Decision takes { "decision": "APPROVED", "note": "Registry details checked", "idempotencyKey": "<UUID>" }, where decision can also be REJECTED. A different staff user must decide than the one who submitted. The states are DRAFT → PENDING → VERIFIED, or PENDING → REJECTED → PENDING after correction and resubmission. A submitted or verified profile cannot be edited. Each submission stores a fixed profile snapshot and each decision stores its reviewer and note. Repeating an identical command with the same key returns the original event; reusing the key for different content returns a conflict.

Apply migrations with pnpm db:deploy before starting the updated API. Existing system Owner roles gain the three B2B permissions through the migration; custom roles must be granted them explicitly.