Changelog
A chronological log of additions, changes, fixes, and deprecations to the SpireStock API and developer platform.
GSTR-1 Return & Fixed Invoice Numbers
- Added
GSTR-1 return (GST e-Invoice add-on): GET /einvoice/gstr1?month=YYYY-MM previews a month's return and GET /einvoice/gstr1/json downloads the file for the GST portal's offline upload. It covers B2B invoices, inter-state B2C invoices above Rs 1 lakh, other B2C supplies by rate, 0% items as exempt supplies, the HSN summary split into B2B and B2C, and the documents issued. Every amount comes from the printed invoice, and IRN-registered B2B invoices are left to the portal's own auto-fill unless include_einvoiced=1 is passed.
- Added
The download is refused with 422 and a list of problems while the portal would reject the file: an invalid customer GSTIN, a missing or malformed HSN code, an unknown place of supply, CGST + SGST charged to another state or IGST to your own, or a workspace state code that disagrees with its GSTIN. 4-digit HSN codes are reported as a warning.
- Added
Dashboard: a GSTR-1 Return page under Finance shows the month's tax totals, what goes into each table and anything to fix, with links to where it is fixed, and downloads the JSON.
- Changed
Invoice numbers are fixed the first time an invoice is issued: printed (singly or with print-all), e-invoiced or filed in GSTR-1. Every later print or filing reuses that number, so an order added for the same party and day afterwards no longer renumbers an invoice that was already printed. GET /accounts/invoice/{orderId}?format=json now returns invoice_no.
- Fixed
Print-all numbered each invoice by its position in that print run (-002, -0010), so one invoice could carry a different number from its single print and its e-invoice. Every print now uses the invoice's own number.
Import Preview, Approval Confirmations & Reliable Sheet Uploads
- Added
POST /imports/preview/{type} checks a product-variant, scheme or variant-price sheet before it is imported and saves nothing. It reports how each column maps to the template, required columns that are missing, columns that will be ignored, and every row's errors with its Excel row number; counts cover the whole file and the first 200 rows come back for display.
- Added
Dashboard imports show that preview as soon as a file is chosen, with a scrollable table, an errors-only filter and an Import button that names how many rows will be saved. Every upload screen lists the accepted files: .xlsx or .csv up to 10 MB.
- Changed
Forward, Approve and Decline in the dashboard ask for confirmation first, naming the action and the records it applies to. This covers the Approvals inbox, leaves, sample requests and an order's own page.
- Changed
POST /imports/product-variants, /imports/schemes and /imports/rate-list validate every row the same way as the preview, return the first 100 failing rows in errors, and answer 400 when a required column is missing.
- Fixed
Sheets made from the import templates now import fully. Container Qty, SKU Code, Start Date and End Date were ignored, matching variant prices by SKU code never found the variant, and every row of the schemes template was skipped because its Scheme Type column was not recognised.
- Fixed
Large uploads are read row by row instead of being loaded whole, so sheets close to the 10 MB limit no longer risk failing part-way. Text cells from workbooks saved by other spreadsheet tools are read correctly.
- Fixed
Confirmation and form dialogs always open in the middle of the screen, and the Product List on the products page fits its panel without scrolling sideways.
Add-on Modules: Demand Forecast, Cold Chain & GST e-Invoice
- Added
AI Forecasting add-on: GET /forecasting/demand forecasts each product variant for 7, 14 or 30 days with an 80% range, learned from up to 180 days of orders with weekly seasonality. GET /forecasting/production-plan suggests tomorrow's quantity rounded up to whole crates, GET /forecasting/summary compares the next 7 days with the last 7 and reports backtested accuracy, and POST /forecasting/insights returns a short written summary.
- Added
Cold Chain add-on: register vehicles, chillers, cold rooms, freezers and bulk milk coolers with a safe temperature band under /cold-chain/assets, then post readings to POST /cold-chain/readings (single or up to 500 at once; temperature loggers can post with an API key holding the cold-chain write scope). Readings outside the band open an excursion and alert workspace admins; excursions are acknowledged and resolved with a note, GET /cold-chain/summary gives time in range per asset, and GET /cold-chain/export downloads the compliance log as Excel.
- Added
GST e-Invoice add-on: GET /einvoice/invoices classifies each invoice as B2B or not required and lists anything the Invoice Registration Portal would reject (GSTIN checksum, state and PIN codes, HSN, totals). GET /einvoice/invoices/{key}/json and POST /einvoice/bulk-json produce NIC schema 1.1 JSON for the portal's bulk upload; POST /einvoice/invoices/{key}/irn records the IRN, acknowledgement and signed QR, which then print on the invoice, and POST /einvoice/invoices/{key}/cancel cancels within the 24-hour window.
- Added
Add-on access: the add-on endpoints answer 402 with code ADDON_REQUIRED when a workspace has not added that module. Workspaces on a trial can use every add-on before buying.
- Added
Team invites: an invite link now opens a join form for the inviting workspace (GET /signup/invite/{token}, POST /signup/accept-invite) instead of creating a new workspace. Invites accept staff roles only, and GET /workspace/members lists admins and employees, filterable with type=admin or type=employee.
- Added
Refer a friend by email: POST /referrals/invite sends your referral link to up to 10 addresses with an optional note of up to 300 characters, and GET /referrals/invites lists what was sent. An address is emailed at most once in 30 days.
- Added
WhatsApp: POST /workspace/whatsapp/verify checks the saved Meta Cloud API credentials by reading the number's display name and quality rating, without sending a message.
- Changed
Free-text fields have length limits, and longer values are rejected with a 400 naming the field: descriptions, remarks and reasons 500 characters; notes, comments and replies 1,000; support and bug write-ups and product descriptions 2,000.
- Changed
The support chatbot is now managed for every workspace by the platform; chatbot settings are no longer part of PUT /workspace/config.
- Fixed
Text where a number or date was expected (for example ?page=abc, /returns/abc or an impossible date) returns a 400 naming the field instead of a 500, and error responses no longer include database messages.
- Fixed
Returns are credited only to a distributor or retailer account in the workspace; POST /returns rejects any other outlet_id.
- Fixed
Deleting a product also removes its customer price-list rows; /users/{id}/orders and /users/{id}/schemes return 404 for unknown users; order and delivery WhatsApp messages use the workspace's own number when one is configured.
- Security
GET /settings/configuration no longer returns server-side keys, and PUT /settings/configuration accepts only the documented configuration fields.
Distribution Operations: Reports, Pricing, Approvals, Crates & Accounts
- Added
Dispatch and MIS reports under /reports: plant-wise indent with POST /reports/indent/generate, daily sale (daily demand), distributor-wise date-wise, truck sheet by vehicle and by route, sales statement, amount to be paid, summary sheet, SKU and distributor contribution, tagging, visits, HO entry, packing station, login activity and the report filter options. Report days are calendar days in the workspace time zone; each date parameter states whether it takes YYYY-MM-DD only or also dd/mm/yyyy.
- Added
Pricing and schemes: GET /orders/price-list/{userId} returns a customer's price list with per-user rates; GET and PATCH /users/{id}/products manage per-user prices with history; POST /orders/calculate-schemes previews the schemes and totals an order would get without saving it; /schemes/admin/{kind} manages free, new, bulk-pack, quantitative and flat schemes and their customer assignments.
- Added
Approval workflow: GET /approvals, GET /approvals/my-level, GET /approvals/{type}/{id}/trail, and forward, approve or decline for orders, leave and FOC, one at a time (PATCH /approvals/{type}/{id}) or up to 500 at once (POST /approvals/{type}/action). Levels come from the workspace's permission workflow (GET /settings/permission-workflows).
- Added
Crates across the party, transporter and plant ledgers: balances, ledger, monthly and day-wise crate summaries, one party's month, delivery approvals (PATCH /crates/approvals/{id}), manual entries, and the OTP-verified plant gate flow (POST /crates/plant/send-otp, then /crates/plant/dispatch or /crates/plant/receive).
- Added
Accounts: party ledger overview, invoices with GST, TCS and incentives (HTML, or JSON with format=json), print-all for a day, and gatepass and challan issue with PDF download (GET /accounts/challans/{id}/pdf).
- Added
Excel imports with a validate-first preview and a separate commit: rate list by state and zone (/imports/rate-list/preview and /commit, with dry_run), free schemes by customer code (/imports/free-schemes/preview and /commit), outstanding and revised amount, plus downloadable templates.
- Added
Masters for states, zones, towns, routes with their ordered towns, and mobile app versions under /masters.
- Added
Attendance and tracking exports: the monthly attendance grid, one employee's month (/reports/attendance/monthly/staff/{userId}) and the GPS travel summary with travel allowance (/tracking/travel-summary with time_period).
- Added
Wallet recharge requests: POST /wallet/recharge-requests files a customer's top-up with amount, payment mode, UTR and an optional receipt, and leaves the balance untouched until staff with the Amount to be paid permission approve it (POST /wallet/recharge-requests/{id}/approve) or reject it with a reason (/reject). GET /wallet/recharge-requests lists them with status counts; customers see only their own. GET /wallet/balance?all=1 lists every wallet in the workspace for the same staff.
- Added
Platform permission definitions are managed by platform owners under /super-admin/permission-definitions, with every change audit-logged. The core view, add, edit and delete permissions can be relabelled but not renamed or removed.
- Added
Feature modules: GET /workspace/features returns which optional areas a workspace has switched on, and PUT /workspace/features lets workspace administrators change them. New workspaces start with the core areas; existing workspaces keep everything they had.
- Added
Onboarding: GET /dashboard/onboarding returns the Get Started checklist with each step ticked from the workspace's own data, and GET and PUT /auth/me/onboarding store the signed-in user's product-tour progress.
- Added
Every operation in the OpenAPI spec now carries x-api-key-scope (read, write or none) and x-permission (the staff permission it needs), derived from the tables that enforce them. The new endpoints are described by hand with real, anonymised example responses, and the reference has new pages for Reports, Pricing & Schemes, Approvals & Permissions, Crates & Logistics, Accounts, Imports, Masters, and Attendance & Tracking.
- Added
MCP server 0.2.0: run_report exposes the new reports and takes production_unit_id, and list_masters adds states, app versions, incentive slabs and brand products.
- Changed
GET /orders accepts date filters (order_date or date_from/date_to in dd/mm/yyyy or YYYY-MM-DD), route, town, customer, customer code, user type and sort, and returns flat_incentive, bulkpack_incentive and invoice_amount on each row. GET /orders/{id} includes the applied schemes.
- Changed
POST /orders prices every line on the server from the customer's price list and applies their schemes; rates sent by the client are ignored. PUT /orders/{id} edits the lines of any order not yet delivered, re-prices it and restarts its approval chain.
- Changed
PATCH /orders/{id}/status takes status (2 forward, 3 approve, 4 delivered) or action, and forward and approve now go through the approval workflow. Marking an order delivered is reserved to workspace administrators.
- Changed
Accounts imported from an earlier system sign in with their existing passwords; the stored hash is upgraded to bcrypt on the first successful login. POST /portal/login accepts a customer code as well as an email or phone number.
- Changed
POST /users onboards distributors and employees in one call (contacts, addresses, plants, area, KYC documents) and maps the product catalogue to new distributors. GET /users takes a tab of primary, secondary or employee.
- Changed
Customers can no longer credit a wallet directly: POST /wallet/recharge and /wallet/auto-debit are for workspace staff only, and GET /wallet/transactions returns completed entries unless status=all is passed.
- Changed
List endpoints page on the server: page and limit (up to 100 per page), search and sort, with pagination { total, page, limit, total_pages } in the response and the record id as the final sort key so pages never repeat or skip rows. This now covers workspace members, user pickers (/helpers/users), approvals, ledger and crate summaries, login activity, visits, scheme users, beat plans and the sales-app customer and order lists.
- Changed
GET /tracking/live/{userId} (new ?date=) and GET /tracking/location-log page a day's GPS points with a cursor: pass next_cursor back as ?cursor= until has_more is false. Without limit a page keeps the old size (1,000 trail points, 500 log points); an explicit limit is capped at 100. The location log with no date now means today instead of the first 500 points ever.
- Changed
The activity-log and scan-log exports return up to 50,000 rows instead of stopping silently at 1,000 and 5,000; X-Export-Truncated: true and X-Export-Row-Cap: 50000 mark a file that hit the cap. GET /accounts/ledger-summary is paged and returns whole-list totals, and GET /users/{id}/schemes pages the applied schemes instead of stopping at 1,000.
- Added
The API reference has a Pagination section covering page and limit, search, sort, the id tie-break and cursors, and every paged endpoint links to it. New reference pages for Onboarding & Features and Wallet; Users, Workspace, Approvals, Reports, Crates, Accounts, Exports and Attendance & Tracking list the newly paged endpoints.
- Changed
Faster reports and lists on large workspaces: new database indexes for orders, order lines, tracking, attendance, notifications, activity logs and crate ledgers, built online without blocking writes.
- Changed
Report endpoints are rate limited to 60 requests per minute and 600 per hour per caller, up from 20 and 200, so moving between report pages during dispatch no longer trips the limit. Exports stay at 5 per minute.
- Changed
Upload errors are client errors: a file over the size limit returns 413 and an unsupported type returns 400, each naming the allowed types. Imports take .xlsx and .csv; .xls is refused up front instead of failing after upload.
- Fixed
The reference documented POST /auth/otp/request and /auth/otp/verify as taking a phone number; they take an email address. PATCH /orders/{id}/status was documented with an order_status field; the field is status.
- Fixed
The playground and the in-page Try It console can call a staging or local API: the portal's content security policy and the spec's server list now follow the API it is configured for instead of always naming api.spirestock.com.
- Fixed
A workspace administrator who signs up by email is signed in straight away; the first request after sign-up no longer answers 401.
- Fixed
Single-record routes answer 404 for an id that is not a whole number, instead of 500.
- Changed
GET /tracking/live/{userId} replays a past day even when live tracking is switched off for the workspace, without a current position; today stays hidden while it is off.
- Fixed
The reference for POST /signup/register now lists the fields the API reads (company_name, slug, admin_email, admin_phone, admin_password and the optional admin name, state, pincode and referral_code), and the write endpoints show their full response shapes.
- Fixed
Secondary sales are in the reference. GET /secondary-sales/summary takes distributor_id, so the totals follow the same filters as the list, and sale_count is an integer. Both endpoints answer 400 for a distributor_id that is not a positive integer or a date that is not YYYY-MM-DD, and the list uses the standard page and limit rules (max 100).
- Fixed
Browsers can read X-Export-Truncated, X-Export-Row-Cap and Content-Disposition on cross-origin export downloads; they are now listed in Access-Control-Expose-Headers.
- Fixed
MCP server 0.2.2 caps list tools at 100 rows per call.
- Security
Staff routes are default-deny. A non-admin session needs the module permission a route names; a route with no rule is for workspace administrators only. Each endpoint's Access line in the reference, and x-permission in the spec, names the permission.
- Security
Customer tokens (distributors, retailers, super-stockists and portal logins) are confined to the customer-portal routes, and any customer id they send is replaced with their own. Everything else answers 403.
- Security
API keys can no longer reach /cron, /sales-app or /mobile, the tracking routes that record a person's own attendance and location, or writes to the permission matrix under /settings. Those act as, or change the access of, a human user. Report, export, crate, account and master reads need read; imports, approvals and other writes need write.
- Security
Handover OTPs (plant dispatch and receive, order delivery, crate collection) are stored only as a SHA-256 hash, expire after 24 hours, are compared in constant time, are deleted on use, and are burned after five wrong attempts.
- Security
User objects no longer include firebase_token, oauth_id, failed_login_attempts or locked_until, and driver objects no longer include the app password hash, push token, session token or OTP. Drivers carry has_app_password instead.
- Security
GET /workspace/config never returns stored credentials (SMTP password, WhatsApp tokens and app secret, Firebase and Google keys); each is replaced by has_<field>. On PUT a blank value keeps the stored secret and clear_<field>: true removes it.
- Security
HTTP cron triggers (/cron/*) accept only the shared CRON_SECRET in X-Cron-Secret and are disabled when it is not configured.
Desktop Sign-In & Authentication Hardening
- Added
Desktop sign-in handoff. POST /auth/desktop/code mints a single-use code for an already-authenticated session, and POST /auth/desktop/exchange trades that code plus the caller's own state value for a session. Codes are 256-bit, expire after two minutes, and are redeemed by a conditional UPDATE so a code can never be spent twice.
- Added
GET /downloads/desktop/version and GET /downloads/desktop/mac report the current macOS build, read from the signed release manifest rather than a constant.
- Changed
Account lockout now applies to every authentication method. Five failed attempts locks the account for 30 minutes, and OTP, magic link and passkey all honour it — previously only password login checked, so a locked account could still be entered another way. A locked account returns 423.
- Changed
POST /auth/otp/request and POST /auth/magic-link/request are now rate limited, and every auth limiter is keyed on the target account rather than the caller's IP. Limits are shared across API instances, so they no longer reset on deploy.
- Changed
Passkey login requires user verification (biometric or PIN), not just user presence, and rejects an authenticator whose signature counter goes backwards. Synced passkeys that report a permanent counter of zero are unaffected.
- Changed
OTP verification returns one message for every failure. Previously “no OTP found” and “invalid OTP” were distinguishable, which revealed whether an address had a code outstanding.
- Fixed
Invite and password-reset links are no longer redeemable at /auth/magic-link/verify for a full session. They now carry a purpose and are exchanged at POST /auth/magic-link/set-password/:token, which sets a password and returns no token.
- Fixed
One-time codes, OTPs and magic links are deleted seven days after they expire. Nothing previously removed them.
API Key Notifications & Operator Roles
- Added
Workspace admins are emailed when an API key is created or revoked, so a key minted by one admin is visible to the rest.
- Changed
Platform operator routes are gated by role. Destructive operations require an explicit write role rather than any authenticated platform session.
- Fixed
A workspace granted a plan by an operator no longer stays billing read-only, which had kept writes refused with 402 after the grant.
MCP Server, Machine Access & Email Webhooks
- Added
@spirestock/mcp-server on npm — a Model Context Protocol server that connects Claude, Cursor and other AI tools directly to a workspace using an API key. See the MCP guide for the tool list and setup.
- Added
Resend email webhook with delivery tracking and an automatic suppression list, so hard bounces stop being retried.
- Added
Multi-provider SMTP failover for platform email: a provider outage falls through to the next rather than dropping the message.
- Changed
Machine access is plan-gated. A workspace on an active trial can use API keys; once the trial expires, key-authenticated requests return 402 with the same shape as the billing read-only response, including reads.
- Changed
Repeated bad API keys from one address are throttled — 30 failures in 15 minutes returns 429 until the window clears.
- Fixed
Corrected field mappings in the MCP account, product and master tools, and four defects found in an adversarial review of that surface.
API Key Limits & Referral Endpoints
- Added
Referral endpoints: GET /referral/lookup/:code and POST /referral/scan/:code are public and rate limited; GET /referral/me returns the calling workspace's own code and stats.
- Changed
An organization may hold at most 50 active API keys. Creating one beyond the cap returns 400 — revoke an unused key first.
- Fixed
Closed two cases where a revoked or out-of-scope API key was still accepted.
Session Integrity & Endpoint Fixes
- Fixed
Logging out, changing your password, or signing in again now genuinely revokes the previous session token. This was already the documented behaviour but was not enforced, so older tokens kept working.
- Fixed
Every issued token is now unique. Two tokens minted for the same user within the same second used to be identical, so rotating a session in that window left the old token valid.
- Fixed
Validation failures raised inside service layers now return their real status (usually 400) instead of 500 Internal Server Error.
- Fixed
Repaired report, export and dashboard endpoints that returned 500 on every call, including the SKU sales, performance, product secondary, delivery challan, packing station, truck sheet and amount-to-be-paid exports.
API Keys & Webhooks
- Added
API key authentication via the X-API-Key header, with read/write and per-resource scopes. Keys skip the Turnstile and single-session constraints that apply to browser JWTs.
- Added
Customer webhooks for order.created, order.delivered and user.created, with HMAC-SHA256 signatures over {timestamp}.{body}.
- Added
Webhook management endpoints under /developer: create, update, delete, rotate signing secret, send a test delivery, and read the delivery log.
- Added
Automatic delivery retries with exponential backoff, and an SSRF guard that rejects webhook URLs pointing at private, loopback or reserved addresses.
Initial Release
- Added
SpireStock REST API v1 with JWT authentication
- Added
Order management endpoints (CRUD + status flow)
- Added
User management (distributors, retailers, employees)
- Added
Product catalog with variants
- Added
Dashboard statistics and analytics
- Added
Export endpoints (XLSX, PDF) for orders, users, sales, attendance
- Added
Workspace configuration and member management
- Added
Multi-tenant architecture with organization scoping
- Added
Rate limiting (120 req/min general, 20/15min login)
- Added
OpenAPI 3.0 specification with Swagger UI
- Added
Developer portal with interactive documentation
