Skip to main content

API Documentation & OpenAPI Reference

Complete production API contract covering authentication, catalogs, PKCE grants, size recommendations, webhooks, error codes, and rate limits.

Authentication

Send Authorization: Bearer YOUR_KEY or X-API-Key: YOUR_KEY strictly from backend servers.

Quota & Rate Headers

Inspect X-RateLimit-Remaining, X-UniFit-Quota-Used, and X-Powered-By: UniFit AI.

Error Codes

400 validation, 401/403 consent/auth, 402 trial expired, 429 rate/quota overflow.

1. Authentication & Security Boundaries

Use publishableKey (pk_live_...) strictly in storefront JS/mobile clients and server API keys (uf_live_... / uf_sbx_...) solely on backend servers via Authorization: Bearer or X-API-Key. Never ship secret API keys in client code.

2. Brand Registration & Catalog Sync

Register stores via POST /v1/brands/onboard, manage settings at PATCH /v1/brands/:brandId/settings, create/sync SKUs with POST /v1/products and POST /v1/brands/:brandId/products/import-csv.

3. Product Variants & Size Charts

Upsert SKU inventory & sizes at POST /v1/products/:id/variants, attach garment specs via POST /v1/products/:id/garment-measurements, and manage canonical cm size tables via /v1/brands/:brandId/size-charts.

4. Customer Authorization (PKCE) & Recommendations

Customers approve size access on /auth/authorize with S256 PKCE code challenge. Backend exchanges authorization code at POST /v1/consents/token for a short-lived 15-minute scoped grant, then calls POST /v1/recommendations.

5. Fit Feedback, Webhooks, Error Codes & Rate Limits

Submit post-purchase fit feedback at POST /v1/recommendations/:id/feedback. Verify webhook X-UniFit-Signature (HMAC-SHA256). Handle 400 validation, 401/403 scope, 402 TRIAL_EXPIRED, and 429 rate/quota headers cleanly.

POST /v1/recommendations — Production Contract Examples

Requires scoped OAuth 2.0 + PKCE grantToken and server-side API credentials; never invent client-side fit calculations.

curl -X POST "https://beunifit.in/api/v1/recommendations" \
  -H "Authorization: Bearer uf_sbx_YOUR_SERVER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "productId": "prod_123",
    "variantId": "variant_456",
    "grantToken": "short_lived_pkce_grant_token"
  }'

# Example Production Response:
# {
#   "id": "rec_123",
#   "recommendedSize": "M",
#   "alternativeSize": "S",
#   "confidenceScore": 0.94,
#   "fitMatchLabel": "Regular Fit Match",
#   "zoneBreakdown": [{ "zone": "CHEST", "fitStatus": "IDEAL" }],
#   "poweredBy": "Powered by UniFit AI"
# }