API Reference
The SpireStock REST API lets you programmatically manage orders, users, products, pricing and schemes, approvals, crates, accounts and master data, and pull the dispatch and MIS reports for your sales & distribution operations.
New here? The use-case recipes show the common integrations — ERP order sync, bulk master import, BI exports — end to end, with the exact endpoints and runnable code. This page is the full reference for every one of them.
Base URL
https://api.spirestock.com/api/v1Authentication
Two credentials are accepted. Send one or the other on every request — only login and signup are unauthenticated.
API key — the credential for servers, scheduled jobs and integrations. Create one under API Keys & Webhooks and send it as a header:
X-API-Key: df_9f3a1c7e2b8d...JWT bearer token — for browser sessions, obtained from login or OTP verification:
Authorization: Bearer eyJhbGciOiJIUzI1NiIs...Tokens expire after 15 days, and only one is valid per user at a time — signing in again invalidates the previous one. Logging in also requires a Cloudflare Turnstile token that only a browser can obtain, so anything server-side needs an API key. See Getting Started for scopes and the full comparison.
Requests without an API key must also send a descriptive User-Agent of at least 10 characters — defaults like curl/8.5.0, python-requests/2.31.0 and Node’s node are rejected with 403. Requests carrying X-API-Key are exempt.
Access control
Every endpoint below ends with an Access line naming what each kind of caller needs. The same facts are in the OpenAPI spec as x-api-key-scope and x-permission on every operation.
- API keys act with workspace-admin authority, bounded by their scopes:
readfor GET,writefor everything else, optionally narrowed to route groups such asread,reports. Keys never reach/auth,/developer,/billing,/portal,/driver-app,/sales-app,/mobile,/cronor the platform planes, nor the tracking routes that record a person’s own attendance and location, nor permission-matrix writes. - Staff session tokens are default-deny: each route needs the sub-module permission it names (for example Orders (8),
list). A route without a rule is for workspace administrators only. - Customer tokens (distributors, retailers, super-stockists, and tokens from
/portal/login) are confined to the customer-portal routes, and any customer id they send is replaced with their own. Every other route answers403. - Dates. Report days are IST calendar days (Asia/Kolkata) and “today” means today in IST. Each parameter says whether it takes
YYYY-MM-DDonly or alsodd/mm/yyyy.
Rate Limits
The API enforces rate limits per IP and per authenticated user:
- General endpoints: 120 requests/min, 2,000 requests/hour
- Login / OTP: 20 requests per 15 minutes (IP-based)
- Signup: 5 requests per hour (IP-based)
- Export endpoints: 5 requests/min, 50 requests/hour
- Report endpoints: 60 requests/min, 600 requests/hour
When rate-limited you will receive a 429 Too Many Requests response with a Retry-After header.
Error Format
{
"response_code": 400,
"message": "Validation failed"
}Pagination
Lists are paged on the server, so no call returns an unbounded number of rows. Endpoints marked Paged use page numbers; the few over very large, append-only tables (GPS points) are marked Cursor paged.
Page and limit
pagestarts at 1. A missing, non-numeric or smaller value reads as 1, so a client that sends nothing gets the first page.limitis the page size. The default differs per endpoint (20, 25, 30 or 50 — each endpoint says which). The maximum is 100 on every endpoint: a larger value is clamped to 100, not rejected.- The response carries
paginationwithtotal(rows matching the filters),page,limit(after clamping) andtotal_pages. An empty result hastotal_pages: 0; a page past the end returns an emptydatawith the same totals. - Counters and grand totals that a screen shows above a list (for example
summaryon approvals and visits, ortotalson the ledger summary) always cover the whole filtered list, not just the page.
{
"response_code": 200,
"data": [ ... ],
"pagination": {
"total": 10113,
"page": 2,
"limit": 50,
"total_pages": 203
}
}Search and sort
searchis a case-insensitive “contains” match on the fields each endpoint lists. It is trimmed and cut to 100 characters, and%and_match literally rather than as wildcards. Search on the server instead of downloading a list to filter it.- Where an endpoint offers
sort_by, only the listed columns are accepted; any other value falls back to the default.sort_orderisASCorDESC. - Every paged list adds
idas the final sort key. Rows that tie on the sort column (two customers with the same first name, two orders on the same day) therefore keep a stable order, and no row repeats or disappears between pages.
Cursors
- Cursor-paged endpoints return
has_moreandnext_cursor(inpagination, ortrail_paginationon the live trail). Sendnext_cursorback as?cursor=with the same filters to get the next page; it isnullon the last page. - Rows come oldest first, ordered by time and then id, so a cursor never skips or repeats a point even when new points arrive while you read.
totalcounts the whole range. - Treat the cursor as opaque. A garbled or expired one is read as “from the start”, not as an error.
- Without
limitthese endpoints keep their historical page size (1,000 points for the live trail, 500 for the location log); an explicitlimitis clamped to 100 like everywhere else.
{
"response_code": 200,
"data": [ ... ],
"pagination": {
"total": 3904,
"limit": 100,
"has_more": true,
"next_cursor": "WyIyMDI0LTA1LTE3VDAwOjMwOjQ3LjAwMFoiLDE0MDAxMTZd"
}
}Reading everything
# Offset: walk every page of a list
page=1
while :; do
body=$(curl -s "$BASE/workspace/members?page=$page&limit=100" -H "X-API-Key: $KEY")
# ... use body.data ...
[ "$page" -ge "$(echo "$body" | jq .pagination.total_pages)" ] && break
page=$((page + 1))
done
# Cursor: follow next_cursor until has_more is false
cursor=""
while :; do
body=$(curl -s "$BASE/tracking/location-log?user_id=7&date=2024-05-17&limit=100&cursor=$cursor" -H "X-API-Key: $KEY")
# ... use body.data ...
[ "$(echo "$body" | jq .pagination.has_more)" = "true" ] || break
cursor=$(echo "$body" | jq -r .pagination.next_cursor)
doneFor a full dump, the Excel/PDF exports are usually the better tool. The orders, users, secondary sales, ledger, activity and scan-log exports return up to 50,000 rows per file; when that cap is reached the response carries X-Export-Truncated: true and X-Export-Row-Cap: 50000, so narrow the date range and export again.
Authentication
Open Authentication reference →https://api.spirestock.com/api/v1/auth/loginAuthenticate with email and password. Returns a JWT token, user profile, navigation modules, and workspace details. Accounts imported from a previous system sign in with their existing password: a Django pbkdf2_sha256 hash is verified and transparently upgraded to bcrypt on the first successful login, with no change to the request or response. In production the request must also carry a Cloudflare Turnstile token, so servers should use an API key instead. Five failed attempts lock the account for 30 minutes.
Request Body
| Name | Type | Required | Description |
|---|---|---|---|
email | string | Yes | User email address |
password | string | Yes | Account password |
curl -X POST https://api.spirestock.com/api/v1/auth/login \
-H "Content-Type: application/json" \
-d '{
"email": "[email protected]",
"password": "your-password"
}'https://api.spirestock.com/api/v1/auth/otp/requestEmail a one-time code (valid 5 minutes) for passwordless login. The response is the same whether or not the address has an account.
Request Body
| Name | Type | Required | Description |
|---|---|---|---|
email | string | Yes | Account email address |
curl -X POST https://api.spirestock.com/api/v1/auth/otp/request \
-H "Content-Type: application/json" \
-d '{
"email": "[email protected]"
}'https://api.spirestock.com/api/v1/auth/otp/verifyVerify the emailed code and receive a JWT. Every failure returns the same message, and a successful sign-in revokes the user's previous session.
Request Body
| Name | Type | Required | Description |
|---|---|---|---|
email | string | Yes | Email used in the OTP request |
otp | string | Yes | The code from the email |
curl -X POST https://api.spirestock.com/api/v1/auth/otp/verify \
-H "Content-Type: application/json" \
-d '{
"email": "[email protected]",
"otp": "482910"
}'https://api.spirestock.com/api/v1/auth/meRetrieve the authenticated user’s profile, role, and organization context.
curl https://api.spirestock.com/api/v1/auth/me \ -H "Authorization: Bearer YOUR_TOKEN"
https://api.spirestock.com/api/v1/portal/loginCustomer-portal sign-in for distributors, retailers and super-stockists. The identifier can be the email, the phone number, or the SAP customer code (emp_sap_id); username accepts an email or a SAP code. Imported passwords work as for /auth/login. The token (valid 30 days) is a portal token: it is confined to the customer-portal routes, and any customer id in the query or body is replaced with the signed-in customer's own id, so a customer can only ever see their own orders, ledger and crates. Every other route answers 403. Requires a Turnstile token in production; rate limited to 15 attempts per 15 minutes.
Request Body
| Name | Type | Required | Description |
|---|---|---|---|
emp_sap_id | string | No | SAP customer code (or send email, phone or username) |
email | string | No | Account email |
phone | string | No | Registered mobile number |
password | string | Yes | Account password |
curl -X POST https://api.spirestock.com/api/v1/portal/login \
-H "Content-Type: application/json" \
-d '{
"emp_sap_id": "CUST-011",
"password": "your-password"
}'Signup
Open Signup reference →https://api.spirestock.com/api/v1/signup/registerRegister a new organization and its admin user. Creates the workspace (free plan, with a trial) and default settings, and returns a JWT for immediate sign-in. Missing required fields answer 400 "company_name, slug, admin_email, admin_phone, admin_password are required"; disposable email addresses and weak passwords are rejected with 400. Requires a Turnstile token in production; rate limited to 5 signups per hour.
Request Body
| Name | Type | Required | Description |
|---|---|---|---|
company_name | string | Yes | Name of the organization, 2-100 characters |
slug | string | Yes | Workspace subdomain (min 5 characters, starts with a letter); check it first with GET /signup/check-slug/{slug} |
admin_email | string | Yes | Admin email address |
admin_phone | string | Yes | Admin phone number |
admin_password | string | Yes | Password (min 8 characters with upper, lower, digit and symbol) |
admin_first_name | string | No | Defaults to the first word of company_name |
admin_last_name | string | No | Defaults to Admin |
state | string | No | State |
pincode | string | No | Pincode |
referral_code | string | No | Referral code, if any |
curl -X POST https://api.spirestock.com/api/v1/signup/register \
-H "Content-Type: application/json" \
-d '{
"company_name": "Acme Dairy",
"slug": "acmedairy",
"admin_first_name": "Jane",
"admin_last_name": "Smith",
"admin_email": "[email protected]",
"admin_phone": "9876500020",
"admin_password": "secureP@ss123"
}'Orders
Open Orders reference →https://api.spirestock.com/api/v1/ordersList orders with the order filters. Each row carries flat_incentive, bulkpack_incentive and invoice_amount (order total minus incentives). Dates are calendar days in the API server's local time zone (production runs in IST); with no usable date the list defaults to today. Staff only see orders of their own plants. Access: API key `read` scope; staff need Orders (8) — list.
Pagedpage and limit (max 100), id as the final sort key. How pagination works
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
page | number | No | Page number(default: 1) |
limit | number | No | Items per page (default 20, max 100)(default: 20) |
status | number | No | 1 initiated, 2 forwarded, 3 approved, 4 delivered |
order_date | string | No | One day, dd/mm/yyyy or YYYY-MM-DD (overrides the range) |
date_from | string | No | Range start, dd/mm/yyyy or YYYY-MM-DD |
date_to | string | No | Range end (inclusive) |
production_unit_id | number | No | Plant |
route_id | number | No | Route |
town_id | number | No | Town |
user_id | number | No | Customer |
user_sap_id | string | No | Customer SAP id (exact) |
user_type | string | No | e.g. Distributor |
town_name | string | No | Town name contains |
route_name | string | No | Route name contains |
search | string | No | Order code, customer name or SAP id contains |
scanned_by_driver | string | No | true/1 or false/0 |
sort_by | string | No | order_date (default), order_total_amount, order_code, created_at |
sort_order | string | No | ASC or DESC (default) |
curl "https://api.spirestock.com/api/v1/orders?order_date=10/06/2024&production_unit_id=17&status=3&limit=20" \ -H "X-API-Key: YOUR_API_KEY"
https://api.spirestock.com/api/v1/orders/summaryOrder counts per status for a day or range (same date parameters as GET /orders). Access: API key `read` scope; staff need Orders (8) — list.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
order_date | string | No | One day |
date_from | string | No | Range start |
date_to | string | No | Range end |
curl "https://api.spirestock.com/api/v1/orders/summary?date_from=2024-06-01&date_to=2024-06-10" \ -H "X-API-Key: YOUR_API_KEY"
https://api.spirestock.com/api/v1/ordersCreate an order. Rates, amounts and schemes are always computed on the server from the customer's price list, area and assigned schemes; client-sent rates are ignored (preview first with POST /orders/calculate-schemes). One order per customer per day, within the order cut-off. The approval chain starts on creation. Fires order.created. Access: API key `write` scope; staff need Orders (8) — add.
Request Body
| Name | Type | Required | Description |
|---|---|---|---|
user_id | number | Yes | Customer (distributor or retailer) id |
items | array | Yes | [{ product_variant_id, quantity, packaging_type: "0" crates (default) | "1" packets }] |
mode_of_payment | string | No | e.g. RTGS, UPI |
utr_no | string | No | Payment reference (max 50) |
amount_to_be_paid | number | No | Committed amount; defaults to the invoice amount |
curl -X POST https://api.spirestock.com/api/v1/orders \
-H "X-API-Key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"user_id": 44663,
"items": [
{
"product_variant_id": 446,
"quantity": 3,
"packaging_type": "0"
}
],
"mode_of_payment": "RTGS"
}'https://api.spirestock.com/api/v1/orders/{id}One order with details[] (lines, each with the schemes on that variant), schemes[] (every applied scheme with a readable description), total_incentive and invoice_amount. Orders in another workspace give 404. Access: API key `read` scope; staff need Orders (8) — view (without it, only their own records).
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
id | number | Yes | Order id |
curl https://api.spirestock.com/api/v1/orders/339189 \ -H "X-API-Key: YOUR_API_KEY"
https://api.spirestock.com/api/v1/orders/{id}Edit an order. With items[]: the lines are replaced, re-priced and schemes re-applied, the indent flag is cleared and the approval chain restarts (data.approval_reset); allowed until the order is delivered. Without items: header-only edit of mode_of_payment, vehicle_no, transporter_name, driver_name, revised_amount, outstanding_amount, order_date, utr_no and amount_to_be_paid, answered with message "Order updated" and the order (no totals or approval_reset). Access: API key `write` scope; staff need Orders (8) — edit.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
id | number | Yes | Order id |
Request Body
| Name | Type | Required | Description |
|---|---|---|---|
items | array | No | Full line list, same shape as POST /orders |
mode_of_payment | string | No | Header field |
amount_to_be_paid | number | No | 0 or more |
utr_no | string | No | Header field |
curl -X PUT https://api.spirestock.com/api/v1/orders/339189 \
-H "X-API-Key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"items": [
{
"product_variant_id": 446,
"quantity": 4,
"packaging_type": "0"
}
]
}'https://api.spirestock.com/api/v1/orders/{id}/statusMove an order through the workflow: status 2 forwards and 3 approves (same level rules as POST /approvals/order/action); 4 marks it delivered (workspace admins only), answers message "Order status updated to 4" with the order and no workflow block, and fires order.delivered. When other approvers of the same level are still pending the message is "Your approval is recorded; waiting for the other approvers of this level." and workflow.waiting is true. Or send action forward | approve with a remark. Orders cannot be declined. Access: API key `write` scope; staff need Orders (8) — edit.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
id | number | Yes | Order id |
Request Body
| Name | Type | Required | Description |
|---|---|---|---|
status | number | No | 2 forward, 3 approve, 4 delivered |
action | string | No | forward or approve (instead of status) |
remark | string | No | Shown in the approval trail |
curl -X PATCH https://api.spirestock.com/api/v1/orders/339403/status \
-H "X-API-Key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"status": 3
}'https://api.spirestock.com/api/v1/usersList users. Use tab for the user-management tabs — primary (distributors, user_type 2), secondary (retailers, 3), employee (staff, 0 and 1) — or the older type filter. Rows include role, basic details, contact person, outstanding_amount and platform (App, Web or -). Access: API key `read` scope; staff need Manage Users (3) or Create User (4) — list.
Pagedpage and limit (max 100), id as the final sort key. How pagination works
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
tab | string | No | primary, secondary or employee |
type | string | No | Without tab: distributor, retailer, super_stockist, employee or driver |
status | number | No | 1 active (default without tab), 0 inactive; empty for all |
search | string | No | Name, store, SAP id, email or phone |
role_id | number | No | Role |
town_id | number | No | Town |
page | number | No | Page number; junk or a value below 1 reads as 1(default: 1) |
limit | number | No | Page size, default 20, max 100 (larger values are clamped)(default: 20) |
curl "https://api.spirestock.com/api/v1/users?tab=primary&limit=20" \ -H "X-API-Key: YOUR_API_KEY"
https://api.spirestock.com/api/v1/usersCreate a user. kind primary creates a distributor (store_name required); kind employee a staff member. Contact numbers, contact persons, addresses, basic details (plants, credit limit, security amount), area (zone_id, town_id, route_id) and KYC documents (aadhaar_card, pan_card, cin, gstin, fssai) are accepted in the same call. Without a password, an invite email valid for 7 days is sent. Distributors get the product catalogue mapped automatically (mapped_variants). For kind primary the is_distributor / is_super_stockist flags follow role_id (a Distributor or Super Stockist role) unless sent explicitly; without either they stay 0 and the customer cannot sign in to the customer portal. data is the full user record (never the password). Fires user.created. Access: API key `write` scope; staff need Manage Users (3) or Create User (4) — add (never on administrator accounts).
Request Body
| Name | Type | Required | Description |
|---|---|---|---|
kind | string | No | primary (distributor) or employee |
first_name | string | Yes | First name |
last_name | string | Yes | Last name |
primary_contact_number | string | Yes | Mobile number |
store_name | string | No | Required for kind primary |
official_email | string | No | Required without kind; receives the invite |
emp_sap_id | string | No | SAP id (unique) |
role_id | number | No | Role; for kind primary a Distributor or Super Stockist role sets is_distributor / is_super_stockist |
town_id | number | No | Area allocation |
documents | object | No | { aadhaar_card, pan_card, cin, gstin, fssai } |
curl -X POST https://api.spirestock.com/api/v1/users \
-H "X-API-Key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"kind": "primary",
"first_name": "Sample",
"last_name": "User",
"store_name": "Demo Store E",
"primary_contact_number": "9876543210",
"emp_sap_id": "CUST-019",
"role_id": 396,
"zone_id": 12,
"town_id": 427,
"route_id": 82
}'https://api.spirestock.com/api/v1/users/{id}One user with role, basic details, addresses, contact numbers and persons, KYC documents, area allocations and plant names. Users in another workspace give 404. Access: API key `read` scope; staff need Manage Users (3) — view.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
id | number | Yes | User id |
curl https://api.spirestock.com/api/v1/users/44663 \ -H "X-API-Key: YOUR_API_KEY"
https://api.spirestock.com/api/v1/users/reporting-optionsStaff (user_type 0 or 1) a user can report to, for the reporting-to picker. With role_id, only users of that role's reporting role. Sorted by first name, then id. Access: API key `read` scope; staff need Manage Users (3) or Create User (4) — list.
Pagedpage and limit (max 100), id as the final sort key. How pagination works
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
role_id | number | No | The role being assigned; limits options to its reporting role |
search | string | No | Case-insensitive contains on first name, last name, SAP id or role name; max 100 characters, % and _ match literally |
page | number | No | Page number; junk or a value below 1 reads as 1(default: 1) |
limit | number | No | Page size, default 50, max 100 (larger values are clamped)(default: 50) |
curl "https://api.spirestock.com/api/v1/users/reporting-options?search=sales&limit=20" \ -H "X-API-Key: YOUR_API_KEY"
https://api.spirestock.com/api/v1/helpers/usersSearch-as-you-type user picker over active users. Customer pickers (thousands of retailers) should search rather than page. Field staff without a user-management grant only see their reporting tree and the customers allocated to their towns that they created. Sorted by first name, then id. Access: API key `read` scope; staff need Manage Users (3) or Create User (4) or Orders (8) or Order Grievance Request (11) or Amount to be paid (12) or Product and Variant Management (17) or Manage Schemes (20) or Vehicle Management (23) or Driver Registration (24) or Manage Leaves (38) or FOC Management (39) or Bulk Notifications (40) or Crate Summary (41) or User Crate Summary (42) — list (without it, only their own records).
Pagedpage and limit (max 100), id as the final sort key. How pagination works
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
type | string | No | distributor, retailer or employee |
user_type | string | No | 1 is an alias of type=employee |
production_unit_id | number | No | Only users whose basic details name this plant |
search | string | No | Case-insensitive contains on first name, last name, store name, SAP id or phone; max 100 characters, % and _ match literally |
page | number | No | Page number; junk or a value below 1 reads as 1(default: 1) |
limit | number | No | Page size, default 50, max 100 (larger values are clamped)(default: 50) |
curl "https://api.spirestock.com/api/v1/helpers/users?type=employee&search=sample" \ -H "X-API-Key: YOUR_API_KEY"
Products
Open Products reference →https://api.spirestock.com/api/v1/productsList all products in the catalog with optional search filter. Products include their class and variants.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
page | number | No | Page number (default: 1) |
limit | number | No | Items per page (default: 20, max: 100) |
search | string | No | Search by product name |
status | number | No | Filter by status: 1 (active), 0 (inactive) |
curl "https://api.spirestock.com/api/v1/products?search=milk&status=1" \ -H "Authorization: Bearer YOUR_TOKEN"
https://api.spirestock.com/api/v1/productsAdd a product to the catalogue. product_class_name and product_hsn are copied from the product class (a product_hsn you send is used only when the class has none). Variants are created separately with POST /products/{id}/variants; a variants array in this body is ignored. Product names are unique (409 Product name already exists).
Request Body
| Name | Type | Required | Description |
|---|---|---|---|
product_name | string | Yes | Product name (unique) |
product_class_id | number | Yes | Product class id |
product_description | string | No | Description (alias description) |
container_id | number | No | Container (alias product_container_id) |
packaging_type_id | number | No | Packaging type |
product_color_code | string | No | Colour code |
product_hsn | string | No | HSN code; only used when the class has none |
curl -X POST https://api.spirestock.com/api/v1/products \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"product_name": "Toned Milk",
"product_class_id": 42,
"product_description": "Toned milk in pouches"
}'Dashboard
Open Dashboard reference →https://api.spirestock.com/api/v1/dashboard/statsRetrieve summary statistics for the organization dashboard including order counts by status, employee metrics, revenue, and collection data.
curl https://api.spirestock.com/api/v1/dashboard/stats \ -H "Authorization: Bearer YOUR_TOKEN"
https://api.spirestock.com/api/v1/dashboard/monthly-salesRetrieve product-wise sales data with daily trends, monthly totals, and year-over-year comparison. Returns data grouped by product class.
curl https://api.spirestock.com/api/v1/dashboard/monthly-sales \ -H "Authorization: Bearer YOUR_TOKEN"
Exports
Open Exports reference →https://api.spirestock.com/api/v1/exports/ordersExport orders as XLSX or PDF. Supports status and date range filters. Access: API key `read` scope; staff need Orders (8) — export.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
format | string | No | Export format: xlsx (default) or pdf(default: xlsx) |
status | number | No | Filter by order status (1-4) |
date_from | string | No | Start date (YYYY-MM-DD) |
date_to | string | No | End date (YYYY-MM-DD) |
production_unit_id | number | No | Filter by production unit |
curl "https://api.spirestock.com/api/v1/exports/orders?format=xlsx&date_from=2026-05-01&date_to=2026-05-31" \ -H "Authorization: Bearer YOUR_TOKEN" \ -o orders-export.xlsx
https://api.spirestock.com/api/v1/exports/usersExport user list as XLSX or PDF with optional type and status filters.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
format | string | No | Export format: xlsx (default) or pdf(default: xlsx) |
type | string | No | Filter by user type: admin, employee, distributor |
status | number | No | Filter by status: 1 (active), 0 (inactive) |
curl "https://api.spirestock.com/api/v1/exports/users?format=pdf&type=distributor" \ -H "Authorization: Bearer YOUR_TOKEN" \ -o users-export.pdf
https://api.spirestock.com/api/v1/exports/salesExport sales report as XLSX or PDF. Includes revenue breakdown by product class and trends. Access: API key `read` scope; staff need Sales Report (45) — export.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
format | string | No | Export format: xlsx (default) or pdf(default: xlsx) |
date_from | string | No | Start date (YYYY-MM-DD) |
date_to | string | No | End date (YYYY-MM-DD) |
curl "https://api.spirestock.com/api/v1/exports/sales?format=xlsx&date_from=2026-01-01&date_to=2026-05-31" \ -H "Authorization: Bearer YOUR_TOKEN" \ -o sales-report.xlsx
https://api.spirestock.com/api/v1/exports/activityThe activity log as XLSX (default) or PDF, newest first. At most 50,000 rows: when the cap is hit the response carries X-Export-Truncated: true and X-Export-Row-Cap: 50000, so narrow the range and export again. date_from and date_to are compared as UTC days. Access: API key `read` scope; staff need Log In Activity Log Report (53) — export.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
format | string | No | xlsx or pdf(default: xlsx) |
date_from | string | No | YYYY-MM-DD |
date_to | string | No | YYYY-MM-DD (inclusive) |
curl -OJ "https://api.spirestock.com/api/v1/exports/activity?date_from=2024-06-01&date_to=2024-06-30" \ -H "X-API-Key: YOUR_API_KEY"
https://api.spirestock.com/api/v1/exports/scan-logsQR scan logs as XLSX (default) or PDF, newest first, with scan type, result and who scanned. At most 50,000 rows, flagged with X-Export-Truncated: true and X-Export-Row-Cap: 50000 when the cap is hit. Access: API key `read` scope; staff need any report sub-module (the /reports/* catch-all) — export.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
format | string | No | xlsx or pdf(default: xlsx) |
scan_type | string | No | Scan type |
scan_result | string | No | Scan result |
from | string | No | Start date/time (ISO 8601) |
to | string | No | End date/time (ISO 8601) |
curl -OJ "https://api.spirestock.com/api/v1/exports/scan-logs?from=2024-06-01" \ -H "X-API-Key: YOUR_API_KEY"
Workspace
Open Workspace reference →https://api.spirestock.com/api/v1/workspace/configRetrieve the current workspace configuration including branding, organizational details, and operational settings. Stored credentials (smtp_password, whatsapp_api_token, whatsapp_verify_token, whatsapp_app_secret, firebase_server_key, google_app_key) are never returned; each appears as has_<field>, true when a value is saved. Access: API key `read` scope; any staff user (reference data).
curl https://api.spirestock.com/api/v1/workspace/config \ -H "Authorization: Bearer YOUR_TOKEN"
https://api.spirestock.com/api/v1/workspace/configUpdate workspace configuration. Only admin users can modify workspace settings. Credentials are write-only: send a new value to replace one, leave it out or send it blank to keep the stored value, and send clear_<field>: true to remove it. Access: API key `write` scope; workspace administrators only.
Request Body
| Name | Type | Required | Description |
|---|---|---|---|
logo | string | No | Logo URL |
primary_color | string | No | Brand primary color hex code |
secondary_color | string | No | Brand secondary color hex code |
org_footer_name | string | No | Organization footer/legal name |
org_address | string | No | Organization address |
contact_number | string | No | Contact phone number |
smtp_password | string | No | Write-only. Blank keeps the stored value; the same applies to whatsapp_api_token, whatsapp_verify_token, whatsapp_app_secret, firebase_server_key and google_app_key |
clear_smtp_password | boolean | No | true removes the stored value; clear_<field> works for each credential field |
curl -X PUT https://api.spirestock.com/api/v1/workspace/config \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"primary_color": "#2563eb",
"org_footer_name": "Acme Dairy Co. Pvt. Ltd.",
"contact_number": "+911234567890"
}'https://api.spirestock.com/api/v1/workspace/membersActive users of the workspace (staff and customers) with role and last login. It used to return the whole tenant in one response; it is now paged. Sorted by first name, then id. Access: API key `read` scope; staff need Manage Users (3) — list.
Pagedpage and limit (max 100), id as the final sort key. How pagination works
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
search | string | No | Case-insensitive contains on first name, last name, email, role name, SAP id or store name; max 100 characters, % and _ match literally |
page | number | No | Page number; junk or a value below 1 reads as 1(default: 1) |
limit | number | No | Page size, default 50, max 100 (larger values are clamped)(default: 50) |
curl "https://api.spirestock.com/api/v1/workspace/members?page=2&limit=50" \ -H "X-API-Key: YOUR_API_KEY"
Onboarding & Features
Open Onboarding & Features reference →https://api.spirestock.com/api/v1/workspace/featuresWhich optional modules (crates, logistics, tracking, wallet and so on) are switched on for the workspace. modules maps every module key to true or false; core lists the areas that are always on; catalogue describes each module; source says how the set was decided (default, derived, existing, admin) and decided_at when; can_edit is true for administrators. A workspace created before feature modules existed gets every module on, stored on first read with source existing. Access: API key `read` scope; any staff user (reference data).
curl https://api.spirestock.com/api/v1/workspace/features \ -H "X-API-Key: YOUR_API_KEY"
https://api.spirestock.com/api/v1/workspace/featuresSwitch modules on or off. Partial: send only the keys to change. Unknown keys and non-boolean values are rejected with 400 rather than ignored. Sets source to admin and returns the full set, same shape as GET. Access: API keys cannot call this endpoint; workspace administrators only.
Request Body
| Name | Type | Required | Description |
|---|---|---|---|
modules | object | Yes | { "crates": true, "wallet": false } |
curl -X PUT https://api.spirestock.com/api/v1/workspace/features \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{ "modules": { "crates": true, "wallet": false } }'https://api.spirestock.com/api/v1/dashboard/onboardingThe Get Started checklist for administrators: each step with done, the progress (completed, total, percent, complete), the workspace counts behind it, empty_workspace, and when the caller dismissed the checklist. Steps for switched-off modules are left out. Other callers get 403. Access: API key `read` scope; workspace administrators only.
curl https://api.spirestock.com/api/v1/dashboard/onboarding \ -H "X-API-Key: YOUR_API_KEY"
https://api.spirestock.com/api/v1/auth/me/onboardingThe caller's product-tour state: tour (completed_at, dismissed_at, remind_after, last_step, variant), checklist.dismissed_at, is_admin, and auto_show, which says whether the tour should open by itself on this page load. A finished or skipped tour never comes back; a snoozed one returns once remind_after has passed. Access: API keys cannot call this endpoint; any staff user, for their own records.
curl https://api.spirestock.com/api/v1/auth/me/onboarding \ -H "Authorization: Bearer YOUR_TOKEN"
https://api.spirestock.com/api/v1/auth/me/onboardingRecord a tour or checklist action and get the new state back (same shape as GET). tour: complete, dismiss, snooze (returns after 3 days), progress (with step 0-50) or restart, optionally with variant admin or staff. checklist: dismiss or restore. Send at least one of tour or checklist. Access: API keys cannot call this endpoint; any staff user, for their own records.
Request Body
| Name | Type | Required | Description |
|---|---|---|---|
tour | string | No | complete, dismiss, snooze, progress or restart |
step | number | No | 0-50, required with tour=progress |
variant | string | No | admin or staff |
checklist | string | No | dismiss or restore |
curl -X PUT https://api.spirestock.com/api/v1/auth/me/onboarding \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{ "tour": "progress", "step": 3, "variant": "admin" }'Wallet
Open Wallet reference →https://api.spirestock.com/api/v1/wallet/balanceThe caller's wallet (or user_id's; customer tokens always get their own), created on first read, with the last 10 completed transactions and pending_requests (count and amount of recharge requests awaiting review). With all=1: every wallet in the workspace, highest balance first, each with its user; needs the Amount to be paid (12) list grant, and customers get 403. Not paged. Balances are decimal strings. Access: API key `read` scope; any staff user, for their own records.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
user_id | number | No | Whose wallet. Default: the caller |
all | string | No | 1 for every wallet in the workspace |
curl https://api.spirestock.com/api/v1/wallet/balance \ -H "X-API-Key: YOUR_API_KEY"
https://api.spirestock.com/api/v1/wallet/recharge-requestsRecharge requests, newest first. Reviewers see every request; customers and staff without the grant see only their own. summary gives count and amount per status under the same filters (ignoring status) and payment_modes the accepted modes. Each row carries the requesting user and reviewed_by_name. Not cached. Access: API key `read` scope; staff need Amount to be paid (12) — list (without it, only their own records).
Pagedpage and limit (max 100), id as the final sort key. How pagination works
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
status | string | No | all (default), pending, completed (alias approved) or rejected |
user_id | number | No | One customer |
payment_mode | string | No | UPI, NEFT, RTGS, IMPS, Bank Transfer, Cheque or Cash |
from | string | No | IST day, YYYY-MM-DD or dd/mm/yyyy |
to | string | No | IST day (inclusive) |
search | string | No | UTR/reference or the customer's name, store name or SAP id contains (max 60 characters) |
page | number | No | Page number; junk or a value below 1 reads as 1(default: 1) |
limit | number | No | Page size, default 25, max 100 (larger values are clamped)(default: 25) |
curl "https://api.spirestock.com/api/v1/wallet/recharge-requests?status=pending" \ -H "X-API-Key: YOUR_API_KEY"
https://api.spirestock.com/api/v1/wallet/recharge-requestsFile a recharge request for the caller's own wallet; it is stored as pending and does not change the balance until a reviewer approves it. amount Rs.1 to Rs.5,00,000 with at most 2 decimals. A UTR or reference (5-40 letters, digits, - or /, stored upper-case) is required for every mode except Cash and must not already be pending or approved (409). Send JSON, or multipart/form-data with the receipt image as file. Access: API keys cannot call this endpoint; any staff user, for their own records.
Request Body
| Name | Type | Required | Description |
|---|---|---|---|
amount | string | Yes | Rupees, for example 1500 or 750.50 |
payment_mode | string | Yes | UPI, NEFT, RTGS, IMPS, Bank Transfer, Cheque or Cash (case-insensitive) |
utr_reference | string | No | Required except for Cash. Aliases reference, utr |
notes | string | No | Up to 500 characters |
receipt_media_id | string | No | Media id of a receipt the caller uploaded |
curl -X POST https://api.spirestock.com/api/v1/wallet/recharge-requests \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{ "amount": "1500", "payment_mode": "UPI", "utr_reference": "UTR000000001" }'https://api.spirestock.com/api/v1/wallet/recharge-requests/{id}/approveApprove a pending request: the wallet is credited under a row lock, the request becomes completed with balance_after, and the customer is notified. Nobody can review their own request (403); a request already decided is 409. In this response balance_after and wallet.balance are numbers. Access: API keys cannot call this endpoint; staff need Amount to be paid (12) — edit.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
id | number | Yes | Request id |
curl -X POST https://api.spirestock.com/api/v1/wallet/recharge-requests/6/approve \ -H "Authorization: Bearer YOUR_TOKEN"
https://api.spirestock.com/api/v1/wallet/recharge-requests/{id}/rejectReject a pending request with a reason (3-500 characters). The balance is untouched and the customer is notified. A request already decided is 409. Access: API keys cannot call this endpoint; staff need Amount to be paid (12) — edit.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
id | number | Yes | Request id |
Request Body
| Name | Type | Required | Description |
|---|---|---|---|
reason | string | Yes | Why it was rejected, 3-500 characters |
curl -X POST https://api.spirestock.com/api/v1/wallet/recharge-requests/7/reject \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{ "reason": "Reference not found in bank statement" }'Secondary Sales
Open Secondary Sales reference →https://api.spirestock.com/api/v1/secondary-salesSales a distributor made to its retailers, newest sale day first with id as the tie-break. Access: API key `read` scope; staff need Orders (8) — list.
Pagedpage and limit (max 100), id as the final sort key. How pagination works
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
distributor_id | number | No | One distributor; a value that is not a positive integer is 400 |
date_from | string | No | First sale day, YYYY-MM-DD only |
date_to | string | No | Last sale day (inclusive), YYYY-MM-DD only; a start after the end is 400 |
page | number | No | Page number; junk or a value below 1 reads as 1(default: 1) |
limit | number | No | Page size, default 20, max 100 (larger values are clamped)(default: 20) |
curl "https://api.spirestock.com/api/v1/secondary-sales?distributor_id=1201&date_from=2024-06-01&date_to=2024-06-30" \ -H "X-API-Key: YOUR_API_KEY"
https://api.spirestock.com/api/v1/secondary-sales/summaryTotals per distributor under the same filters as the list: sale_count, total_quantity and total_amount, highest amount first. Not paged. Field staff without the grant see only distributors allocated to their towns, or sales their reporting tree recorded. Cached 30 seconds. Access: API key `read` scope; staff need Orders (8) — list (without it, only their own records).
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
distributor_id | number | No | One distributor; a value that is not a positive integer is 400 |
date_from | string | No | First sale day, YYYY-MM-DD only |
date_to | string | No | Last sale day (inclusive), YYYY-MM-DD only; a start after the end is 400 |
curl "https://api.spirestock.com/api/v1/secondary-sales/summary?date_from=2024-06-01&date_to=2024-06-30" \ -H "X-API-Key: YOUR_API_KEY"
API Keys & Webhooks
Open API Keys & Webhooks reference →https://api.spirestock.com/api/v1/developer/api-keysList the API keys issued for your workspace. The secret itself is never returned — only the prefix, so you can identify a key you already saved. Workspace administrators only.
curl https://api.spirestock.com/api/v1/developer/api-keys \ -H "Authorization: Bearer YOUR_TOKEN"
https://api.spirestock.com/api/v1/developer/api-keysIssue a new API key. The plaintext key is returned once, in this response only — it is stored as a SHA-256 hash and cannot be retrieved again. Send it as X-API-Key on subsequent requests. Workspace administrators only; requires a session token, not an API key.
Request Body
| Name | Type | Required | Description |
|---|---|---|---|
name | string | Yes | Label to identify the key later |
scopes | string | No | Comma-separated. Actions: read (GET/HEAD), write (all methods, implies read). Optional resource scopes confine the key to those route groups, e.g. 'read,orders'. Use '*' for full access.(default: read) |
expires_in_days | integer | No | 1-3650. Omit for a key that never expires |
curl -X POST https://api.spirestock.com/api/v1/developer/api-keys \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"name": "Warehouse sync",
"scopes": "read,orders",
"expires_in_days": 90
}'https://api.spirestock.com/api/v1/developer/api-keys/{id}Revoke an API key. The record is kept for audit purposes and its status is set to 0. Workspace administrators only.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
id | integer | Yes | API key ID |
curl -X DELETE https://api.spirestock.com/api/v1/developer/api-keys/3 \ -H "Authorization: Bearer YOUR_TOKEN"
https://api.spirestock.com/api/v1/developer/webhooksList the webhook endpoints registered for your workspace, including delivery health via last_triggered_at and failure_count. Signing secrets are never included — rotate if you lost one. The response also carries supported_events.
curl https://api.spirestock.com/api/v1/developer/webhooks \ -H "Authorization: Bearer YOUR_TOKEN"
https://api.spirestock.com/api/v1/developer/webhooksRegister a webhook endpoint. A signing secret is generated and returned in this response only — store it and use it to verify deliveries. The URL must be HTTPS and resolve to a public address; private, loopback and link-local targets are rejected. Workspace administrators only.
Request Body
| Name | Type | Required | Description |
|---|---|---|---|
name | string | Yes | Label to identify the endpoint |
url | string | Yes | HTTPS URL that will receive the POST. Must resolve to a public address |
events | string[] | string | No | Any of order.created, order.delivered, user.created — as an array or comma-separated string. Unknown events are rejected(default: order.created,order.delivered) |
curl -X POST https://api.spirestock.com/api/v1/developer/webhooks \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"name": "Order events",
"url": "https://example.com/hooks/spirestock",
"events": ["order.created", "order.delivered"]
}'https://api.spirestock.com/api/v1/developer/webhooks/{id}Update a webhook endpoint. Omitted fields are left unchanged. Send status 0 to pause deliveries without deleting the endpoint or rotating its secret — pausing also cancels deliveries already queued for it. Workspace administrators only.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
id | integer | Yes | Webhook ID |
Request Body
| Name | Type | Required | Description |
|---|---|---|---|
name | string | No | Label to identify the endpoint |
url | string | No | HTTPS URL that will receive the POST |
events | string[] | string | No | Events to subscribe to, as an array or comma-separated string |
status | integer | No | 1 to deliver, 0 to pause |
curl -X PUT https://api.spirestock.com/api/v1/developer/webhooks/1 \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"events": ["order.created", "order.delivered", "user.created"],
"status": 1
}'https://api.spirestock.com/api/v1/developer/webhooks/{id}Delete a webhook endpoint permanently. Deliveries stop immediately, any queued deliveries are cancelled, and the signing secret is discarded. Workspace administrators only.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
id | integer | Yes | Webhook ID |
curl -X DELETE https://api.spirestock.com/api/v1/developer/webhooks/1 \ -H "Authorization: Bearer YOUR_TOKEN"
https://api.spirestock.com/api/v1/developer/webhooks/{id}/rotate-secretIssue a new signing secret for an endpoint. The only way to recover a secret lost after creation, and the correct response to one that leaked. Deliveries are signed with the new secret immediately, with no grace period — deploy it to your endpoint first. Workspace administrators only.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
id | integer | Yes | Webhook ID |
curl -X POST https://api.spirestock.com/api/v1/developer/webhooks/1/rotate-secret \ -H "Authorization: Bearer YOUR_TOKEN"
https://api.spirestock.com/api/v1/developer/webhooks/{id}/testSend a webhook.test payload, signed exactly like a real event, so you can confirm your endpoint is reachable and your signature check works before real events fire. Never retried. A delivery failure is reported in the body rather than as an error status — you asked whether the endpoint is reachable, and the answer 'no' is still a successful answer. On failure delivered is false, response_status is the endpoint's status (null when it could not be reached) and message is "Webhook test failed: " followed by the error or the first 500 characters of the endpoint's response body.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
id | integer | Yes | Webhook ID |
curl -X POST https://api.spirestock.com/api/v1/developer/webhooks/1/test \ -H "Authorization: Bearer YOUR_TOKEN"
https://api.spirestock.com/api/v1/developer/webhook-deliveriesRecent delivery attempts, newest first — what was sent, what your endpoint returned, and what is still queued for retry. The first place to look when an endpoint is not receiving what you expect.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
webhook_id | integer | No | Limit to a single endpoint |
status | string | No | One of pending, sending, sent, dead |
limit | integer | No | 1-100 (larger values are clamped)(default: 50) |
curl "https://api.spirestock.com/api/v1/developer/webhook-deliveries?webhook_id=1&status=dead" \ -H "Authorization: Bearer YOUR_TOKEN"
Reports
Open Reports reference →https://api.spirestock.com/api/v1/reports/filtersPlants, routes, customers and vehicle numbers for the dispatch-report filters, limited to the plants the caller can see for the chosen report. Access: API key `read` scope; staff need any report sub-module (the /reports/* catch-all) — list.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
report | string | No | Scope rules: dashboard, indent, contribution, summary (default), trucksheet, dailySale, sales |
production_unit_id | number | No | Plant filter; a plant outside your scope is 403 |
curl https://api.spirestock.com/api/v1/reports/filters \ -H "X-API-Key: YOUR_API_KEY"
https://api.spirestock.com/api/v1/reports/indentIndent: per-customer crates for one plant and day, milk and other variants with free (scheme) quantities, crate totals, incentives, invoice amount and amount to be paid. rows is empty until the indent is generated; counts and action (generate, regenerate, generated) say where the day stands. milk[] and other[] line up with milk_variants[] and other_variants[]. Access: API key `read` scope; staff need the indent permission of the requested plant (indent access is granted per plant) — list.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
date | string | No | Day, YYYY-MM-DD only (dd/mm/yyyy is rejected with 400). Default: today in IST |
production_unit_id | number | Yes | Plant (production unit) id; see GET /reports/filters |
curl "https://api.spirestock.com/api/v1/reports/indent?date=2024-06-10&production_unit_id=17" \ -H "X-API-Key: YOUR_API_KEY"
https://api.spirestock.com/api/v1/reports/indent/generateGenerate (or regenerate) the indent: marks every approved order of the plant for that day as indented. Answers 400 with error: true and "No Order Found." when there are no approved orders. Access: API key `write` scope; staff need the indent permission of the requested plant (indent access is granted per plant) — edit.
Request Body
| Name | Type | Required | Description |
|---|---|---|---|
production_unit_id | number | Yes | Plant id |
date | string | No | Day, YYYY-MM-DD only (dd/mm/yyyy is rejected with 400). Default: today in IST |
regenerate | boolean | No | true to regenerate an existing indent |
curl -X POST https://api.spirestock.com/api/v1/reports/indent/generate \
-H "X-API-Key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"production_unit_id": 17,
"date": "2024-06-10"
}'https://api.spirestock.com/api/v1/reports/daily-saleDaily sale / demand sheet: milk-class crates per customer and variant over a date range, with per-variant totals. /reports/daily-demand returns the same data. Access: API key `read` scope; staff need Daily Demand Sheet (51) — list.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
date_from | string | No | Start day, YYYY-MM-DD only (dd/mm/yyyy is rejected with 400). Aliases from_date, start_date, date. Default: today in IST |
date_to | string | No | End day (inclusive), same format. Aliases to_date, end_date. Default: the start day |
production_unit_id | number | No | Plant filter; a plant outside your scope is 403 |
user_id | number | No | One customer |
curl "https://api.spirestock.com/api/v1/reports/daily-sale?date_from=2024-06-10&date_to=2024-06-10" \ -H "X-API-Key: YOUR_API_KEY"
https://api.spirestock.com/api/v1/reports/dist-date-wiseDistributor-wise date-wise report: one row per customer per order day with every variant's quantity (null where not ordered). Access: API key `read` scope; staff need Distributorwise Datewise Report (29) — list.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
date_from | string | No | Start day, YYYY-MM-DD only (dd/mm/yyyy is rejected with 400). Aliases from_date, start_date, date. Default: today in IST |
date_to | string | No | End day (inclusive), same format. Aliases to_date, end_date. Default: the start day |
production_unit_id | number | No | Plant filter; a plant outside your scope is 403 |
user_id | number | No | One customer |
curl "https://api.spirestock.com/api/v1/reports/dist-date-wise?date_from=2024-06-01&date_to=2024-06-10" \ -H "X-API-Key: YOUR_API_KEY"
https://api.spirestock.com/api/v1/reports/trucksheet-dispatchTruck sheet by route: every order on the route with milk, other and free quantities and crates, plus the route's vehicle and driver. GET /reports/truck-sheet is the same report by vehicle_no (mode: "vehicle"). An unknown route returns 200 with empty lists. Access: API key `read` scope; staff need Truck Sheet Report (30) — list.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
date_from | string | No | Start day, YYYY-MM-DD only (dd/mm/yyyy is rejected with 400). Aliases from_date, start_date, date. Default: today in IST |
date_to | string | No | End day (inclusive), same format. Aliases to_date, end_date. Default: the start day |
production_unit_id | number | Yes | Plant (production unit) id; see GET /reports/filters |
route_id | number | No | Route id (or route_code) |
route_code | string | No | Route code, e.g. R0019 |
curl "https://api.spirestock.com/api/v1/reports/trucksheet-dispatch?date=2024-06-10&production_unit_id=17&route_id=96" \ -H "X-API-Key: YOUR_API_KEY"
https://api.spirestock.com/api/v1/reports/sales-statementSales statement: per order, opening outstanding, milk and other sale amounts, amount received, closing outstanding and the crate position. Access: API key `read` scope; staff need Sales Report (45) — list.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
date_from | string | No | Start day, YYYY-MM-DD only (dd/mm/yyyy is rejected with 400). Aliases from_date, start_date, date. Default: today in IST |
date_to | string | No | End day (inclusive), same format. Aliases to_date, end_date. Default: the start day |
production_unit_id | number | No | Plant filter; a plant outside your scope is 403 |
user_id | number | No | One customer |
curl "https://api.spirestock.com/api/v1/reports/sales-statement?date_from=2024-06-01&date_to=2024-06-10" \ -H "X-API-Key: YOUR_API_KEY"
https://api.spirestock.com/api/v1/reports/amount-to-be-paidInvoice amount against the amount each customer committed to pay, with UTR and security deposit. data is empty until the day's indent is generated (meta.indent_generated). Access: API key `read` scope; staff need Amount to be paid (12) — list.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
date | string | No | Day, YYYY-MM-DD only (dd/mm/yyyy is rejected with 400) (alias order_date). Default: today in IST |
production_unit_id | number | No | Plant filter; a plant outside your scope is 403 |
user_type | string | No | distributor or retailer |
curl "https://api.spirestock.com/api/v1/reports/amount-to-be-paid?date=2024-06-10" \ -H "X-API-Key: YOUR_API_KEY"
https://api.spirestock.com/api/v1/reports/summary-sheetSummary sheet: litres and pouches per class and variant split into without scheme, scheme, bonus, employee and FOC; product totals; town-wise totals per class. Access: API key `read` scope; staff need Summary Report (26) — list.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
date_from | string | No | Start day, YYYY-MM-DD only (dd/mm/yyyy is rejected with 400). Aliases from_date, start_date, date. Default: today in IST |
date_to | string | No | End day (inclusive), same format. Aliases to_date, end_date. Default: the start day |
production_unit_id | number | No | Plant filter; a plant outside your scope is 403 |
curl "https://api.spirestock.com/api/v1/reports/summary-sheet?date=2024-06-10" \ -H "X-API-Key: YOUR_API_KEY"
https://api.spirestock.com/api/v1/reports/summaryHeadline totals for a period: orders, amount, items, average order value, unique customers, collections, a status breakdown and the top 10 customers. Counts are strings (Postgres bigint). Invalid dates fall back to the defaults instead of 400. Access: API key `read` scope; staff need Summary Report (26) — list.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
date_from | string | No | YYYY-MM-DD. Default: the 1st of the current IST month |
date_to | string | No | YYYY-MM-DD. Default: today in IST |
production_unit_id | number | No | Plant filter; a plant outside your scope is 403 |
curl "https://api.spirestock.com/api/v1/reports/summary?date_from=2024-06-01&date_to=2024-06-10" \ -H "X-API-Key: YOUR_API_KEY"
https://api.spirestock.com/api/v1/reports/sku-contributionPer distributor, the share (%) of each variant in their own volume. /reports/distributor-contribution is the transpose: each distributor's share of a variant's total. Access: API key `read` scope; staff need SKU Contribution Report (55) — list.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
date_from | string | No | Start day, YYYY-MM-DD only (dd/mm/yyyy is rejected with 400). Aliases from_date, start_date, date. Default: today in IST |
date_to | string | No | End day (inclusive), same format. Aliases to_date, end_date. Default: the start day |
distributor_id | number | No | One distributor (alias user_id) |
curl "https://api.spirestock.com/api/v1/reports/sku-contribution?date_from=2024-06-01&date_to=2024-06-10" \ -H "X-API-Key: YOUR_API_KEY"
https://api.spirestock.com/api/v1/reports/taggingOutlets tagged by field staff, with who tagged them and when (tagged_date_ist). The date filter applies only when date_from or date_to is sent. Access: API key `read` scope; staff need Tagging Report (50) — list.
Pagedpage and limit (max 100), id as the final sort key. How pagination works
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
search | string | No | Store name contains |
tagged_by | number | No | Employee id (alias emp_id) |
town_id | number | No | Town |
date_from | string | No | YYYY-MM-DD |
date_to | string | No | YYYY-MM-DD |
page | number | No | Default 1 |
limit | number | No | Default 50, max 100 (larger values are clamped) |
curl "https://api.spirestock.com/api/v1/reports/tagging?limit=1" \ -H "X-API-Key: YOUR_API_KEY"
https://api.spirestock.com/api/v1/reports/visitsCustomer visits from the imported visit history (source: imported) and the sales app (source: sales_app). summary counts visits, distinct employees and distinct outlets over the whole range, not just the page; meta.total equals pagination.total. Oldest first, ordered by visited_at, source and id. GET /reports/visits/{id}/details returns the product lines of one visit. Access: API key `read` scope; staff need Visit Report (54) — list.
Pagedpage and limit (max 100), id as the final sort key. How pagination works
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
date_from | string | No | Start day, YYYY-MM-DD only (dd/mm/yyyy is rejected with 400). Aliases from_date, start_date, date. Default: today in IST |
date_to | string | No | End day (inclusive), same format. Aliases to_date, end_date. Default: the start day |
employee_id | number | No | Employee (alias filter_employee) |
outlet_id | number | No | Outlet (alias filter_store_id); excludes sales-app visits |
page | number | No | Page number; junk or a value below 1 reads as 1(default: 1) |
limit | number | No | Page size, default 50, max 100 (larger values are clamped)(default: 50) |
curl "https://api.spirestock.com/api/v1/reports/visits?date_from=2024-05-01&date_to=2024-05-31" \ -H "X-API-Key: YOUR_API_KEY"
https://api.spirestock.com/api/v1/reports/ho-entryHead-office employee purchase sheet: variants with employee price, enabled employees, quantities per employee, totals and FOC. PUT /reports/ho-entry saves it (admins). Access: API key `read` scope; workspace administrators only.
curl https://api.spirestock.com/api/v1/reports/ho-entry \ -H "X-API-Key: YOUR_API_KEY"
https://api.spirestock.com/api/v1/reports/packing-stationPer class and variant for one day: pouches, crates and litres to pack. Access: API key `read` scope; staff need Packing Station Report (28) — list.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
date | string | No | Day, YYYY-MM-DD only (dd/mm/yyyy is rejected with 400). Default: today in IST |
curl "https://api.spirestock.com/api/v1/reports/packing-station?date=2024-06-10" \ -H "X-API-Key: YOUR_API_KEY"
https://api.spirestock.com/api/v1/reports/visits/filter-optionsThe employees (both sources) and outlets (imported visits only; sales-app visits carry a name, not an outlet id) that have visits in the date range, for the visit report's filters. Employees sorted by name; outlets by name, capped at 1,000. Not paged. Access: API key `read` scope; staff need Visit Report (54) — list.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
date_from | string | No | Start day, YYYY-MM-DD only. Default: today in IST |
date_to | string | No | End day (inclusive). Default: the start day |
curl "https://api.spirestock.com/api/v1/reports/visits/filter-options?date_from=2024-05-01&date_to=2024-05-31" \ -H "X-API-Key: YOUR_API_KEY"
Pricing & Schemes
Open Pricing & Schemes reference →https://api.spirestock.com/api/v1/orders/price-list/{userId}A customer's price list: the variants made at their plant, grouped by class and product, with the per-user price (sp_user per pouch; rate and container_sp_user per crate), MRP, rate_source and validity, plus order shifts, the order cut-off (order_time) and the customer's outstanding amount. Access: API key `read` scope; staff need Orders (8) — add.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
userId | number | Yes | Customer id |
search | string | No | Variant name contains |
curl https://api.spirestock.com/api/v1/orders/price-list/44216 \ -H "X-API-Key: YOUR_API_KEY"
https://api.spirestock.com/api/v1/orders/calculate-schemesScheme preview. Prices a draft order exactly as POST /orders would (customer price list, free, quantitative, flat, bulk-pack and new schemes) and returns lines, applied schemes and totals without saving anything. rate_source on each line says where its rate came from. Access: API key `write` scope; staff need Orders (8) — add.
Request Body
| Name | Type | Required | Description |
|---|---|---|---|
user_id | number | Yes | Customer id |
items | array | Yes | [{ product_variant_id, quantity, packaging_type: "0" crates | "1" packets }] |
curl -X POST https://api.spirestock.com/api/v1/orders/calculate-schemes \
-H "X-API-Key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"user_id": 44663,
"items": [
{
"product_variant_id": 446,
"quantity": 3,
"packaging_type": "0"
},
{
"product_variant_id": 453,
"quantity": 31,
"packaging_type": "0"
}
]
}'https://api.spirestock.com/api/v1/users/{id}/productsEvery per-user price row for a customer. PATCH /users/{id}/products/{variantRowId} with { price } changes one (per pouch; the crate price follows) and records history. Access: API key `read` scope; staff need Manage Users (3) — view.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
id | number | Yes | Customer id |
search | string | No | SKU, variant or product name contains |
curl https://api.spirestock.com/api/v1/users/44216/products \ -H "X-API-Key: YOUR_API_KEY"
https://api.spirestock.com/api/v1/users/{id}/schemesSchemes a customer is enrolled in (assigned: free, flat, bulkpack, new) and the scheme rows applied on their orders (applied, newest first, each with order_code, order_date and variant names). assigned is always complete; applied is paged by the top-level pagination object (it used to stop silently at 1,000 rows). Access: API key `read` scope; staff need Manage Users (3) — view.
Pagedpage and limit (max 100), id as the final sort key. How pagination works
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
id | number | Yes | Customer id |
page | number | No | Page number; junk or a value below 1 reads as 1(default: 1) |
limit | number | No | Page size, default 50, max 100 (larger values are clamped)(default: 50) |
curl https://api.spirestock.com/api/v1/users/44216/schemes \ -H "X-API-Key: YOUR_API_KEY"
https://api.spirestock.com/api/v1/schemes/admin/listsAll schemes of the five scheme kinds, newest first: free (buy X get Y free), new, bulkpack (slab incentive per unit), quantitative (free goods by order-size slab) and flat (fixed incentive per unit). Access: API key `read` scope; staff need Manage Schemes (20) — list.
curl https://api.spirestock.com/api/v1/schemes/admin/lists \ -H "X-API-Key: YOUR_API_KEY"
https://api.spirestock.com/api/v1/schemes/admin/{kind}/{id}One scheme with its area (route_ids, zone_ids, town_ids) and enrolled users. kind is free, quantitative, bulkpack, new or flat. POST /schemes/admin/{kind} creates one and PUT /schemes/admin/{kind}/{id} updates it. Access: API key `read` scope; staff need Manage Schemes (20) — list.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
kind | string | Yes | free, quantitative, bulkpack, new or flat |
id | number | Yes | Scheme id |
curl https://api.spirestock.com/api/v1/schemes/admin/free/141 \ -H "X-API-Key: YOUR_API_KEY"
https://api.spirestock.com/api/v1/schemes/admin/{kind}/{id}/usersThe customers assigned to one scheme, with their town, route and state, oldest assignment first. GET /schemes/admin/{kind}/{id} still returns the full set for the edit form. Access: API key `read` scope; staff need Manage Schemes (20) — list.
Pagedpage and limit (max 100), id as the final sort key. How pagination works
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
kind | string | Yes | free, quantitative, bulkpack, new or flat |
id | number | Yes | Scheme id |
search | string | No | Case-insensitive contains on the user's full name, store name or SAP id; max 100 characters, % and _ match literally |
page | number | No | Page number; junk or a value below 1 reads as 1(default: 1) |
limit | number | No | Page size, default 50, max 100 (larger values are clamped)(default: 50) |
curl "https://api.spirestock.com/api/v1/schemes/admin/free/124/users?limit=50" \ -H "X-API-Key: YOUR_API_KEY"
Approvals & Permissions
Open Approvals & Permissions reference →https://api.spirestock.com/api/v1/approvalsRecords waiting on the caller (workspace admins see everything at status 1 or 2), with pending counts and the caller's level per type. Types: order, leave, foc, merged into one list newest first (orders by order_date) with id as the tie-break; summary counts every pending record, not just the page. Access: API key `read` scope; staff need Orders (8) or Manage Leaves (38) or FOC Management (39) — list.
Pagedpage and limit (max 100), id as the final sort key. How pagination works
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
type | string | No | order, leave or foc |
page | number | No | Page number; junk or a value below 1 reads as 1(default: 1) |
limit | number | No | Page size, default 20, max 100 (larger values are clamped)(default: 20) |
curl https://api.spirestock.com/api/v1/approvals \ -H "X-API-Key: YOUR_API_KEY"
https://api.spirestock.com/api/v1/approvals/{type}/{id}/trailWho initiated a record, who acted at each level, and who is still pending. Access: API key `read` scope; staff need Orders (8) or Manage Leaves (38) or FOC Management (39) — list.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
type | string | Yes | order, leave or foc |
id | number | Yes | Record id |
curl https://api.spirestock.com/api/v1/approvals/order/339403/trail \ -H "X-API-Key: YOUR_API_KEY"
https://api.spirestock.com/api/v1/approvals/{type}/actionForward, approve or decline up to 500 records. Levels come from the workspace's permission workflow: rank 2 Forward, rank 3 Approve. Admins can approve at any point; others act only at their own level, and approve waits until Forward is done. Orders cannot be declined. With several ids the response is 200 with a result per record. Access: API key `write` scope; by type: order — Orders (8) — edit; leave — Manage Leaves (38) — edit; foc — FOC Management (39) — edit.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
type | string | Yes | order, leave or foc |
Request Body
| Name | Type | Required | Description |
|---|---|---|---|
ids | array | Yes | 1-500 record ids |
action | string | Yes | forward, approve or decline |
remark | string | No | Shown in the trail |
curl -X POST https://api.spirestock.com/api/v1/approvals/order/action \
-H "X-API-Key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"ids": [
339403,
338021
],
"action": "approve",
"remark": "OK"
}'https://api.spirestock.com/api/v1/approvals/my-levelThe caller's approval level per type: 0 not an approver, 2 Forward, 3 Approve (admins get 3). Access: API key `read` scope; staff need Orders (8) or Manage Leaves (38) or FOC Management (39) — list.
curl https://api.spirestock.com/api/v1/approvals/my-level \ -H "X-API-Key: YOUR_API_KEY"
https://api.spirestock.com/api/v1/settings/my-permissionsThe caller's effective sub-module grants, workflow levels and what they can do per approval type. Staff routes are default-deny: a route with no rule in the permission table is admin-only. Access: API key `read` scope; any staff user, for their own records.
curl https://api.spirestock.com/api/v1/settings/my-permissions \ -H "X-API-Key: YOUR_API_KEY"
https://api.spirestock.com/api/v1/settings/permission-workflowsThe approval workflow matrix: levels (Initiate, Forward, Approve) and, per sub-module and permission, which roles sit at each level. Writing it (PUT) needs a signed-in admin; API keys are refused. Access: API key `read` scope; staff need Manage Permission Workflows (33) — list.
curl https://api.spirestock.com/api/v1/settings/permission-workflows \ -H "X-API-Key: YOUR_API_KEY"
https://api.spirestock.com/api/v1/foc/usersActive employees with a role, for the FOC request filter. Sorted by first name, then id. Access: API key `read` scope; staff need FOC Management (39) — list.
Pagedpage and limit (max 100), id as the final sort key. How pagination works
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
search | string | No | Case-insensitive contains on first name, last name or SAP id; max 100 characters, % and _ match literally |
page | number | No | Page number; junk or a value below 1 reads as 1(default: 1) |
limit | number | No | Page size, default 50, max 100 (larger values are clamped)(default: 50) |
curl "https://api.spirestock.com/api/v1/foc/users?search=sample" \ -H "X-API-Key: YOUR_API_KEY"
Crates & Logistics
Open Crates & Logistics reference →https://api.spirestock.com/api/v1/crates/summaryCurrent crate balance per party from the party ledger. Crates are tracked in three ledgers (party, transporter/vehicle, plant); normal and jumbo crates are counted separately, and a positive party balance is crates the party holds. Access: API key `read` scope; staff need Crate Summary (41) or User Crate Summary (42) — list.
curl https://api.spirestock.com/api/v1/crates/summary \ -H "X-API-Key: YOUR_API_KEY"
https://api.spirestock.com/api/v1/crates/ledgerParty-ledger entries, newest first. Access: API key `read` scope; staff need Crate Summary (41) or User Crate Summary (42) — list.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
user_id | number | No | One party |
page | number | No | Default 1 |
limit | number | No | Default 20 |
curl "https://api.spirestock.com/api/v1/crates/ledger?limit=2" \ -H "X-API-Key: YOUR_API_KEY"
https://api.spirestock.com/api/v1/crates/crate-summaryCrate summary grid: per distributor, opening, daily dispatch and receive for each day of the month, month totals and shortage for the month and since starting. routes lists the route filter options. Access: API key `read` scope; staff need Crate Summary (41) or User Crate Summary (42) — list.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
month | string | No | Month, YYYY-MM (MM/YYYY also accepted). Default: the current IST month |
crate_type | string | No | normal (default) or jumbo |
route_id | number | No | Route |
curl "https://api.spirestock.com/api/v1/crates/crate-summary?month=2024-06" \ -H "X-API-Key: YOUR_API_KEY"
https://api.spirestock.com/api/v1/crates/user-crate-summaryOne party's month: dispatched from plant, returned to vehicle, deposited in plant, and the differences with vehicle and party, per day. Access: API key `read` scope; staff need Crate Summary (41) or User Crate Summary (42) — list.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
month | string | No | Month, YYYY-MM (MM/YYYY also accepted). Default: the current IST month |
user_id | number | Yes | Party id |
crate_type | string | No | normal or jumbo |
include_legacy | string | No | "1" adds legacy-formula columns |
curl "https://api.spirestock.com/api/v1/crates/user-crate-summary?month=2024-06&user_id=44663" \ -H "X-API-Key: YOUR_API_KEY"
https://api.spirestock.com/api/v1/crates/approvalsDriver-raised delivery and return confirmations. actionable is true for pending requests raised today (IST); only those can be decided with PATCH /crates/approvals/{id} { status: 2 approve | 3 decline }, which also marks the order delivered and posts the ledgers. Access: API key `read` scope; staff need Approval Pending Report (57) — list.
Pagedpage and limit (max 100), id as the final sort key. How pagination works
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
status | string | No | 1 pending, 2 approved, 3 declined |
user_id | number | No | Party |
date | string | No | Day, YYYY-MM-DD or DD/MM/YYYY. Default: today in IST |
page | number | No | Default 1 |
limit | number | No | Default 30, max 100 |
curl "https://api.spirestock.com/api/v1/crates/approvals?limit=2" \ -H "X-API-Key: YOUR_API_KEY"
https://api.spirestock.com/api/v1/crates/manualManual crate entry for a party and day (Dispatch credits, Receive debits the party ledger). The party must have an order that day, and only one dispatch per party per day (409). Access: API key `write` scope; staff need Crate Summary (41) — add.
Request Body
| Name | Type | Required | Description |
|---|---|---|---|
user_id | number | Yes | Party id |
crates_type | string | Yes | Dispatch or Receive |
crate_date | string | Yes | YYYY-MM-DD or DD/MM/YYYY |
normal | number | No | Normal crates |
jumbo | number | No | Jumbo crates |
curl -X POST https://api.spirestock.com/api/v1/crates/manual \
-H "X-API-Key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"user_id": 44663,
"crates_type": "Dispatch",
"crate_date": "2024-06-10",
"normal": 4,
"jumbo": 0
}'https://api.spirestock.com/api/v1/crates/plant/send-otpPlant gate, step 1: sends a 4-digit OTP to the vehicle's driver in the driver app. Step 2 is POST /crates/plant/dispatch (with order_id) or /crates/plant/receive, carrying the OTP and crates_list [{ user_id, normal_crate, jumbo_crate }]. The OTP is single-use and replaced by the next one sent. Access: API key `write` scope; staff need Crate Summary (41) — add.
Request Body
| Name | Type | Required | Description |
|---|---|---|---|
vehicle_id | number | Yes | Vehicle id |
normal_crates | number | No | Normal crates |
jumbo_crates | number | No | Jumbo crates |
otp_type | string | No | "0" dispatch (default), "1" receive |
curl -X POST https://api.spirestock.com/api/v1/crates/plant/send-otp \
-H "X-API-Key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"vehicle_id": 103,
"normal_crates": 120,
"jumbo_crates": 0,
"otp_type": "0"
}'https://api.spirestock.com/api/v1/crates/monthly-summaryOpening, dispatched, received, shortage and closing crates (normal and jumbo) per active distributor or retailer for one IST month. Sorted by first name, then id. Access: API key `read` scope; staff need Crate Summary (41) or User Crate Summary (42) — list.
Pagedpage and limit (max 100), id as the final sort key. How pagination works
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
month | string | No | YYYY-MM (MM/YYYY and MM-YYYY also accepted). Default: the current IST month |
search | string | No | Case-insensitive contains on the customer's name, store name or SAP id; max 100 characters, % and _ match literally |
page | number | No | Page number; junk or a value below 1 reads as 1(default: 1) |
limit | number | No | Page size, default 50, max 100 (larger values are clamped)(default: 50) |
curl "https://api.spirestock.com/api/v1/crates/monthly-summary?month=2024-05&limit=50" \ -H "X-API-Key: YOUR_API_KEY"
https://api.spirestock.com/api/v1/crates/distributorsActive distributors for the crate screens' picker. Sorted by first name, then id. Cached 60 seconds. Access: API key `read` scope; staff need Crate Summary (41) or User Crate Summary (42) — list.
Pagedpage and limit (max 100), id as the final sort key. How pagination works
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
search | string | No | Case-insensitive contains on first name, last name, store name or SAP id; max 100 characters, % and _ match literally |
page | number | No | Page number; junk or a value below 1 reads as 1(default: 1) |
limit | number | No | Page size, default 50, max 100 (larger values are clamped)(default: 50) |
curl "https://api.spirestock.com/api/v1/crates/distributors?search=demo" \ -H "X-API-Key: YOUR_API_KEY"
Accounts
Open Accounts reference →https://api.spirestock.com/api/v1/accounts/ledgerWithout user_id: one row per party with opening, credit, debit and closing balance. With user_id: that party's ledger entries, newest first, plus current_balance. Access: API key `read` scope; staff need Invoices (14) or Amount to be paid (12) — list.
Pagedpage and limit (max 100), id as the final sort key. How pagination works
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
user_id | number | No | One party |
search | string | No | Name or store contains |
page | number | No | Default 1 |
limit | number | No | Default 30, max 100 |
curl "https://api.spirestock.com/api/v1/accounts/ledger?limit=2" \ -H "X-API-Key: YOUR_API_KEY"
https://api.spirestock.com/api/v1/accounts/invoicesIndented orders for a day or range with flat and bulk-pack incentives and the invoice amount (order total minus incentives). Access: API key `read` scope; staff need Invoices (14) — list.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
start_date | string | No | Day, YYYY-MM-DD or DD/MM/YYYY. Default: today in IST |
end_date | string | No | Default: start_date |
user_id | number | No | One party |
curl "https://api.spirestock.com/api/v1/accounts/invoices?start_date=10/06/2024" \ -H "X-API-Key: YOUR_API_KEY"
https://api.spirestock.com/api/v1/accounts/invoice/{orderId}The tax invoice for an order's party and day. Printable HTML by default; format=json returns the computed invoice: lines, GST split (CGST/SGST or IGST), TCS, round-off, amounts in words, incentives, the party block and invoice_no. GET /accounts/invoices/print-all?date= prints every invoice of a day. The invoice number is fixed the first time the invoice is issued (printed as HTML, singly or with print-all, e-invoiced or filed in GSTR-1) and reused from then on, so an order added to the same party and day later does not renumber it; format=json only reads it. Access: API key `read` scope; staff need Invoices (14) — view.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
orderId | number | Yes | Order id |
format | string | No | json for data instead of HTML |
curl "https://api.spirestock.com/api/v1/accounts/invoice/339189?format=json" \ -H "X-API-Key: YOUR_API_KEY"
https://api.spirestock.com/api/v1/accounts/gatepassOrders of a day with their gatepass/challan if one has been issued, and each plant's invoice serial. Access: API key `read` scope; staff need Gatepass & Challan (47) — list.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
date | string | No | Day, YYYY-MM-DD or DD/MM/YYYY. Default: today in IST |
curl "https://api.spirestock.com/api/v1/accounts/gatepass?date=2024-06-10" \ -H "X-API-Key: YOUR_API_KEY"
https://api.spirestock.com/api/v1/accounts/gatepassIssues the challan for a party and day (201), or returns the existing one (200). Numbers run per plant per financial year. Download the PDF from invoice_path (GET /accounts/challans/{id}/pdf, application/pdf). Access: API key `write` scope; staff need Gatepass & Challan (47) — add.
Request Body
| Name | Type | Required | Description |
|---|---|---|---|
user_id | number | Yes | Party id |
order_date | string | Yes | YYYY-MM-DD or DD/MM/YYYY |
invoice_type | string | No | Default challan |
curl -X POST https://api.spirestock.com/api/v1/accounts/gatepass \
-H "X-API-Key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"user_id": 44663,
"order_date": "2024-06-10"
}'https://api.spirestock.com/api/v1/accounts/ledger-summaryOutstanding per active distributor or retailer: latest ledger balance (null when the party has no entry) and total credit and debit (decimal strings). totals sums the whole filtered list, not just the page: total_outstanding, total_credit, total_debit and customers_with_balance (parties with a non-zero balance). Sorted by first name, then id. Cached 30 seconds. Access: API key `read` scope; staff need Invoices (14) or Amount to be paid (12) — list.
Pagedpage and limit (max 100), id as the final sort key. How pagination works
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
search | string | No | Case-insensitive contains on the customer's full name, store name or SAP id; max 100 characters, % and _ match literally |
page | number | No | Page number; junk or a value below 1 reads as 1(default: 1) |
limit | number | No | Page size, default 50, max 100 (larger values are clamped)(default: 50) |
curl "https://api.spirestock.com/api/v1/accounts/ledger-summary?limit=50" \ -H "X-API-Key: YOUR_API_KEY"
GST Returns
Open GST Returns reference →https://api.spirestock.com/api/v1/einvoice/gstr1Preview the GSTR-1 return for a month, built from the same invoices as the Accounts invoices and with the same amounts to the paisa. Reports what goes into each table (4A B2B, 5 B2C large: inter-state above Rs 1 lakh, 7 B2C others, 8 exempt supplies: 0% items, 12 HSN summary split B2B/B2C, 13 documents issued), the tax totals, the problems that would make the GST portal reject the file and warnings worth checking. B2B invoices with an IRN are left out of 4A by default because the portal fills them in from the e-invoice system. Reads only: no invoice number is fixed by a preview. GST e-Invoice add-on (402 ADDON_REQUIRED without it). Access: API key `read` scope; staff need Invoices (14) — list.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
month | string | No | Return period, YYYY-MM. Default: the current month in IST; a future month is refused (400) |
include_einvoiced | string | No | 1 to put IRN-generated B2B invoices in 4A as well(default: 0) |
curl "https://api.spirestock.com/api/v1/einvoice/gstr1?month=2026-10" \ -H "X-API-Key: YOUR_API_KEY"
https://api.spirestock.com/api/v1/einvoice/gstr1/jsonDownload the GSTR-1 JSON to upload on the GST portal (Returns, GSTR-1, Prepare offline, Upload). Answers 422 with the list of problems while anything would be rejected (an invalid GSTIN, a missing or malformed HSN code, an unknown place of supply, a tax type that contradicts the place of supply, a workspace state code that disagrees with its GSTIN), and 404 when the month has no invoices. Downloading fixes every invoice number in the file. Amounts per line come from the printed invoice: taxable value and CGST + SGST, or IGST for inter-state supplies; 0% lines are reported in Table 8 as exempt. GST e-Invoice add-on. Access: API key `read` scope; staff need Invoices (14) — list.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
month | string | No | Return period, YYYY-MM. Default: the current month in IST |
include_einvoiced | string | No | 1 to put IRN-generated B2B invoices in 4A as well(default: 0) |
curl "https://api.spirestock.com/api/v1/einvoice/gstr1/json?month=2026-10" \ -H "X-API-Key: YOUR_API_KEY" -OJ
Imports
Open Imports reference →https://api.spirestock.com/api/v1/imports/preview/{type}Check a product-variant, scheme or variant-price sheet before importing it; nothing is saved. type is product-variants, schemes or rate-list. Headers are matched to the template's columns (case, spacing and text in brackets are ignored). Every row is validated, including that the product, variant or SKU exists. rows holds the first 200 rows as text; valid_rows, invalid_rows and errors (first 100 failing rows) cover the whole file. A missing required column is reported in missing_required, and POST /imports/{type} then answers 400. Upload as multipart/form-data, field file (.xlsx or .csv, max 10 MB). Other file types answer 400 and files over 10 MB answer 413. Access: API key `write` scope; staff need Product and Variant Management (17) or Upload Rate List (18) or Upload Free Scheme List (32) — add.
Request Body
| Name | Type | Required | Description |
|---|---|---|---|
file | file | Yes | The workbook (.xlsx or .csv) |
curl -X POST https://api.spirestock.com/api/v1/imports/preview/schemes \ -H "X-API-Key: YOUR_API_KEY" \ -F "[email protected]"
https://api.spirestock.com/api/v1/imports/rate-list/previewRate list, step 1. Columns must be exactly STATE, ZONE, USERTYPE, SKU, CONTAINER RATE. Every row comes back validated with errors[]; nothing is saved. Upload as multipart/form-data, field file (.xlsx or .csv, max 10 MB). Other file types answer 400 and files over 10 MB answer 413. Access: API key `write` scope; staff need Upload Rate List (18) — add.
Request Body
| Name | Type | Required | Description |
|---|---|---|---|
file | file | Yes | The workbook |
state_id | number | Yes | State |
zone_ids | string | Yes | JSON array or comma-separated zone ids |
curl -X POST https://api.spirestock.com/api/v1/imports/rate-list/preview \ -H "X-API-Key: YOUR_API_KEY" \ -F "file=@user_rate_list.xlsx" \ -F "state_id=14" \ -F "zone_ids=12"
https://api.spirestock.com/api/v1/imports/rate-list/commitStep 2: send the preview rows back. Closes the current rate-master rows, creates the new ones and updates every matching customer's per-user price, with history. dry_run reports the counts without saving. Rows with an unknown sku_code, a missing state_id / zone_id or a rate of 0 or less answer 400 "Row 1: invalid state/zone/SKU/rate" (up to five rows listed) and nothing is saved. Access: API key `write` scope; staff need Upload Rate List (18) — add.
Request Body
| Name | Type | Required | Description |
|---|---|---|---|
rows | array | Yes | [{ state_id, zone_id, user_type, sku_code, rate }] |
dry_run | boolean | No | true to only count |
curl -X POST https://api.spirestock.com/api/v1/imports/rate-list/commit \
-H "X-API-Key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"rows": [
{
"state_id": 14,
"zone_id": 12,
"user_type": 2,
"sku_code": "SKU-009",
"rate": 720
}
],
"dry_run": true
}'https://api.spirestock.com/api/v1/imports/free-schemes/previewFree-scheme sheet, step 1. Columns: SapId, State, Route, Town, Variant Material Code, On Order Of Quantity, Free Variant Material Code, Container Quantity, Pouch Quantity. Rows come back resolved with blocking errors and non-blocking warnings. Step 2, POST /imports/free-schemes/commit, replaces every existing free scheme; skip_invalid saves only valid rows. Upload as multipart/form-data, field file (.xlsx or .csv, max 10 MB). Other file types answer 400 and files over 10 MB answer 413. Access: API key `write` scope; staff need Upload Free Scheme List (32) — add.
Request Body
| Name | Type | Required | Description |
|---|---|---|---|
file | file | Yes | The workbook |
curl -X POST https://api.spirestock.com/api/v1/imports/free-schemes/preview \ -H "X-API-Key: YOUR_API_KEY" \ -F "file=@user_scheme.xlsx"
https://api.spirestock.com/api/v1/imports/outstandingOutstanding upload. A multipart file (SAPID, PARTY NAME, AMOUNT) returns a preview and saves nothing; JSON { rows: [{ sap_id, outstanding_amount }] } applies it. /imports/revised-amount works the same way for revised amounts on a day's orders (order_date YYYY-MM-DD). Access: API key `write` scope; staff need Upload Outstanding (6) — add.
Request Body
| Name | Type | Required | Description |
|---|---|---|---|
rows | array | Yes | [{ sap_id, outstanding_amount }] — or upload file for a preview |
curl -X POST https://api.spirestock.com/api/v1/imports/outstanding \
-H "X-API-Key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"rows": [
{
"sap_id": "CUST-011",
"outstanding_amount": 1500
}
]
}'https://api.spirestock.com/api/v1/imports/sheet-template/{type}Download the Excel template: rate-list (user_rate_list.xlsx) or free-scheme (user_scheme.xlsx). Access: API key `read` scope; staff need Product and Variant Management (17) or Upload Rate List (18) or Upload Free Scheme List (32) or Upload Outstanding (6) or Upload Revised Amount (44) or Manage Holidays (43) — add.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
type | string | Yes | rate-list or free-scheme |
curl https://api.spirestock.com/api/v1/imports/sheet-template/rate-list \ -H "X-API-Key: YOUR_API_KEY"
Masters
Open Masters reference →https://api.spirestock.com/api/v1/masters/statesStates with GST state code and the inter-state flag. Master lists return the full set (no pagination). POST creates, PUT /masters/states/{id} updates (a rename cascades to zones, towns, routes and cities). For India (the default country_id) POST needs a valid GST `state_code` and any `state` name must match that code (e.g. 08 is Rajasthan) — otherwise 400; other countries take a free-text name. There is no DELETE. Access: API key `read` scope; staff need Master list (27) — list.
curl https://api.spirestock.com/api/v1/masters/states \ -H "X-API-Key: YOUR_API_KEY"
https://api.spirestock.com/api/v1/masters/zonesZones with their towns (town_ids, town_names). Access: API key `read` scope; staff need Master list (27) — list.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
state_id | number | No | State |
curl https://api.spirestock.com/api/v1/masters/zones \ -H "X-API-Key: YOUR_API_KEY"
https://api.spirestock.com/api/v1/masters/townsTowns, filterable by state and zone. Access: API key `read` scope; staff need Master list (27) — list.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
state_id | number | No | State |
zone_id | string | No | Zone id or comma-separated list |
curl https://api.spirestock.com/api/v1/masters/towns \ -H "X-API-Key: YOUR_API_KEY"
https://api.spirestock.com/api/v1/masters/routesRoutes with their plant and ordered towns. Route towns are managed through the towns array on POST /masters/routes and PUT /masters/routes/{id}; PATCH /masters/routes/{id}/status activates or deactivates a route. Access: API key `read` scope; staff need Master list (27) or Vehicle Management (23) or Driver Registration (24) — list.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
state_id | number | No | State |
production_unit_id | number | No | Plant |
status | number | No | 1 active, 0 inactive |
curl https://api.spirestock.com/api/v1/masters/routes \ -H "X-API-Key: YOUR_API_KEY"
https://api.spirestock.com/api/v1/masters/routesCreate a route. towns replaces the route's town list; unknown towns are dropped. Names and codes are unique (409). Access: API key `write` scope; staff need Master list (27) — add.
Request Body
| Name | Type | Required | Description |
|---|---|---|---|
route | string | Yes | Route name |
route_code | string | No | Unique code |
state_id | number | Yes | State |
production_unit_id | number | No | Plant |
towns | array | No | [{ town_id, order_index }] |
curl -X POST https://api.spirestock.com/api/v1/masters/routes \
-H "X-API-Key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"route": "Route C",
"route_code": "R0019",
"state_id": 14,
"production_unit_id": 17,
"towns": [
{
"town_id": 423,
"order_index": 1
}
]
}'https://api.spirestock.com/api/v1/masters/app-versionsLatest mobile-app version per app type in data, plus every version (versions) and the app types (app_types). Access: API key `read` scope; staff need Master list (27) — list.
curl https://api.spirestock.com/api/v1/masters/app-versions \ -H "X-API-Key: YOUR_API_KEY"
Attendance & Tracking
Open Attendance & Tracking reference →https://api.spirestock.com/api/v1/reports/attendance/monthlyMonthly attendance grid: one row per employee with a status per day (P, A, a leave alias such as CL, or the holiday name), in/out times, days present/absent and percentage. In the current month the grid stops at today (IST). month, days and overall_percentage are top-level keys. Access: API key `read` scope; staff need Monthly Attendance Report (48) — list.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
month | string | No | YYYY-MM. Default: the current IST month |
user_id | number | No | One employee |
curl "https://api.spirestock.com/api/v1/reports/attendance/monthly?month=2024-05" \ -H "X-API-Key: YOUR_API_KEY"
https://api.spirestock.com/api/v1/reports/attendance/monthly/staff/{userId}One employee's month: punch in/out times and locations, working hours (H:MM) and km travelled per day. Access: API key `read` scope; staff need any report sub-module (the /reports/* catch-all) — list.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
userId | number | Yes | Employee id |
month | string | No | YYYY-MM. Default: the current IST month |
curl "https://api.spirestock.com/api/v1/reports/attendance/monthly/staff/51674?month=2024-05" \ -H "X-API-Key: YOUR_API_KEY"
https://api.spirestock.com/api/v1/tracking/travel-summaryDistance travelled from GPS fixes (accuracy 50 m or better) with the per-km charge and total. time_period 1 is daily (one row per employee); 2 is monthly (one row per employee, or per day with user_id). Without time_period the legacy summary is returned. Access: API key `read` scope; staff need User Travel Summary (49) — list.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
time_period | string | No | 1 daily, 2 monthly |
travel_date | string | No | Daily: YYYY-MM-DD or dd/mm/yyyy. Default: today in IST |
month | string | No | Monthly: YYYY-MM or mm/yyyy |
user_id | number | No | One employee |
curl "https://api.spirestock.com/api/v1/tracking/travel-summary?time_period=1&travel_date=2024-06-10" \ -H "X-API-Key: YOUR_API_KEY"
https://api.spirestock.com/api/v1/reports/login-activitySign-ins (web and mobile) by IST day, newest first. Names and roles come from the current profile. The old 5,000-row cap is gone; page through the range instead. Access: API key `read` scope; staff need Log In Activity Log Report (53) — list.
Pagedpage and limit (max 100), id as the final sort key. How pagination works
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
date_from | string | No | YYYY-MM-DD. Default: today in IST |
date_to | string | No | Default: date_from |
role_id | number | No | Role |
platform | string | No | web or mobile |
search | string | No | Case-insensitive contains on the user's full name, SAP id or role name; max 100 characters, % and _ match literally |
page | number | No | Page number; junk or a value below 1 reads as 1(default: 1) |
limit | number | No | Page size, default 50, max 100 (larger values are clamped)(default: 50) |
curl https://api.spirestock.com/api/v1/reports/login-activity \ -H "X-API-Key: YOUR_API_KEY"
https://api.spirestock.com/api/v1/tracking/live/{userId}One rep's last known position (current, or null when the rep has never pinged; user_name only comes with a position) and the GPS trail of one IST day, oldest point first. The trail is cursor-paged: pass trail_pagination.next_cursor back as cursor until has_more is false; total counts the whole day. Without limit a page holds 1,000 points; an explicit limit is clamped to 100. Non-managers can only read their own id. With live tracking switched off for the workspace, today (or no date) answers { user_id, current: null, trail: [], live_tracking_enabled: false }; a past date still returns its trail and trail_pagination, with current null, no user_name and live_tracking_enabled: false. Access: API key `read` scope; staff need User Tracking (5) — list.
Cursor pagedFollow next_cursor until has_more is false. How pagination works
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
userId | number | Yes | Employee user id |
date | string | No | IST day to replay, YYYY-MM-DD or dd/mm/yyyy. Default: today |
limit | number | No | Points per page. Default 1,000; an explicit value is clamped to 1-100 |
cursor | string | No | next_cursor from the previous page |
curl "https://api.spirestock.com/api/v1/tracking/live/44955?date=2024-05-17&limit=100" \ -H "X-API-Key: YOUR_API_KEY"
https://api.spirestock.com/api/v1/tracking/location-logRaw GPS fixes with the employee's name and SAP id, oldest first, cursor-paged on (created_at, id): pass pagination.next_cursor back as cursor with the same filters until has_more is false. No date means today (IST). Without limit a page holds 500 points; an explicit limit is clamped to 100. Cached 15 seconds. Access: API key `read` scope; staff need User Tracking (5) — list.
Cursor pagedFollow next_cursor until has_more is false. How pagination works
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
user_id | number | No | One employee |
date | string | No | One IST day, YYYY-MM-DD or dd/mm/yyyy |
from_date | string | No | Range start (IST day) |
to_date | string | No | Range end (inclusive) |
limit | number | No | Points per page. Default 500; an explicit value is clamped to 1-100 |
cursor | string | No | next_cursor from the previous page |
curl "https://api.spirestock.com/api/v1/tracking/location-log?user_id=44955&date=2024-05-17&limit=100" \ -H "X-API-Key: YOUR_API_KEY"
https://api.spirestock.com/api/v1/beat-plansPlanned market visits per sales rep and day, newest plan_date first. Staff tokens only ever see their own plans. Dates are YYYY-MM-DD; other values are ignored. outlets is a JSON string. Cached 60 seconds. Access: API key `read` scope; any staff user, for their own records.
Pagedpage and limit (max 100), id as the final sort key. How pagination works
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
user_id | number | No | Sales rep |
date | string | No | One day, YYYY-MM-DD (overrides the range) |
date_from | string | No | Range start, YYYY-MM-DD |
date_to | string | No | Range end (inclusive), YYYY-MM-DD |
status | number | No | 1 planned, 2 in progress, 3 completed |
search | string | No | Case-insensitive contains on rep name or route name; max 100 characters, % and _ match literally |
page | number | No | Page number; junk or a value below 1 reads as 1(default: 1) |
limit | number | No | Page size, default 20, max 100 (larger values are clamped)(default: 20) |
curl "https://api.spirestock.com/api/v1/beat-plans?date_from=2024-05-01&date_to=2024-05-31" \ -H "X-API-Key: YOUR_API_KEY"
