B2b
Returns null when the caller has no active membership in an approved company. Mirrors storefront getMyB2BContext.
Authorization
better-auth.session_token In: cookie
Response Body
application/json
curl -X GET "https://example.com/api/v1/b2b/context"{}Filters: status, requesterId. Staff role filter (requesterId = self) is applied by the storefront caller — API trusts the incoming filter. Newest first.
Authorization
better-auth.session_token In: cookie
Path Parameters
Response Body
application/json
curl -X GET "https://example.com/api/v1/b2b/string/purchase-requests"[ { "id": "string", "status": "string", "quantity": 0, "unit_price": "string", "note": "string", "review_note": "string", "created_at": "string", "reviewed_at": "string", "order_id": "string", "product_name": "string", "product_image": "string", "variant_name": "string", "requester_name": "string", "requester_email": "string", "reviewer_name": "string", "reviewer_email": "string" }]Authorization
better-auth.session_token In: cookie
Path Parameters
Response Body
application/json
curl -X GET "https://example.com/api/v1/b2b/string/team"[ { "id": "string", "userId": "string", "fullName": "string", "email": "string", "b2bRole": "string", "status": "string", "joinedAt": "string", "createdAt": "string" }]Staff role sees only their own pending count; approvers/admin/finance see company-wide. Role inferred from caller context.
Authorization
better-auth.session_token In: cookie
Path Parameters
Response Body
application/json
curl -X GET "https://example.com/api/v1/b2b/string/dashboard-stats"{}Resolves order IDs via purchase_requests.order_id. Optional ?status filter. Includes per-parent subOrderCount aggregated in one round-trip.
Authorization
better-auth.session_token In: cookie
Path Parameters
Response Body
application/json
curl -X GET "https://example.com/api/v1/b2b/string/orders"[ { "id": "string", "shortId": "string", "status": "string", "totalAmount": "string", "subOrderCount": 0, "requestedBy": "string", "createdAt": "string" }]Authorization
better-auth.session_token In: cookie
Path Parameters
Response Body
application/json
curl -X GET "https://example.com/api/v1/b2b/string/company-details"{}Pending/rejected companies always return complete=true (banner only applies post-approval).
Authorization
better-auth.session_token In: cookie
Path Parameters
Response Body
application/json
curl -X GET "https://example.com/api/v1/b2b/string/tax-completeness"{ "complete": true, "missingTin": true, "missingMsic": true}Staff role filter (requesterId = self) applied from caller context. Default limit 10, bounded 1..50.
Authorization
better-auth.session_token In: cookie
Path Parameters
Response Body
application/json
curl -X GET "https://example.com/api/v1/b2b/string/recent-requests"[ { "id": "string", "product_name": "string", "quantity": 0, "requester_name": "string", "status": "string", "created_at": "string" }]totalSpendThisMonth, pendingPayments (approved awaiting checkout), approvedThisMonth, teamSize.
Authorization
better-auth.session_token In: cookie
Path Parameters
Response Body
application/json
curl -X GET "https://example.com/api/v1/b2b/string/finance-stats"{}Authorization
better-auth.session_token In: cookie
Path Parameters
Response Body
application/json
curl -X GET "https://example.com/api/v1/b2b/string/monthly-spend"[ { "month": "string", "total_spend": "string" }]Authorization
better-auth.session_token In: cookie
Path Parameters
Response Body
application/json
curl -X GET "https://example.com/api/v1/b2b/string/procurement-history"[ { "id": "string", "status": "string", "quantity": 0, "unit_price": "string", "product_name": "string", "product_image": "string", "variant_name": "string", "requester_name": "string", "order_id": "string", "updated_at": "string", "created_at": "string" }]Includes product.store_id + weight_kg for the order RPC; requester name is joined.
Authorization
better-auth.session_token In: cookie
Path Parameters
Response Body
application/json
curl -X GET "https://example.com/api/v1/b2b/string/approved-for-checkout"[ { "id": "string", "quantity": 0, "unit_price": "string", "product_id": "string", "variant_id": "string", "product_name": "string", "product_image": "string", "variant_name": "string", "store_id": "string", "store_name": "string", "weight_kg": 0, "requester_name": "string", "created_at": "string" }]Caller must be an active member of the company that owns this order (resolved via purchase_requests). Returns null when the order does not belong to the caller company — no existence leak. Shape mirrors customer order detail plus purchaseRequestMeta.
Authorization
better-auth.session_token In: cookie
Path Parameters
Response Body
application/json
curl -X GET "https://example.com/api/v1/b2b/orders/string"{}Caller must belong to the owning company (404 otherwise, no existence leak).
Authorization
better-auth.session_token In: cookie
Path Parameters
Response Body
application/json
curl -X GET "https://example.com/api/v1/b2b/purchase-requests/string"{}Customer-only. Creates b2b_companies row in pending. SSM cert upload deferred — caller posts JSON metadata; cert can be uploaded out-of-band via Supabase storage until a multipart endpoint is added.
Authorization
better-auth.session_token In: cookie
Request Body
application/json
TypeScript Definitions
Use the request body type in TypeScript.
Response Body
curl -X POST "https://example.com/api/v1/b2b/companies" \ -H "Content-Type: application/json" \ -d '{ "name": "string", "ssm_number": "string", "industry": "string", "address_line1": "string", "city": "string", "state": "string", "postcode": "string", "contact_name": "string", "contact_phone": "string", "contact_email": "user@example.com" }'Active B2B member. Server-side price snapshot (variant override > base price). Phase-17 tax-info gate (TIN + MSIC required).
Authorization
better-auth.session_token In: cookie
Request Body
application/json
TypeScript Definitions
Use the request body type in TypeScript.
Response Body
curl -X POST "https://example.com/api/v1/b2b/purchase-requests" \ -H "Content-Type: application/json" \ -d '{ "productId": "dcd53ddb-8104-4e48-8cc0-5df1088c6113", "quantity": 1 }'Authorization
better-auth.session_token In: cookie
Path Parameters
Response Body
curl -X POST "https://example.com/api/v1/b2b/purchase-requests/string/approve"Authorization
better-auth.session_token In: cookie
Path Parameters
Request Body
application/json
TypeScript Definitions
Use the request body type in TypeScript.
Response Body
curl -X POST "https://example.com/api/v1/b2b/purchase-requests/string/reject" \ -H "Content-Type: application/json" \ -d '{ "note": "string" }'Phase-17 TIN+MSIC required. TIN is validated against TIN_REGEX and normalized.
Authorization
better-auth.session_token In: cookie
Path Parameters
Request Body
application/json
TypeScript Definitions
Use the request body type in TypeScript.
Response Body
curl -X PATCH "https://example.com/api/v1/b2b/companies/string" \ -H "Content-Type: application/json" \ -d '{ "companyId": "8bb73d03-06b4-47c7-80c7-59301f770eda", "name": "string", "addressLine1": "string", "city": "string", "state": "string", "postcode": "string", "contactName": "string", "contactPhone": "string", "contactEmail": "user@example.com", "industry": "string", "tin": "string", "msicCode": "string" }'