{"openapi":"3.1.0","info":{"title":"AVS Invoice API","version":"1.0.0","description":"Token-authenticated REST API for AVS Invoice, scoped to your organization."},"servers":[{"url":"https://0.0.0.0:3000/api/v1"}],"tags":[{"name":"Identity","description":"Who-am-I, organization membership, the live scope catalog, and OAuth2 token issuance/revocation."},{"name":"Dashboard","description":"Mobile dashboard summaries, built on the same aggregations as the web dashboard."},{"name":"Customers","description":"Customer master records for sales documents."},{"name":"Vendors","description":"Vendor master records for purchase documents."},{"name":"Tax Rates","description":"GST/tax rate presets applied to items and line items."},{"name":"Currencies","description":"Currencies available for multi-currency sales/purchase documents."},{"name":"Payment Terms","description":"Payment-term presets (net days) used by customers and invoices."},{"name":"Accounts","description":"Financial accounts (cash/bank/wallet/etc.) used as payment sources and destinations."},{"name":"Items","description":"Item (product/service) master records, with optional size variants."},{"name":"Item Groups","description":"Hierarchical grouping/category tree for items. Uses the items.* permission scope."},{"name":"Warehouses","description":"Physical/logical stock locations. Managed under the settings.* permission scope."},{"name":"Price Lists","description":"Per-item selling/purchase price overrides, grouped into named lists."},{"name":"Number Series","description":"Auto-numbering configuration (prefix/suffix/padding) per document type."},{"name":"Expenses","description":"Standalone business expenses not tied to a vendor bill."},{"name":"Customer Contacts","description":"Named contacts on a customer record (e.g. for the customer portal). Uses the customers.* scope."},{"name":"Quotes","description":"Sales quotes. Read-only via the API — creation/editing happens in the web app."},{"name":"Sales Orders","description":"Confirmed sales orders. Read-only via the API."},{"name":"Credit Notes","description":"Customer credit notes against invoices. Read-only via the API; uses the invoices.* permission scope."},{"name":"Debit Notes","description":"Vendor debit notes against bills. Read-only via the API; uses the bills.* permission scope."},{"name":"Bills","description":"Vendor bills. Read-only via the API."},{"name":"Purchase Orders","description":"Purchase orders sent to vendors. Read-only via the API."},{"name":"Payments Made","description":"Payments made to vendors, with bill allocations. Read-only via the API."},{"name":"Inventory","description":"Stock-on-hand positions (item variant × warehouse). Read-only via the API."},{"name":"Customer Ledger","description":"Computed running-balance statement per customer (invoices, payments, adjustments). Read-only."},{"name":"Vendor Ledger","description":"Computed running-balance statement per vendor (bills, payments, debit notes). Read-only; uses the reports.read scope."},{"name":"Invoices","description":"Customer invoices — the one fully write-enabled sales document in the API."},{"name":"Payments Received","description":"Payments received from customers, allocated against invoices or customer credit."}],"paths":{"/api/v1/me":{"get":{"summary":"Get the authenticated principal","description":"Returns the user, active organization, role, raw token scopes, and effective permissions (token scopes ∩ role permissions).","responses":{"200":{"description":"Get the authenticated principal","content":{"application/json":{"example":{"success":true,"data":{"user":{"id":"clx2usr001000000000000001","email":"you@example.com","name":"Karthik"},"organization":{"id":"clx2org001000000000000001","name":"AVS Textiles","slug":"avs-textiles"},"role":"ADMIN","tokenType":"oauth","scopes":["invoices","paymentsReceived.read","customers.read"],"effectivePermissions":["invoices.read","invoices.create","invoices.update","invoices.delete","paymentsReceived.read","customers.read"]}}}}},"401":{"description":"Missing bearer token","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"unauthorized"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"unauthorized","message":"Missing bearer token"}}}}}},"security":[],"tags":["Identity"]}},"/api/v1/me/organizations":{"get":{"summary":"List the authenticated user's organizations","description":"Bare array, not paginated — use for an organization switcher.","responses":{"200":{"description":"List the authenticated user's organizations","content":{"application/json":{"example":{"success":true,"data":[{"id":"clx2org001000000000000001","name":"AVS Textiles","slug":"avs-textiles","roleKey":"ADMIN"},{"id":"clx2org002000000000000001","name":"Sunrise Apparel","slug":"sunrise-apparel","roleKey":"VIEWER"}]}}}},"401":{"description":"Missing bearer token","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"unauthorized"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"unauthorized","message":"Missing bearer token"}}}}}},"security":[],"tags":["Identity"]}},"/api/v1/me/organization":{"get":{"summary":"Get the active organization's business profile","description":"The seller info that appears on invoices: name, legal name, GSTIN, address, phone, email, state code, and base currency. Org-scoped via the token only — no request parameter.","responses":{"200":{"description":"Get the active organization's business profile","content":{"application/json":{"example":{"success":true,"data":{"name":"AVS Textiles","legalName":"AVS Textiles Private Limited","gstin":"27AAAAA0000A1Z5","address":"12 Industrial Estate, Sector 5, Navi Mumbai, 400701","phone":"9876500000","email":"accounts@avstextiles.in","stateCode":"27","currency":"INR"}}}}},"401":{"description":"Missing bearer token","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"unauthorized"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"unauthorized","message":"Missing bearer token"}}}}},"404":{"description":"Resource not found","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"not_found"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"not_found","message":"Resource not found"}}}}}},"security":[],"tags":["Identity"]}},"/api/v1/scopes":{"get":{"summary":"Get the live scope catalog","description":"Public — no authentication required. The authoritative, always-current list of group/module/granular scopes.","responses":{"200":{"description":"Get the live scope catalog","content":{"application/json":{"example":{"success":true,"data":{"groups":["read","write","full"],"modules":["customers","quotes","salesOrders","invoices","paymentsReceived","vendors","expenses","purchaseOrders","bills","paymentsMade","items","taxes","currencies","paymentTerms","numberSeries","accounts","priceLists","reports","settings","users","roles","inventory","whatsapp"],"granular":["customers.read","customers.create","customers.update","customers.delete","customers.approve","customers.send","invoices.read","invoices.create","invoices.update","invoices.delete","invoices.approve","invoices.send"]}}}}}},"security":[],"tags":["Identity"]}},"/api/v1/oauth/token":{"post":{"summary":"Issue an OAuth2 token (password or refresh_token grant)","description":"First-party mobile client only — the password grant means sending the end user's own credentials, which is not an appropriate pattern for a third-party integration. Third-party integrations should use a Personal Access Token instead (see Authentication). Response is the raw OAuth2 token payload, not the standard envelope.","responses":{"201":{"description":"Issue an OAuth2 token (password or refresh_token grant)","content":{"application/json":{"example":{"access_token":"avs_at_9x7f2h1kQmZ...","refresh_token":"avs_rt_3jf82hDkqLp...","token_type":"Bearer","expires_in":3600,"scope":"invoices.read paymentsReceived.read customers.read"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"invalid_request"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"invalid_request","message":"Invalid request"}}}}}},"security":[],"requestBody":{"required":true,"content":{"application/x-www-form-urlencoded":{"example":{"grant_type":"password","username":"you@example.com","password":"••••••","client_id":"avs-mobile","scope":"invoices.read customers.read"}}}},"tags":["Identity"]}},"/api/v1/oauth/revoke":{"post":{"summary":"Revoke an OAuth2 access or refresh token","description":"Always returns 200 regardless of whether the token existed (RFC 7009 semantics). Response is not the standard envelope.","responses":{"201":{"description":"Revoke an OAuth2 access or refresh token","content":{"application/json":{"example":{"success":true}}}}},"security":[],"requestBody":{"required":true,"content":{"application/x-www-form-urlencoded":{"example":{"token":"avs_at_9x7f2h1kQmZ..."}}}},"tags":["Identity"]}},"/api/v1/dashboard/receivables":{"get":{"summary":"Get the receivables summary","description":"Total outstanding, overdue amount, and an aging breakdown across open invoices (SENT, PARTIALLY_PAID, OVERDUE).","responses":{"200":{"description":"Get the receivables summary","content":{"application/json":{"example":{"success":true,"data":{"totalOutstanding":245000,"overdueAmount":87000,"aging":[{"bucket":"Current","amount":158000},{"bucket":"1-30d","amount":42000},{"bucket":"31-60d","amount":25000},{"bucket":"61-90d","amount":12000},{"bucket":"90+d","amount":8000}]}}}}},"401":{"description":"Missing bearer token","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"unauthorized"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"unauthorized","message":"Missing bearer token"}}}}},"403":{"description":"Access denied","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"forbidden"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"forbidden","message":"Access denied"}}}}}},"security":[{"bearerAuth":[]}],"tags":["Dashboard"]}},"/api/v1/customers":{"get":{"summary":"List customers","parameters":[{"name":"page","in":"query","required":false,"description":"1-based page number.","schema":{"type":"number","example":1}},{"name":"limit","in":"query","required":false,"description":"Page size, max 200.","schema":{"type":"number","example":50}},{"name":"q","in":"query","required":false,"description":"Free-text search across display name, GSTIN, phone, email.","schema":{"type":"string"}}],"responses":{"200":{"description":"List customers","content":{"application/json":{"example":{"success":true,"data":[{"id":"clx1a2b3c4d5e6f7g8h9i0j1","organizationId":"clx0org000000000000000001","displayName":"Bansal Textiles Pvt Ltd","legalName":"Bansal Textiles Private Limited","email":"accounts@bansaltextiles.in","phone":"9876543210","gstin":"07AAACB1234C1Z5","pan":"AAACB1234C","currencyCode":"INR","paymentTermId":"clxpt00000000000000000001","paymentTermsDays":30,"placeOfSupplyStateCode":"07","billingAddress":{"line1":"12 Nehru Market","line2":"Chandni Chowk","city":"New Delhi","state":"Delhi","stateCode":"07","pincode":"110006","country":"India"},"shippingAddress":null,"openingBalance":15000.5,"notes":"Prefers e-invoices before the 5th of every month.","isActive":true,"tenantOrgId":null,"portalEnabled":false,"portalEnabledAt":null,"createdBy":"clxusr0000000000000000001","updatedBy":"clxusr0000000000000000001","createdAt":"2026-08-01T09:15:00.000Z","updatedAt":"2026-08-20T11:42:00.000Z"}],"meta":{"page":1,"limit":50,"total":1,"hasMore":false}}}}},"401":{"description":"Missing bearer token","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"unauthorized"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"unauthorized","message":"Missing bearer token"}}}}},"403":{"description":"Access denied","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"forbidden"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"forbidden","message":"Access denied"}}}}}},"security":[{"bearerAuth":[]}],"tags":["Customers"]},"post":{"summary":"Create a customer","responses":{"201":{"description":"Create a customer","content":{"application/json":{"example":{"success":true,"data":{"id":"clx1a2b3c4d5e6f7g8h9i0j1","organizationId":"clx0org000000000000000001","displayName":"Bansal Textiles Pvt Ltd","legalName":"Bansal Textiles Private Limited","email":"accounts@bansaltextiles.in","phone":"9876543210","gstin":"07AAACB1234C1Z5","pan":"AAACB1234C","currencyCode":"INR","paymentTermId":"clxpt00000000000000000001","paymentTermsDays":30,"placeOfSupplyStateCode":"07","billingAddress":{"line1":"12 Nehru Market","line2":"Chandni Chowk","city":"New Delhi","state":"Delhi","stateCode":"07","pincode":"110006","country":"India"},"shippingAddress":null,"openingBalance":15000.5,"notes":"Prefers e-invoices before the 5th of every month.","isActive":true,"tenantOrgId":null,"portalEnabled":false,"portalEnabledAt":null,"createdBy":"clxusr0000000000000000001","updatedBy":"clxusr0000000000000000001","createdAt":"2026-08-01T09:15:00.000Z","updatedAt":"2026-08-20T11:42:00.000Z"}}}}},"401":{"description":"Missing bearer token","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"unauthorized"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"unauthorized","message":"Missing bearer token"}}}}},"403":{"description":"Access denied","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"forbidden"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"forbidden","message":"Access denied"}}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"validation_error"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"validation_error","message":"Validation failed"}}}}}},"security":[{"bearerAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$schema":"https://json-schema.org/draft/2020-12/schema","type":"object","properties":{"displayName":{"type":"string","minLength":1,"maxLength":191},"legalName":{"anyOf":[{"type":"string","maxLength":191},{"type":"string","const":""}]},"email":{"anyOf":[{"type":"string","format":"email","pattern":"^(?!\\.)(?!.*\\.\\.)([A-Za-z0-9_'+\\-\\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\\-]*\\.)+[A-Za-z]{2,}$"},{"type":"string","const":""}]},"phone":{"anyOf":[{"type":"string","maxLength":30},{"type":"string","const":""}]},"gstin":{"anyOf":[{"type":"string","pattern":"^[0-9A-Z]{15}$"},{"type":"string","const":""}]},"pan":{"anyOf":[{"type":"string","pattern":"^[A-Z]{5}[0-9]{4}[A-Z]$"},{"type":"string","const":""}]},"currencyCode":{"default":"INR","type":"string","minLength":3,"maxLength":3},"paymentTermId":{"anyOf":[{"type":"string","maxLength":30},{"type":"string","const":""}]},"priceListId":{"anyOf":[{"type":"string","maxLength":30},{"type":"string","const":""}]},"salespersonId":{"type":"string","maxLength":30},"placeOfSupplyStateCode":{"anyOf":[{"type":"string","minLength":2,"maxLength":2},{"type":"string","const":""}]},"openingBalance":{"default":0,"type":"number","minimum":0},"billingAddress":{"type":"object","properties":{"line1":{"type":"string","maxLength":255},"line2":{"type":"string","maxLength":255},"city":{"type":"string","maxLength":100},"state":{"type":"string","maxLength":100},"stateCode":{"type":"string","minLength":2,"maxLength":2},"pincode":{"type":"string","maxLength":10},"country":{"type":"string","maxLength":100}}},"shippingAddress":{"type":"object","properties":{"line1":{"type":"string","maxLength":255},"line2":{"type":"string","maxLength":255},"city":{"type":"string","maxLength":100},"state":{"type":"string","maxLength":100},"stateCode":{"type":"string","minLength":2,"maxLength":2},"pincode":{"type":"string","maxLength":10},"country":{"type":"string","maxLength":100}}},"notes":{"anyOf":[{"type":"string","maxLength":2000},{"type":"string","const":""}]}},"required":["displayName"]},"example":{"displayName":"Bansal Textiles Pvt Ltd","email":"accounts@bansaltextiles.in","gstin":"07AAACB1234C1Z5","currencyCode":"INR"}}}},"tags":["Customers"]}},"/api/v1/customers/{id}":{"get":{"summary":"Get a customer","parameters":[{"name":"id","in":"path","required":true,"description":"Customer ID.","schema":{"type":"string","example":"clx1a2b3c4d5e6f7g8h9i0j1"}}],"responses":{"200":{"description":"Get a customer","content":{"application/json":{"example":{"success":true,"data":{"id":"clx1a2b3c4d5e6f7g8h9i0j1","organizationId":"clx0org000000000000000001","displayName":"Bansal Textiles Pvt Ltd","legalName":"Bansal Textiles Private Limited","email":"accounts@bansaltextiles.in","phone":"9876543210","gstin":"07AAACB1234C1Z5","pan":"AAACB1234C","currencyCode":"INR","paymentTermId":"clxpt00000000000000000001","paymentTermsDays":30,"placeOfSupplyStateCode":"07","billingAddress":{"line1":"12 Nehru Market","line2":"Chandni Chowk","city":"New Delhi","state":"Delhi","stateCode":"07","pincode":"110006","country":"India"},"shippingAddress":null,"openingBalance":15000.5,"notes":"Prefers e-invoices before the 5th of every month.","isActive":true,"tenantOrgId":null,"portalEnabled":false,"portalEnabledAt":null,"createdBy":"clxusr0000000000000000001","updatedBy":"clxusr0000000000000000001","createdAt":"2026-08-01T09:15:00.000Z","updatedAt":"2026-08-20T11:42:00.000Z"}}}}},"401":{"description":"Missing bearer token","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"unauthorized"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"unauthorized","message":"Missing bearer token"}}}}},"403":{"description":"Access denied","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"forbidden"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"forbidden","message":"Access denied"}}}}},"404":{"description":"Resource not found","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"not_found"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"not_found","message":"Resource not found"}}}}}},"security":[{"bearerAuth":[]}],"tags":["Customers"]},"patch":{"summary":"Update a customer","description":"PATCH validates against the full customer schema (same as create) — displayName is required in every update, not just changed fields.","parameters":[{"name":"id","in":"path","required":true,"description":"Customer ID.","schema":{"type":"string","example":"clx1a2b3c4d5e6f7g8h9i0j1"}}],"responses":{"200":{"description":"Update a customer","content":{"application/json":{"example":{"success":true,"data":{"id":"clx1a2b3c4d5e6f7g8h9i0j1","organizationId":"clx0org000000000000000001","displayName":"Bansal Textiles Pvt Ltd","legalName":"Bansal Textiles Private Limited","email":"accounts@bansaltextiles.in","phone":"9876543210","gstin":"07AAACB1234C1Z5","pan":"AAACB1234C","currencyCode":"INR","paymentTermId":"clxpt00000000000000000001","paymentTermsDays":30,"placeOfSupplyStateCode":"07","billingAddress":{"line1":"12 Nehru Market","line2":"Chandni Chowk","city":"New Delhi","state":"Delhi","stateCode":"07","pincode":"110006","country":"India"},"shippingAddress":null,"openingBalance":15000.5,"notes":"Prefers e-invoices before the 5th of every month.","isActive":true,"tenantOrgId":null,"portalEnabled":false,"portalEnabledAt":null,"createdBy":"clxusr0000000000000000001","updatedBy":"clxusr0000000000000000001","createdAt":"2026-08-01T09:15:00.000Z","updatedAt":"2026-08-20T11:42:00.000Z"}}}}},"401":{"description":"Missing bearer token","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"unauthorized"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"unauthorized","message":"Missing bearer token"}}}}},"403":{"description":"Access denied","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"forbidden"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"forbidden","message":"Access denied"}}}}},"404":{"description":"Resource not found","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"not_found"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"not_found","message":"Resource not found"}}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"validation_error"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"validation_error","message":"Validation failed"}}}}}},"security":[{"bearerAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$schema":"https://json-schema.org/draft/2020-12/schema","type":"object","properties":{"displayName":{"type":"string","minLength":1,"maxLength":191},"legalName":{"anyOf":[{"type":"string","maxLength":191},{"type":"string","const":""}]},"email":{"anyOf":[{"type":"string","format":"email","pattern":"^(?!\\.)(?!.*\\.\\.)([A-Za-z0-9_'+\\-\\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\\-]*\\.)+[A-Za-z]{2,}$"},{"type":"string","const":""}]},"phone":{"anyOf":[{"type":"string","maxLength":30},{"type":"string","const":""}]},"gstin":{"anyOf":[{"type":"string","pattern":"^[0-9A-Z]{15}$"},{"type":"string","const":""}]},"pan":{"anyOf":[{"type":"string","pattern":"^[A-Z]{5}[0-9]{4}[A-Z]$"},{"type":"string","const":""}]},"currencyCode":{"default":"INR","type":"string","minLength":3,"maxLength":3},"paymentTermId":{"anyOf":[{"type":"string","maxLength":30},{"type":"string","const":""}]},"priceListId":{"anyOf":[{"type":"string","maxLength":30},{"type":"string","const":""}]},"salespersonId":{"type":"string","maxLength":30},"placeOfSupplyStateCode":{"anyOf":[{"type":"string","minLength":2,"maxLength":2},{"type":"string","const":""}]},"openingBalance":{"default":0,"type":"number","minimum":0},"billingAddress":{"type":"object","properties":{"line1":{"type":"string","maxLength":255},"line2":{"type":"string","maxLength":255},"city":{"type":"string","maxLength":100},"state":{"type":"string","maxLength":100},"stateCode":{"type":"string","minLength":2,"maxLength":2},"pincode":{"type":"string","maxLength":10},"country":{"type":"string","maxLength":100}}},"shippingAddress":{"type":"object","properties":{"line1":{"type":"string","maxLength":255},"line2":{"type":"string","maxLength":255},"city":{"type":"string","maxLength":100},"state":{"type":"string","maxLength":100},"stateCode":{"type":"string","minLength":2,"maxLength":2},"pincode":{"type":"string","maxLength":10},"country":{"type":"string","maxLength":100}}},"notes":{"anyOf":[{"type":"string","maxLength":2000},{"type":"string","const":""}]}},"required":["displayName"]},"example":{"displayName":"Bansal Textiles Pvt Ltd","email":"accounts@bansaltextiles.in","gstin":"07AAACB1234C1Z5","currencyCode":"INR","phone":"9000011111"}}}},"tags":["Customers"]},"delete":{"summary":"Delete a customer","parameters":[{"name":"id","in":"path","required":true,"description":"Customer ID.","schema":{"type":"string","example":"clx1a2b3c4d5e6f7g8h9i0j1"}}],"responses":{"200":{"description":"Delete a customer","content":{"application/json":{"example":{"success":true,"data":{"deleted":true}}}}},"401":{"description":"Missing bearer token","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"unauthorized"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"unauthorized","message":"Missing bearer token"}}}}},"403":{"description":"Access denied","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"forbidden"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"forbidden","message":"Access denied"}}}}},"404":{"description":"Resource not found","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"not_found"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"not_found","message":"Resource not found"}}}}}},"security":[{"bearerAuth":[]}],"tags":["Customers"]}},"/api/v1/customers/{id}/ledger-pdf":{"get":{"summary":"Render the customer ledger statement as a PDF","description":"Bearer-token counterpart to the session-authed web ledger PDF — same builder, so the two are always in sync.","parameters":[{"name":"id","in":"path","required":true,"description":"Customer ID.","schema":{"type":"string","example":"clx1a2b3c4d5e6f7g8h9i0j1"}},{"name":"from","in":"query","required":false,"description":"Statement start date, YYYY-MM-DD. Omit for no lower bound.","schema":{"type":"string"}},{"name":"to","in":"query","required":false,"description":"Statement end date, YYYY-MM-DD. Omit for no upper bound.","schema":{"type":"string"}}],"responses":{"200":{"description":"The ledger statement as a PDF, streamed inline with a Content-Disposition filename.","content":{"application/pdf":{"schema":{"type":"string","format":"binary"}}}},"401":{"description":"Missing bearer token","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"unauthorized"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"unauthorized","message":"Missing bearer token"}}}}},"403":{"description":"Access denied","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"forbidden"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"forbidden","message":"Access denied"}}}}},"404":{"description":"Resource not found","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"not_found"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"not_found","message":"Resource not found"}}}}}},"security":[{"bearerAuth":[]}],"tags":["Customers"]}},"/api/v1/vendors":{"get":{"summary":"List vendors","parameters":[{"name":"page","in":"query","required":false,"description":"1-based page number.","schema":{"type":"number","example":1}},{"name":"limit","in":"query","required":false,"description":"Page size, max 200.","schema":{"type":"number","example":50}},{"name":"q","in":"query","required":false,"description":"Free-text search across display name, GSTIN, phone, email.","schema":{"type":"string"}}],"responses":{"200":{"description":"List vendors","content":{"application/json":{"example":{"success":true,"data":[{"id":"clx2v1e2n3d4o5r6a7b8c9d0","organizationId":"clx0org000000000000000001","displayName":"Shree Fabrics Suppliers","legalName":"Shree Fabrics Suppliers LLP","email":"sales@shreefabrics.com","phone":"9123456780","gstin":"27AAECS5678D1Z2","pan":"AAECS5678D","currencyCode":"INR","paymentTermId":null,"paymentTermsDays":45,"placeOfSupplyStateCode":"27","billingAddress":{"line1":"Plot 22, MIDC Industrial Area","city":"Mumbai","state":"Maharashtra","stateCode":"27","pincode":"400093","country":"India"},"shippingAddress":null,"openingBalance":0,"notes":null,"isActive":true,"vendorCode":"SFS","lastLotSequence":128,"msmeType":"SMALL","udyamNumber":"UDYAM-MH-19-0012345","msmeAgreedCreditDays":45,"createdBy":"clxusr0000000000000000001","updatedBy":"clxusr0000000000000000002","createdAt":"2026-06-15T07:30:00.000Z","updatedAt":"2026-09-01T13:05:00.000Z"}],"meta":{"page":1,"limit":50,"total":1,"hasMore":false}}}}},"401":{"description":"Missing bearer token","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"unauthorized"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"unauthorized","message":"Missing bearer token"}}}}},"403":{"description":"Access denied","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"forbidden"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"forbidden","message":"Access denied"}}}}}},"security":[{"bearerAuth":[]}],"tags":["Vendors"]},"post":{"summary":"Create a vendor","responses":{"201":{"description":"Create a vendor","content":{"application/json":{"example":{"success":true,"data":{"id":"clx2v1e2n3d4o5r6a7b8c9d0","organizationId":"clx0org000000000000000001","displayName":"Shree Fabrics Suppliers","legalName":"Shree Fabrics Suppliers LLP","email":"sales@shreefabrics.com","phone":"9123456780","gstin":"27AAECS5678D1Z2","pan":"AAECS5678D","currencyCode":"INR","paymentTermId":null,"paymentTermsDays":45,"placeOfSupplyStateCode":"27","billingAddress":{"line1":"Plot 22, MIDC Industrial Area","city":"Mumbai","state":"Maharashtra","stateCode":"27","pincode":"400093","country":"India"},"shippingAddress":null,"openingBalance":0,"notes":null,"isActive":true,"vendorCode":"SFS","lastLotSequence":128,"msmeType":"SMALL","udyamNumber":"UDYAM-MH-19-0012345","msmeAgreedCreditDays":45,"createdBy":"clxusr0000000000000000001","updatedBy":"clxusr0000000000000000002","createdAt":"2026-06-15T07:30:00.000Z","updatedAt":"2026-09-01T13:05:00.000Z"}}}}},"401":{"description":"Missing bearer token","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"unauthorized"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"unauthorized","message":"Missing bearer token"}}}}},"403":{"description":"Access denied","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"forbidden"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"forbidden","message":"Access denied"}}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"validation_error"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"validation_error","message":"Validation failed"}}}}}},"security":[{"bearerAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$schema":"https://json-schema.org/draft/2020-12/schema","type":"object","properties":{"displayName":{"type":"string","minLength":1,"maxLength":191},"vendorCode":{"anyOf":[{"type":"string","pattern":"^[A-Z0-9]{3}$"},{"type":"string","const":""}]},"legalName":{"anyOf":[{"type":"string","maxLength":191},{"type":"string","const":""}]},"email":{"anyOf":[{"type":"string","format":"email","pattern":"^(?!\\.)(?!.*\\.\\.)([A-Za-z0-9_'+\\-\\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\\-]*\\.)+[A-Za-z]{2,}$"},{"type":"string","const":""}]},"phone":{"anyOf":[{"type":"string","maxLength":30},{"type":"string","const":""}]},"gstin":{"anyOf":[{"type":"string","pattern":"^[0-9A-Z]{15}$"},{"type":"string","const":""}]},"pan":{"anyOf":[{"type":"string","pattern":"^[A-Z]{5}[0-9]{4}[A-Z]$"},{"type":"string","const":""}]},"currencyCode":{"default":"INR","type":"string","minLength":3,"maxLength":3},"paymentTermsDays":{"default":0,"type":"integer","minimum":0,"maximum":365},"placeOfSupplyStateCode":{"anyOf":[{"type":"string","minLength":2,"maxLength":2},{"type":"string","const":""}]},"openingBalance":{"default":0,"type":"number","minimum":0},"billingAddress":{"type":"object","properties":{"line1":{"type":"string","maxLength":255},"line2":{"type":"string","maxLength":255},"city":{"type":"string","maxLength":100},"state":{"type":"string","maxLength":100},"stateCode":{"type":"string","minLength":2,"maxLength":2},"pincode":{"type":"string","maxLength":10},"country":{"type":"string","maxLength":100}}},"shippingAddress":{"type":"object","properties":{"line1":{"type":"string","maxLength":255},"line2":{"type":"string","maxLength":255},"city":{"type":"string","maxLength":100},"state":{"type":"string","maxLength":100},"stateCode":{"type":"string","minLength":2,"maxLength":2},"pincode":{"type":"string","maxLength":10},"country":{"type":"string","maxLength":100}}},"notes":{"anyOf":[{"type":"string","maxLength":2000},{"type":"string","const":""}]},"leadTimeDays":{"anyOf":[{"type":"integer","minimum":0,"maximum":365},{"type":"null"}]},"msmeType":{"anyOf":[{"type":"string","enum":["MICRO","SMALL","MEDIUM"]},{"type":"null"}]},"udyamNumber":{"anyOf":[{"type":"string","pattern":"^UDYAM-[A-Z]{2}-\\d{2}-\\d{7}$"},{"type":"null"}]},"msmeHasAgreement":{"type":"boolean"},"msmeAgreedCreditDays":{"anyOf":[{"type":"integer","minimum":0,"maximum":45},{"type":"null"}]}},"required":["displayName","leadTimeDays","msmeType","udyamNumber","msmeAgreedCreditDays"]},"example":{"displayName":"Shree Fabrics Suppliers","currencyCode":"INR","paymentTermsDays":45}}}},"tags":["Vendors"]}},"/api/v1/vendors/{id}":{"get":{"summary":"Get a vendor","parameters":[{"name":"id","in":"path","required":true,"description":"Vendor ID.","schema":{"type":"string","example":"clx2v1e2n3d4o5r6a7b8c9d0"}}],"responses":{"200":{"description":"Get a vendor","content":{"application/json":{"example":{"success":true,"data":{"id":"clx2v1e2n3d4o5r6a7b8c9d0","organizationId":"clx0org000000000000000001","displayName":"Shree Fabrics Suppliers","legalName":"Shree Fabrics Suppliers LLP","email":"sales@shreefabrics.com","phone":"9123456780","gstin":"27AAECS5678D1Z2","pan":"AAECS5678D","currencyCode":"INR","paymentTermId":null,"paymentTermsDays":45,"placeOfSupplyStateCode":"27","billingAddress":{"line1":"Plot 22, MIDC Industrial Area","city":"Mumbai","state":"Maharashtra","stateCode":"27","pincode":"400093","country":"India"},"shippingAddress":null,"openingBalance":0,"notes":null,"isActive":true,"vendorCode":"SFS","lastLotSequence":128,"msmeType":"SMALL","udyamNumber":"UDYAM-MH-19-0012345","msmeAgreedCreditDays":45,"createdBy":"clxusr0000000000000000001","updatedBy":"clxusr0000000000000000002","createdAt":"2026-06-15T07:30:00.000Z","updatedAt":"2026-09-01T13:05:00.000Z"}}}}},"401":{"description":"Missing bearer token","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"unauthorized"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"unauthorized","message":"Missing bearer token"}}}}},"403":{"description":"Access denied","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"forbidden"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"forbidden","message":"Access denied"}}}}},"404":{"description":"Resource not found","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"not_found"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"not_found","message":"Resource not found"}}}}}},"security":[{"bearerAuth":[]}],"tags":["Vendors"]},"patch":{"summary":"Update a vendor","description":"PATCH validates against the full vendor schema (same as create) — displayName is required in every update, not just changed fields. The MSME block (msmeType, udyamNumber, msmeAgreedCreditDays) is only written when the body names at least one of those fields, and is then replaced as a unit; send msmeType: null to clear it. msmeAgreedCreditDays null means no written agreement (15-day rule); the maximum is 45.","parameters":[{"name":"id","in":"path","required":true,"description":"Vendor ID.","schema":{"type":"string","example":"clx2v1e2n3d4o5r6a7b8c9d0"}}],"responses":{"200":{"description":"Update a vendor","content":{"application/json":{"example":{"success":true,"data":{"id":"clx2v1e2n3d4o5r6a7b8c9d0","organizationId":"clx0org000000000000000001","displayName":"Shree Fabrics Suppliers","legalName":"Shree Fabrics Suppliers LLP","email":"sales@shreefabrics.com","phone":"9123456780","gstin":"27AAECS5678D1Z2","pan":"AAECS5678D","currencyCode":"INR","paymentTermId":null,"paymentTermsDays":45,"placeOfSupplyStateCode":"27","billingAddress":{"line1":"Plot 22, MIDC Industrial Area","city":"Mumbai","state":"Maharashtra","stateCode":"27","pincode":"400093","country":"India"},"shippingAddress":null,"openingBalance":0,"notes":null,"isActive":true,"vendorCode":"SFS","lastLotSequence":128,"msmeType":"SMALL","udyamNumber":"UDYAM-MH-19-0012345","msmeAgreedCreditDays":45,"createdBy":"clxusr0000000000000000001","updatedBy":"clxusr0000000000000000002","createdAt":"2026-06-15T07:30:00.000Z","updatedAt":"2026-09-01T13:05:00.000Z"}}}}},"401":{"description":"Missing bearer token","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"unauthorized"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"unauthorized","message":"Missing bearer token"}}}}},"403":{"description":"Access denied","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"forbidden"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"forbidden","message":"Access denied"}}}}},"404":{"description":"Resource not found","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"not_found"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"not_found","message":"Resource not found"}}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"validation_error"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"validation_error","message":"Validation failed"}}}}}},"security":[{"bearerAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$schema":"https://json-schema.org/draft/2020-12/schema","type":"object","properties":{"displayName":{"type":"string","minLength":1,"maxLength":191},"vendorCode":{"anyOf":[{"type":"string","pattern":"^[A-Z0-9]{3}$"},{"type":"string","const":""}]},"legalName":{"anyOf":[{"type":"string","maxLength":191},{"type":"string","const":""}]},"email":{"anyOf":[{"type":"string","format":"email","pattern":"^(?!\\.)(?!.*\\.\\.)([A-Za-z0-9_'+\\-\\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\\-]*\\.)+[A-Za-z]{2,}$"},{"type":"string","const":""}]},"phone":{"anyOf":[{"type":"string","maxLength":30},{"type":"string","const":""}]},"gstin":{"anyOf":[{"type":"string","pattern":"^[0-9A-Z]{15}$"},{"type":"string","const":""}]},"pan":{"anyOf":[{"type":"string","pattern":"^[A-Z]{5}[0-9]{4}[A-Z]$"},{"type":"string","const":""}]},"currencyCode":{"default":"INR","type":"string","minLength":3,"maxLength":3},"paymentTermsDays":{"default":0,"type":"integer","minimum":0,"maximum":365},"placeOfSupplyStateCode":{"anyOf":[{"type":"string","minLength":2,"maxLength":2},{"type":"string","const":""}]},"openingBalance":{"default":0,"type":"number","minimum":0},"billingAddress":{"type":"object","properties":{"line1":{"type":"string","maxLength":255},"line2":{"type":"string","maxLength":255},"city":{"type":"string","maxLength":100},"state":{"type":"string","maxLength":100},"stateCode":{"type":"string","minLength":2,"maxLength":2},"pincode":{"type":"string","maxLength":10},"country":{"type":"string","maxLength":100}}},"shippingAddress":{"type":"object","properties":{"line1":{"type":"string","maxLength":255},"line2":{"type":"string","maxLength":255},"city":{"type":"string","maxLength":100},"state":{"type":"string","maxLength":100},"stateCode":{"type":"string","minLength":2,"maxLength":2},"pincode":{"type":"string","maxLength":10},"country":{"type":"string","maxLength":100}}},"notes":{"anyOf":[{"type":"string","maxLength":2000},{"type":"string","const":""}]},"leadTimeDays":{"anyOf":[{"type":"integer","minimum":0,"maximum":365},{"type":"null"}]},"msmeType":{"anyOf":[{"type":"string","enum":["MICRO","SMALL","MEDIUM"]},{"type":"null"}]},"udyamNumber":{"anyOf":[{"type":"string","pattern":"^UDYAM-[A-Z]{2}-\\d{2}-\\d{7}$"},{"type":"null"}]},"msmeHasAgreement":{"type":"boolean"},"msmeAgreedCreditDays":{"anyOf":[{"type":"integer","minimum":0,"maximum":45},{"type":"null"}]}},"required":["displayName","leadTimeDays","msmeType","udyamNumber","msmeAgreedCreditDays"]},"example":{"displayName":"Shree Fabrics Suppliers","currencyCode":"INR","paymentTermsDays":45,"phone":"9000011111"}}}},"tags":["Vendors"]},"delete":{"summary":"Delete a vendor","parameters":[{"name":"id","in":"path","required":true,"description":"Vendor ID.","schema":{"type":"string","example":"clx2v1e2n3d4o5r6a7b8c9d0"}}],"responses":{"200":{"description":"Delete a vendor","content":{"application/json":{"example":{"success":true,"data":{"deleted":true}}}}},"401":{"description":"Missing bearer token","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"unauthorized"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"unauthorized","message":"Missing bearer token"}}}}},"403":{"description":"Access denied","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"forbidden"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"forbidden","message":"Access denied"}}}}},"404":{"description":"Resource not found","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"not_found"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"not_found","message":"Resource not found"}}}}}},"security":[{"bearerAuth":[]}],"tags":["Vendors"]}},"/api/v1/tax-rates":{"get":{"summary":"List tax rates","parameters":[{"name":"page","in":"query","required":false,"description":"1-based page number.","schema":{"type":"number","example":1}},{"name":"limit","in":"query","required":false,"description":"Page size, max 200.","schema":{"type":"number","example":50}}],"responses":{"200":{"description":"List tax rates","content":{"application/json":{"example":{"success":true,"data":[{"id":"clx6tax000000000000000001","organizationId":"clx0org000000000000000001","name":"GST 12%","ratePercent":12,"isGST":true,"isDefault":false,"createdAt":"2026-01-05T04:00:00.000Z","updatedAt":"2026-01-05T04:00:00.000Z"}],"meta":{"page":1,"limit":50,"total":1,"hasMore":false}}}}},"401":{"description":"Missing bearer token","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"unauthorized"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"unauthorized","message":"Missing bearer token"}}}}},"403":{"description":"Access denied","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"forbidden"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"forbidden","message":"Access denied"}}}}}},"security":[{"bearerAuth":[]}],"tags":["Tax Rates"]},"post":{"summary":"Create a tax rate","responses":{"201":{"description":"Create a tax rate","content":{"application/json":{"example":{"success":true,"data":{"id":"clx6tax000000000000000001","organizationId":"clx0org000000000000000001","name":"GST 12%","ratePercent":12,"isGST":true,"isDefault":false,"createdAt":"2026-01-05T04:00:00.000Z","updatedAt":"2026-01-05T04:00:00.000Z"}}}}},"401":{"description":"Missing bearer token","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"unauthorized"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"unauthorized","message":"Missing bearer token"}}}}},"403":{"description":"Access denied","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"forbidden"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"forbidden","message":"Access denied"}}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"validation_error"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"validation_error","message":"Validation failed"}}}}}},"security":[{"bearerAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$schema":"https://json-schema.org/draft/2020-12/schema","type":"object","properties":{"name":{"type":"string","minLength":1,"maxLength":100},"ratePercent":{"type":"number","minimum":0,"maximum":100},"isGST":{"default":true,"type":"boolean"},"isDefault":{"default":false,"type":"boolean"}},"required":["name","ratePercent"]},"example":{"name":"GST 12%","ratePercent":12}}}},"tags":["Tax Rates"]}},"/api/v1/tax-rates/{id}":{"get":{"summary":"Get a tax rate","parameters":[{"name":"id","in":"path","required":true,"description":"Tax rate ID.","schema":{"type":"string","example":"clx6tax000000000000000001"}}],"responses":{"200":{"description":"Get a tax rate","content":{"application/json":{"example":{"success":true,"data":{"id":"clx6tax000000000000000001","organizationId":"clx0org000000000000000001","name":"GST 12%","ratePercent":12,"isGST":true,"isDefault":false,"createdAt":"2026-01-05T04:00:00.000Z","updatedAt":"2026-01-05T04:00:00.000Z"}}}}},"401":{"description":"Missing bearer token","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"unauthorized"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"unauthorized","message":"Missing bearer token"}}}}},"403":{"description":"Access denied","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"forbidden"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"forbidden","message":"Access denied"}}}}},"404":{"description":"Resource not found","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"not_found"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"not_found","message":"Resource not found"}}}}}},"security":[{"bearerAuth":[]}],"tags":["Tax Rates"]},"patch":{"summary":"Update a tax rate","description":"PATCH validates against the full tax rate schema (same as create) — name and ratePercent are required in every update, not just changed fields.","parameters":[{"name":"id","in":"path","required":true,"description":"Tax rate ID.","schema":{"type":"string","example":"clx6tax000000000000000001"}}],"responses":{"200":{"description":"Update a tax rate","content":{"application/json":{"example":{"success":true,"data":{"id":"clx6tax000000000000000001","organizationId":"clx0org000000000000000001","name":"GST 12%","ratePercent":12,"isGST":true,"isDefault":false,"createdAt":"2026-01-05T04:00:00.000Z","updatedAt":"2026-01-05T04:00:00.000Z"}}}}},"401":{"description":"Missing bearer token","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"unauthorized"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"unauthorized","message":"Missing bearer token"}}}}},"403":{"description":"Access denied","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"forbidden"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"forbidden","message":"Access denied"}}}}},"404":{"description":"Resource not found","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"not_found"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"not_found","message":"Resource not found"}}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"validation_error"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"validation_error","message":"Validation failed"}}}}}},"security":[{"bearerAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$schema":"https://json-schema.org/draft/2020-12/schema","type":"object","properties":{"name":{"type":"string","minLength":1,"maxLength":100},"ratePercent":{"type":"number","minimum":0,"maximum":100},"isGST":{"default":true,"type":"boolean"},"isDefault":{"default":false,"type":"boolean"}},"required":["name","ratePercent"]},"example":{"name":"GST 18%","ratePercent":18}}}},"tags":["Tax Rates"]},"delete":{"summary":"Delete a tax rate","parameters":[{"name":"id","in":"path","required":true,"description":"Tax rate ID.","schema":{"type":"string","example":"clx6tax000000000000000001"}}],"responses":{"200":{"description":"Delete a tax rate","content":{"application/json":{"example":{"success":true,"data":{"deleted":true}}}}},"401":{"description":"Missing bearer token","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"unauthorized"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"unauthorized","message":"Missing bearer token"}}}}},"403":{"description":"Access denied","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"forbidden"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"forbidden","message":"Access denied"}}}}},"404":{"description":"Resource not found","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"not_found"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"not_found","message":"Resource not found"}}}}}},"security":[{"bearerAuth":[]}],"tags":["Tax Rates"]}},"/api/v1/currencies":{"get":{"summary":"List currencies","parameters":[{"name":"page","in":"query","required":false,"description":"1-based page number.","schema":{"type":"number","example":1}},{"name":"limit","in":"query","required":false,"description":"Page size, max 200.","schema":{"type":"number","example":50}}],"responses":{"200":{"description":"List currencies","content":{"application/json":{"example":{"success":true,"data":[{"id":"clx8cur000000000000000001","organizationId":"clx0org000000000000000001","code":"USD","name":"US Dollar","symbol":"$","exchangeRate":83.245,"isBase":false,"isActive":true,"createdAt":"2026-02-10T06:00:00.000Z","updatedAt":"2026-09-01T06:00:00.000Z"}],"meta":{"page":1,"limit":50,"total":1,"hasMore":false}}}}},"401":{"description":"Missing bearer token","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"unauthorized"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"unauthorized","message":"Missing bearer token"}}}}},"403":{"description":"Access denied","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"forbidden"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"forbidden","message":"Access denied"}}}}}},"security":[{"bearerAuth":[]}],"tags":["Currencies"]},"post":{"summary":"Create a currency","responses":{"201":{"description":"Create a currency","content":{"application/json":{"example":{"success":true,"data":{"id":"clx8cur000000000000000001","organizationId":"clx0org000000000000000001","code":"USD","name":"US Dollar","symbol":"$","exchangeRate":83.245,"isBase":false,"isActive":true,"createdAt":"2026-02-10T06:00:00.000Z","updatedAt":"2026-09-01T06:00:00.000Z"}}}}},"401":{"description":"Missing bearer token","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"unauthorized"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"unauthorized","message":"Missing bearer token"}}}}},"403":{"description":"Access denied","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"forbidden"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"forbidden","message":"Access denied"}}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"validation_error"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"validation_error","message":"Validation failed"}}}}}},"security":[{"bearerAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$schema":"https://json-schema.org/draft/2020-12/schema","type":"object","properties":{"code":{"type":"string","minLength":3,"maxLength":3},"name":{"type":"string","minLength":1,"maxLength":50},"symbol":{"type":"string","minLength":1,"maxLength":10},"exchangeRate":{"type":"number","exclusiveMinimum":0},"isBase":{"default":false,"type":"boolean"},"isActive":{"default":true,"type":"boolean"}},"required":["code","name","symbol","exchangeRate"]},"example":{"code":"USD","name":"US Dollar","symbol":"$","exchangeRate":83.245}}}},"tags":["Currencies"]}},"/api/v1/currencies/{id}":{"get":{"summary":"Get a currency","parameters":[{"name":"id","in":"path","required":true,"description":"Currency ID.","schema":{"type":"string","example":"clx8cur000000000000000001"}}],"responses":{"200":{"description":"Get a currency","content":{"application/json":{"example":{"success":true,"data":{"id":"clx8cur000000000000000001","organizationId":"clx0org000000000000000001","code":"USD","name":"US Dollar","symbol":"$","exchangeRate":83.245,"isBase":false,"isActive":true,"createdAt":"2026-02-10T06:00:00.000Z","updatedAt":"2026-09-01T06:00:00.000Z"}}}}},"401":{"description":"Missing bearer token","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"unauthorized"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"unauthorized","message":"Missing bearer token"}}}}},"403":{"description":"Access denied","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"forbidden"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"forbidden","message":"Access denied"}}}}},"404":{"description":"Resource not found","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"not_found"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"not_found","message":"Resource not found"}}}}}},"security":[{"bearerAuth":[]}],"tags":["Currencies"]},"patch":{"summary":"Update a currency","description":"PATCH validates against the full currency schema (same as create) — code, name, symbol, and exchangeRate are all required in every update.","parameters":[{"name":"id","in":"path","required":true,"description":"Currency ID.","schema":{"type":"string","example":"clx8cur000000000000000001"}}],"responses":{"200":{"description":"Update a currency","content":{"application/json":{"example":{"success":true,"data":{"id":"clx8cur000000000000000001","organizationId":"clx0org000000000000000001","code":"USD","name":"US Dollar","symbol":"$","exchangeRate":83.245,"isBase":false,"isActive":true,"createdAt":"2026-02-10T06:00:00.000Z","updatedAt":"2026-09-01T06:00:00.000Z"}}}}},"401":{"description":"Missing bearer token","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"unauthorized"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"unauthorized","message":"Missing bearer token"}}}}},"403":{"description":"Access denied","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"forbidden"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"forbidden","message":"Access denied"}}}}},"404":{"description":"Resource not found","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"not_found"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"not_found","message":"Resource not found"}}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"validation_error"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"validation_error","message":"Validation failed"}}}}}},"security":[{"bearerAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$schema":"https://json-schema.org/draft/2020-12/schema","type":"object","properties":{"code":{"type":"string","minLength":3,"maxLength":3},"name":{"type":"string","minLength":1,"maxLength":50},"symbol":{"type":"string","minLength":1,"maxLength":10},"exchangeRate":{"type":"number","exclusiveMinimum":0},"isBase":{"default":false,"type":"boolean"},"isActive":{"default":true,"type":"boolean"}},"required":["code","name","symbol","exchangeRate"]},"example":{"code":"USD","name":"US Dollar","symbol":"$","exchangeRate":84.1}}}},"tags":["Currencies"]},"delete":{"summary":"Delete a currency","parameters":[{"name":"id","in":"path","required":true,"description":"Currency ID.","schema":{"type":"string","example":"clx8cur000000000000000001"}}],"responses":{"200":{"description":"Delete a currency","content":{"application/json":{"example":{"success":true,"data":{"deleted":true}}}}},"401":{"description":"Missing bearer token","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"unauthorized"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"unauthorized","message":"Missing bearer token"}}}}},"403":{"description":"Access denied","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"forbidden"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"forbidden","message":"Access denied"}}}}},"404":{"description":"Resource not found","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"not_found"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"not_found","message":"Resource not found"}}}}}},"security":[{"bearerAuth":[]}],"tags":["Currencies"]}},"/api/v1/payment-terms":{"get":{"summary":"List payment terms","parameters":[{"name":"page","in":"query","required":false,"description":"1-based page number.","schema":{"type":"number","example":1}},{"name":"limit","in":"query","required":false,"description":"Page size, max 200.","schema":{"type":"number","example":50}}],"responses":{"200":{"description":"List payment terms","content":{"application/json":{"example":{"success":true,"data":[{"id":"clxpt00000000000000000001","organizationId":"clx0org000000000000000001","name":"Net 30","days":30,"isDefault":true,"createdAt":"2026-01-01T00:00:00.000Z","updatedAt":"2026-01-01T00:00:00.000Z"}],"meta":{"page":1,"limit":50,"total":1,"hasMore":false}}}}},"401":{"description":"Missing bearer token","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"unauthorized"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"unauthorized","message":"Missing bearer token"}}}}},"403":{"description":"Access denied","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"forbidden"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"forbidden","message":"Access denied"}}}}}},"security":[{"bearerAuth":[]}],"tags":["Payment Terms"]},"post":{"summary":"Create a payment term","responses":{"201":{"description":"Create a payment term","content":{"application/json":{"example":{"success":true,"data":{"id":"clxpt00000000000000000001","organizationId":"clx0org000000000000000001","name":"Net 30","days":30,"isDefault":true,"createdAt":"2026-01-01T00:00:00.000Z","updatedAt":"2026-01-01T00:00:00.000Z"}}}}},"401":{"description":"Missing bearer token","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"unauthorized"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"unauthorized","message":"Missing bearer token"}}}}},"403":{"description":"Access denied","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"forbidden"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"forbidden","message":"Access denied"}}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"validation_error"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"validation_error","message":"Validation failed"}}}}}},"security":[{"bearerAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$schema":"https://json-schema.org/draft/2020-12/schema","type":"object","properties":{"name":{"type":"string","minLength":1,"maxLength":100},"days":{"type":"integer","minimum":0,"maximum":365},"isDefault":{"default":false,"type":"boolean"}},"required":["name","days"]},"example":{"name":"Net 30","days":30}}}},"tags":["Payment Terms"]}},"/api/v1/payment-terms/{id}":{"get":{"summary":"Get a payment term","parameters":[{"name":"id","in":"path","required":true,"description":"Payment term ID.","schema":{"type":"string","example":"clxpt00000000000000000001"}}],"responses":{"200":{"description":"Get a payment term","content":{"application/json":{"example":{"success":true,"data":{"id":"clxpt00000000000000000001","organizationId":"clx0org000000000000000001","name":"Net 30","days":30,"isDefault":true,"createdAt":"2026-01-01T00:00:00.000Z","updatedAt":"2026-01-01T00:00:00.000Z"}}}}},"401":{"description":"Missing bearer token","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"unauthorized"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"unauthorized","message":"Missing bearer token"}}}}},"403":{"description":"Access denied","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"forbidden"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"forbidden","message":"Access denied"}}}}},"404":{"description":"Resource not found","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"not_found"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"not_found","message":"Resource not found"}}}}}},"security":[{"bearerAuth":[]}],"tags":["Payment Terms"]},"patch":{"summary":"Update a payment term","description":"PATCH validates against the full payment term schema (same as create) — name and days are required in every update, not just changed fields.","parameters":[{"name":"id","in":"path","required":true,"description":"Payment term ID.","schema":{"type":"string","example":"clxpt00000000000000000001"}}],"responses":{"200":{"description":"Update a payment term","content":{"application/json":{"example":{"success":true,"data":{"id":"clxpt00000000000000000001","organizationId":"clx0org000000000000000001","name":"Net 30","days":30,"isDefault":true,"createdAt":"2026-01-01T00:00:00.000Z","updatedAt":"2026-01-01T00:00:00.000Z"}}}}},"401":{"description":"Missing bearer token","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"unauthorized"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"unauthorized","message":"Missing bearer token"}}}}},"403":{"description":"Access denied","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"forbidden"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"forbidden","message":"Access denied"}}}}},"404":{"description":"Resource not found","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"not_found"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"not_found","message":"Resource not found"}}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"validation_error"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"validation_error","message":"Validation failed"}}}}}},"security":[{"bearerAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$schema":"https://json-schema.org/draft/2020-12/schema","type":"object","properties":{"name":{"type":"string","minLength":1,"maxLength":100},"days":{"type":"integer","minimum":0,"maximum":365},"isDefault":{"default":false,"type":"boolean"}},"required":["name","days"]},"example":{"name":"Net 45","days":45}}}},"tags":["Payment Terms"]},"delete":{"summary":"Delete a payment term","parameters":[{"name":"id","in":"path","required":true,"description":"Payment term ID.","schema":{"type":"string","example":"clxpt00000000000000000001"}}],"responses":{"200":{"description":"Delete a payment term","content":{"application/json":{"example":{"success":true,"data":{"deleted":true}}}}},"401":{"description":"Missing bearer token","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"unauthorized"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"unauthorized","message":"Missing bearer token"}}}}},"403":{"description":"Access denied","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"forbidden"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"forbidden","message":"Access denied"}}}}},"404":{"description":"Resource not found","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"not_found"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"not_found","message":"Resource not found"}}}}}},"security":[{"bearerAuth":[]}],"tags":["Payment Terms"]}},"/api/v1/accounts":{"get":{"summary":"List accounts","parameters":[{"name":"page","in":"query","required":false,"description":"1-based page number.","schema":{"type":"number","example":1}},{"name":"limit","in":"query","required":false,"description":"Page size, max 200.","schema":{"type":"number","example":50}}],"responses":{"200":{"description":"List accounts","content":{"application/json":{"example":{"success":true,"data":[{"id":"clx3acct00000000000000001","organizationId":"clx0org000000000000000001","accountName":"HDFC Bank - Current A/C","accountType":"BANK","bankName":"HDFC Bank","accountNumber":"50100123456789","ifscCode":"HDFC0001234","isDefault":true,"isActive":true,"createdAt":"2025-04-01T06:30:00.000Z","updatedAt":"2025-04-01T06:30:00.000Z"}],"meta":{"page":1,"limit":50,"total":1,"hasMore":false}}}}},"401":{"description":"Missing bearer token","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"unauthorized"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"unauthorized","message":"Missing bearer token"}}}}},"403":{"description":"Access denied","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"forbidden"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"forbidden","message":"Access denied"}}}}}},"security":[{"bearerAuth":[]}],"tags":["Accounts"]},"post":{"summary":"Create an account","responses":{"201":{"description":"Create an account","content":{"application/json":{"example":{"success":true,"data":{"id":"clx3acct00000000000000001","organizationId":"clx0org000000000000000001","accountName":"HDFC Bank - Current A/C","accountType":"BANK","bankName":"HDFC Bank","accountNumber":"50100123456789","ifscCode":"HDFC0001234","isDefault":true,"isActive":true,"createdAt":"2025-04-01T06:30:00.000Z","updatedAt":"2025-04-01T06:30:00.000Z"}}}}},"401":{"description":"Missing bearer token","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"unauthorized"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"unauthorized","message":"Missing bearer token"}}}}},"403":{"description":"Access denied","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"forbidden"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"forbidden","message":"Access denied"}}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"validation_error"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"validation_error","message":"Validation failed"}}}}}},"security":[{"bearerAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$schema":"https://json-schema.org/draft/2020-12/schema","type":"object","properties":{"accountName":{"type":"string","minLength":1,"maxLength":100},"accountType":{"type":"string","enum":["CASH","BANK","WALLET","RECEIVABLE","PAYABLE","DEBT","LOAN","OTHER"]},"bankName":{"type":"string","maxLength":100},"accountNumber":{"type":"string","maxLength":50},"ifscCode":{"type":"string","maxLength":20},"isDefault":{"default":false,"type":"boolean"},"isActive":{"default":true,"type":"boolean"}},"required":["accountName","accountType","bankName","accountNumber","ifscCode"]},"example":{"accountName":"HDFC Bank - Current A/C","accountType":"BANK"}}}},"tags":["Accounts"]}},"/api/v1/accounts/{id}":{"get":{"summary":"Get an account","parameters":[{"name":"id","in":"path","required":true,"description":"Account ID.","schema":{"type":"string","example":"clx3acct00000000000000001"}}],"responses":{"200":{"description":"Get an account","content":{"application/json":{"example":{"success":true,"data":{"id":"clx3acct00000000000000001","organizationId":"clx0org000000000000000001","accountName":"HDFC Bank - Current A/C","accountType":"BANK","bankName":"HDFC Bank","accountNumber":"50100123456789","ifscCode":"HDFC0001234","isDefault":true,"isActive":true,"createdAt":"2025-04-01T06:30:00.000Z","updatedAt":"2025-04-01T06:30:00.000Z"}}}}},"401":{"description":"Missing bearer token","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"unauthorized"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"unauthorized","message":"Missing bearer token"}}}}},"403":{"description":"Access denied","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"forbidden"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"forbidden","message":"Access denied"}}}}},"404":{"description":"Resource not found","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"not_found"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"not_found","message":"Resource not found"}}}}}},"security":[{"bearerAuth":[]}],"tags":["Accounts"]},"patch":{"summary":"Update an account","description":"PATCH validates against the full account schema (same as create) — accountName and accountType are required in every update.","parameters":[{"name":"id","in":"path","required":true,"description":"Account ID.","schema":{"type":"string","example":"clx3acct00000000000000001"}}],"responses":{"200":{"description":"Update an account","content":{"application/json":{"example":{"success":true,"data":{"id":"clx3acct00000000000000001","organizationId":"clx0org000000000000000001","accountName":"HDFC Bank - Current A/C","accountType":"BANK","bankName":"HDFC Bank","accountNumber":"50100123456789","ifscCode":"HDFC0001234","isDefault":true,"isActive":true,"createdAt":"2025-04-01T06:30:00.000Z","updatedAt":"2025-04-01T06:30:00.000Z"}}}}},"401":{"description":"Missing bearer token","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"unauthorized"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"unauthorized","message":"Missing bearer token"}}}}},"403":{"description":"Access denied","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"forbidden"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"forbidden","message":"Access denied"}}}}},"404":{"description":"Resource not found","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"not_found"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"not_found","message":"Resource not found"}}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"validation_error"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"validation_error","message":"Validation failed"}}}}}},"security":[{"bearerAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$schema":"https://json-schema.org/draft/2020-12/schema","type":"object","properties":{"accountName":{"type":"string","minLength":1,"maxLength":100},"accountType":{"type":"string","enum":["CASH","BANK","WALLET","RECEIVABLE","PAYABLE","DEBT","LOAN","OTHER"]},"bankName":{"type":"string","maxLength":100},"accountNumber":{"type":"string","maxLength":50},"ifscCode":{"type":"string","maxLength":20},"isDefault":{"default":false,"type":"boolean"},"isActive":{"default":true,"type":"boolean"}},"required":["accountName","accountType","bankName","accountNumber","ifscCode"]},"example":{"accountName":"HDFC Bank - Current A/C","accountType":"BANK","isDefault":true}}}},"tags":["Accounts"]},"delete":{"summary":"Delete an account","parameters":[{"name":"id","in":"path","required":true,"description":"Account ID.","schema":{"type":"string","example":"clx3acct00000000000000001"}}],"responses":{"200":{"description":"Delete an account","content":{"application/json":{"example":{"success":true,"data":{"deleted":true}}}}},"401":{"description":"Missing bearer token","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"unauthorized"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"unauthorized","message":"Missing bearer token"}}}}},"403":{"description":"Access denied","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"forbidden"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"forbidden","message":"Access denied"}}}}},"404":{"description":"Resource not found","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"not_found"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"not_found","message":"Resource not found"}}}}}},"security":[{"bearerAuth":[]}],"tags":["Accounts"]}},"/api/v1/items":{"get":{"summary":"List items","description":"List rows do not include the `variants` array — fetch a single item for its variants.","parameters":[{"name":"page","in":"query","required":false,"description":"1-based page number.","schema":{"type":"number","example":1}},{"name":"limit","in":"query","required":false,"description":"Page size, max 200.","schema":{"type":"number","example":50}},{"name":"q","in":"query","required":false,"description":"Free-text search.","schema":{"type":"string"}}],"responses":{"200":{"description":"List items","content":{"application/json":{"example":{"success":true,"data":[{"id":"clx3itm000000000000000001","organizationId":"clx0org000000000000000001","name":"Cotton Bedsheet - Printed","sku":"BSH-COT-001","hsnOrSac":"6304","type":"GOODS","groupId":"clx4grp000000000000000001","sizeModuleId":"clx5szm000000000000000001","unit":"PCS","pricingMode":"PCS","defaultLengthUnit":null,"masterUnit":"BOX","piecesPerMaster":12,"sellingPrice":899,"purchasePrice":550,"isPriceInclusive":false,"taxRateId":"clx6tax000000000000000001","description":"100% cotton printed double bedsheet with 2 pillow covers.","reorderQuantity":20,"barcode":"8901234567890","trackInventory":true,"isActive":true,"primaryVendorId":"clx2v1e2n3d4o5r6a7b8c9d0","createdBy":"clxusr0000000000000000001","updatedBy":"clxusr0000000000000000001","createdAt":"2026-05-10T06:00:00.000Z","updatedAt":"2026-08-28T10:12:00.000Z"}],"meta":{"page":1,"limit":50,"total":1,"hasMore":false}}}}},"401":{"description":"Missing bearer token","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"unauthorized"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"unauthorized","message":"Missing bearer token"}}}}},"403":{"description":"Access denied","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"forbidden"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"forbidden","message":"Access denied"}}}}}},"security":[{"bearerAuth":[]}],"tags":["Items"]},"post":{"summary":"Create an item","responses":{"201":{"description":"Create an item","content":{"application/json":{"example":{"success":true,"data":{"id":"clx3itm000000000000000001","organizationId":"clx0org000000000000000001","name":"Cotton Bedsheet - Printed","sku":"BSH-COT-001","hsnOrSac":"6304","type":"GOODS","groupId":"clx4grp000000000000000001","sizeModuleId":"clx5szm000000000000000001","unit":"PCS","pricingMode":"PCS","defaultLengthUnit":null,"masterUnit":"BOX","piecesPerMaster":12,"sellingPrice":899,"purchasePrice":550,"isPriceInclusive":false,"taxRateId":"clx6tax000000000000000001","description":"100% cotton printed double bedsheet with 2 pillow covers.","reorderQuantity":20,"barcode":"8901234567890","trackInventory":true,"isActive":true,"primaryVendorId":"clx2v1e2n3d4o5r6a7b8c9d0","createdBy":"clxusr0000000000000000001","updatedBy":"clxusr0000000000000000001","createdAt":"2026-05-10T06:00:00.000Z","updatedAt":"2026-08-28T10:12:00.000Z","variants":[{"id":"clx7var000000000000000001","organizationId":"clx0org000000000000000001","itemId":"clx3itm000000000000000001","size":"Queen","sku":"BSH-COT-001-Q","barcode":"8901234567891","sellingPrice":899,"purchasePrice":550,"isActive":true,"sortOrder":0,"createdAt":"2026-05-10T06:00:00.000Z","updatedAt":"2026-05-10T06:00:00.000Z"}]}}}}},"401":{"description":"Missing bearer token","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"unauthorized"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"unauthorized","message":"Missing bearer token"}}}}},"403":{"description":"Access denied","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"forbidden"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"forbidden","message":"Access denied"}}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"validation_error"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"validation_error","message":"Validation failed"}}}}}},"security":[{"bearerAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$schema":"https://json-schema.org/draft/2020-12/schema","type":"object","properties":{"name":{"type":"string","minLength":1,"maxLength":191},"sku":{"anyOf":[{"type":"string","maxLength":100},{"type":"string","const":""}]},"hsnOrSac":{"anyOf":[{"type":"string","maxLength":10},{"type":"string","const":""}]},"type":{"default":"GOODS","type":"string","enum":["GOODS","SERVICE","BUNDLE"]},"groupId":{"anyOf":[{"type":"string","maxLength":30},{"type":"string","const":""}]},"sizeModuleId":{"anyOf":[{"type":"string","maxLength":30},{"type":"string","const":""}]},"unit":{"default":"PCS","type":"string","minLength":1,"maxLength":20},"masterUnit":{"anyOf":[{"type":"string","maxLength":20},{"type":"string","const":""}]},"piecesPerMaster":{"default":1,"type":"number","exclusiveMinimum":0},"sellingPrice":{"default":0,"type":"number","minimum":0},"purchasePrice":{"default":0,"type":"number","minimum":0},"isPriceInclusive":{"default":"inherit","type":"string","enum":["inherit","true","false"]},"taxRateId":{"anyOf":[{"type":"string","maxLength":30},{"type":"string","const":""}]},"barcode":{"anyOf":[{"type":"string","maxLength":100},{"type":"string","const":""}]},"description":{"anyOf":[{"type":"string","maxLength":2000},{"type":"string","const":""}]},"trackInventory":{"default":false,"type":"boolean"},"primaryVendorId":{"anyOf":[{"type":"string","maxLength":30},{"type":"null"}]},"variants":{"default":[],"type":"array","items":{"type":"object","properties":{"id":{"anyOf":[{"type":"string","maxLength":30},{"type":"string","const":""}]},"size":{"default":"","type":"string","maxLength":100},"options":{"default":[],"maxItems":5,"type":"array","items":{"type":"object","properties":{"optionTypeId":{"type":"string","minLength":1,"maxLength":30},"optionValueId":{"type":"string","minLength":1,"maxLength":30}},"required":["optionTypeId","optionValueId"]}},"sku":{"anyOf":[{"type":"string","maxLength":100},{"type":"string","const":""}]},"barcode":{"anyOf":[{"type":"string","maxLength":100},{"type":"string","const":""}]},"sellingPrice":{"default":0,"type":"number","minimum":0},"purchasePrice":{"default":0,"type":"number","minimum":0},"stock":{"default":0,"type":"number","minimum":0},"lowStockThreshold":{"default":10,"type":"integer","minimum":0,"maximum":9007199254740991},"isActive":{"default":true,"type":"boolean"},"sortOrder":{"default":0,"type":"integer","minimum":-9007199254740991,"maximum":9007199254740991}}}},"axes":{"default":[],"maxItems":5,"type":"array","items":{"type":"object","properties":{"optionTypeId":{"type":"string","minLength":1,"maxLength":30},"name":{"type":"string","minLength":1,"maxLength":100},"sortOrder":{"default":0,"type":"integer","minimum":-9007199254740991,"maximum":9007199254740991},"values":{"maxItems":200,"type":"array","items":{"type":"object","properties":{"optionValueId":{"type":"string","minLength":1,"maxLength":30},"value":{"type":"string","minLength":1,"maxLength":100},"groupLabel":{"default":null,"anyOf":[{"type":"string","maxLength":100},{"type":"null"}]},"sortOrder":{"default":0,"type":"integer","minimum":-9007199254740991,"maximum":9007199254740991}},"required":["optionValueId","value"]}}},"required":["optionTypeId","name","values"]}},"pricingMode":{"default":"PCS","type":"string","enum":["PCS","AREA"]},"defaultLengthUnit":{"default":null,"anyOf":[{"type":"string","enum":["FT","IN","CM","MM","M"]},{"type":"null"}]}},"required":["name"]},"example":{"name":"Cotton Bedsheet - Printed","sellingPrice":899}}}},"tags":["Items"]}},"/api/v1/items/{id}":{"get":{"summary":"Get an item","description":"Includes the item's `variants` array.","parameters":[{"name":"id","in":"path","required":true,"description":"Item ID.","schema":{"type":"string","example":"clx3itm000000000000000001"}}],"responses":{"200":{"description":"Get an item","content":{"application/json":{"example":{"success":true,"data":{"id":"clx3itm000000000000000001","organizationId":"clx0org000000000000000001","name":"Cotton Bedsheet - Printed","sku":"BSH-COT-001","hsnOrSac":"6304","type":"GOODS","groupId":"clx4grp000000000000000001","sizeModuleId":"clx5szm000000000000000001","unit":"PCS","pricingMode":"PCS","defaultLengthUnit":null,"masterUnit":"BOX","piecesPerMaster":12,"sellingPrice":899,"purchasePrice":550,"isPriceInclusive":false,"taxRateId":"clx6tax000000000000000001","description":"100% cotton printed double bedsheet with 2 pillow covers.","reorderQuantity":20,"barcode":"8901234567890","trackInventory":true,"isActive":true,"primaryVendorId":"clx2v1e2n3d4o5r6a7b8c9d0","createdBy":"clxusr0000000000000000001","updatedBy":"clxusr0000000000000000001","createdAt":"2026-05-10T06:00:00.000Z","updatedAt":"2026-08-28T10:12:00.000Z","variants":[{"id":"clx7var000000000000000001","organizationId":"clx0org000000000000000001","itemId":"clx3itm000000000000000001","size":"Queen","sku":"BSH-COT-001-Q","barcode":"8901234567891","sellingPrice":899,"purchasePrice":550,"isActive":true,"sortOrder":0,"createdAt":"2026-05-10T06:00:00.000Z","updatedAt":"2026-05-10T06:00:00.000Z"}]}}}}},"401":{"description":"Missing bearer token","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"unauthorized"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"unauthorized","message":"Missing bearer token"}}}}},"403":{"description":"Access denied","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"forbidden"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"forbidden","message":"Access denied"}}}}},"404":{"description":"Resource not found","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"not_found"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"not_found","message":"Resource not found"}}}}}},"security":[{"bearerAuth":[]}],"tags":["Items"]},"patch":{"summary":"Update an item","description":"PATCH validates against the full item schema (same as create) — name is required in every update, not just changed fields.","parameters":[{"name":"id","in":"path","required":true,"description":"Item ID.","schema":{"type":"string","example":"clx3itm000000000000000001"}}],"responses":{"200":{"description":"Update an item","content":{"application/json":{"example":{"success":true,"data":{"id":"clx3itm000000000000000001","organizationId":"clx0org000000000000000001","name":"Cotton Bedsheet - Printed","sku":"BSH-COT-001","hsnOrSac":"6304","type":"GOODS","groupId":"clx4grp000000000000000001","sizeModuleId":"clx5szm000000000000000001","unit":"PCS","pricingMode":"PCS","defaultLengthUnit":null,"masterUnit":"BOX","piecesPerMaster":12,"sellingPrice":899,"purchasePrice":550,"isPriceInclusive":false,"taxRateId":"clx6tax000000000000000001","description":"100% cotton printed double bedsheet with 2 pillow covers.","reorderQuantity":20,"barcode":"8901234567890","trackInventory":true,"isActive":true,"primaryVendorId":"clx2v1e2n3d4o5r6a7b8c9d0","createdBy":"clxusr0000000000000000001","updatedBy":"clxusr0000000000000000001","createdAt":"2026-05-10T06:00:00.000Z","updatedAt":"2026-08-28T10:12:00.000Z","variants":[{"id":"clx7var000000000000000001","organizationId":"clx0org000000000000000001","itemId":"clx3itm000000000000000001","size":"Queen","sku":"BSH-COT-001-Q","barcode":"8901234567891","sellingPrice":899,"purchasePrice":550,"isActive":true,"sortOrder":0,"createdAt":"2026-05-10T06:00:00.000Z","updatedAt":"2026-05-10T06:00:00.000Z"}]}}}}},"401":{"description":"Missing bearer token","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"unauthorized"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"unauthorized","message":"Missing bearer token"}}}}},"403":{"description":"Access denied","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"forbidden"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"forbidden","message":"Access denied"}}}}},"404":{"description":"Resource not found","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"not_found"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"not_found","message":"Resource not found"}}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"validation_error"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"validation_error","message":"Validation failed"}}}}}},"security":[{"bearerAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$schema":"https://json-schema.org/draft/2020-12/schema","type":"object","properties":{"name":{"type":"string","minLength":1,"maxLength":191},"sku":{"anyOf":[{"type":"string","maxLength":100},{"type":"string","const":""}]},"hsnOrSac":{"anyOf":[{"type":"string","maxLength":10},{"type":"string","const":""}]},"type":{"default":"GOODS","type":"string","enum":["GOODS","SERVICE","BUNDLE"]},"groupId":{"anyOf":[{"type":"string","maxLength":30},{"type":"string","const":""}]},"sizeModuleId":{"anyOf":[{"type":"string","maxLength":30},{"type":"string","const":""}]},"unit":{"default":"PCS","type":"string","minLength":1,"maxLength":20},"masterUnit":{"anyOf":[{"type":"string","maxLength":20},{"type":"string","const":""}]},"piecesPerMaster":{"default":1,"type":"number","exclusiveMinimum":0},"sellingPrice":{"default":0,"type":"number","minimum":0},"purchasePrice":{"default":0,"type":"number","minimum":0},"isPriceInclusive":{"default":"inherit","type":"string","enum":["inherit","true","false"]},"taxRateId":{"anyOf":[{"type":"string","maxLength":30},{"type":"string","const":""}]},"barcode":{"anyOf":[{"type":"string","maxLength":100},{"type":"string","const":""}]},"description":{"anyOf":[{"type":"string","maxLength":2000},{"type":"string","const":""}]},"trackInventory":{"default":false,"type":"boolean"},"primaryVendorId":{"anyOf":[{"type":"string","maxLength":30},{"type":"null"}]},"variants":{"default":[],"type":"array","items":{"type":"object","properties":{"id":{"anyOf":[{"type":"string","maxLength":30},{"type":"string","const":""}]},"size":{"default":"","type":"string","maxLength":100},"options":{"default":[],"maxItems":5,"type":"array","items":{"type":"object","properties":{"optionTypeId":{"type":"string","minLength":1,"maxLength":30},"optionValueId":{"type":"string","minLength":1,"maxLength":30}},"required":["optionTypeId","optionValueId"]}},"sku":{"anyOf":[{"type":"string","maxLength":100},{"type":"string","const":""}]},"barcode":{"anyOf":[{"type":"string","maxLength":100},{"type":"string","const":""}]},"sellingPrice":{"default":0,"type":"number","minimum":0},"purchasePrice":{"default":0,"type":"number","minimum":0},"stock":{"default":0,"type":"number","minimum":0},"lowStockThreshold":{"default":10,"type":"integer","minimum":0,"maximum":9007199254740991},"isActive":{"default":true,"type":"boolean"},"sortOrder":{"default":0,"type":"integer","minimum":-9007199254740991,"maximum":9007199254740991}}}},"axes":{"default":[],"maxItems":5,"type":"array","items":{"type":"object","properties":{"optionTypeId":{"type":"string","minLength":1,"maxLength":30},"name":{"type":"string","minLength":1,"maxLength":100},"sortOrder":{"default":0,"type":"integer","minimum":-9007199254740991,"maximum":9007199254740991},"values":{"maxItems":200,"type":"array","items":{"type":"object","properties":{"optionValueId":{"type":"string","minLength":1,"maxLength":30},"value":{"type":"string","minLength":1,"maxLength":100},"groupLabel":{"default":null,"anyOf":[{"type":"string","maxLength":100},{"type":"null"}]},"sortOrder":{"default":0,"type":"integer","minimum":-9007199254740991,"maximum":9007199254740991}},"required":["optionValueId","value"]}}},"required":["optionTypeId","name","values"]}},"pricingMode":{"default":"PCS","type":"string","enum":["PCS","AREA"]},"defaultLengthUnit":{"default":null,"anyOf":[{"type":"string","enum":["FT","IN","CM","MM","M"]},{"type":"null"}]}},"required":["name"]},"example":{"name":"Cotton Bedsheet - Printed","sellingPrice":949}}}},"tags":["Items"]},"delete":{"summary":"Delete an item","parameters":[{"name":"id","in":"path","required":true,"description":"Item ID.","schema":{"type":"string","example":"clx3itm000000000000000001"}}],"responses":{"200":{"description":"Delete an item","content":{"application/json":{"example":{"success":true,"data":{"deleted":true}}}}},"401":{"description":"Missing bearer token","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"unauthorized"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"unauthorized","message":"Missing bearer token"}}}}},"403":{"description":"Access denied","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"forbidden"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"forbidden","message":"Access denied"}}}}},"404":{"description":"Resource not found","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"not_found"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"not_found","message":"Resource not found"}}}}}},"security":[{"bearerAuth":[]}],"tags":["Items"]}},"/api/v1/items/{id}/core":{"patch":{"summary":"Update an item's core scalar fields","description":"Additive, mobile-safe update of core fields only (name/sku/hsnOrSac/type/unit/prices/barcode/description/trackInventory). Never touches variants, price-list entries, taxRateId, groupId/sizeModuleId, masterUnit/piecesPerMaster, isPriceInclusive, primaryVendorId, or area-pricing fields. This is a full replace of the core columns — an omitted core field resets to its default, so send the complete current core-field set, not just what changed.","parameters":[{"name":"id","in":"path","required":true,"description":"Item ID.","schema":{"type":"string","example":"clx3itm000000000000000001"}}],"responses":{"200":{"description":"Update an item's core scalar fields","content":{"application/json":{"example":{"success":true,"data":{"id":"clx3itm000000000000000001","organizationId":"clx0org000000000000000001","name":"Cotton Bedsheet - Printed","sku":"BSH-COT-001","hsnOrSac":"6304","type":"GOODS","groupId":"clx4grp000000000000000001","sizeModuleId":"clx5szm000000000000000001","unit":"PCS","pricingMode":"PCS","defaultLengthUnit":null,"masterUnit":"BOX","piecesPerMaster":12,"sellingPrice":899,"purchasePrice":550,"isPriceInclusive":false,"taxRateId":"clx6tax000000000000000001","description":"100% cotton printed double bedsheet with 2 pillow covers.","reorderQuantity":20,"barcode":"8901234567890","trackInventory":true,"isActive":true,"primaryVendorId":"clx2v1e2n3d4o5r6a7b8c9d0","createdBy":"clxusr0000000000000000001","updatedBy":"clxusr0000000000000000001","createdAt":"2026-05-10T06:00:00.000Z","updatedAt":"2026-08-28T10:12:00.000Z","variants":[{"id":"clx7var000000000000000001","organizationId":"clx0org000000000000000001","itemId":"clx3itm000000000000000001","size":"Queen","sku":"BSH-COT-001-Q","barcode":"8901234567891","sellingPrice":899,"purchasePrice":550,"isActive":true,"sortOrder":0,"createdAt":"2026-05-10T06:00:00.000Z","updatedAt":"2026-05-10T06:00:00.000Z"}]}}}}},"401":{"description":"Missing bearer token","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"unauthorized"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"unauthorized","message":"Missing bearer token"}}}}},"403":{"description":"Access denied","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"forbidden"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"forbidden","message":"Access denied"}}}}},"404":{"description":"Resource not found","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"not_found"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"not_found","message":"Resource not found"}}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"validation_error"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"validation_error","message":"Validation failed"}}}}}},"security":[{"bearerAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$schema":"https://json-schema.org/draft/2020-12/schema","type":"object","properties":{"name":{"type":"string","minLength":1,"maxLength":191},"sku":{"anyOf":[{"type":"string","maxLength":100},{"type":"string","const":""}]},"hsnOrSac":{"anyOf":[{"type":"string","maxLength":10},{"type":"string","const":""}]},"type":{"default":"GOODS","type":"string","enum":["GOODS","SERVICE","BUNDLE"]},"unit":{"default":"PCS","type":"string","minLength":1,"maxLength":20},"sellingPrice":{"default":0,"type":"number","minimum":0},"purchasePrice":{"default":0,"type":"number","minimum":0},"barcode":{"anyOf":[{"type":"string","maxLength":100},{"type":"string","const":""}]},"description":{"anyOf":[{"type":"string","maxLength":2000},{"type":"string","const":""}]},"trackInventory":{"default":false,"type":"boolean"}},"required":["name"]},"example":{"name":"Cotton Bedsheet - Printed","sku":"BSH-COT-001","hsnOrSac":"6304","type":"GOODS","unit":"PCS","sellingPrice":949,"purchasePrice":550,"barcode":"8901234567890","description":"100% cotton printed double bedsheet with 2 pillow covers.","trackInventory":true}}}},"tags":["Items"]}},"/api/v1/item-groups":{"get":{"summary":"List item groups","parameters":[{"name":"page","in":"query","required":false,"description":"1-based page number.","schema":{"type":"number","example":1}},{"name":"limit","in":"query","required":false,"description":"Page size, max 200.","schema":{"type":"number","example":50}}],"responses":{"200":{"description":"List item groups","content":{"application/json":{"example":{"success":true,"data":[{"id":"clx4grp000000000000000001","organizationId":"clx0org000000000000000001","name":"Bedsheets","parentGroupId":"clx4grp000000000000000000","sortOrder":2,"description":"All bedsheet SKUs, printed and plain.","createdBy":"clxusr0000000000000000001","updatedBy":"clxusr0000000000000000001","createdAt":"2026-04-01T05:00:00.000Z","updatedAt":"2026-04-01T05:00:00.000Z"}],"meta":{"page":1,"limit":50,"total":1,"hasMore":false}}}}},"401":{"description":"Missing bearer token","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"unauthorized"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"unauthorized","message":"Missing bearer token"}}}}},"403":{"description":"Access denied","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"forbidden"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"forbidden","message":"Access denied"}}}}}},"security":[{"bearerAuth":[]}],"tags":["Item Groups"]},"post":{"summary":"Create an item group","responses":{"201":{"description":"Create an item group","content":{"application/json":{"example":{"success":true,"data":{"id":"clx4grp000000000000000001","organizationId":"clx0org000000000000000001","name":"Bedsheets","parentGroupId":"clx4grp000000000000000000","sortOrder":2,"description":"All bedsheet SKUs, printed and plain.","createdBy":"clxusr0000000000000000001","updatedBy":"clxusr0000000000000000001","createdAt":"2026-04-01T05:00:00.000Z","updatedAt":"2026-04-01T05:00:00.000Z"}}}}},"401":{"description":"Missing bearer token","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"unauthorized"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"unauthorized","message":"Missing bearer token"}}}}},"403":{"description":"Access denied","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"forbidden"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"forbidden","message":"Access denied"}}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"validation_error"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"validation_error","message":"Validation failed"}}}}}},"security":[{"bearerAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$schema":"https://json-schema.org/draft/2020-12/schema","type":"object","properties":{"name":{"type":"string","minLength":1,"maxLength":191},"parentGroupId":{"anyOf":[{"type":"string","maxLength":30},{"type":"string","const":""}]},"sortOrder":{"default":0,"type":"integer","minimum":-9007199254740991,"maximum":9007199254740991},"description":{"anyOf":[{"type":"string","maxLength":2000},{"type":"string","const":""}]}},"required":["name"]},"example":{"name":"Bedsheets"}}}},"tags":["Item Groups"]}},"/api/v1/item-groups/{id}":{"get":{"summary":"Get an item group","parameters":[{"name":"id","in":"path","required":true,"description":"Item group ID.","schema":{"type":"string","example":"clx4grp000000000000000001"}}],"responses":{"200":{"description":"Get an item group","content":{"application/json":{"example":{"success":true,"data":{"id":"clx4grp000000000000000001","organizationId":"clx0org000000000000000001","name":"Bedsheets","parentGroupId":"clx4grp000000000000000000","sortOrder":2,"description":"All bedsheet SKUs, printed and plain.","createdBy":"clxusr0000000000000000001","updatedBy":"clxusr0000000000000000001","createdAt":"2026-04-01T05:00:00.000Z","updatedAt":"2026-04-01T05:00:00.000Z"}}}}},"401":{"description":"Missing bearer token","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"unauthorized"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"unauthorized","message":"Missing bearer token"}}}}},"403":{"description":"Access denied","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"forbidden"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"forbidden","message":"Access denied"}}}}},"404":{"description":"Resource not found","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"not_found"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"not_found","message":"Resource not found"}}}}}},"security":[{"bearerAuth":[]}],"tags":["Item Groups"]},"patch":{"summary":"Update an item group","description":"PATCH validates against the full item group schema (same as create) — name is required in every update, not just changed fields.","parameters":[{"name":"id","in":"path","required":true,"description":"Item group ID.","schema":{"type":"string","example":"clx4grp000000000000000001"}}],"responses":{"200":{"description":"Update an item group","content":{"application/json":{"example":{"success":true,"data":{"id":"clx4grp000000000000000001","organizationId":"clx0org000000000000000001","name":"Bedsheets","parentGroupId":"clx4grp000000000000000000","sortOrder":2,"description":"All bedsheet SKUs, printed and plain.","createdBy":"clxusr0000000000000000001","updatedBy":"clxusr0000000000000000001","createdAt":"2026-04-01T05:00:00.000Z","updatedAt":"2026-04-01T05:00:00.000Z"}}}}},"401":{"description":"Missing bearer token","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"unauthorized"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"unauthorized","message":"Missing bearer token"}}}}},"403":{"description":"Access denied","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"forbidden"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"forbidden","message":"Access denied"}}}}},"404":{"description":"Resource not found","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"not_found"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"not_found","message":"Resource not found"}}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"validation_error"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"validation_error","message":"Validation failed"}}}}}},"security":[{"bearerAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$schema":"https://json-schema.org/draft/2020-12/schema","type":"object","properties":{"name":{"type":"string","minLength":1,"maxLength":191},"parentGroupId":{"anyOf":[{"type":"string","maxLength":30},{"type":"string","const":""}]},"sortOrder":{"default":0,"type":"integer","minimum":-9007199254740991,"maximum":9007199254740991},"description":{"anyOf":[{"type":"string","maxLength":2000},{"type":"string","const":""}]}},"required":["name"]},"example":{"name":"Bedsheets","sortOrder":3}}}},"tags":["Item Groups"]},"delete":{"summary":"Delete an item group","parameters":[{"name":"id","in":"path","required":true,"description":"Item group ID.","schema":{"type":"string","example":"clx4grp000000000000000001"}}],"responses":{"200":{"description":"Delete an item group","content":{"application/json":{"example":{"success":true,"data":{"deleted":true}}}}},"401":{"description":"Missing bearer token","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"unauthorized"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"unauthorized","message":"Missing bearer token"}}}}},"403":{"description":"Access denied","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"forbidden"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"forbidden","message":"Access denied"}}}}},"404":{"description":"Resource not found","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"not_found"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"not_found","message":"Resource not found"}}}}}},"security":[{"bearerAuth":[]}],"tags":["Item Groups"]}},"/api/v1/warehouses":{"get":{"summary":"List warehouses","parameters":[{"name":"page","in":"query","required":false,"description":"1-based page number.","schema":{"type":"number","example":1}},{"name":"limit","in":"query","required":false,"description":"Page size, max 200.","schema":{"type":"number","example":50}}],"responses":{"200":{"description":"List warehouses","content":{"application/json":{"example":{"success":true,"data":[{"id":"clx9wh0000000000000000001","organizationId":"clx0org000000000000000001","name":"Main Warehouse - Delhi","code":"DEL01","systemKind":"USER","addressLine1":"Plot 45, Okhla Industrial Area Phase II","addressLine2":null,"city":"New Delhi","pincode":"110020","phone":"9988776655","isDefault":true,"isActive":true,"createdBy":"clxusr0000000000000000001","createdAt":"2026-01-01T00:00:00.000Z","updatedAt":"2026-07-15T09:00:00.000Z"}],"meta":{"page":1,"limit":50,"total":1,"hasMore":false}}}}},"401":{"description":"Missing bearer token","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"unauthorized"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"unauthorized","message":"Missing bearer token"}}}}},"403":{"description":"Access denied","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"forbidden"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"forbidden","message":"Access denied"}}}}}},"security":[{"bearerAuth":[]}],"tags":["Warehouses"]},"post":{"summary":"Create a warehouse","responses":{"201":{"description":"Create a warehouse","content":{"application/json":{"example":{"success":true,"data":{"id":"clx9wh0000000000000000001","organizationId":"clx0org000000000000000001","name":"Main Warehouse - Delhi","code":"DEL01","systemKind":"USER","addressLine1":"Plot 45, Okhla Industrial Area Phase II","addressLine2":null,"city":"New Delhi","pincode":"110020","phone":"9988776655","isDefault":true,"isActive":true,"createdBy":"clxusr0000000000000000001","createdAt":"2026-01-01T00:00:00.000Z","updatedAt":"2026-07-15T09:00:00.000Z"}}}}},"401":{"description":"Missing bearer token","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"unauthorized"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"unauthorized","message":"Missing bearer token"}}}}},"403":{"description":"Access denied","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"forbidden"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"forbidden","message":"Access denied"}}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"validation_error"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"validation_error","message":"Validation failed"}}}}}},"security":[{"bearerAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$schema":"https://json-schema.org/draft/2020-12/schema","type":"object","properties":{"name":{"type":"string","minLength":1,"maxLength":191},"code":{"anyOf":[{"type":"string","maxLength":30},{"type":"string","const":""}]},"addressLine1":{"anyOf":[{"type":"string","maxLength":255},{"type":"string","const":""}]},"addressLine2":{"anyOf":[{"type":"string","maxLength":255},{"type":"string","const":""}]},"city":{"anyOf":[{"type":"string","maxLength":100},{"type":"string","const":""}]},"pincode":{"anyOf":[{"type":"string","maxLength":10},{"type":"string","const":""}]},"phone":{"anyOf":[{"type":"string","maxLength":30},{"type":"string","const":""}]},"isDefault":{"default":false,"type":"boolean"},"isActive":{"default":true,"type":"boolean"}},"required":["name"]},"example":{"name":"Main Warehouse - Delhi","code":"DEL01"}}}},"tags":["Warehouses"]}},"/api/v1/warehouses/{id}":{"get":{"summary":"Get a warehouse","parameters":[{"name":"id","in":"path","required":true,"description":"Warehouse ID.","schema":{"type":"string","example":"clx9wh0000000000000000001"}}],"responses":{"200":{"description":"Get a warehouse","content":{"application/json":{"example":{"success":true,"data":{"id":"clx9wh0000000000000000001","organizationId":"clx0org000000000000000001","name":"Main Warehouse - Delhi","code":"DEL01","systemKind":"USER","addressLine1":"Plot 45, Okhla Industrial Area Phase II","addressLine2":null,"city":"New Delhi","pincode":"110020","phone":"9988776655","isDefault":true,"isActive":true,"createdBy":"clxusr0000000000000000001","createdAt":"2026-01-01T00:00:00.000Z","updatedAt":"2026-07-15T09:00:00.000Z"}}}}},"401":{"description":"Missing bearer token","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"unauthorized"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"unauthorized","message":"Missing bearer token"}}}}},"403":{"description":"Access denied","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"forbidden"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"forbidden","message":"Access denied"}}}}},"404":{"description":"Resource not found","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"not_found"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"not_found","message":"Resource not found"}}}}}},"security":[{"bearerAuth":[]}],"tags":["Warehouses"]},"patch":{"summary":"Update a warehouse","description":"PATCH validates against the full warehouse schema (same as create) — name is required in every update, not just changed fields.","parameters":[{"name":"id","in":"path","required":true,"description":"Warehouse ID.","schema":{"type":"string","example":"clx9wh0000000000000000001"}}],"responses":{"200":{"description":"Update a warehouse","content":{"application/json":{"example":{"success":true,"data":{"id":"clx9wh0000000000000000001","organizationId":"clx0org000000000000000001","name":"Main Warehouse - Delhi","code":"DEL01","systemKind":"USER","addressLine1":"Plot 45, Okhla Industrial Area Phase II","addressLine2":null,"city":"New Delhi","pincode":"110020","phone":"9988776655","isDefault":true,"isActive":true,"createdBy":"clxusr0000000000000000001","createdAt":"2026-01-01T00:00:00.000Z","updatedAt":"2026-07-15T09:00:00.000Z"}}}}},"401":{"description":"Missing bearer token","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"unauthorized"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"unauthorized","message":"Missing bearer token"}}}}},"403":{"description":"Access denied","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"forbidden"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"forbidden","message":"Access denied"}}}}},"404":{"description":"Resource not found","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"not_found"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"not_found","message":"Resource not found"}}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"validation_error"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"validation_error","message":"Validation failed"}}}}}},"security":[{"bearerAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$schema":"https://json-schema.org/draft/2020-12/schema","type":"object","properties":{"name":{"type":"string","minLength":1,"maxLength":191},"code":{"anyOf":[{"type":"string","maxLength":30},{"type":"string","const":""}]},"addressLine1":{"anyOf":[{"type":"string","maxLength":255},{"type":"string","const":""}]},"addressLine2":{"anyOf":[{"type":"string","maxLength":255},{"type":"string","const":""}]},"city":{"anyOf":[{"type":"string","maxLength":100},{"type":"string","const":""}]},"pincode":{"anyOf":[{"type":"string","maxLength":10},{"type":"string","const":""}]},"phone":{"anyOf":[{"type":"string","maxLength":30},{"type":"string","const":""}]},"isDefault":{"default":false,"type":"boolean"},"isActive":{"default":true,"type":"boolean"}},"required":["name"]},"example":{"name":"Main Warehouse - Delhi","code":"DEL01","isDefault":true}}}},"tags":["Warehouses"]},"delete":{"summary":"Delete a warehouse","description":"Uses the settings.update scope, not a distinct delete scope.","parameters":[{"name":"id","in":"path","required":true,"description":"Warehouse ID.","schema":{"type":"string","example":"clx9wh0000000000000000001"}}],"responses":{"200":{"description":"Delete a warehouse","content":{"application/json":{"example":{"success":true,"data":{"deleted":true}}}}},"401":{"description":"Missing bearer token","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"unauthorized"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"unauthorized","message":"Missing bearer token"}}}}},"403":{"description":"Access denied","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"forbidden"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"forbidden","message":"Access denied"}}}}},"404":{"description":"Resource not found","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"not_found"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"not_found","message":"Resource not found"}}}}}},"security":[{"bearerAuth":[]}],"tags":["Warehouses"]}},"/api/v1/price-lists":{"get":{"summary":"List price lists","parameters":[{"name":"page","in":"query","required":false,"description":"1-based page number.","schema":{"type":"number","example":1}},{"name":"limit","in":"query","required":false,"description":"Page size, max 200.","schema":{"type":"number","example":50}},{"name":"q","in":"query","required":false,"description":"Free-text search on name.","schema":{"type":"string"}}],"responses":{"200":{"description":"List price lists","content":{"application/json":{"example":{"success":true,"data":[{"id":"clx2price0000qzrm1p5x8n2a","organizationId":"clx0org000000000000000001","name":"Retail Selling Price List","type":"SELLING","description":"Standard MRP-based selling price list","isActive":true,"isDefault":true,"effectiveFrom":"2026-01-01T00:00:00.000Z","effectiveTo":null,"createdAt":"2026-01-01T09:15:00.000Z","updatedAt":"2026-01-01T09:15:00.000Z"}],"meta":{"page":1,"limit":50,"total":1,"hasMore":false}}}}},"401":{"description":"Missing bearer token","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"unauthorized"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"unauthorized","message":"Missing bearer token"}}}}},"403":{"description":"Access denied","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"forbidden"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"forbidden","message":"Access denied"}}}}}},"security":[{"bearerAuth":[]}],"tags":["Price Lists"]},"post":{"summary":"Create a price list","responses":{"201":{"description":"Create a price list","content":{"application/json":{"example":{"success":true,"data":{"id":"clx2price0000qzrm1p5x8n2a","organizationId":"clx0org000000000000000001","name":"Retail Selling Price List","type":"SELLING","description":"Standard MRP-based selling price list","isActive":true,"isDefault":true,"effectiveFrom":"2026-01-01T00:00:00.000Z","effectiveTo":null,"createdAt":"2026-01-01T09:15:00.000Z","updatedAt":"2026-01-01T09:15:00.000Z","entries":[{"id":"clx2entry0000qzrmabcd1234","organizationId":"clx0org000000000000000001","priceListId":"clx2price0000qzrm1p5x8n2a","itemId":"clx3itm000000000000000001","itemVariantId":null,"rate":499.5,"createdAt":"2026-01-01T09:15:00.000Z","updatedAt":"2026-01-01T09:15:00.000Z"}]}}}}},"401":{"description":"Missing bearer token","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"unauthorized"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"unauthorized","message":"Missing bearer token"}}}}},"403":{"description":"Access denied","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"forbidden"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"forbidden","message":"Access denied"}}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"validation_error"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"validation_error","message":"Validation failed"}}}}}},"security":[{"bearerAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$schema":"https://json-schema.org/draft/2020-12/schema","type":"object","properties":{"name":{"type":"string","minLength":1,"maxLength":150},"type":{"type":"string","enum":["SELLING","PURCHASE"]},"description":{"anyOf":[{"type":"string","maxLength":500},{"type":"string","const":""}]},"isActive":{"default":true,"type":"boolean"},"isDefault":{"default":false,"type":"boolean"},"effectiveFrom":{"anyOf":[{"type":"string","format":"date-time"},{"type":"string","const":""}]},"effectiveTo":{"anyOf":[{"type":"string","format":"date-time"},{"type":"string","const":""}]},"entries":{"type":"array","items":{"type":"object","properties":{"itemId":{"type":"string","minLength":1},"itemVariantId":{"anyOf":[{"type":"string"},{"type":"null"}]},"rate":{"type":"number","minimum":0}},"required":["itemId","rate"]}}},"required":["name","type"]},"example":{"name":"Retail Selling Price List","type":"SELLING","entries":[{"itemId":"clx3itm000000000000000001","rate":499.5}]}}}},"tags":["Price Lists"]}},"/api/v1/price-lists/{id}":{"get":{"summary":"Get a price list","parameters":[{"name":"id","in":"path","required":true,"description":"Price list ID.","schema":{"type":"string","example":"clx2price0000qzrm1p5x8n2a"}}],"responses":{"200":{"description":"Get a price list","content":{"application/json":{"example":{"success":true,"data":{"id":"clx2price0000qzrm1p5x8n2a","organizationId":"clx0org000000000000000001","name":"Retail Selling Price List","type":"SELLING","description":"Standard MRP-based selling price list","isActive":true,"isDefault":true,"effectiveFrom":"2026-01-01T00:00:00.000Z","effectiveTo":null,"createdAt":"2026-01-01T09:15:00.000Z","updatedAt":"2026-01-01T09:15:00.000Z","entries":[{"id":"clx2entry0000qzrmabcd1234","organizationId":"clx0org000000000000000001","priceListId":"clx2price0000qzrm1p5x8n2a","itemId":"clx3itm000000000000000001","itemVariantId":null,"rate":499.5,"createdAt":"2026-01-01T09:15:00.000Z","updatedAt":"2026-01-01T09:15:00.000Z"}]}}}}},"401":{"description":"Missing bearer token","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"unauthorized"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"unauthorized","message":"Missing bearer token"}}}}},"403":{"description":"Access denied","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"forbidden"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"forbidden","message":"Access denied"}}}}},"404":{"description":"Resource not found","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"not_found"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"not_found","message":"Resource not found"}}}}}},"security":[{"bearerAuth":[]}],"tags":["Price Lists"]},"patch":{"summary":"Update a price list","description":"PATCH validates against the full price list schema (same as create) — name and type are required in every update, not just changed fields.","parameters":[{"name":"id","in":"path","required":true,"description":"Price list ID.","schema":{"type":"string","example":"clx2price0000qzrm1p5x8n2a"}}],"responses":{"200":{"description":"Update a price list","content":{"application/json":{"example":{"success":true,"data":{"id":"clx2price0000qzrm1p5x8n2a","organizationId":"clx0org000000000000000001","name":"Retail Selling Price List","type":"SELLING","description":"Standard MRP-based selling price list","isActive":true,"isDefault":true,"effectiveFrom":"2026-01-01T00:00:00.000Z","effectiveTo":null,"createdAt":"2026-01-01T09:15:00.000Z","updatedAt":"2026-01-01T09:15:00.000Z","entries":[{"id":"clx2entry0000qzrmabcd1234","organizationId":"clx0org000000000000000001","priceListId":"clx2price0000qzrm1p5x8n2a","itemId":"clx3itm000000000000000001","itemVariantId":null,"rate":499.5,"createdAt":"2026-01-01T09:15:00.000Z","updatedAt":"2026-01-01T09:15:00.000Z"}]}}}}},"401":{"description":"Missing bearer token","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"unauthorized"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"unauthorized","message":"Missing bearer token"}}}}},"403":{"description":"Access denied","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"forbidden"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"forbidden","message":"Access denied"}}}}},"404":{"description":"Resource not found","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"not_found"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"not_found","message":"Resource not found"}}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"validation_error"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"validation_error","message":"Validation failed"}}}}}},"security":[{"bearerAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$schema":"https://json-schema.org/draft/2020-12/schema","type":"object","properties":{"name":{"type":"string","minLength":1,"maxLength":150},"type":{"type":"string","enum":["SELLING","PURCHASE"]},"description":{"anyOf":[{"type":"string","maxLength":500},{"type":"string","const":""}]},"isActive":{"default":true,"type":"boolean"},"isDefault":{"default":false,"type":"boolean"},"effectiveFrom":{"anyOf":[{"type":"string","format":"date-time"},{"type":"string","const":""}]},"effectiveTo":{"anyOf":[{"type":"string","format":"date-time"},{"type":"string","const":""}]},"entries":{"type":"array","items":{"type":"object","properties":{"itemId":{"type":"string","minLength":1},"itemVariantId":{"anyOf":[{"type":"string"},{"type":"null"}]},"rate":{"type":"number","minimum":0}},"required":["itemId","rate"]}}},"required":["name","type"]},"example":{"name":"Retail Selling Price List","type":"SELLING","isDefault":true}}}},"tags":["Price Lists"]},"delete":{"summary":"Delete a price list","parameters":[{"name":"id","in":"path","required":true,"description":"Price list ID.","schema":{"type":"string","example":"clx2price0000qzrm1p5x8n2a"}}],"responses":{"200":{"description":"Delete a price list","content":{"application/json":{"example":{"success":true,"data":{"deleted":true}}}}},"401":{"description":"Missing bearer token","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"unauthorized"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"unauthorized","message":"Missing bearer token"}}}}},"403":{"description":"Access denied","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"forbidden"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"forbidden","message":"Access denied"}}}}},"404":{"description":"Resource not found","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"not_found"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"not_found","message":"Resource not found"}}}}}},"security":[{"bearerAuth":[]}],"tags":["Price Lists"]}},"/api/v1/number-series":{"get":{"summary":"List number series","parameters":[{"name":"page","in":"query","required":false,"description":"1-based page number.","schema":{"type":"number","example":1}},{"name":"limit","in":"query","required":false,"description":"Page size, max 200.","schema":{"type":"number","example":50}}],"responses":{"200":{"description":"List number series","content":{"application/json":{"example":{"success":true,"data":[{"id":"clx4ns000000000000000001","organizationId":"clx0org000000000000000001","docType":"INVOICE","prefix":"INV-","suffix":"","padding":5,"nextNumber":42,"resetYearly":true,"updatedAt":"2026-04-01T00:00:00.000Z"}],"meta":{"page":1,"limit":50,"total":1,"hasMore":false}}}}},"401":{"description":"Missing bearer token","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"unauthorized"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"unauthorized","message":"Missing bearer token"}}}}},"403":{"description":"Access denied","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"forbidden"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"forbidden","message":"Access denied"}}}}}},"security":[{"bearerAuth":[]}],"tags":["Number Series"]},"post":{"summary":"Create a number series","description":"docType has a unique constraint per organization — one series per document type.","responses":{"201":{"description":"Create a number series","content":{"application/json":{"example":{"success":true,"data":{"id":"clx4ns000000000000000001","organizationId":"clx0org000000000000000001","docType":"INVOICE","prefix":"INV-","suffix":"","padding":5,"nextNumber":42,"resetYearly":true,"updatedAt":"2026-04-01T00:00:00.000Z"}}}}},"401":{"description":"Missing bearer token","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"unauthorized"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"unauthorized","message":"Missing bearer token"}}}}},"403":{"description":"Access denied","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"forbidden"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"forbidden","message":"Access denied"}}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"conflict"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"conflict","message":"Conflict"}}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"validation_error"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"validation_error","message":"Validation failed"}}}}}},"security":[{"bearerAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$schema":"https://json-schema.org/draft/2020-12/schema","type":"object","properties":{"docType":{"type":"string","enum":["QUOTE","SALES_ORDER","INVOICE","PAYMENT_RECEIVED","PURCHASE_ORDER","BILL","PAYMENT_MADE","EXPENSE","CREDIT_NOTE","DEBIT_NOTE","DEBIT_ADJUSTMENT","CREDIT_ADJUSTMENT"]},"prefix":{"default":"","type":"string","maxLength":40},"suffix":{"default":"","type":"string","maxLength":20},"padding":{"default":5,"type":"integer","minimum":1,"maximum":10},"nextNumber":{"default":1,"type":"integer","minimum":1,"maximum":9007199254740991},"resetYearly":{"default":true,"type":"boolean"}},"required":["docType"]},"example":{"docType":"INVOICE","prefix":"INV-","padding":5}}}},"tags":["Number Series"]}},"/api/v1/number-series/{id}":{"get":{"summary":"Get a number series","parameters":[{"name":"id","in":"path","required":true,"description":"Number series ID.","schema":{"type":"string","example":"clx4ns000000000000000001"}}],"responses":{"200":{"description":"Get a number series","content":{"application/json":{"example":{"success":true,"data":{"id":"clx4ns000000000000000001","organizationId":"clx0org000000000000000001","docType":"INVOICE","prefix":"INV-","suffix":"","padding":5,"nextNumber":42,"resetYearly":true,"updatedAt":"2026-04-01T00:00:00.000Z"}}}}},"401":{"description":"Missing bearer token","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"unauthorized"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"unauthorized","message":"Missing bearer token"}}}}},"403":{"description":"Access denied","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"forbidden"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"forbidden","message":"Access denied"}}}}},"404":{"description":"Resource not found","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"not_found"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"not_found","message":"Resource not found"}}}}}},"security":[{"bearerAuth":[]}],"tags":["Number Series"]},"patch":{"summary":"Update a number series","description":"docType is immutable and cannot be changed after creation.","parameters":[{"name":"id","in":"path","required":true,"description":"Number series ID.","schema":{"type":"string","example":"clx4ns000000000000000001"}}],"responses":{"200":{"description":"Update a number series","content":{"application/json":{"example":{"success":true,"data":{"id":"clx4ns000000000000000001","organizationId":"clx0org000000000000000001","docType":"INVOICE","prefix":"INV-","suffix":"","padding":5,"nextNumber":42,"resetYearly":true,"updatedAt":"2026-04-01T00:00:00.000Z"}}}}},"401":{"description":"Missing bearer token","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"unauthorized"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"unauthorized","message":"Missing bearer token"}}}}},"403":{"description":"Access denied","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"forbidden"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"forbidden","message":"Access denied"}}}}},"404":{"description":"Resource not found","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"not_found"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"not_found","message":"Resource not found"}}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"validation_error"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"validation_error","message":"Validation failed"}}}}}},"security":[{"bearerAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$schema":"https://json-schema.org/draft/2020-12/schema","type":"object","properties":{"prefix":{"type":"string","maxLength":40},"suffix":{"type":"string","maxLength":20},"padding":{"type":"integer","minimum":1,"maximum":10},"nextNumber":{"type":"integer","minimum":1,"maximum":9007199254740991},"resetYearly":{"type":"boolean"}}},"example":{"nextNumber":100}}}},"tags":["Number Series"]},"delete":{"summary":"Delete a number series","parameters":[{"name":"id","in":"path","required":true,"description":"Number series ID.","schema":{"type":"string","example":"clx4ns000000000000000001"}}],"responses":{"200":{"description":"Delete a number series","content":{"application/json":{"example":{"success":true,"data":{"deleted":true}}}}},"401":{"description":"Missing bearer token","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"unauthorized"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"unauthorized","message":"Missing bearer token"}}}}},"403":{"description":"Access denied","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"forbidden"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"forbidden","message":"Access denied"}}}}},"404":{"description":"Resource not found","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"not_found"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"not_found","message":"Resource not found"}}}}}},"security":[{"bearerAuth":[]}],"tags":["Number Series"]}},"/api/v1/expenses":{"get":{"summary":"List expenses","parameters":[{"name":"page","in":"query","required":false,"description":"1-based page number.","schema":{"type":"number","example":1}},{"name":"limit","in":"query","required":false,"description":"Page size, max 200.","schema":{"type":"number","example":50}}],"responses":{"200":{"description":"List expenses","content":{"application/json":{"example":{"success":true,"data":[{"id":"clx5exp00000000000000001","organizationId":"clx0org000000000000000001","expenseNumber":"EXP-00042","vendorId":"clx2v1e2n3d4o5r6a7b8c9d0","category":"Office Supplies","expenseDate":"2026-09-01T00:00:00.000Z","paidThroughAccount":"Petty Cash","amount":2500,"taxRatePercent":18,"taxAmount":450,"itcEligible":true,"notes":"Stationery purchase for Q3","currencyCode":"INR","exchangeRate":1,"createdBy":"clxusr0000000000000000001","updatedBy":null,"createdAt":"2026-09-01T10:00:00.000Z","updatedAt":"2026-09-01T10:00:00.000Z"}],"meta":{"page":1,"limit":50,"total":1,"hasMore":false}}}}},"401":{"description":"Missing bearer token","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"unauthorized"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"unauthorized","message":"Missing bearer token"}}}}},"403":{"description":"Access denied","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"forbidden"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"forbidden","message":"Access denied"}}}}}},"security":[{"bearerAuth":[]}],"tags":["Expenses"]},"post":{"summary":"Create an expense","description":"expenseNumber is allocated automatically from the org's number series — do not send it.","responses":{"201":{"description":"Create an expense","content":{"application/json":{"example":{"success":true,"data":{"id":"clx5exp00000000000000001","organizationId":"clx0org000000000000000001","expenseNumber":"EXP-00042","vendorId":"clx2v1e2n3d4o5r6a7b8c9d0","category":"Office Supplies","expenseDate":"2026-09-01T00:00:00.000Z","paidThroughAccount":"Petty Cash","amount":2500,"taxRatePercent":18,"taxAmount":450,"itcEligible":true,"notes":"Stationery purchase for Q3","currencyCode":"INR","exchangeRate":1,"createdBy":"clxusr0000000000000000001","updatedBy":null,"createdAt":"2026-09-01T10:00:00.000Z","updatedAt":"2026-09-01T10:00:00.000Z"}}}}},"401":{"description":"Missing bearer token","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"unauthorized"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"unauthorized","message":"Missing bearer token"}}}}},"403":{"description":"Access denied","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"forbidden"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"forbidden","message":"Access denied"}}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"validation_error"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"validation_error","message":"Validation failed"}}}}}},"security":[{"bearerAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$schema":"https://json-schema.org/draft/2020-12/schema","type":"object","properties":{"vendorId":{"anyOf":[{"type":"string","maxLength":30},{"type":"string","const":""}]},"category":{"type":"string","minLength":1,"maxLength":100},"expenseDate":{"type":"string","format":"date-time"},"paidThroughAccount":{"anyOf":[{"type":"string","maxLength":100},{"type":"string","const":""}]},"amount":{"type":"number","exclusiveMinimum":0},"taxRatePercent":{"default":0,"type":"number","minimum":0,"maximum":100},"taxAmount":{"default":0,"type":"number","minimum":0},"itcEligible":{"default":false,"type":"boolean"},"currencyCode":{"default":"INR","type":"string","minLength":3,"maxLength":3},"exchangeRate":{"default":1,"type":"number","exclusiveMinimum":0},"notes":{"anyOf":[{"type":"string","maxLength":2000},{"type":"string","const":""}]}},"required":["category","expenseDate","amount"]},"example":{"category":"Office Supplies","expenseDate":"2026-09-01","amount":2500}}}},"tags":["Expenses"]}},"/api/v1/expenses/{id}":{"get":{"summary":"Get an expense","parameters":[{"name":"id","in":"path","required":true,"description":"Expense ID.","schema":{"type":"string","example":"clx5exp00000000000000001"}}],"responses":{"200":{"description":"Get an expense","content":{"application/json":{"example":{"success":true,"data":{"id":"clx5exp00000000000000001","organizationId":"clx0org000000000000000001","expenseNumber":"EXP-00042","vendorId":"clx2v1e2n3d4o5r6a7b8c9d0","category":"Office Supplies","expenseDate":"2026-09-01T00:00:00.000Z","paidThroughAccount":"Petty Cash","amount":2500,"taxRatePercent":18,"taxAmount":450,"itcEligible":true,"notes":"Stationery purchase for Q3","currencyCode":"INR","exchangeRate":1,"createdBy":"clxusr0000000000000000001","updatedBy":null,"createdAt":"2026-09-01T10:00:00.000Z","updatedAt":"2026-09-01T10:00:00.000Z"}}}}},"401":{"description":"Missing bearer token","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"unauthorized"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"unauthorized","message":"Missing bearer token"}}}}},"403":{"description":"Access denied","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"forbidden"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"forbidden","message":"Access denied"}}}}},"404":{"description":"Resource not found","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"not_found"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"not_found","message":"Resource not found"}}}}}},"security":[{"bearerAuth":[]}],"tags":["Expenses"]},"patch":{"summary":"Update an expense","description":"PATCH validates against the full expense schema (same as create) — category, expenseDate, and amount are required in every update.","parameters":[{"name":"id","in":"path","required":true,"description":"Expense ID.","schema":{"type":"string","example":"clx5exp00000000000000001"}}],"responses":{"200":{"description":"Update an expense","content":{"application/json":{"example":{"success":true,"data":{"id":"clx5exp00000000000000001","organizationId":"clx0org000000000000000001","expenseNumber":"EXP-00042","vendorId":"clx2v1e2n3d4o5r6a7b8c9d0","category":"Office Supplies","expenseDate":"2026-09-01T00:00:00.000Z","paidThroughAccount":"Petty Cash","amount":2500,"taxRatePercent":18,"taxAmount":450,"itcEligible":true,"notes":"Stationery purchase for Q3","currencyCode":"INR","exchangeRate":1,"createdBy":"clxusr0000000000000000001","updatedBy":null,"createdAt":"2026-09-01T10:00:00.000Z","updatedAt":"2026-09-01T10:00:00.000Z"}}}}},"401":{"description":"Missing bearer token","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"unauthorized"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"unauthorized","message":"Missing bearer token"}}}}},"403":{"description":"Access denied","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"forbidden"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"forbidden","message":"Access denied"}}}}},"404":{"description":"Resource not found","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"not_found"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"not_found","message":"Resource not found"}}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"validation_error"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"validation_error","message":"Validation failed"}}}}}},"security":[{"bearerAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$schema":"https://json-schema.org/draft/2020-12/schema","type":"object","properties":{"vendorId":{"anyOf":[{"type":"string","maxLength":30},{"type":"string","const":""}]},"category":{"type":"string","minLength":1,"maxLength":100},"expenseDate":{"type":"string","format":"date-time"},"paidThroughAccount":{"anyOf":[{"type":"string","maxLength":100},{"type":"string","const":""}]},"amount":{"type":"number","exclusiveMinimum":0},"taxRatePercent":{"default":0,"type":"number","minimum":0,"maximum":100},"taxAmount":{"default":0,"type":"number","minimum":0},"itcEligible":{"default":false,"type":"boolean"},"currencyCode":{"default":"INR","type":"string","minLength":3,"maxLength":3},"exchangeRate":{"default":1,"type":"number","exclusiveMinimum":0},"notes":{"anyOf":[{"type":"string","maxLength":2000},{"type":"string","const":""}]}},"required":["category","expenseDate","amount"]},"example":{"category":"Office Supplies","expenseDate":"2026-09-01","amount":2750}}}},"tags":["Expenses"]},"delete":{"summary":"Delete an expense","parameters":[{"name":"id","in":"path","required":true,"description":"Expense ID.","schema":{"type":"string","example":"clx5exp00000000000000001"}}],"responses":{"200":{"description":"Delete an expense","content":{"application/json":{"example":{"success":true,"data":{"deleted":true}}}}},"401":{"description":"Missing bearer token","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"unauthorized"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"unauthorized","message":"Missing bearer token"}}}}},"403":{"description":"Access denied","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"forbidden"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"forbidden","message":"Access denied"}}}}},"404":{"description":"Resource not found","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"not_found"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"not_found","message":"Resource not found"}}}}}},"security":[{"bearerAuth":[]}],"tags":["Expenses"]}},"/api/v1/customer-contacts":{"get":{"summary":"List customer contacts","parameters":[{"name":"page","in":"query","required":false,"description":"1-based page number.","schema":{"type":"number","example":1}},{"name":"limit","in":"query","required":false,"description":"Page size, max 200.","schema":{"type":"number","example":50}},{"name":"q","in":"query","required":false,"description":"Free-text search.","schema":{"type":"string"}},{"name":"customerId","in":"query","required":false,"description":"Filter to one customer's contacts.","schema":{"type":"string"}}],"responses":{"200":{"description":"List customer contacts","content":{"application/json":{"example":{"success":true,"data":[{"id":"clx6cnt00000000000000001","organizationId":"clx0org000000000000000001","customerId":"clx1a2b3c4d5e6f7g8h9i0j1","name":"Priya Sharma","email":"priya.sharma@example.com","phone":"+919876543210","roleLabel":"Accounts Payable","isPrimary":false,"enabled":true,"invitedAt":null,"lastLoginAt":null,"createdAt":"2026-02-15T05:45:00.000Z","updatedAt":"2026-02-15T05:45:00.000Z"}],"meta":{"page":1,"limit":50,"total":1,"hasMore":false}}}}},"401":{"description":"Missing bearer token","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"unauthorized"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"unauthorized","message":"Missing bearer token"}}}}},"403":{"description":"Access denied","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"forbidden"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"forbidden","message":"Access denied"}}}}}},"security":[{"bearerAuth":[]}],"tags":["Customer Contacts"]},"post":{"summary":"Create a customer contact","responses":{"201":{"description":"Create a customer contact","content":{"application/json":{"example":{"success":true,"data":{"id":"clx6cnt00000000000000001","organizationId":"clx0org000000000000000001","customerId":"clx1a2b3c4d5e6f7g8h9i0j1","name":"Priya Sharma","email":"priya.sharma@example.com","phone":"+919876543210","roleLabel":"Accounts Payable","isPrimary":false,"enabled":true,"invitedAt":null,"lastLoginAt":null,"createdAt":"2026-02-15T05:45:00.000Z","updatedAt":"2026-02-15T05:45:00.000Z"}}}}},"401":{"description":"Missing bearer token","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"unauthorized"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"unauthorized","message":"Missing bearer token"}}}}},"403":{"description":"Access denied","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"forbidden"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"forbidden","message":"Access denied"}}}}},"404":{"description":"Resource not found","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"not_found"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"not_found","message":"Resource not found"}}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"validation_error"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"validation_error","message":"Validation failed"}}}}}},"security":[{"bearerAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$schema":"https://json-schema.org/draft/2020-12/schema","type":"object","properties":{"customerId":{"type":"string","minLength":1},"name":{"type":"string","minLength":1,"maxLength":120},"email":{"anyOf":[{"type":"string","format":"email","pattern":"^(?!\\.)(?!.*\\.\\.)([A-Za-z0-9_'+\\-\\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\\-]*\\.)+[A-Za-z]{2,}$"},{"type":"null"}]},"phone":{"anyOf":[{"type":"string","pattern":"^\\+?\\d{8,15}$"},{"type":"null"}]},"roleLabel":{"anyOf":[{"type":"string","maxLength":60},{"type":"null"}]}},"required":["customerId","name","email","phone","roleLabel"]},"example":{"customerId":"clx1a2b3c4d5e6f7g8h9i0j1","name":"Priya Sharma","email":"priya.sharma@example.com","phone":null,"roleLabel":null}}}},"tags":["Customer Contacts"]}},"/api/v1/customer-contacts/{id}":{"get":{"summary":"Get a customer contact","parameters":[{"name":"id","in":"path","required":true,"description":"Contact ID.","schema":{"type":"string","example":"clx6cnt00000000000000001"}}],"responses":{"200":{"description":"Get a customer contact","content":{"application/json":{"example":{"success":true,"data":{"id":"clx6cnt00000000000000001","organizationId":"clx0org000000000000000001","customerId":"clx1a2b3c4d5e6f7g8h9i0j1","name":"Priya Sharma","email":"priya.sharma@example.com","phone":"+919876543210","roleLabel":"Accounts Payable","isPrimary":false,"enabled":true,"invitedAt":null,"lastLoginAt":null,"createdAt":"2026-02-15T05:45:00.000Z","updatedAt":"2026-02-15T05:45:00.000Z"}}}}},"401":{"description":"Missing bearer token","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"unauthorized"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"unauthorized","message":"Missing bearer token"}}}}},"403":{"description":"Access denied","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"forbidden"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"forbidden","message":"Access denied"}}}}},"404":{"description":"Resource not found","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"not_found"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"not_found","message":"Resource not found"}}}}}},"security":[{"bearerAuth":[]}],"tags":["Customer Contacts"]},"patch":{"summary":"Update a customer contact","parameters":[{"name":"id","in":"path","required":true,"description":"Contact ID.","schema":{"type":"string","example":"clx6cnt00000000000000001"}}],"responses":{"200":{"description":"Update a customer contact","content":{"application/json":{"example":{"success":true,"data":{"id":"clx6cnt00000000000000001","organizationId":"clx0org000000000000000001","customerId":"clx1a2b3c4d5e6f7g8h9i0j1","name":"Priya Sharma","email":"priya.sharma@example.com","phone":"+919876543210","roleLabel":"Accounts Payable","isPrimary":false,"enabled":true,"invitedAt":null,"lastLoginAt":null,"createdAt":"2026-02-15T05:45:00.000Z","updatedAt":"2026-02-15T05:45:00.000Z"}}}}},"401":{"description":"Missing bearer token","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"unauthorized"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"unauthorized","message":"Missing bearer token"}}}}},"403":{"description":"Access denied","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"forbidden"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"forbidden","message":"Access denied"}}}}},"404":{"description":"Resource not found","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"not_found"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"not_found","message":"Resource not found"}}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"validation_error"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"validation_error","message":"Validation failed"}}}}}},"security":[{"bearerAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$schema":"https://json-schema.org/draft/2020-12/schema","type":"object","properties":{"name":{"type":"string","minLength":1,"maxLength":120},"email":{"anyOf":[{"type":"string","format":"email","pattern":"^(?!\\.)(?!.*\\.\\.)([A-Za-z0-9_'+\\-\\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\\-]*\\.)+[A-Za-z]{2,}$"},{"type":"null"}]},"phone":{"anyOf":[{"type":"string","pattern":"^\\+?\\d{8,15}$"},{"type":"null"}]},"roleLabel":{"anyOf":[{"type":"string","maxLength":60},{"type":"null"}]}}},"example":{"roleLabel":"Accounts Payable"}}}},"tags":["Customer Contacts"]},"delete":{"summary":"Disable a customer contact","description":"This is a soft-disable (enabled set to false), not a hard delete — the contact record is retained.","parameters":[{"name":"id","in":"path","required":true,"description":"Contact ID.","schema":{"type":"string","example":"clx6cnt00000000000000001"}}],"responses":{"200":{"description":"Disable a customer contact","content":{"application/json":{"example":{"success":true,"data":{"deleted":true}}}}},"401":{"description":"Missing bearer token","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"unauthorized"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"unauthorized","message":"Missing bearer token"}}}}},"403":{"description":"Access denied","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"forbidden"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"forbidden","message":"Access denied"}}}}},"404":{"description":"Resource not found","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"not_found"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"not_found","message":"Resource not found"}}}}}},"security":[{"bearerAuth":[]}],"tags":["Customer Contacts"]}},"/api/v1/quotes":{"get":{"summary":"List quotes","parameters":[{"name":"page","in":"query","required":false,"description":"1-based page number.","schema":{"type":"number","example":1}},{"name":"limit","in":"query","required":false,"description":"Page size, max 200.","schema":{"type":"number","example":50}},{"name":"q","in":"query","required":false,"description":"Free-text search on quote number.","schema":{"type":"string"}}],"responses":{"200":{"description":"List quotes","content":{"application/json":{"example":{"success":true,"data":[{"id":"clx7quo00000000000000001","organizationId":"clx0org000000000000000001","quoteNumber":"QT-00017","customerId":"clx1a2b3c4d5e6f7g8h9i0j1","status":"SENT","quoteDate":"2026-08-20T00:00:00.000Z","expiryDate":"2026-09-19T00:00:00.000Z","sellerLegalName":"AVS Traders Pvt Ltd","sellerGstin":"29AAAAA0000A1Z5","sellerStateCode":"29","placeOfSupplyStateCode":"29","currencyCode":"INR","exchangeRate":1,"subTotal":10000,"discountTotal":0,"documentDiscount":0,"documentDiscountIsPercent":true,"cgstTotal":900,"sgstTotal":900,"igstTotal":0,"adjustmentLabel":null,"adjustmentAmount":0,"roundOff":0,"total":11800,"warehouseId":"clx9wh0000000000000000001","notes":null,"termsAndConditions":"Valid for 30 days from quote date.","createdBy":"clxusr0000000000000000001","updatedBy":null,"createdAt":"2026-08-20T07:00:00.000Z","updatedAt":"2026-08-20T07:00:00.000Z"}],"meta":{"page":1,"limit":50,"total":1,"hasMore":false}}}}},"401":{"description":"Missing bearer token","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"unauthorized"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"unauthorized","message":"Missing bearer token"}}}}},"403":{"description":"Access denied","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"forbidden"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"forbidden","message":"Access denied"}}}}}},"security":[{"bearerAuth":[]}],"tags":["Quotes"]}},"/api/v1/quotes/{id}":{"get":{"summary":"Get a quote","description":"Includes the quote's line items under `items`.","parameters":[{"name":"id","in":"path","required":true,"description":"Quote ID.","schema":{"type":"string","example":"clx7quo00000000000000001"}}],"responses":{"200":{"description":"Get a quote","content":{"application/json":{"example":{"success":true,"data":{"id":"clx7quo00000000000000001","organizationId":"clx0org000000000000000001","quoteNumber":"QT-00017","customerId":"clx1a2b3c4d5e6f7g8h9i0j1","status":"SENT","quoteDate":"2026-08-20T00:00:00.000Z","expiryDate":"2026-09-19T00:00:00.000Z","sellerLegalName":"AVS Traders Pvt Ltd","sellerGstin":"29AAAAA0000A1Z5","sellerStateCode":"29","placeOfSupplyStateCode":"29","currencyCode":"INR","exchangeRate":1,"subTotal":10000,"discountTotal":0,"documentDiscount":0,"documentDiscountIsPercent":true,"cgstTotal":900,"sgstTotal":900,"igstTotal":0,"adjustmentLabel":null,"adjustmentAmount":0,"roundOff":0,"total":11800,"warehouseId":"clx9wh0000000000000000001","notes":null,"termsAndConditions":"Valid for 30 days from quote date.","createdBy":"clxusr0000000000000000001","updatedBy":null,"createdAt":"2026-08-20T07:00:00.000Z","updatedAt":"2026-08-20T07:00:00.000Z","items":[{"id":"clx7qi000000000000000001","organizationId":"clx0org000000000000000001","quoteId":"clx7quo00000000000000001","itemId":"clx3itm000000000000000001","itemVariantId":null,"description":"Vinyl Banner Print - Standard","hsnOrSac":"4911","quantity":20,"unit":"PCS","rate":500,"discount":0,"taxRatePercent":18,"taxableAmount":10000,"cgstAmount":900,"sgstAmount":900,"igstAmount":0,"total":11800,"sortOrder":0,"width":null,"height":null,"lengthUnit":null,"qtyCount":null}]}}}}},"401":{"description":"Missing bearer token","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"unauthorized"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"unauthorized","message":"Missing bearer token"}}}}},"403":{"description":"Access denied","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"forbidden"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"forbidden","message":"Access denied"}}}}},"404":{"description":"Resource not found","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"not_found"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"not_found","message":"Resource not found"}}}}}},"security":[{"bearerAuth":[]}],"tags":["Quotes"]}},"/api/v1/sales-orders":{"get":{"summary":"List sales orders","parameters":[{"name":"page","in":"query","required":false,"description":"1-based page number.","schema":{"type":"number","example":1}},{"name":"limit","in":"query","required":false,"description":"Page size, max 200.","schema":{"type":"number","example":50}},{"name":"q","in":"query","required":false,"description":"Free-text search on sales order number.","schema":{"type":"string"}}],"responses":{"200":{"description":"List sales orders","content":{"application/json":{"example":{"success":true,"data":[{"id":"clx8so000000000000000001","organizationId":"clx0org000000000000000001","salesOrderNumber":"SO-00031","customerId":"clx1a2b3c4d5e6f7g8h9i0j1","quoteId":"clx7quo00000000000000001","status":"CONFIRMED","orderDate":"2026-08-22T00:00:00.000Z","expectedShipmentDate":"2026-08-29T00:00:00.000Z","sellerLegalName":"AVS Traders Pvt Ltd","sellerGstin":"29AAAAA0000A1Z5","sellerStateCode":"29","placeOfSupplyStateCode":"29","currencyCode":"INR","exchangeRate":1,"subTotal":10000,"discountTotal":0,"documentDiscount":0,"documentDiscountIsPercent":true,"cgstTotal":900,"sgstTotal":900,"igstTotal":0,"adjustmentLabel":null,"adjustmentAmount":0,"roundOff":0,"total":11800,"warehouseId":"clx9wh0000000000000000001","notes":null,"termsAndConditions":"Delivery within 7 business days.","createdBy":"clxusr0000000000000000001","updatedBy":null,"createdAt":"2026-08-22T08:10:00.000Z","updatedAt":"2026-08-22T08:10:00.000Z"}],"meta":{"page":1,"limit":50,"total":1,"hasMore":false}}}}},"401":{"description":"Missing bearer token","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"unauthorized"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"unauthorized","message":"Missing bearer token"}}}}},"403":{"description":"Access denied","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"forbidden"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"forbidden","message":"Access denied"}}}}}},"security":[{"bearerAuth":[]}],"tags":["Sales Orders"]}},"/api/v1/sales-orders/{id}":{"get":{"summary":"Get a sales order","description":"Includes the order's line items under `lineItems` (not `items` — differs from quotes).","parameters":[{"name":"id","in":"path","required":true,"description":"Sales order ID.","schema":{"type":"string","example":"clx8so000000000000000001"}}],"responses":{"200":{"description":"Get a sales order","content":{"application/json":{"example":{"success":true,"data":{"id":"clx8so000000000000000001","organizationId":"clx0org000000000000000001","salesOrderNumber":"SO-00031","customerId":"clx1a2b3c4d5e6f7g8h9i0j1","quoteId":"clx7quo00000000000000001","status":"CONFIRMED","orderDate":"2026-08-22T00:00:00.000Z","expectedShipmentDate":"2026-08-29T00:00:00.000Z","sellerLegalName":"AVS Traders Pvt Ltd","sellerGstin":"29AAAAA0000A1Z5","sellerStateCode":"29","placeOfSupplyStateCode":"29","currencyCode":"INR","exchangeRate":1,"subTotal":10000,"discountTotal":0,"documentDiscount":0,"documentDiscountIsPercent":true,"cgstTotal":900,"sgstTotal":900,"igstTotal":0,"adjustmentLabel":null,"adjustmentAmount":0,"roundOff":0,"total":11800,"warehouseId":"clx9wh0000000000000000001","notes":null,"termsAndConditions":"Delivery within 7 business days.","createdBy":"clxusr0000000000000000001","updatedBy":null,"createdAt":"2026-08-22T08:10:00.000Z","updatedAt":"2026-08-22T08:10:00.000Z","lineItems":[{"id":"clx8soi00000000000000001","organizationId":"clx0org000000000000000001","salesOrderId":"clx8so000000000000000001","itemId":"clx3itm000000000000000001","itemVariantId":null,"description":"Vinyl Banner Print - Standard","hsnOrSac":"4911","quantity":20,"unit":"PCS","rate":500,"discount":0,"taxRatePercent":18,"taxableAmount":10000,"cgstAmount":900,"sgstAmount":900,"igstAmount":0,"total":11800,"sortOrder":0,"width":null,"height":null,"lengthUnit":null,"qtyCount":null}]}}}}},"401":{"description":"Missing bearer token","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"unauthorized"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"unauthorized","message":"Missing bearer token"}}}}},"403":{"description":"Access denied","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"forbidden"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"forbidden","message":"Access denied"}}}}},"404":{"description":"Resource not found","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"not_found"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"not_found","message":"Resource not found"}}}}}},"security":[{"bearerAuth":[]}],"tags":["Sales Orders"]}},"/api/v1/credit-notes":{"get":{"summary":"List credit notes","parameters":[{"name":"page","in":"query","required":false,"description":"1-based page number.","schema":{"type":"number","example":1}},{"name":"limit","in":"query","required":false,"description":"Page size, max 200.","schema":{"type":"number","example":50}},{"name":"q","in":"query","required":false,"description":"Free-text search on credit note number or reason.","schema":{"type":"string"}}],"responses":{"200":{"description":"List credit notes","content":{"application/json":{"example":{"success":true,"data":[{"id":"clx9cn000000000000000001","organizationId":"clx0org000000000000000001","creditNoteNumber":"CN-00009","customerId":"clx1a2b3c4d5e6f7g8h9i0j1","invoiceId":"clxAinv0000000000000000001","status":"OPEN","creditNoteDate":"2026-09-05T00:00:00.000Z","sellerLegalName":"AVS Traders Pvt Ltd","sellerGstin":"29AAAAA0000A1Z5","sellerStateCode":"29","placeOfSupplyStateCode":"29","currencyCode":"INR","exchangeRate":1,"subTotal":2000,"discountTotal":0,"cgstTotal":180,"sgstTotal":180,"igstTotal":0,"roundOff":0,"total":2360,"allocatedAmount":2360,"balanceUnallocated":0,"reason":"Damaged goods returned","notes":null,"termsAndConditions":null,"warehouseId":"clx9wh0000000000000000001","createdBy":"clxusr0000000000000000001","updatedBy":null,"createdAt":"2026-09-05T09:30:00.000Z","updatedAt":"2026-09-05T09:30:00.000Z"}],"meta":{"page":1,"limit":50,"total":1,"hasMore":false}}}}},"401":{"description":"Missing bearer token","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"unauthorized"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"unauthorized","message":"Missing bearer token"}}}}},"403":{"description":"Access denied","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"forbidden"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"forbidden","message":"Access denied"}}}}}},"security":[{"bearerAuth":[]}],"tags":["Credit Notes"]}},"/api/v1/credit-notes/{id}":{"get":{"summary":"Get a credit note","description":"Includes items, allocations (against invoices/cash), and inventory movements.","parameters":[{"name":"id","in":"path","required":true,"description":"Credit note ID.","schema":{"type":"string","example":"clx9cn000000000000000001"}}],"responses":{"200":{"description":"Get a credit note","content":{"application/json":{"example":{"success":true,"data":{"id":"clx9cn000000000000000001","organizationId":"clx0org000000000000000001","creditNoteNumber":"CN-00009","customerId":"clx1a2b3c4d5e6f7g8h9i0j1","invoiceId":"clxAinv0000000000000000001","status":"OPEN","creditNoteDate":"2026-09-05T00:00:00.000Z","sellerLegalName":"AVS Traders Pvt Ltd","sellerGstin":"29AAAAA0000A1Z5","sellerStateCode":"29","placeOfSupplyStateCode":"29","currencyCode":"INR","exchangeRate":1,"subTotal":2000,"discountTotal":0,"cgstTotal":180,"sgstTotal":180,"igstTotal":0,"roundOff":0,"total":2360,"allocatedAmount":2360,"balanceUnallocated":0,"reason":"Damaged goods returned","notes":null,"termsAndConditions":null,"warehouseId":"clx9wh0000000000000000001","createdBy":"clxusr0000000000000000001","updatedBy":null,"createdAt":"2026-09-05T09:30:00.000Z","updatedAt":"2026-09-05T09:30:00.000Z","items":[{"id":"clx9cni00000000000000001","organizationId":"clx0org000000000000000001","creditNoteId":"clx9cn000000000000000001","itemId":"clx3itm000000000000000001","itemVariantId":"clx7var000000000000000002","originalInvoiceItemId":"clxAinvi000000000000000001","description":"Vinyl Banner Print - Standard","hsnOrSac":"4911","quantity":4,"unit":"PCS","rate":500,"discount":0,"taxRatePercent":18,"taxableAmount":2000,"cgstAmount":180,"sgstAmount":180,"igstAmount":0,"total":2360,"restock":true,"sortOrder":0,"width":null,"height":null,"lengthUnit":null,"qtyCount":null}],"allocations":[{"id":"clx9cna00000000000000001","organizationId":"clx0org000000000000000001","creditNoteId":"clx9cn000000000000000001","invoiceId":"clxAinv0000000000000000001","amount":2360,"allocatedAt":"2026-09-05T09:30:00.000Z","createdBy":"clxusr0000000000000000001"}],"movements":[{"id":"clx9sm000000000000000001","organizationId":"clx0org000000000000000001","itemVariantId":"clx7var000000000000000002","warehouseId":"clx9wh0000000000000000001","movementType":"SALES_RETURN_IN","quantity":4,"unitCost":250.5,"totalCost":1002,"balanceAfter":54,"avgCostAfter":250.5,"sourceDocType":"CREDIT_NOTE","sourceDocId":"clx9cn000000000000000001","sourceDocLineId":"clx9cni00000000000000001","lotId":null,"notes":null,"createdBy":"clxusr0000000000000000001","createdAt":"2026-09-05T09:30:00.000Z"}]}}}}},"401":{"description":"Missing bearer token","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"unauthorized"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"unauthorized","message":"Missing bearer token"}}}}},"403":{"description":"Access denied","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"forbidden"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"forbidden","message":"Access denied"}}}}},"404":{"description":"Resource not found","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"not_found"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"not_found","message":"Resource not found"}}}}}},"security":[{"bearerAuth":[]}],"tags":["Credit Notes"]}},"/api/v1/debit-notes":{"get":{"summary":"List debit notes","parameters":[{"name":"page","in":"query","required":false,"description":"1-based page number.","schema":{"type":"number","example":1}},{"name":"limit","in":"query","required":false,"description":"Page size, max 200.","schema":{"type":"number","example":50}},{"name":"q","in":"query","required":false,"description":"Free-text search on debit note number or reason.","schema":{"type":"string"}}],"responses":{"200":{"description":"List debit notes","content":{"application/json":{"example":{"success":true,"data":[{"id":"clx2dn0001000000000000001","organizationId":"clx2org001000000000000001","debitNoteNumber":"DN-2026-0004","vendorId":"clx2vnd001000000000000001","billId":"clx2bil001000000000000001","status":"OPEN","debitNoteDate":"2026-08-12T00:00:00.000Z","sellerLegalName":"AVS Textiles Pvt Ltd","sellerGstin":"27AAAAA0000A1Z5","sellerStateCode":"27","placeOfSupplyStateCode":"27","currencyCode":"INR","exchangeRate":1,"subTotal":5000,"discountTotal":0,"cgstTotal":450,"sgstTotal":450,"igstTotal":0,"roundOff":0,"total":5900,"allocatedAmount":5900,"balanceUnallocated":0,"reason":"Damaged goods returned","notes":null,"termsAndConditions":null,"warehouseId":"clx2wh0001000000000000001","createdBy":"clx2usr001000000000000001","updatedBy":null,"createdAt":"2026-08-12T09:30:00.000Z","updatedAt":"2026-08-12T09:30:00.000Z"}],"meta":{"page":1,"limit":50,"total":1,"hasMore":false}}}}},"401":{"description":"Missing bearer token","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"unauthorized"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"unauthorized","message":"Missing bearer token"}}}}},"403":{"description":"Access denied","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"forbidden"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"forbidden","message":"Access denied"}}}}}},"security":[{"bearerAuth":[]}],"tags":["Debit Notes"]}},"/api/v1/debit-notes/{id}":{"get":{"summary":"Get a debit note","description":"Includes items, allocations (against bills/cash), and inventory movements.","parameters":[{"name":"id","in":"path","required":true,"description":"Debit note ID.","schema":{"type":"string","example":"clx2dn0001000000000000001"}}],"responses":{"200":{"description":"Get a debit note","content":{"application/json":{"example":{"success":true,"data":{"id":"clx2dn0001000000000000001","organizationId":"clx2org001000000000000001","debitNoteNumber":"DN-2026-0004","vendorId":"clx2vnd001000000000000001","billId":"clx2bil001000000000000001","status":"OPEN","debitNoteDate":"2026-08-12T00:00:00.000Z","sellerLegalName":"AVS Textiles Pvt Ltd","sellerGstin":"27AAAAA0000A1Z5","sellerStateCode":"27","placeOfSupplyStateCode":"27","currencyCode":"INR","exchangeRate":1,"subTotal":5000,"discountTotal":0,"cgstTotal":450,"sgstTotal":450,"igstTotal":0,"roundOff":0,"total":5900,"allocatedAmount":5900,"balanceUnallocated":0,"reason":"Damaged goods returned","notes":null,"termsAndConditions":null,"warehouseId":"clx2wh0001000000000000001","createdBy":"clx2usr001000000000000001","updatedBy":null,"createdAt":"2026-08-12T09:30:00.000Z","updatedAt":"2026-08-12T09:30:00.000Z","items":[{"id":"clx2dni001000000000000001","organizationId":"clx2org001000000000000001","debitNoteId":"clx2dn0001000000000000001","itemId":"clx2itm001000000000000001","itemVariantId":"clx2var001000000000000001","originalBillItemId":"clx2bit001000000000000001","description":"Cotton Fabric - Blue","hsnOrSac":"5208","quantity":10,"unit":"MTR","rate":500,"discount":0,"taxRatePercent":18,"taxableAmount":5000,"cgstAmount":450,"sgstAmount":450,"igstAmount":0,"total":5900,"restock":true,"sortOrder":0,"width":null,"height":null,"lengthUnit":null,"qtyCount":null}],"allocations":[{"id":"clx2dna001000000000000001","organizationId":"clx2org001000000000000001","debitNoteId":"clx2dn0001000000000000001","billId":"clx2bil001000000000000001","amount":5900,"allocatedAt":"2026-08-12T09:30:00.000Z","createdBy":"clx2usr001000000000000001"}],"movements":[{"id":"clx2mov001000000000000001","organizationId":"clx2org001000000000000001","itemVariantId":"clx2var001000000000000001","warehouseId":"clx2wh0001000000000000001","movementType":"PURCHASE_RETURN_OUT","quantity":10,"unitCost":480,"totalCost":4800,"balanceAfter":40,"avgCostAfter":480,"sourceDocType":"DEBIT_NOTE","sourceDocId":"clx2dn0001000000000000001","sourceDocLineId":"clx2dni001000000000000001","lotId":null,"notes":null,"createdBy":"clx2usr001000000000000001","createdAt":"2026-08-12T09:30:00.000Z"}]}}}}},"401":{"description":"Missing bearer token","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"unauthorized"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"unauthorized","message":"Missing bearer token"}}}}},"403":{"description":"Access denied","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"forbidden"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"forbidden","message":"Access denied"}}}}},"404":{"description":"Resource not found","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"not_found"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"not_found","message":"Resource not found"}}}}}},"security":[{"bearerAuth":[]}],"tags":["Debit Notes"]}},"/api/v1/bills":{"get":{"summary":"List bills","parameters":[{"name":"page","in":"query","required":false,"description":"1-based page number.","schema":{"type":"number","example":1}},{"name":"limit","in":"query","required":false,"description":"Page size, max 200.","schema":{"type":"number","example":50}},{"name":"q","in":"query","required":false,"description":"Free-text search on bill number or vendor bill number.","schema":{"type":"string"}}],"responses":{"200":{"description":"List bills","content":{"application/json":{"example":{"success":true,"data":[{"id":"clx2bil001000000000000001","organizationId":"clx2org001000000000000001","billNumber":"BILL-2026-0091","vendorBillNumber":"VB-7781","vendorId":"clx2vnd001000000000000001","purchaseOrderId":"clx2po00001000000000000001","status":"PARTIALLY_PAID","billDate":"2026-07-01T00:00:00.000Z","dueDate":"2026-07-31T00:00:00.000Z","sellerLegalName":"AVS Textiles Pvt Ltd","sellerGstin":"27AAAAA0000A1Z5","sellerStateCode":"27","placeOfSupplyStateCode":"27","currencyCode":"INR","exchangeRate":1,"subTotal":50000,"discountTotal":0,"documentDiscount":0,"documentDiscountIsPercent":true,"cgstTotal":4500,"sgstTotal":4500,"igstTotal":0,"adjustmentLabel":null,"adjustmentAmount":0,"roundOff":0,"total":59000,"amountPaid":30000,"balanceDue":29000,"itcEligible":true,"warehouseId":"clx2wh0001000000000000001","notes":null,"createdBy":"clx2usr001000000000000001","updatedBy":null,"createdAt":"2026-07-01T10:00:00.000Z","updatedAt":"2026-07-15T08:00:00.000Z"}],"meta":{"page":1,"limit":50,"total":1,"hasMore":false}}}}},"401":{"description":"Missing bearer token","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"unauthorized"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"unauthorized","message":"Missing bearer token"}}}}},"403":{"description":"Access denied","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"forbidden"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"forbidden","message":"Access denied"}}}}}},"security":[{"bearerAuth":[]}],"tags":["Bills"]}},"/api/v1/bills/{id}":{"get":{"summary":"Get a bill","description":"Includes items and payment allocations. No `movements` key on this module.","parameters":[{"name":"id","in":"path","required":true,"description":"Bill ID.","schema":{"type":"string","example":"clx2bil001000000000000001"}}],"responses":{"200":{"description":"Get a bill","content":{"application/json":{"example":{"success":true,"data":{"id":"clx2bil001000000000000001","organizationId":"clx2org001000000000000001","billNumber":"BILL-2026-0091","vendorBillNumber":"VB-7781","vendorId":"clx2vnd001000000000000001","purchaseOrderId":"clx2po00001000000000000001","status":"PARTIALLY_PAID","billDate":"2026-07-01T00:00:00.000Z","dueDate":"2026-07-31T00:00:00.000Z","sellerLegalName":"AVS Textiles Pvt Ltd","sellerGstin":"27AAAAA0000A1Z5","sellerStateCode":"27","placeOfSupplyStateCode":"27","currencyCode":"INR","exchangeRate":1,"subTotal":50000,"discountTotal":0,"documentDiscount":0,"documentDiscountIsPercent":true,"cgstTotal":4500,"sgstTotal":4500,"igstTotal":0,"adjustmentLabel":null,"adjustmentAmount":0,"roundOff":0,"total":59000,"amountPaid":30000,"balanceDue":29000,"itcEligible":true,"warehouseId":"clx2wh0001000000000000001","notes":null,"createdBy":"clx2usr001000000000000001","updatedBy":null,"createdAt":"2026-07-01T10:00:00.000Z","updatedAt":"2026-07-15T08:00:00.000Z","items":[{"id":"clx2bit001000000000000001","organizationId":"clx2org001000000000000001","billId":"clx2bil001000000000000001","itemId":"clx2itm001000000000000001","itemVariantId":"clx2var001000000000000001","description":"Cotton Fabric - Blue","hsnOrSac":"5208","quantity":100,"unit":"MTR","rate":500,"discount":0,"taxRatePercent":18,"taxableAmount":50000,"cgstAmount":4500,"sgstAmount":4500,"igstAmount":0,"total":59000,"sortOrder":0,"width":null,"height":null,"lengthUnit":null,"qtyCount":null}],"allocations":[{"id":"clx2pma001000000000000001","organizationId":"clx2org001000000000000001","paymentId":"clx2pmt001000000000000001","billId":"clx2bil001000000000000001","amount":30000}]}}}}},"401":{"description":"Missing bearer token","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"unauthorized"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"unauthorized","message":"Missing bearer token"}}}}},"403":{"description":"Access denied","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"forbidden"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"forbidden","message":"Access denied"}}}}},"404":{"description":"Resource not found","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"not_found"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"not_found","message":"Resource not found"}}}}}},"security":[{"bearerAuth":[]}],"tags":["Bills"]}},"/api/v1/purchase-orders":{"get":{"summary":"List purchase orders","parameters":[{"name":"page","in":"query","required":false,"description":"1-based page number.","schema":{"type":"number","example":1}},{"name":"limit","in":"query","required":false,"description":"Page size, max 200.","schema":{"type":"number","example":50}},{"name":"q","in":"query","required":false,"description":"Free-text search on purchase order number.","schema":{"type":"string"}}],"responses":{"200":{"description":"List purchase orders","content":{"application/json":{"example":{"success":true,"data":[{"id":"clx2po00001000000000000001","organizationId":"clx2org001000000000000001","purchaseOrderNumber":"PO-2026-0037","vendorId":"clx2vnd001000000000000001","status":"CONFIRMED","orderDate":"2026-06-20T00:00:00.000Z","expectedDeliveryDate":"2026-06-30T00:00:00.000Z","sellerLegalName":"AVS Textiles Pvt Ltd","sellerGstin":"27AAAAA0000A1Z5","sellerStateCode":"27","placeOfSupplyStateCode":"27","currencyCode":"INR","exchangeRate":1,"subTotal":50000,"discountTotal":0,"documentDiscount":0,"documentDiscountIsPercent":true,"cgstTotal":4500,"sgstTotal":4500,"igstTotal":0,"adjustmentLabel":null,"adjustmentAmount":0,"roundOff":0,"total":59000,"warehouseId":"clx2wh0001000000000000001","notes":null,"termsAndConditions":null,"createdBy":"clx2usr001000000000000001","updatedBy":null,"createdAt":"2026-06-20T09:00:00.000Z","updatedAt":"2026-06-20T09:00:00.000Z"}],"meta":{"page":1,"limit":50,"total":1,"hasMore":false}}}}},"401":{"description":"Missing bearer token","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"unauthorized"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"unauthorized","message":"Missing bearer token"}}}}},"403":{"description":"Access denied","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"forbidden"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"forbidden","message":"Access denied"}}}}}},"security":[{"bearerAuth":[]}],"tags":["Purchase Orders"]}},"/api/v1/purchase-orders/{id}":{"get":{"summary":"Get a purchase order","description":"Line items are nested under `lines` (this module's own naming — not `items` or `lineItems`).","parameters":[{"name":"id","in":"path","required":true,"description":"Purchase order ID.","schema":{"type":"string","example":"clx2po00001000000000000001"}}],"responses":{"200":{"description":"Get a purchase order","content":{"application/json":{"example":{"success":true,"data":{"id":"clx2po00001000000000000001","organizationId":"clx2org001000000000000001","purchaseOrderNumber":"PO-2026-0037","vendorId":"clx2vnd001000000000000001","status":"CONFIRMED","orderDate":"2026-06-20T00:00:00.000Z","expectedDeliveryDate":"2026-06-30T00:00:00.000Z","sellerLegalName":"AVS Textiles Pvt Ltd","sellerGstin":"27AAAAA0000A1Z5","sellerStateCode":"27","placeOfSupplyStateCode":"27","currencyCode":"INR","exchangeRate":1,"subTotal":50000,"discountTotal":0,"documentDiscount":0,"documentDiscountIsPercent":true,"cgstTotal":4500,"sgstTotal":4500,"igstTotal":0,"adjustmentLabel":null,"adjustmentAmount":0,"roundOff":0,"total":59000,"warehouseId":"clx2wh0001000000000000001","notes":null,"termsAndConditions":null,"createdBy":"clx2usr001000000000000001","updatedBy":null,"createdAt":"2026-06-20T09:00:00.000Z","updatedAt":"2026-06-20T09:00:00.000Z","lines":[{"id":"clx2poi001000000000000001","organizationId":"clx2org001000000000000001","purchaseOrderId":"clx2po00001000000000000001","itemId":"clx2itm001000000000000001","itemVariantId":"clx2var001000000000000001","description":"Cotton Fabric - Blue","hsnOrSac":"5208","quantity":100,"unit":"MTR","rate":500,"discount":0,"taxRatePercent":18,"taxableAmount":50000,"cgstAmount":4500,"sgstAmount":4500,"igstAmount":0,"total":59000,"sortOrder":0,"width":null,"height":null,"lengthUnit":null,"qtyCount":null}]}}}}},"401":{"description":"Missing bearer token","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"unauthorized"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"unauthorized","message":"Missing bearer token"}}}}},"403":{"description":"Access denied","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"forbidden"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"forbidden","message":"Access denied"}}}}},"404":{"description":"Resource not found","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"not_found"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"not_found","message":"Resource not found"}}}}}},"security":[{"bearerAuth":[]}],"tags":["Purchase Orders"]}},"/api/v1/payments-made":{"get":{"summary":"List payments made","parameters":[{"name":"page","in":"query","required":false,"description":"1-based page number.","schema":{"type":"number","example":1}},{"name":"limit","in":"query","required":false,"description":"Page size, max 200.","schema":{"type":"number","example":50}},{"name":"q","in":"query","required":false,"description":"Free-text search on payment number, reference number, or vendor name.","schema":{"type":"string"}}],"responses":{"200":{"description":"List payments made","content":{"application/json":{"example":{"success":true,"data":[{"id":"clx2pmt001000000000000001","paymentNumber":"PMT-2026-0058","vendorId":"clx2vnd001000000000000001","vendorName":"Shree Textile Suppliers","paymentDate":"2026-07-15T00:00:00.000Z","mode":"BANK_TRANSFER","referenceNumber":"UTR1234567890","paidThroughAccount":"HDFC Current A/C","amount":30000,"allocated":30000,"openingBalanceApplied":0,"currencyCode":"INR","exchangeRate":1,"notes":null,"createdAt":"2026-07-15T08:00:00.000Z","updatedAt":"2026-07-15T08:00:00.000Z"}],"meta":{"page":1,"limit":50,"total":1,"hasMore":false}}}}},"401":{"description":"Missing bearer token","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"unauthorized"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"unauthorized","message":"Missing bearer token"}}}}},"403":{"description":"Access denied","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"forbidden"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"forbidden","message":"Access denied"}}}}}},"security":[{"bearerAuth":[]}],"tags":["Payments Made"]}},"/api/v1/payments-made/{id}":{"get":{"summary":"Get a payment made","description":"Adds bill allocations and createdBy on top of the list row shape.","parameters":[{"name":"id","in":"path","required":true,"description":"Payment ID.","schema":{"type":"string","example":"clx2pmt001000000000000001"}}],"responses":{"200":{"description":"Get a payment made","content":{"application/json":{"example":{"success":true,"data":{"id":"clx2pmt001000000000000001","paymentNumber":"PMT-2026-0058","vendorId":"clx2vnd001000000000000001","vendorName":"Shree Textile Suppliers","paymentDate":"2026-07-15T00:00:00.000Z","mode":"BANK_TRANSFER","referenceNumber":"UTR1234567890","paidThroughAccount":"HDFC Current A/C","amount":30000,"allocated":30000,"openingBalanceApplied":0,"currencyCode":"INR","exchangeRate":1,"notes":null,"createdAt":"2026-07-15T08:00:00.000Z","updatedAt":"2026-07-15T08:00:00.000Z","createdBy":"clx2usr001000000000000001","allocations":[{"id":"clx2pma001000000000000001","paymentId":"clx2pmt001000000000000001","billId":"clx2bil001000000000000001","billNumber":"BILL-2026-0091","amount":30000}]}}}}},"401":{"description":"Missing bearer token","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"unauthorized"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"unauthorized","message":"Missing bearer token"}}}}},"403":{"description":"Access denied","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"forbidden"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"forbidden","message":"Access denied"}}}}},"404":{"description":"Resource not found","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"not_found"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"not_found","message":"Resource not found"}}}}}},"security":[{"bearerAuth":[]}],"tags":["Payments Made"]}},"/api/v1/inventory":{"get":{"summary":"List stock positions","parameters":[{"name":"page","in":"query","required":false,"description":"1-based page number.","schema":{"type":"number","example":1}},{"name":"limit","in":"query","required":false,"description":"Page size, max 200.","schema":{"type":"number","example":50}},{"name":"q","in":"query","required":false,"description":"Free-text search on item/variant/warehouse name or code.","schema":{"type":"string"}}],"responses":{"200":{"description":"List stock positions","content":{"application/json":{"example":{"success":true,"data":[{"id":"clx2soh001000000000000001","itemVariantId":"clx2var001000000000000001","warehouseId":"clx2wh0001000000000000001","itemId":"clx2itm001000000000000001","itemName":"Cotton Fabric","variantSize":"Blue - 44in","variantSku":"CF-BLUE-44","warehouseName":"Main Warehouse","warehouseCode":"MAIN","quantityOnHand":40,"quantityReserved":5,"quantityAvailable":35,"averageCost":480.5,"lowStockThreshold":10,"lastMovementAt":"2026-08-12T09:30:00.000Z","updatedAt":"2026-08-12T09:30:00.000Z"}],"meta":{"page":1,"limit":50,"total":1,"hasMore":false}}}}},"401":{"description":"Missing bearer token","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"unauthorized"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"unauthorized","message":"Missing bearer token"}}}}},"403":{"description":"Access denied","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"forbidden"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"forbidden","message":"Access denied"}}}}}},"security":[{"bearerAuth":[]}],"tags":["Inventory"]}},"/api/v1/inventory/{id}":{"get":{"summary":"Get a stock position","description":"Adds up to 100 recent inventory movements for this item variant + warehouse, newest first.","parameters":[{"name":"id","in":"path","required":true,"description":"Stock-on-hand position ID.","schema":{"type":"string","example":"clx2soh001000000000000001"}}],"responses":{"200":{"description":"Get a stock position","content":{"application/json":{"example":{"success":true,"data":{"id":"clx2soh001000000000000001","itemVariantId":"clx2var001000000000000001","warehouseId":"clx2wh0001000000000000001","itemId":"clx2itm001000000000000001","itemName":"Cotton Fabric","variantSize":"Blue - 44in","variantSku":"CF-BLUE-44","warehouseName":"Main Warehouse","warehouseCode":"MAIN","quantityOnHand":40,"quantityReserved":5,"quantityAvailable":35,"averageCost":480.5,"lowStockThreshold":10,"lastMovementAt":"2026-08-12T09:30:00.000Z","updatedAt":"2026-08-12T09:30:00.000Z","movements":[{"id":"clx2mov001000000000000001","movementType":"PURCHASE_RETURN_OUT","quantity":10,"unitCost":480,"totalCost":4800,"balanceAfter":40,"avgCostAfter":480.5,"sourceDocType":"DEBIT_NOTE","sourceDocId":"clx2dn0001000000000000001","notes":null,"createdAt":"2026-08-12T09:30:00.000Z"}]}}}}},"401":{"description":"Missing bearer token","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"unauthorized"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"unauthorized","message":"Missing bearer token"}}}}},"403":{"description":"Access denied","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"forbidden"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"forbidden","message":"Access denied"}}}}},"404":{"description":"Resource not found","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"not_found"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"not_found","message":"Resource not found"}}}}}},"security":[{"bearerAuth":[]}],"tags":["Inventory"]}},"/api/v1/customer-ledger":{"get":{"summary":"List ledger-eligible customers","parameters":[{"name":"q","in":"query","required":false,"description":"Free-text search on display name, GSTIN, phone, or email.","schema":{"type":"string"}}],"responses":{"200":{"description":"List ledger-eligible customers","content":{"application/json":{"example":{"success":true,"data":[{"id":"clx2cus001000000000000001","displayName":"Acme Retailers","gstin":"27BBBBB1111B1Z9","phone":"9876543210","email":"accounts@acme.example","currencyCode":"INR","openingBalance":5000}],"meta":{"page":1,"limit":50,"total":1,"hasMore":false}}}}},"401":{"description":"Missing bearer token","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"unauthorized"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"unauthorized","message":"Missing bearer token"}}}}},"403":{"description":"Access denied","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"forbidden"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"forbidden","message":"Access denied"}}}}}},"security":[{"bearerAuth":[]}],"tags":["Customer Ledger"]}},"/api/v1/customer-ledger/{id}":{"get":{"summary":"Get a customer's computed ledger","description":"id is the customerId. Optional ?from=YYYY-MM-DD&to=YYYY-MM-DD windows the `entries` array; `outstanding` always reflects the full history.","parameters":[{"name":"id","in":"path","required":true,"description":"Customer ID.","schema":{"type":"string","example":"clx2cus001000000000000001"}},{"name":"from","in":"query","required":false,"description":"Window start date, YYYY-MM-DD.","schema":{"type":"string"}},{"name":"to","in":"query","required":false,"description":"Window end date, YYYY-MM-DD.","schema":{"type":"string"}}],"responses":{"200":{"description":"Get a customer's computed ledger","content":{"application/json":{"example":{"success":true,"data":{"customer":{"id":"clx2cus001000000000000001","displayName":"Acme Retailers","legalName":"Acme Retailers Pvt Ltd","gstin":"27BBBBB1111B1Z9","phone":"9876543210","email":"accounts@acme.example","currencyCode":"INR","openingBalance":5000},"from":"2026-07-01","to":"2026-08-31","openingBalance":5000,"outstanding":12500,"entries":[{"date":"2026-07-05T00:00:00.000Z","type":"invoice","number":"INV-2026-0102","debit":11800,"credit":0,"status":"SENT","balance":16800},{"date":"2026-07-20T00:00:00.000Z","type":"payment","number":"PR-2026-0044","debit":0,"credit":4300,"status":"BANK_TRANSFER","balance":12500}]}}}}},"401":{"description":"Missing bearer token","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"unauthorized"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"unauthorized","message":"Missing bearer token"}}}}},"403":{"description":"Access denied","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"forbidden"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"forbidden","message":"Access denied"}}}}},"404":{"description":"Resource not found","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"not_found"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"not_found","message":"Resource not found"}}}}}},"security":[{"bearerAuth":[]}],"tags":["Customer Ledger"]}},"/api/v1/vendor-ledger":{"get":{"summary":"List ledger-eligible vendors","parameters":[{"name":"q","in":"query","required":false,"description":"Free-text search on display name, GSTIN, phone, or email.","schema":{"type":"string"}}],"responses":{"200":{"description":"List ledger-eligible vendors","content":{"application/json":{"example":{"success":true,"data":[{"vendorId":"clx2vnd001000000000000001","displayName":"Shree Textile Suppliers","openingBalance":0,"currencyCode":"INR"}],"meta":{"page":1,"limit":50,"total":1,"hasMore":false}}}}},"401":{"description":"Missing bearer token","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"unauthorized"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"unauthorized","message":"Missing bearer token"}}}}},"403":{"description":"Access denied","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"forbidden"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"forbidden","message":"Access denied"}}}}}},"security":[{"bearerAuth":[]}],"tags":["Vendor Ledger"]}},"/api/v1/vendor-ledger/{id}":{"get":{"summary":"Get a vendor's computed ledger","description":"id is the vendorId. Optional ?from=YYYY-MM-DD&to=YYYY-MM-DD windows the `entries` array. Payables sign convention: bills/debit notes credit the balance, payments debit it.","parameters":[{"name":"id","in":"path","required":true,"description":"Vendor ID.","schema":{"type":"string","example":"clx2vnd001000000000000001"}},{"name":"from","in":"query","required":false,"description":"Window start date, YYYY-MM-DD.","schema":{"type":"string"}},{"name":"to","in":"query","required":false,"description":"Window end date, YYYY-MM-DD.","schema":{"type":"string"}}],"responses":{"200":{"description":"Get a vendor's computed ledger","content":{"application/json":{"example":{"success":true,"data":{"vendor":{"id":"clx2vnd001000000000000001","displayName":"Shree Textile Suppliers"},"entries":[{"date":"2026-07-01T00:00:00.000Z","type":"invoice","number":"BILL-2026-0091","debit":0,"credit":59000,"status":"PARTIALLY_PAID","balance":59000},{"date":"2026-07-15T00:00:00.000Z","type":"payment","number":"PMT-2026-0058","debit":30000,"credit":0,"status":"","balance":29000}],"openingBalance":0,"outstanding":29000}}}}},"401":{"description":"Missing bearer token","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"unauthorized"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"unauthorized","message":"Missing bearer token"}}}}},"403":{"description":"Access denied","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"forbidden"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"forbidden","message":"Access denied"}}}}},"404":{"description":"Resource not found","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"not_found"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"not_found","message":"Resource not found"}}}}}},"security":[{"bearerAuth":[]}],"tags":["Vendor Ledger"]}},"/api/v1/invoices":{"get":{"summary":"List invoices","parameters":[{"name":"page","in":"query","required":false,"description":"1-based page number.","schema":{"type":"number","example":1}},{"name":"limit","in":"query","required":false,"description":"Page size, max 200.","schema":{"type":"number","example":50}}],"responses":{"200":{"description":"List invoices","content":{"application/json":{"example":{"success":true,"data":[{"id":"clx2inv001000000000000001","organizationId":"clx2org001000000000000001","invoiceNumber":"INV-2026-0102","customerId":"clx2cus001000000000000001","salesOrderId":null,"salespersonId":null,"status":"SENT","invoiceDate":"2026-09-07T00:00:00.000Z","dueDate":"2026-10-07T00:00:00.000Z","sellerLegalName":"AVS Textiles Pvt Ltd","sellerGstin":"27AAAAA0000A1Z5","sellerStateCode":"27","placeOfSupplyStateCode":"27","currencyCode":"INR","exchangeRate":1,"subTotal":13000,"discountTotal":0,"documentDiscount":0,"documentDiscountIsPercent":false,"cgstTotal":1170,"sgstTotal":1170,"igstTotal":0,"adjustmentLabel":null,"adjustmentAmount":0,"roundOff":0,"total":15340,"amountPaid":0,"balanceDue":15340,"warehouseId":"clx2wh0001000000000000001","ewayBillStatus":"NOT_REQUIRED","ewayBillId":null,"emailSentAt":null,"pdfTemplateId":null,"notes":"Thank you for your business","termsAndConditions":null,"createdBy":"clx2usr001000000000000001","updatedBy":null,"createdAt":"2026-09-07T10:00:00.000Z","updatedAt":"2026-09-07T10:00:00.000Z"}],"meta":{"page":1,"limit":50,"total":1,"hasMore":false}}}}},"401":{"description":"Missing bearer token","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"unauthorized"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"unauthorized","message":"Missing bearer token"}}}}},"403":{"description":"Access denied","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"forbidden"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"forbidden","message":"Access denied"}}}}}},"security":[{"bearerAuth":[]}],"tags":["Invoices"]},"post":{"summary":"Create an invoice","description":"Accepts an optional Idempotency-Key header. Returns only { id, status, total } — fetch the invoice afterward for the full row.","parameters":[{"name":"Idempotency-Key","in":"header","required":false,"description":"Unique key per create attempt; a retry with the same key returns the original result.","schema":{"type":"string"}}],"responses":{"201":{"description":"Create an invoice","content":{"application/json":{"example":{"success":true,"data":{"id":"clx2inv001000000000000001","status":"SENT","total":15340}}}}},"401":{"description":"Missing bearer token","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"unauthorized"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"unauthorized","message":"Missing bearer token"}}}}},"403":{"description":"Access denied","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"forbidden"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"forbidden","message":"Access denied"}}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"conflict"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"conflict","message":"Conflict"}}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"validation_error"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"validation_error","message":"Validation failed"}}}}}},"security":[{"bearerAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$schema":"https://json-schema.org/draft/2020-12/schema","type":"object","properties":{"customerId":{"type":"string","minLength":1},"salespersonId":{"type":"string","maxLength":30},"sellerRegistrationId":{"anyOf":[{"type":"string","maxLength":30},{"type":"string","const":""}]},"invoiceDate":{"type":"string","format":"date-time"},"dueDate":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}]},"currencyCode":{"default":"INR","type":"string","minLength":3,"maxLength":3},"exchangeRate":{"default":1,"type":"number","exclusiveMinimum":0},"placeOfSupplyStateCode":{"anyOf":[{"type":"string","minLength":2,"maxLength":2},{"type":"string","const":""}]},"warehouseId":{"anyOf":[{"type":"string","maxLength":30},{"type":"string","const":""}]},"notes":{"anyOf":[{"type":"string","maxLength":2000},{"type":"string","const":""}]},"termsAndConditions":{"anyOf":[{"type":"string","maxLength":2000},{"type":"string","const":""}]},"status":{"default":"DRAFT","type":"string","enum":["DRAFT","SENT"]},"applyCustomerCredit":{"default":false,"type":"boolean"},"schemeIds":{"maxItems":50,"type":"array","items":{"type":"string","minLength":1,"maxLength":30}},"lines":{"minItems":1,"type":"array","items":{"type":"object","properties":{"itemId":{"anyOf":[{"type":"string","maxLength":30},{"type":"null"}]},"itemVariantId":{"anyOf":[{"type":"string","maxLength":30},{"type":"null"}]},"lotId":{"anyOf":[{"type":"string","maxLength":30},{"type":"null"}]},"description":{"type":"string","minLength":1,"maxLength":500},"hsnOrSac":{"anyOf":[{"type":"string","maxLength":10},{"type":"null"}]},"quantity":{"type":"number","exclusiveMinimum":0},"unit":{"default":"PCS","type":"string","maxLength":20},"rate":{"type":"number","minimum":0},"discount":{"default":0,"type":"number","minimum":0},"taxRatePercent":{"default":0,"type":"number","minimum":0,"maximum":100},"priceInclusive":{"default":false,"type":"boolean"},"sortOrder":{"default":0,"type":"integer","minimum":0,"maximum":9007199254740991},"schemeFree":{"type":"boolean"},"width":{"anyOf":[{"type":"number","exclusiveMinimum":0},{"type":"null"}]},"height":{"anyOf":[{"type":"number","exclusiveMinimum":0},{"type":"null"}]},"lengthUnit":{"anyOf":[{"type":"string","enum":["FT","IN","CM","MM","M"]},{"type":"null"}]},"qtyCount":{"anyOf":[{"type":"number","exclusiveMinimum":0},{"type":"null"}]}},"required":["description","quantity","rate"]}},"adjustments":{"default":{"documentDiscount":0,"documentDiscountIsPercent":false,"adjustmentAmount":0,"adjustmentLabel":null},"type":"object","properties":{"documentDiscount":{"default":0,"type":"number","minimum":0},"documentDiscountIsPercent":{"default":false,"type":"boolean"},"adjustmentAmount":{"default":0,"type":"number"},"adjustmentLabel":{"anyOf":[{"type":"string","maxLength":100},{"type":"null"}]}}}},"required":["customerId","invoiceDate","lines"]},"example":{"customerId":"clx2cus001000000000000001","invoiceDate":"2026-09-07","dueDate":"2026-10-07","currencyCode":"INR","placeOfSupplyStateCode":"27","warehouseId":"clx2wh0001000000000000001","status":"SENT","lines":[{"itemId":"clx2itm001000000000000001","description":"Cotton Fabric - Blue","quantity":20,"unit":"MTR","rate":650,"taxRatePercent":18}],"adjustments":{"documentDiscount":0,"documentDiscountIsPercent":false,"adjustmentAmount":0}}}}},"tags":["Invoices"]}},"/api/v1/invoices/{id}":{"get":{"summary":"Get an invoice","description":"Includes line items under `lines`.","parameters":[{"name":"id","in":"path","required":true,"description":"Invoice ID.","schema":{"type":"string","example":"clx2inv001000000000000001"}}],"responses":{"200":{"description":"Get an invoice","content":{"application/json":{"example":{"success":true,"data":{"id":"clx2inv001000000000000001","organizationId":"clx2org001000000000000001","invoiceNumber":"INV-2026-0102","customerId":"clx2cus001000000000000001","salesOrderId":null,"salespersonId":null,"status":"SENT","invoiceDate":"2026-09-07T00:00:00.000Z","dueDate":"2026-10-07T00:00:00.000Z","sellerLegalName":"AVS Textiles Pvt Ltd","sellerGstin":"27AAAAA0000A1Z5","sellerStateCode":"27","placeOfSupplyStateCode":"27","currencyCode":"INR","exchangeRate":1,"subTotal":13000,"discountTotal":0,"documentDiscount":0,"documentDiscountIsPercent":false,"cgstTotal":1170,"sgstTotal":1170,"igstTotal":0,"adjustmentLabel":null,"adjustmentAmount":0,"roundOff":0,"total":15340,"amountPaid":0,"balanceDue":15340,"warehouseId":"clx2wh0001000000000000001","ewayBillStatus":"NOT_REQUIRED","ewayBillId":null,"emailSentAt":null,"pdfTemplateId":null,"notes":"Thank you for your business","termsAndConditions":null,"createdBy":"clx2usr001000000000000001","updatedBy":null,"createdAt":"2026-09-07T10:00:00.000Z","updatedAt":"2026-09-07T10:00:00.000Z","lines":[{"id":"clx2ivi001000000000000001","organizationId":"clx2org001000000000000001","invoiceId":"clx2inv001000000000000001","itemId":"clx2itm001000000000000001","itemVariantId":"clx2var001000000000000001","description":"Cotton Fabric - Blue","hsnOrSac":"5208","quantity":20,"unit":"MTR","rate":650,"discount":0,"taxRatePercent":18,"taxableAmount":13000,"cgstAmount":1170,"sgstAmount":1170,"igstAmount":0,"total":15340,"sortOrder":0,"width":null,"height":null,"lengthUnit":null,"qtyCount":null}]}}}}},"401":{"description":"Missing bearer token","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"unauthorized"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"unauthorized","message":"Missing bearer token"}}}}},"403":{"description":"Access denied","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"forbidden"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"forbidden","message":"Access denied"}}}}},"404":{"description":"Resource not found","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"not_found"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"not_found","message":"Resource not found"}}}}}},"security":[{"bearerAuth":[]}],"tags":["Invoices"]},"patch":{"summary":"Update an invoice","description":"Only DRAFT or SENT invoices are editable. Returns only { id, status, total }.","parameters":[{"name":"id","in":"path","required":true,"description":"Invoice ID.","schema":{"type":"string","example":"clx2inv001000000000000001"}}],"responses":{"200":{"description":"Update an invoice","content":{"application/json":{"example":{"success":true,"data":{"id":"clx2inv001000000000000001","status":"SENT","total":15340}}}}},"401":{"description":"Missing bearer token","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"unauthorized"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"unauthorized","message":"Missing bearer token"}}}}},"403":{"description":"Access denied","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"forbidden"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"forbidden","message":"Access denied"}}}}},"404":{"description":"Resource not found","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"not_found"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"not_found","message":"Resource not found"}}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"conflict"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"conflict","message":"Conflict"}}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"validation_error"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"validation_error","message":"Validation failed"}}}}}},"security":[{"bearerAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$schema":"https://json-schema.org/draft/2020-12/schema","type":"object","properties":{"customerId":{"type":"string","minLength":1},"salespersonId":{"type":"string","maxLength":30},"sellerRegistrationId":{"anyOf":[{"type":"string","maxLength":30},{"type":"string","const":""}]},"invoiceDate":{"type":"string","format":"date-time"},"dueDate":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}]},"currencyCode":{"default":"INR","type":"string","minLength":3,"maxLength":3},"exchangeRate":{"default":1,"type":"number","exclusiveMinimum":0},"placeOfSupplyStateCode":{"anyOf":[{"type":"string","minLength":2,"maxLength":2},{"type":"string","const":""}]},"warehouseId":{"anyOf":[{"type":"string","maxLength":30},{"type":"string","const":""}]},"notes":{"anyOf":[{"type":"string","maxLength":2000},{"type":"string","const":""}]},"termsAndConditions":{"anyOf":[{"type":"string","maxLength":2000},{"type":"string","const":""}]},"status":{"default":"DRAFT","type":"string","enum":["DRAFT","SENT"]},"applyCustomerCredit":{"default":false,"type":"boolean"},"schemeIds":{"maxItems":50,"type":"array","items":{"type":"string","minLength":1,"maxLength":30}},"lines":{"minItems":1,"type":"array","items":{"type":"object","properties":{"itemId":{"anyOf":[{"type":"string","maxLength":30},{"type":"null"}]},"itemVariantId":{"anyOf":[{"type":"string","maxLength":30},{"type":"null"}]},"lotId":{"anyOf":[{"type":"string","maxLength":30},{"type":"null"}]},"description":{"type":"string","minLength":1,"maxLength":500},"hsnOrSac":{"anyOf":[{"type":"string","maxLength":10},{"type":"null"}]},"quantity":{"type":"number","exclusiveMinimum":0},"unit":{"default":"PCS","type":"string","maxLength":20},"rate":{"type":"number","minimum":0},"discount":{"default":0,"type":"number","minimum":0},"taxRatePercent":{"default":0,"type":"number","minimum":0,"maximum":100},"priceInclusive":{"default":false,"type":"boolean"},"sortOrder":{"default":0,"type":"integer","minimum":0,"maximum":9007199254740991},"schemeFree":{"type":"boolean"},"width":{"anyOf":[{"type":"number","exclusiveMinimum":0},{"type":"null"}]},"height":{"anyOf":[{"type":"number","exclusiveMinimum":0},{"type":"null"}]},"lengthUnit":{"anyOf":[{"type":"string","enum":["FT","IN","CM","MM","M"]},{"type":"null"}]},"qtyCount":{"anyOf":[{"type":"number","exclusiveMinimum":0},{"type":"null"}]}},"required":["description","quantity","rate"]}},"adjustments":{"default":{"documentDiscount":0,"documentDiscountIsPercent":false,"adjustmentAmount":0,"adjustmentLabel":null},"type":"object","properties":{"documentDiscount":{"default":0,"type":"number","minimum":0},"documentDiscountIsPercent":{"default":false,"type":"boolean"},"adjustmentAmount":{"default":0,"type":"number"},"adjustmentLabel":{"anyOf":[{"type":"string","maxLength":100},{"type":"null"}]}}}},"required":["customerId","invoiceDate","lines"]},"example":{"customerId":"clx2cus001000000000000001","invoiceDate":"2026-09-07","dueDate":"2026-10-07","currencyCode":"INR","placeOfSupplyStateCode":"27","warehouseId":"clx2wh0001000000000000001","status":"SENT","lines":[{"itemId":"clx2itm001000000000000001","description":"Cotton Fabric - Blue","quantity":20,"unit":"MTR","rate":650,"taxRatePercent":18}],"adjustments":{"documentDiscount":0,"documentDiscountIsPercent":false,"adjustmentAmount":0}}}}},"tags":["Invoices"]},"delete":{"summary":"Delete an invoice","description":"DRAFT invoices only — 409 conflict for any other status; void issued invoices instead.","parameters":[{"name":"id","in":"path","required":true,"description":"Invoice ID.","schema":{"type":"string","example":"clx2inv001000000000000001"}}],"responses":{"200":{"description":"Delete an invoice","content":{"application/json":{"example":{"success":true,"data":{"ok":true}}}}},"401":{"description":"Missing bearer token","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"unauthorized"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"unauthorized","message":"Missing bearer token"}}}}},"403":{"description":"Access denied","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"forbidden"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"forbidden","message":"Access denied"}}}}},"404":{"description":"Resource not found","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"not_found"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"not_found","message":"Resource not found"}}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"conflict"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"conflict","message":"Conflict"}}}}}},"security":[{"bearerAuth":[]}],"tags":["Invoices"]}},"/api/v1/invoices/{id}/void":{"post":{"summary":"Void an invoice","description":"Reverses stock movements for the document. 409 if the current status isn't voidable.","parameters":[{"name":"id","in":"path","required":true,"description":"Invoice ID.","schema":{"type":"string","example":"clx2inv001000000000000001"}}],"responses":{"200":{"description":"Void an invoice","content":{"application/json":{"example":{"success":true,"data":{"id":"clx2inv001000000000000001","status":"VOID"}}}}},"401":{"description":"Missing bearer token","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"unauthorized"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"unauthorized","message":"Missing bearer token"}}}}},"403":{"description":"Access denied","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"forbidden"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"forbidden","message":"Access denied"}}}}},"404":{"description":"Resource not found","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"not_found"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"not_found","message":"Resource not found"}}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"conflict"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"conflict","message":"Conflict"}}}}}},"security":[{"bearerAuth":[]}],"tags":["Invoices"]}},"/api/v1/invoices/{id}/send":{"post":{"summary":"Mark a DRAFT invoice as SENT","description":"Allocates a real invoice number and drains stock. A safe, persisted-data-only transition — no total recompute or line-item mutation. 409 if the invoice isn't currently DRAFT.","parameters":[{"name":"id","in":"path","required":true,"description":"Invoice ID.","schema":{"type":"string","example":"clx2inv001000000000000001"}}],"responses":{"200":{"description":"Mark a DRAFT invoice as SENT","content":{"application/json":{"example":{"success":true,"data":{"id":"clx2inv001000000000000001","status":"SENT","invoiceNumber":"INV-2026-0102"}}}}},"401":{"description":"Missing bearer token","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"unauthorized"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"unauthorized","message":"Missing bearer token"}}}}},"403":{"description":"Access denied","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"forbidden"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"forbidden","message":"Access denied"}}}}},"404":{"description":"Resource not found","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"not_found"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"not_found","message":"Resource not found"}}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"conflict"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"conflict","message":"Conflict"}}}}}},"security":[{"bearerAuth":[]}],"tags":["Invoices"]}},"/api/v1/invoices/{id}/payments":{"get":{"summary":"List payments applied to an invoice","description":"Allocation rows joined with their parent payment, newest first. An invoice with no payments returns an empty array, not a 404.","parameters":[{"name":"id","in":"path","required":true,"description":"Invoice ID.","schema":{"type":"string","example":"clx2inv001000000000000001"}}],"responses":{"200":{"description":"List payments applied to an invoice","content":{"application/json":{"example":{"success":true,"data":[{"paymentId":"clx2pr0001000000000000001","paymentNumber":"PR-2026-0044","paymentDate":"2026-09-07T00:00:00.000Z","mode":"BANK_TRANSFER","amount":15340}]}}}},"401":{"description":"Missing bearer token","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"unauthorized"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"unauthorized","message":"Missing bearer token"}}}}},"403":{"description":"Access denied","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"forbidden"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"forbidden","message":"Access denied"}}}}}},"security":[{"bearerAuth":[]}],"tags":["Invoices"]}},"/api/v1/invoices/{id}/pdf":{"get":{"summary":"Render the invoice as a PDF","description":"Bearer-token counterpart to the session-authed web invoice PDF — same rendering pipeline, so the two are always in sync.","parameters":[{"name":"id","in":"path","required":true,"description":"Invoice ID.","schema":{"type":"string","example":"clx2inv001000000000000001"}}],"responses":{"200":{"description":"The invoice rendered using the org's configured template, streamed inline with a Content-Disposition filename.","content":{"application/pdf":{"schema":{"type":"string","format":"binary"}}}},"401":{"description":"Missing bearer token","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"unauthorized"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"unauthorized","message":"Missing bearer token"}}}}},"403":{"description":"Access denied","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"forbidden"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"forbidden","message":"Access denied"}}}}},"404":{"description":"Resource not found","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"not_found"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"not_found","message":"Resource not found"}}}}}},"security":[{"bearerAuth":[]}],"tags":["Invoices"]}},"/api/v1/payments-received":{"get":{"summary":"List payments received","parameters":[{"name":"page","in":"query","required":false,"description":"1-based page number.","schema":{"type":"number","example":1}},{"name":"limit","in":"query","required":false,"description":"Page size, max 200.","schema":{"type":"number","example":50}},{"name":"q","in":"query","required":false,"description":"Free-text search on payment number or reference number.","schema":{"type":"string"}}],"responses":{"200":{"description":"List payments received","content":{"application/json":{"example":{"success":true,"data":[{"id":"clx2pr0001000000000000001","organizationId":"clx2org001000000000000001","paymentNumber":"PR-2026-0044","customerId":"clx2cus001000000000000001","paymentDate":"2026-09-07T00:00:00.000Z","mode":"BANK_TRANSFER","referenceNumber":"UTR9988776655","depositAccount":"HDFC Current A/C","amount":15340,"allocated":15340,"openingBalanceApplied":0,"currencyCode":"INR","exchangeRate":1,"razorpayPaymentId":null,"isRazorpayAuto":false,"notes":"Full settlement of INV-2026-0102","createdBy":"clx2usr001000000000000001","createdAt":"2026-09-07T11:00:00.000Z","updatedAt":"2026-09-07T11:00:00.000Z"}],"meta":{"page":1,"limit":50,"total":1,"hasMore":false}}}}},"401":{"description":"Missing bearer token","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"unauthorized"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"unauthorized","message":"Missing bearer token"}}}}},"403":{"description":"Access denied","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"forbidden"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"forbidden","message":"Access denied"}}}}}},"security":[{"bearerAuth":[]}],"tags":["Payments Received"]},"post":{"summary":"Record a payment received","description":"Accepts an optional Idempotency-Key header. Sum of allocations + openingBalanceApplied must not exceed amount + tdsAmount. Optional tdsAmount / tdsSectionCode record TDS the customer deducted (it settles invoices like cash). Returns only { id }.","parameters":[{"name":"Idempotency-Key","in":"header","required":false,"description":"Unique key per create attempt; a retry with the same key returns the original result.","schema":{"type":"string"}}],"responses":{"201":{"description":"Record a payment received","content":{"application/json":{"example":{"success":true,"data":{"id":"clx2pr0001000000000000001"}}}}},"401":{"description":"Missing bearer token","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"unauthorized"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"unauthorized","message":"Missing bearer token"}}}}},"403":{"description":"Access denied","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"forbidden"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"forbidden","message":"Access denied"}}}}},"422":{"description":"Validation failed","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"validation_error"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"validation_error","message":"Validation failed"}}}}}},"security":[{"bearerAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$schema":"https://json-schema.org/draft/2020-12/schema","type":"object","properties":{"customerId":{"type":"string","minLength":1},"paymentDate":{"type":"string","format":"date-time"},"mode":{"default":"BANK_TRANSFER","type":"string","enum":["CASH","BANK_TRANSFER","UPI","CARD","CHEQUE","RAZORPAY","OTHER"]},"referenceNumber":{"anyOf":[{"type":"string","maxLength":100},{"type":"string","const":""}]},"depositAccount":{"anyOf":[{"type":"string","maxLength":100},{"type":"string","const":""}]},"amount":{"type":"number","exclusiveMinimum":0},"currencyCode":{"default":"INR","type":"string","minLength":3,"maxLength":3},"exchangeRate":{"default":1,"type":"number","exclusiveMinimum":0},"notes":{"anyOf":[{"type":"string","maxLength":2000},{"type":"string","const":""}]},"allocations":{"default":[],"type":"array","items":{"type":"object","properties":{"invoiceId":{"anyOf":[{"type":"string","maxLength":30},{"type":"null"}]},"customerAdjustmentId":{"anyOf":[{"type":"string","maxLength":30},{"type":"null"}]},"amount":{"type":"number","exclusiveMinimum":0}},"required":["amount"]}},"openingBalanceApplied":{"default":0,"type":"number","minimum":0},"tdsAmount":{"type":"number","minimum":0},"tdsSectionCode":{"anyOf":[{"type":"string","maxLength":10},{"type":"string","const":""}]}},"required":["customerId","paymentDate","amount"]},"example":{"customerId":"clx2cus001000000000000001","paymentDate":"2026-09-07","mode":"BANK_TRANSFER","referenceNumber":"UTR9988776655","amount":15340,"allocations":[{"invoiceId":"clx2inv001000000000000001","amount":15340}]}}}},"tags":["Payments Received"]}},"/api/v1/payments-received/{id}":{"get":{"summary":"Get a payment received","description":"Includes allocations.","parameters":[{"name":"id","in":"path","required":true,"description":"Payment ID.","schema":{"type":"string","example":"clx2pr0001000000000000001"}}],"responses":{"200":{"description":"Get a payment received","content":{"application/json":{"example":{"success":true,"data":{"id":"clx2pr0001000000000000001","organizationId":"clx2org001000000000000001","paymentNumber":"PR-2026-0044","customerId":"clx2cus001000000000000001","paymentDate":"2026-09-07T00:00:00.000Z","mode":"BANK_TRANSFER","referenceNumber":"UTR9988776655","depositAccount":"HDFC Current A/C","amount":15340,"allocated":15340,"openingBalanceApplied":0,"currencyCode":"INR","exchangeRate":1,"razorpayPaymentId":null,"isRazorpayAuto":false,"notes":"Full settlement of INV-2026-0102","createdBy":"clx2usr001000000000000001","createdAt":"2026-09-07T11:00:00.000Z","updatedAt":"2026-09-07T11:00:00.000Z","allocations":[{"id":"clx2pra001000000000000001","organizationId":"clx2org001000000000000001","paymentId":"clx2pr0001000000000000001","invoiceId":"clx2inv001000000000000001","customerAdjustmentId":null,"amount":15340}]}}}}},"401":{"description":"Missing bearer token","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"unauthorized"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"unauthorized","message":"Missing bearer token"}}}}},"403":{"description":"Access denied","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"forbidden"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"forbidden","message":"Access denied"}}}}},"404":{"description":"Resource not found","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"not_found"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"not_found","message":"Resource not found"}}}}}},"security":[{"bearerAuth":[]}],"tags":["Payments Received"]},"delete":{"summary":"Delete a payment received","description":"Reverses allocations (and any opening-balance credit) in a transaction.","parameters":[{"name":"id","in":"path","required":true,"description":"Payment ID.","schema":{"type":"string","example":"clx2pr0001000000000000001"}}],"responses":{"200":{"description":"Delete a payment received","content":{"application/json":{"example":{"success":true,"data":{"ok":true}}}}},"401":{"description":"Missing bearer token","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"unauthorized"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"unauthorized","message":"Missing bearer token"}}}}},"403":{"description":"Access denied","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"forbidden"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"forbidden","message":"Access denied"}}}}},"404":{"description":"Resource not found","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"const":false},"error":{"type":"object","properties":{"code":{"const":"not_found"},"message":{"type":"string"}},"required":["code","message"]}},"required":["success","error"]},"example":{"success":false,"error":{"code":"not_found","message":"Resource not found"}}}}}},"security":[{"bearerAuth":[]}],"tags":["Payments Received"]}}},"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer"}}}}