Plixstar
API Reference

B2b

GET
/api/v1/b2b/context

Returns null when the caller has no active membership in an approved company. Mirrors storefront getMyB2BContext.

Authorization

better-auth.session_token
better-auth.session_token<token>

In: cookie

Response Body

application/json

curl -X GET "https://example.com/api/v1/b2b/context"
{}
GET
/api/v1/b2b/{companyId}/purchase-requests

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
better-auth.session_token<token>

In: cookie

Path Parameters

companyId*string

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"  }]
GET
/api/v1/b2b/{companyId}/team

Authorization

better-auth.session_token
better-auth.session_token<token>

In: cookie

Path Parameters

companyId*string

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"  }]
GET
/api/v1/b2b/{companyId}/dashboard-stats

Staff role sees only their own pending count; approvers/admin/finance see company-wide. Role inferred from caller context.

Authorization

better-auth.session_token
better-auth.session_token<token>

In: cookie

Path Parameters

companyId*string

Response Body

application/json

curl -X GET "https://example.com/api/v1/b2b/string/dashboard-stats"
{}
GET
/api/v1/b2b/{companyId}/orders

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
better-auth.session_token<token>

In: cookie

Path Parameters

companyId*string

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"  }]
GET
/api/v1/b2b/{companyId}/company-details

Authorization

better-auth.session_token
better-auth.session_token<token>

In: cookie

Path Parameters

companyId*string

Response Body

application/json

curl -X GET "https://example.com/api/v1/b2b/string/company-details"
{}
GET
/api/v1/b2b/{companyId}/tax-completeness

Pending/rejected companies always return complete=true (banner only applies post-approval).

Authorization

better-auth.session_token
better-auth.session_token<token>

In: cookie

Path Parameters

companyId*string

Response Body

application/json

curl -X GET "https://example.com/api/v1/b2b/string/tax-completeness"
{  "complete": true,  "missingTin": true,  "missingMsic": true}
GET
/api/v1/b2b/{companyId}/recent-requests

Staff role filter (requesterId = self) applied from caller context. Default limit 10, bounded 1..50.

Authorization

better-auth.session_token
better-auth.session_token<token>

In: cookie

Path Parameters

companyId*string

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"  }]
GET
/api/v1/b2b/{companyId}/finance-stats

totalSpendThisMonth, pendingPayments (approved awaiting checkout), approvedThisMonth, teamSize.

Authorization

better-auth.session_token
better-auth.session_token<token>

In: cookie

Path Parameters

companyId*string

Response Body

application/json

curl -X GET "https://example.com/api/v1/b2b/string/finance-stats"
{}
GET
/api/v1/b2b/{companyId}/monthly-spend

Authorization

better-auth.session_token
better-auth.session_token<token>

In: cookie

Path Parameters

companyId*string

Response Body

application/json

curl -X GET "https://example.com/api/v1/b2b/string/monthly-spend"
[  {    "month": "string",    "total_spend": "string"  }]
GET
/api/v1/b2b/{companyId}/procurement-history

Authorization

better-auth.session_token
better-auth.session_token<token>

In: cookie

Path Parameters

companyId*string

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"  }]
GET
/api/v1/b2b/{companyId}/approved-for-checkout

Includes product.store_id + weight_kg for the order RPC; requester name is joined.

Authorization

better-auth.session_token
better-auth.session_token<token>

In: cookie

Path Parameters

companyId*string

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"  }]
GET
/api/v1/b2b/orders/{parentId}

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
better-auth.session_token<token>

In: cookie

Path Parameters

parentId*string

Response Body

application/json

curl -X GET "https://example.com/api/v1/b2b/orders/string"
{}
GET
/api/v1/b2b/purchase-requests/{id}

Caller must belong to the owning company (404 otherwise, no existence leak).

Authorization

better-auth.session_token
better-auth.session_token<token>

In: cookie

Path Parameters

id*string

Response Body

application/json

curl -X GET "https://example.com/api/v1/b2b/purchase-requests/string"
{}
POST
/api/v1/b2b/companies

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
better-auth.session_token<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"  }'
Empty
POST
/api/v1/b2b/purchase-requests

Active B2B member. Server-side price snapshot (variant override > base price). Phase-17 tax-info gate (TIN + MSIC required).

Authorization

better-auth.session_token
better-auth.session_token<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  }'
Empty
POST
/api/v1/b2b/purchase-requests/{id}/approve

Authorization

better-auth.session_token
better-auth.session_token<token>

In: cookie

Path Parameters

id*string

Response Body

curl -X POST "https://example.com/api/v1/b2b/purchase-requests/string/approve"
Empty
POST
/api/v1/b2b/purchase-requests/{id}/reject

Authorization

better-auth.session_token
better-auth.session_token<token>

In: cookie

Path Parameters

id*string

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"  }'
Empty
PATCH
/api/v1/b2b/companies/{companyId}

Phase-17 TIN+MSIC required. TIN is validated against TIN_REGEX and normalized.

Authorization

better-auth.session_token
better-auth.session_token<token>

In: cookie

Path Parameters

companyId*string

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"  }'
Empty