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.

i

Base URL

https://api.spirestock.com/api/v1

Authentication

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: read for GET, write for everything else, optionally narrowed to route groups such as read,reports. Keys never reach /auth, /developer, /billing, /portal, /driver-app, /sales-app, /mobile, /cron or 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 answers 403.
  • Dates. Report days are IST calendar days (Asia/Kolkata) and “today” means today in IST. Each parameter says whether it takes YYYY-MM-DD only or also dd/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

  • page starts at 1. A missing, non-numeric or smaller value reads as 1, so a client that sends nothing gets the first page.
  • limit is 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 pagination with total (rows matching the filters), page, limit (after clamping) and total_pages. An empty result has total_pages: 0; a page past the end returns an empty data with the same totals.
  • Counters and grand totals that a screen shows above a list (for example summary on approvals and visits, or totals on 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

  • search is 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_order is ASC or DESC.
  • Every paged list adds id as 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_more and next_cursor (in pagination, or trail_pagination on the live trail). Send next_cursor back as ?cursor= with the same filters to get the next page; it is null on 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. total counts the whole range.
  • Treat the cursor as opaque. A garbled or expired one is read as “from the start”, not as an error.
  • Without limit these endpoints keep their historical page size (1,000 points for the live trail, 500 for the location log); an explicit limit is 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)
done

For 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.

POSThttps://api.spirestock.com/api/v1/auth/login

Authenticate 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
NameTypeRequiredDescription
emailstringYesUser email address
passwordstringYesAccount password
curl -X POST https://api.spirestock.com/api/v1/auth/login \
  -H "Content-Type: application/json" \
  -d '{
    "email": "[email protected]",
    "password": "your-password"
  }'
POSThttps://api.spirestock.com/api/v1/auth/otp/request

Email 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
NameTypeRequiredDescription
emailstringYesAccount email address
curl -X POST https://api.spirestock.com/api/v1/auth/otp/request \
  -H "Content-Type: application/json" \
  -d '{
    "email": "[email protected]"
  }'
POSThttps://api.spirestock.com/api/v1/auth/otp/verify

Verify 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
NameTypeRequiredDescription
emailstringYesEmail used in the OTP request
otpstringYesThe 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"
  }'
GEThttps://api.spirestock.com/api/v1/auth/me

Retrieve the authenticated user’s profile, role, and organization context.

curl https://api.spirestock.com/api/v1/auth/me \
  -H "Authorization: Bearer YOUR_TOKEN"
POSThttps://api.spirestock.com/api/v1/portal/login

Customer-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
NameTypeRequiredDescription
emp_sap_idstringNoSAP customer code (or send email, phone or username)
emailstringNoAccount email
phonestringNoRegistered mobile number
passwordstringYesAccount 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"
  }'
POSThttps://api.spirestock.com/api/v1/signup/register

Register 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
NameTypeRequiredDescription
company_namestringYesName of the organization, 2-100 characters
slugstringYesWorkspace subdomain (min 5 characters, starts with a letter); check it first with GET /signup/check-slug/{slug}
admin_emailstringYesAdmin email address
admin_phonestringYesAdmin phone number
admin_passwordstringYesPassword (min 8 characters with upper, lower, digit and symbol)
admin_first_namestringNoDefaults to the first word of company_name
admin_last_namestringNoDefaults to Admin
statestringNoState
pincodestringNoPincode
referral_codestringNoReferral 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"
  }'
GEThttps://api.spirestock.com/api/v1/orders

List 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
NameTypeRequiredDescription
pagenumberNoPage number(default: 1)
limitnumberNoItems per page (default 20, max 100)(default: 20)
statusnumberNo1 initiated, 2 forwarded, 3 approved, 4 delivered
order_datestringNoOne day, dd/mm/yyyy or YYYY-MM-DD (overrides the range)
date_fromstringNoRange start, dd/mm/yyyy or YYYY-MM-DD
date_tostringNoRange end (inclusive)
production_unit_idnumberNoPlant
route_idnumberNoRoute
town_idnumberNoTown
user_idnumberNoCustomer
user_sap_idstringNoCustomer SAP id (exact)
user_typestringNoe.g. Distributor
town_namestringNoTown name contains
route_namestringNoRoute name contains
searchstringNoOrder code, customer name or SAP id contains
scanned_by_driverstringNotrue/1 or false/0
sort_bystringNoorder_date (default), order_total_amount, order_code, created_at
sort_orderstringNoASC 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"
GEThttps://api.spirestock.com/api/v1/orders/summary

Order 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
NameTypeRequiredDescription
order_datestringNoOne day
date_fromstringNoRange start
date_tostringNoRange 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"
POSThttps://api.spirestock.com/api/v1/orders

Create 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
NameTypeRequiredDescription
user_idnumberYesCustomer (distributor or retailer) id
itemsarrayYes[{ product_variant_id, quantity, packaging_type: "0" crates (default) | "1" packets }]
mode_of_paymentstringNoe.g. RTGS, UPI
utr_nostringNoPayment reference (max 50)
amount_to_be_paidnumberNoCommitted 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"
  }'
GEThttps://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
NameTypeRequiredDescription
idnumberYesOrder id
curl https://api.spirestock.com/api/v1/orders/339189 \
  -H "X-API-Key: YOUR_API_KEY"
PUThttps://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
NameTypeRequiredDescription
idnumberYesOrder id
Request Body
NameTypeRequiredDescription
itemsarrayNoFull line list, same shape as POST /orders
mode_of_paymentstringNoHeader field
amount_to_be_paidnumberNo0 or more
utr_nostringNoHeader 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"
      }
    ]
  }'
PATCHhttps://api.spirestock.com/api/v1/orders/{id}/status

Move 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
NameTypeRequiredDescription
idnumberYesOrder id
Request Body
NameTypeRequiredDescription
statusnumberNo2 forward, 3 approve, 4 delivered
actionstringNoforward or approve (instead of status)
remarkstringNoShown 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
  }'
GEThttps://api.spirestock.com/api/v1/users

List 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
NameTypeRequiredDescription
tabstringNoprimary, secondary or employee
typestringNoWithout tab: distributor, retailer, super_stockist, employee or driver
statusnumberNo1 active (default without tab), 0 inactive; empty for all
searchstringNoName, store, SAP id, email or phone
role_idnumberNoRole
town_idnumberNoTown
pagenumberNoPage number; junk or a value below 1 reads as 1(default: 1)
limitnumberNoPage 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"
POSThttps://api.spirestock.com/api/v1/users

Create 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
NameTypeRequiredDescription
kindstringNoprimary (distributor) or employee
first_namestringYesFirst name
last_namestringYesLast name
primary_contact_numberstringYesMobile number
store_namestringNoRequired for kind primary
official_emailstringNoRequired without kind; receives the invite
emp_sap_idstringNoSAP id (unique)
role_idnumberNoRole; for kind primary a Distributor or Super Stockist role sets is_distributor / is_super_stockist
town_idnumberNoArea allocation
documentsobjectNo{ 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
  }'
GEThttps://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
NameTypeRequiredDescription
idnumberYesUser id
curl https://api.spirestock.com/api/v1/users/44663 \
  -H "X-API-Key: YOUR_API_KEY"
GEThttps://api.spirestock.com/api/v1/users/reporting-options

Staff (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
NameTypeRequiredDescription
role_idnumberNoThe role being assigned; limits options to its reporting role
searchstringNoCase-insensitive contains on first name, last name, SAP id or role name; max 100 characters, % and _ match literally
pagenumberNoPage number; junk or a value below 1 reads as 1(default: 1)
limitnumberNoPage 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"
GEThttps://api.spirestock.com/api/v1/helpers/users

Search-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
NameTypeRequiredDescription
typestringNodistributor, retailer or employee
user_typestringNo1 is an alias of type=employee
production_unit_idnumberNoOnly users whose basic details name this plant
searchstringNoCase-insensitive contains on first name, last name, store name, SAP id or phone; max 100 characters, % and _ match literally
pagenumberNoPage number; junk or a value below 1 reads as 1(default: 1)
limitnumberNoPage 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"
GEThttps://api.spirestock.com/api/v1/products

List all products in the catalog with optional search filter. Products include their class and variants.

Parameters
NameTypeRequiredDescription
pagenumberNoPage number (default: 1)
limitnumberNoItems per page (default: 20, max: 100)
searchstringNoSearch by product name
statusnumberNoFilter by status: 1 (active), 0 (inactive)
curl "https://api.spirestock.com/api/v1/products?search=milk&status=1" \
  -H "Authorization: Bearer YOUR_TOKEN"
POSThttps://api.spirestock.com/api/v1/products

Add 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
NameTypeRequiredDescription
product_namestringYesProduct name (unique)
product_class_idnumberYesProduct class id
product_descriptionstringNoDescription (alias description)
container_idnumberNoContainer (alias product_container_id)
packaging_type_idnumberNoPackaging type
product_color_codestringNoColour code
product_hsnstringNoHSN 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"
  }'
GEThttps://api.spirestock.com/api/v1/dashboard/stats

Retrieve 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"
GEThttps://api.spirestock.com/api/v1/dashboard/monthly-sales

Retrieve 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"
GEThttps://api.spirestock.com/api/v1/exports/orders

Export orders as XLSX or PDF. Supports status and date range filters. Access: API key `read` scope; staff need Orders (8) — export.

Parameters
NameTypeRequiredDescription
formatstringNoExport format: xlsx (default) or pdf(default: xlsx)
statusnumberNoFilter by order status (1-4)
date_fromstringNoStart date (YYYY-MM-DD)
date_tostringNoEnd date (YYYY-MM-DD)
production_unit_idnumberNoFilter 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
GEThttps://api.spirestock.com/api/v1/exports/users

Export user list as XLSX or PDF with optional type and status filters.

Parameters
NameTypeRequiredDescription
formatstringNoExport format: xlsx (default) or pdf(default: xlsx)
typestringNoFilter by user type: admin, employee, distributor
statusnumberNoFilter 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
GEThttps://api.spirestock.com/api/v1/exports/sales

Export 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
NameTypeRequiredDescription
formatstringNoExport format: xlsx (default) or pdf(default: xlsx)
date_fromstringNoStart date (YYYY-MM-DD)
date_tostringNoEnd 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
GEThttps://api.spirestock.com/api/v1/exports/activity

The 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
NameTypeRequiredDescription
formatstringNoxlsx or pdf(default: xlsx)
date_fromstringNoYYYY-MM-DD
date_tostringNoYYYY-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"
GEThttps://api.spirestock.com/api/v1/exports/scan-logs

QR 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
NameTypeRequiredDescription
formatstringNoxlsx or pdf(default: xlsx)
scan_typestringNoScan type
scan_resultstringNoScan result
fromstringNoStart date/time (ISO 8601)
tostringNoEnd 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"
GEThttps://api.spirestock.com/api/v1/workspace/config

Retrieve 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"
PUThttps://api.spirestock.com/api/v1/workspace/config

Update 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
NameTypeRequiredDescription
logostringNoLogo URL
primary_colorstringNoBrand primary color hex code
secondary_colorstringNoBrand secondary color hex code
org_footer_namestringNoOrganization footer/legal name
org_addressstringNoOrganization address
contact_numberstringNoContact phone number
smtp_passwordstringNoWrite-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_passwordbooleanNotrue 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"
  }'
GEThttps://api.spirestock.com/api/v1/workspace/members

Active 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
NameTypeRequiredDescription
searchstringNoCase-insensitive contains on first name, last name, email, role name, SAP id or store name; max 100 characters, % and _ match literally
pagenumberNoPage number; junk or a value below 1 reads as 1(default: 1)
limitnumberNoPage 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"
GEThttps://api.spirestock.com/api/v1/workspace/features

Which 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"
PUThttps://api.spirestock.com/api/v1/workspace/features

Switch 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
NameTypeRequiredDescription
modulesobjectYes{ "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 } }'
GEThttps://api.spirestock.com/api/v1/dashboard/onboarding

The 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"
GEThttps://api.spirestock.com/api/v1/auth/me/onboarding

The 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"
PUThttps://api.spirestock.com/api/v1/auth/me/onboarding

Record 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
NameTypeRequiredDescription
tourstringNocomplete, dismiss, snooze, progress or restart
stepnumberNo0-50, required with tour=progress
variantstringNoadmin or staff
checkliststringNodismiss 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" }'
GEThttps://api.spirestock.com/api/v1/wallet/balance

The 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
NameTypeRequiredDescription
user_idnumberNoWhose wallet. Default: the caller
allstringNo1 for every wallet in the workspace
curl https://api.spirestock.com/api/v1/wallet/balance \
  -H "X-API-Key: YOUR_API_KEY"
GEThttps://api.spirestock.com/api/v1/wallet/recharge-requests

Recharge 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
NameTypeRequiredDescription
statusstringNoall (default), pending, completed (alias approved) or rejected
user_idnumberNoOne customer
payment_modestringNoUPI, NEFT, RTGS, IMPS, Bank Transfer, Cheque or Cash
fromstringNoIST day, YYYY-MM-DD or dd/mm/yyyy
tostringNoIST day (inclusive)
searchstringNoUTR/reference or the customer's name, store name or SAP id contains (max 60 characters)
pagenumberNoPage number; junk or a value below 1 reads as 1(default: 1)
limitnumberNoPage 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"
POSThttps://api.spirestock.com/api/v1/wallet/recharge-requests

File 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
NameTypeRequiredDescription
amountstringYesRupees, for example 1500 or 750.50
payment_modestringYesUPI, NEFT, RTGS, IMPS, Bank Transfer, Cheque or Cash (case-insensitive)
utr_referencestringNoRequired except for Cash. Aliases reference, utr
notesstringNoUp to 500 characters
receipt_media_idstringNoMedia 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" }'
POSThttps://api.spirestock.com/api/v1/wallet/recharge-requests/{id}/approve

Approve 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
NameTypeRequiredDescription
idnumberYesRequest id
curl -X POST https://api.spirestock.com/api/v1/wallet/recharge-requests/6/approve \
  -H "Authorization: Bearer YOUR_TOKEN"
POSThttps://api.spirestock.com/api/v1/wallet/recharge-requests/{id}/reject

Reject 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
NameTypeRequiredDescription
idnumberYesRequest id
Request Body
NameTypeRequiredDescription
reasonstringYesWhy 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" }'
GEThttps://api.spirestock.com/api/v1/secondary-sales

Sales 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
NameTypeRequiredDescription
distributor_idnumberNoOne distributor; a value that is not a positive integer is 400
date_fromstringNoFirst sale day, YYYY-MM-DD only
date_tostringNoLast sale day (inclusive), YYYY-MM-DD only; a start after the end is 400
pagenumberNoPage number; junk or a value below 1 reads as 1(default: 1)
limitnumberNoPage 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"
GEThttps://api.spirestock.com/api/v1/secondary-sales/summary

Totals 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
NameTypeRequiredDescription
distributor_idnumberNoOne distributor; a value that is not a positive integer is 400
date_fromstringNoFirst sale day, YYYY-MM-DD only
date_tostringNoLast 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"
GEThttps://api.spirestock.com/api/v1/developer/api-keys

List 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"
POSThttps://api.spirestock.com/api/v1/developer/api-keys

Issue 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
NameTypeRequiredDescription
namestringYesLabel to identify the key later
scopesstringNoComma-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_daysintegerNo1-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
  }'
DELETEhttps://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
NameTypeRequiredDescription
idintegerYesAPI key ID
curl -X DELETE https://api.spirestock.com/api/v1/developer/api-keys/3 \
  -H "Authorization: Bearer YOUR_TOKEN"
GEThttps://api.spirestock.com/api/v1/developer/webhooks

List 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"
POSThttps://api.spirestock.com/api/v1/developer/webhooks

Register 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
NameTypeRequiredDescription
namestringYesLabel to identify the endpoint
urlstringYesHTTPS URL that will receive the POST. Must resolve to a public address
eventsstring[] | stringNoAny 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"]
  }'
PUThttps://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
NameTypeRequiredDescription
idintegerYesWebhook ID
Request Body
NameTypeRequiredDescription
namestringNoLabel to identify the endpoint
urlstringNoHTTPS URL that will receive the POST
eventsstring[] | stringNoEvents to subscribe to, as an array or comma-separated string
statusintegerNo1 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
  }'
DELETEhttps://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
NameTypeRequiredDescription
idintegerYesWebhook ID
curl -X DELETE https://api.spirestock.com/api/v1/developer/webhooks/1 \
  -H "Authorization: Bearer YOUR_TOKEN"
POSThttps://api.spirestock.com/api/v1/developer/webhooks/{id}/rotate-secret

Issue 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
NameTypeRequiredDescription
idintegerYesWebhook ID
curl -X POST https://api.spirestock.com/api/v1/developer/webhooks/1/rotate-secret \
  -H "Authorization: Bearer YOUR_TOKEN"
POSThttps://api.spirestock.com/api/v1/developer/webhooks/{id}/test

Send 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
NameTypeRequiredDescription
idintegerYesWebhook ID
curl -X POST https://api.spirestock.com/api/v1/developer/webhooks/1/test \
  -H "Authorization: Bearer YOUR_TOKEN"
GEThttps://api.spirestock.com/api/v1/developer/webhook-deliveries

Recent 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
NameTypeRequiredDescription
webhook_idintegerNoLimit to a single endpoint
statusstringNoOne of pending, sending, sent, dead
limitintegerNo1-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"
GEThttps://api.spirestock.com/api/v1/reports/filters

Plants, 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
NameTypeRequiredDescription
reportstringNoScope rules: dashboard, indent, contribution, summary (default), trucksheet, dailySale, sales
production_unit_idnumberNoPlant filter; a plant outside your scope is 403
curl https://api.spirestock.com/api/v1/reports/filters \
  -H "X-API-Key: YOUR_API_KEY"
GEThttps://api.spirestock.com/api/v1/reports/indent

Indent: 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
NameTypeRequiredDescription
datestringNoDay, YYYY-MM-DD only (dd/mm/yyyy is rejected with 400). Default: today in IST
production_unit_idnumberYesPlant (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"
POSThttps://api.spirestock.com/api/v1/reports/indent/generate

Generate (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
NameTypeRequiredDescription
production_unit_idnumberYesPlant id
datestringNoDay, YYYY-MM-DD only (dd/mm/yyyy is rejected with 400). Default: today in IST
regeneratebooleanNotrue 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"
  }'
GEThttps://api.spirestock.com/api/v1/reports/daily-sale

Daily 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
NameTypeRequiredDescription
date_fromstringNoStart day, YYYY-MM-DD only (dd/mm/yyyy is rejected with 400). Aliases from_date, start_date, date. Default: today in IST
date_tostringNoEnd day (inclusive), same format. Aliases to_date, end_date. Default: the start day
production_unit_idnumberNoPlant filter; a plant outside your scope is 403
user_idnumberNoOne 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"
GEThttps://api.spirestock.com/api/v1/reports/dist-date-wise

Distributor-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
NameTypeRequiredDescription
date_fromstringNoStart day, YYYY-MM-DD only (dd/mm/yyyy is rejected with 400). Aliases from_date, start_date, date. Default: today in IST
date_tostringNoEnd day (inclusive), same format. Aliases to_date, end_date. Default: the start day
production_unit_idnumberNoPlant filter; a plant outside your scope is 403
user_idnumberNoOne 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"
GEThttps://api.spirestock.com/api/v1/reports/trucksheet-dispatch

Truck 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
NameTypeRequiredDescription
date_fromstringNoStart day, YYYY-MM-DD only (dd/mm/yyyy is rejected with 400). Aliases from_date, start_date, date. Default: today in IST
date_tostringNoEnd day (inclusive), same format. Aliases to_date, end_date. Default: the start day
production_unit_idnumberYesPlant (production unit) id; see GET /reports/filters
route_idnumberNoRoute id (or route_code)
route_codestringNoRoute 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"
GEThttps://api.spirestock.com/api/v1/reports/sales-statement

Sales 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
NameTypeRequiredDescription
date_fromstringNoStart day, YYYY-MM-DD only (dd/mm/yyyy is rejected with 400). Aliases from_date, start_date, date. Default: today in IST
date_tostringNoEnd day (inclusive), same format. Aliases to_date, end_date. Default: the start day
production_unit_idnumberNoPlant filter; a plant outside your scope is 403
user_idnumberNoOne 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"
GEThttps://api.spirestock.com/api/v1/reports/amount-to-be-paid

Invoice 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
NameTypeRequiredDescription
datestringNoDay, YYYY-MM-DD only (dd/mm/yyyy is rejected with 400) (alias order_date). Default: today in IST
production_unit_idnumberNoPlant filter; a plant outside your scope is 403
user_typestringNodistributor 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"
GEThttps://api.spirestock.com/api/v1/reports/summary-sheet

Summary 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
NameTypeRequiredDescription
date_fromstringNoStart day, YYYY-MM-DD only (dd/mm/yyyy is rejected with 400). Aliases from_date, start_date, date. Default: today in IST
date_tostringNoEnd day (inclusive), same format. Aliases to_date, end_date. Default: the start day
production_unit_idnumberNoPlant 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"
GEThttps://api.spirestock.com/api/v1/reports/summary

Headline 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
NameTypeRequiredDescription
date_fromstringNoYYYY-MM-DD. Default: the 1st of the current IST month
date_tostringNoYYYY-MM-DD. Default: today in IST
production_unit_idnumberNoPlant 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"
GEThttps://api.spirestock.com/api/v1/reports/sku-contribution

Per 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
NameTypeRequiredDescription
date_fromstringNoStart day, YYYY-MM-DD only (dd/mm/yyyy is rejected with 400). Aliases from_date, start_date, date. Default: today in IST
date_tostringNoEnd day (inclusive), same format. Aliases to_date, end_date. Default: the start day
distributor_idnumberNoOne 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"
GEThttps://api.spirestock.com/api/v1/reports/tagging

Outlets 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
NameTypeRequiredDescription
searchstringNoStore name contains
tagged_bynumberNoEmployee id (alias emp_id)
town_idnumberNoTown
date_fromstringNoYYYY-MM-DD
date_tostringNoYYYY-MM-DD
pagenumberNoDefault 1
limitnumberNoDefault 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"
GEThttps://api.spirestock.com/api/v1/reports/visits

Customer 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
NameTypeRequiredDescription
date_fromstringNoStart day, YYYY-MM-DD only (dd/mm/yyyy is rejected with 400). Aliases from_date, start_date, date. Default: today in IST
date_tostringNoEnd day (inclusive), same format. Aliases to_date, end_date. Default: the start day
employee_idnumberNoEmployee (alias filter_employee)
outlet_idnumberNoOutlet (alias filter_store_id); excludes sales-app visits
pagenumberNoPage number; junk or a value below 1 reads as 1(default: 1)
limitnumberNoPage 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"
GEThttps://api.spirestock.com/api/v1/reports/ho-entry

Head-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"
GEThttps://api.spirestock.com/api/v1/reports/packing-station

Per 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
NameTypeRequiredDescription
datestringNoDay, 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"
GEThttps://api.spirestock.com/api/v1/reports/visits/filter-options

The 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
NameTypeRequiredDescription
date_fromstringNoStart day, YYYY-MM-DD only. Default: today in IST
date_tostringNoEnd 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"
GEThttps://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
NameTypeRequiredDescription
userIdnumberYesCustomer id
searchstringNoVariant name contains
curl https://api.spirestock.com/api/v1/orders/price-list/44216 \
  -H "X-API-Key: YOUR_API_KEY"
POSThttps://api.spirestock.com/api/v1/orders/calculate-schemes

Scheme 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
NameTypeRequiredDescription
user_idnumberYesCustomer id
itemsarrayYes[{ 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"
      }
    ]
  }'
GEThttps://api.spirestock.com/api/v1/users/{id}/products

Every 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
NameTypeRequiredDescription
idnumberYesCustomer id
searchstringNoSKU, variant or product name contains
curl https://api.spirestock.com/api/v1/users/44216/products \
  -H "X-API-Key: YOUR_API_KEY"
GEThttps://api.spirestock.com/api/v1/users/{id}/schemes

Schemes 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
NameTypeRequiredDescription
idnumberYesCustomer id
pagenumberNoPage number; junk or a value below 1 reads as 1(default: 1)
limitnumberNoPage 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"
GEThttps://api.spirestock.com/api/v1/schemes/admin/lists

All 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"
GEThttps://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
NameTypeRequiredDescription
kindstringYesfree, quantitative, bulkpack, new or flat
idnumberYesScheme id
curl https://api.spirestock.com/api/v1/schemes/admin/free/141 \
  -H "X-API-Key: YOUR_API_KEY"
GEThttps://api.spirestock.com/api/v1/schemes/admin/{kind}/{id}/users

The 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
NameTypeRequiredDescription
kindstringYesfree, quantitative, bulkpack, new or flat
idnumberYesScheme id
searchstringNoCase-insensitive contains on the user's full name, store name or SAP id; max 100 characters, % and _ match literally
pagenumberNoPage number; junk or a value below 1 reads as 1(default: 1)
limitnumberNoPage 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"
GEThttps://api.spirestock.com/api/v1/approvals

Records 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
NameTypeRequiredDescription
typestringNoorder, leave or foc
pagenumberNoPage number; junk or a value below 1 reads as 1(default: 1)
limitnumberNoPage 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"
GEThttps://api.spirestock.com/api/v1/approvals/{type}/{id}/trail

Who 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
NameTypeRequiredDescription
typestringYesorder, leave or foc
idnumberYesRecord id
curl https://api.spirestock.com/api/v1/approvals/order/339403/trail \
  -H "X-API-Key: YOUR_API_KEY"
POSThttps://api.spirestock.com/api/v1/approvals/{type}/action

Forward, 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
NameTypeRequiredDescription
typestringYesorder, leave or foc
Request Body
NameTypeRequiredDescription
idsarrayYes1-500 record ids
actionstringYesforward, approve or decline
remarkstringNoShown 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"
  }'
GEThttps://api.spirestock.com/api/v1/approvals/my-level

The 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"
GEThttps://api.spirestock.com/api/v1/settings/my-permissions

The 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"
GEThttps://api.spirestock.com/api/v1/settings/permission-workflows

The 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"
GEThttps://api.spirestock.com/api/v1/foc/users

Active 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
NameTypeRequiredDescription
searchstringNoCase-insensitive contains on first name, last name or SAP id; max 100 characters, % and _ match literally
pagenumberNoPage number; junk or a value below 1 reads as 1(default: 1)
limitnumberNoPage 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"
GEThttps://api.spirestock.com/api/v1/crates/summary

Current 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"
GEThttps://api.spirestock.com/api/v1/crates/ledger

Party-ledger entries, newest first. Access: API key `read` scope; staff need Crate Summary (41) or User Crate Summary (42) — list.

Parameters
NameTypeRequiredDescription
user_idnumberNoOne party
pagenumberNoDefault 1
limitnumberNoDefault 20
curl "https://api.spirestock.com/api/v1/crates/ledger?limit=2" \
  -H "X-API-Key: YOUR_API_KEY"
GEThttps://api.spirestock.com/api/v1/crates/crate-summary

Crate 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
NameTypeRequiredDescription
monthstringNoMonth, YYYY-MM (MM/YYYY also accepted). Default: the current IST month
crate_typestringNonormal (default) or jumbo
route_idnumberNoRoute
curl "https://api.spirestock.com/api/v1/crates/crate-summary?month=2024-06" \
  -H "X-API-Key: YOUR_API_KEY"
GEThttps://api.spirestock.com/api/v1/crates/user-crate-summary

One 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
NameTypeRequiredDescription
monthstringNoMonth, YYYY-MM (MM/YYYY also accepted). Default: the current IST month
user_idnumberYesParty id
crate_typestringNonormal or jumbo
include_legacystringNo"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"
GEThttps://api.spirestock.com/api/v1/crates/approvals

Driver-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
NameTypeRequiredDescription
statusstringNo1 pending, 2 approved, 3 declined
user_idnumberNoParty
datestringNoDay, YYYY-MM-DD or DD/MM/YYYY. Default: today in IST
pagenumberNoDefault 1
limitnumberNoDefault 30, max 100
curl "https://api.spirestock.com/api/v1/crates/approvals?limit=2" \
  -H "X-API-Key: YOUR_API_KEY"
POSThttps://api.spirestock.com/api/v1/crates/manual

Manual 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
NameTypeRequiredDescription
user_idnumberYesParty id
crates_typestringYesDispatch or Receive
crate_datestringYesYYYY-MM-DD or DD/MM/YYYY
normalnumberNoNormal crates
jumbonumberNoJumbo 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
  }'
POSThttps://api.spirestock.com/api/v1/crates/plant/send-otp

Plant 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
NameTypeRequiredDescription
vehicle_idnumberYesVehicle id
normal_cratesnumberNoNormal crates
jumbo_cratesnumberNoJumbo crates
otp_typestringNo"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"
  }'
GEThttps://api.spirestock.com/api/v1/crates/monthly-summary

Opening, 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
NameTypeRequiredDescription
monthstringNoYYYY-MM (MM/YYYY and MM-YYYY also accepted). Default: the current IST month
searchstringNoCase-insensitive contains on the customer's name, store name or SAP id; max 100 characters, % and _ match literally
pagenumberNoPage number; junk or a value below 1 reads as 1(default: 1)
limitnumberNoPage 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"
GEThttps://api.spirestock.com/api/v1/crates/distributors

Active 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
NameTypeRequiredDescription
searchstringNoCase-insensitive contains on first name, last name, store name or SAP id; max 100 characters, % and _ match literally
pagenumberNoPage number; junk or a value below 1 reads as 1(default: 1)
limitnumberNoPage 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"
GEThttps://api.spirestock.com/api/v1/accounts/ledger

Without 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
NameTypeRequiredDescription
user_idnumberNoOne party
searchstringNoName or store contains
pagenumberNoDefault 1
limitnumberNoDefault 30, max 100
curl "https://api.spirestock.com/api/v1/accounts/ledger?limit=2" \
  -H "X-API-Key: YOUR_API_KEY"
GEThttps://api.spirestock.com/api/v1/accounts/invoices

Indented 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
NameTypeRequiredDescription
start_datestringNoDay, YYYY-MM-DD or DD/MM/YYYY. Default: today in IST
end_datestringNoDefault: start_date
user_idnumberNoOne party
curl "https://api.spirestock.com/api/v1/accounts/invoices?start_date=10/06/2024" \
  -H "X-API-Key: YOUR_API_KEY"
GEThttps://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
NameTypeRequiredDescription
orderIdnumberYesOrder id
formatstringNojson for data instead of HTML
curl "https://api.spirestock.com/api/v1/accounts/invoice/339189?format=json" \
  -H "X-API-Key: YOUR_API_KEY"
GEThttps://api.spirestock.com/api/v1/accounts/gatepass

Orders 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
NameTypeRequiredDescription
datestringNoDay, 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"
POSThttps://api.spirestock.com/api/v1/accounts/gatepass

Issues 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
NameTypeRequiredDescription
user_idnumberYesParty id
order_datestringYesYYYY-MM-DD or DD/MM/YYYY
invoice_typestringNoDefault 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"
  }'
GEThttps://api.spirestock.com/api/v1/accounts/ledger-summary

Outstanding 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
NameTypeRequiredDescription
searchstringNoCase-insensitive contains on the customer's full name, store name or SAP id; max 100 characters, % and _ match literally
pagenumberNoPage number; junk or a value below 1 reads as 1(default: 1)
limitnumberNoPage 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"
GEThttps://api.spirestock.com/api/v1/einvoice/gstr1

Preview 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
NameTypeRequiredDescription
monthstringNoReturn period, YYYY-MM. Default: the current month in IST; a future month is refused (400)
include_einvoicedstringNo1 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"
GEThttps://api.spirestock.com/api/v1/einvoice/gstr1/json

Download 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
NameTypeRequiredDescription
monthstringNoReturn period, YYYY-MM. Default: the current month in IST
include_einvoicedstringNo1 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
POSThttps://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
NameTypeRequiredDescription
filefileYesThe 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]"
POSThttps://api.spirestock.com/api/v1/imports/rate-list/preview

Rate 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
NameTypeRequiredDescription
filefileYesThe workbook
state_idnumberYesState
zone_idsstringYesJSON 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"
POSThttps://api.spirestock.com/api/v1/imports/rate-list/commit

Step 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
NameTypeRequiredDescription
rowsarrayYes[{ state_id, zone_id, user_type, sku_code, rate }]
dry_runbooleanNotrue 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
  }'
POSThttps://api.spirestock.com/api/v1/imports/free-schemes/preview

Free-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
NameTypeRequiredDescription
filefileYesThe 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"
POSThttps://api.spirestock.com/api/v1/imports/outstanding

Outstanding 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
NameTypeRequiredDescription
rowsarrayYes[{ 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
      }
    ]
  }'
GEThttps://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
NameTypeRequiredDescription
typestringYesrate-list or free-scheme
curl https://api.spirestock.com/api/v1/imports/sheet-template/rate-list \
  -H "X-API-Key: YOUR_API_KEY"
GEThttps://api.spirestock.com/api/v1/masters/states

States 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"
GEThttps://api.spirestock.com/api/v1/masters/zones

Zones with their towns (town_ids, town_names). Access: API key `read` scope; staff need Master list (27) — list.

Parameters
NameTypeRequiredDescription
state_idnumberNoState
curl https://api.spirestock.com/api/v1/masters/zones \
  -H "X-API-Key: YOUR_API_KEY"
GEThttps://api.spirestock.com/api/v1/masters/towns

Towns, filterable by state and zone. Access: API key `read` scope; staff need Master list (27) — list.

Parameters
NameTypeRequiredDescription
state_idnumberNoState
zone_idstringNoZone id or comma-separated list
curl https://api.spirestock.com/api/v1/masters/towns \
  -H "X-API-Key: YOUR_API_KEY"
GEThttps://api.spirestock.com/api/v1/masters/routes

Routes 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
NameTypeRequiredDescription
state_idnumberNoState
production_unit_idnumberNoPlant
statusnumberNo1 active, 0 inactive
curl https://api.spirestock.com/api/v1/masters/routes \
  -H "X-API-Key: YOUR_API_KEY"
POSThttps://api.spirestock.com/api/v1/masters/routes

Create 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
NameTypeRequiredDescription
routestringYesRoute name
route_codestringNoUnique code
state_idnumberYesState
production_unit_idnumberNoPlant
townsarrayNo[{ 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
      }
    ]
  }'
GEThttps://api.spirestock.com/api/v1/masters/app-versions

Latest 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"
GEThttps://api.spirestock.com/api/v1/reports/attendance/monthly

Monthly 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
NameTypeRequiredDescription
monthstringNoYYYY-MM. Default: the current IST month
user_idnumberNoOne employee
curl "https://api.spirestock.com/api/v1/reports/attendance/monthly?month=2024-05" \
  -H "X-API-Key: YOUR_API_KEY"
GEThttps://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
NameTypeRequiredDescription
userIdnumberYesEmployee id
monthstringNoYYYY-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"
GEThttps://api.spirestock.com/api/v1/tracking/travel-summary

Distance 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
NameTypeRequiredDescription
time_periodstringNo1 daily, 2 monthly
travel_datestringNoDaily: YYYY-MM-DD or dd/mm/yyyy. Default: today in IST
monthstringNoMonthly: YYYY-MM or mm/yyyy
user_idnumberNoOne 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"
GEThttps://api.spirestock.com/api/v1/reports/login-activity

Sign-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
NameTypeRequiredDescription
date_fromstringNoYYYY-MM-DD. Default: today in IST
date_tostringNoDefault: date_from
role_idnumberNoRole
platformstringNoweb or mobile
searchstringNoCase-insensitive contains on the user's full name, SAP id or role name; max 100 characters, % and _ match literally
pagenumberNoPage number; junk or a value below 1 reads as 1(default: 1)
limitnumberNoPage 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"
GEThttps://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
NameTypeRequiredDescription
userIdnumberYesEmployee user id
datestringNoIST day to replay, YYYY-MM-DD or dd/mm/yyyy. Default: today
limitnumberNoPoints per page. Default 1,000; an explicit value is clamped to 1-100
cursorstringNonext_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"
GEThttps://api.spirestock.com/api/v1/tracking/location-log

Raw 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
NameTypeRequiredDescription
user_idnumberNoOne employee
datestringNoOne IST day, YYYY-MM-DD or dd/mm/yyyy
from_datestringNoRange start (IST day)
to_datestringNoRange end (inclusive)
limitnumberNoPoints per page. Default 500; an explicit value is clamped to 1-100
cursorstringNonext_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"
GEThttps://api.spirestock.com/api/v1/beat-plans

Planned 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
NameTypeRequiredDescription
user_idnumberNoSales rep
datestringNoOne day, YYYY-MM-DD (overrides the range)
date_fromstringNoRange start, YYYY-MM-DD
date_tostringNoRange end (inclusive), YYYY-MM-DD
statusnumberNo1 planned, 2 in progress, 3 completed
searchstringNoCase-insensitive contains on rep name or route name; max 100 characters, % and _ match literally
pagenumberNoPage number; junk or a value below 1 reads as 1(default: 1)
limitnumberNoPage 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"