---
title: "Accounts API — SpireStock REST API"
description: "Read party ledgers and invoices with GST, TCS and incentives, print a day's invoices, and issue gatepass and challan PDFs."
source: https://developers.spirestock.com/api-reference/accounts
---

# Accounts API

Read party ledgers and invoices with GST, TCS and incentives, print a day's invoices, and issue gatepass and challan PDFs.

Base URL: `https://api.spirestock.com/api/v1`. Every request needs an API key (`X-API-Key`) or a session token (`Authorization: Bearer`); see https://developers.spirestock.com/api-reference/auth.

## Endpoints

- [GET /accounts/ledger](https://developers.spirestock.com/api-reference/accounts#get-accounts-ledger)
- [GET /accounts/invoices](https://developers.spirestock.com/api-reference/accounts#get-accounts-invoices)
- [GET /accounts/invoice/{orderId}](https://developers.spirestock.com/api-reference/accounts#get-accounts-invoice-orderId)
- [GET /accounts/gatepass](https://developers.spirestock.com/api-reference/accounts#get-accounts-gatepass)
- [POST /accounts/gatepass](https://developers.spirestock.com/api-reference/accounts#post-accounts-gatepass)
- [GET /accounts/ledger-summary](https://developers.spirestock.com/api-reference/accounts#get-accounts-ledger-summary)

## GET /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.

Paged (page and limit): see https://developers.spirestock.com/api-reference#pagination.

**Parameters**

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `user_id` | number | no | One party |
| `search` | string | no | Name or store contains |
| `page` | number | no | Default 1 |
| `limit` | number | no | Default 30, max 100 |

**Example request**

```bash
curl "https://api.spirestock.com/api/v1/accounts/ledger?limit=2" \
  -H "X-API-Key: YOUR_API_KEY"
```

**Example response**

```json
{
  "response_code": 200,
  "data": [
    {
      "user_id": 44165,
      "user_name": "Sample User AO",
      "first_name": "Sample",
      "last_name": "User",
      "store_name": "Demo Store D",
      "opening_balance": "0",
      "credit": "0",
      "debit": "0",
      "closing_balance": "0",
      "balance": "0",
      "last_transaction_date": null
    }
  ],
  "pagination": {
    "total": 10026,
    "page": 1,
    "limit": 2,
    "total_pages": 5013
  }
}
```

## GET /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**

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `start_date` | string | no | Day, YYYY-MM-DD or DD/MM/YYYY. Default: today in IST |
| `end_date` | string | no | Default: start_date |
| `user_id` | number | no | One party |

**Example request**

```bash
curl "https://api.spirestock.com/api/v1/accounts/invoices?start_date=10/06/2024" \
  -H "X-API-Key: YOUR_API_KEY"
```

**Example response**

```json
{
  "response_code": 200,
  "data": [
    {
      "id": 339254,
      "order_code": "ORD0001008",
      "user_id": 44658,
      "order_date": "2024-06-10T13:26:11.000Z",
      "order_status": 3,
      "order_total_amount": 7707.6,
      "order_day": "2024-06-10",
      "first_name": "Sample",
      "middle_name": "",
      "last_name": "User",
      "store_name": "Demo Store C",
      "emp_sap_id": "CUST-003",
      "route_name": "Route H",
      "flat_incentive": 0,
      "bulkpack_incentive": 0,
      "user_name": "Sample User AK",
      "invoice_amount": 7707.6
    }
  ],
  "start_date": "2024-06-10",
  "end_date": "2024-06-10",
  "total": 73
}
```

## GET /accounts/invoice/{orderId}

The tax invoice for an order's party and day. Printable HTML by default; format=json returns the computed invoice: lines, GST split (CGST/SGST or IGST), TCS, round-off, amounts in words, incentives, the party block and invoice_no. GET /accounts/invoices/print-all?date= prints every invoice of a day. The invoice number is fixed the first time the invoice is issued (printed as HTML, singly or with print-all, e-invoiced or filed in GSTR-1) and reused from then on, so an order added to the same party and day later does not renumber it; format=json only reads it.

Access: API key `read` scope; staff need Invoices (14) — view.

**Parameters**

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `orderId` | number | yes | Order id |
| `format` | string | no | json for data instead of HTML |

**Example request**

```bash
curl "https://api.spirestock.com/api/v1/accounts/invoice/339189?format=json" \
  -H "X-API-Key: YOUR_API_KEY"
```

**Example response**

```json
{
  "response_code": 200,
  "data": {
    "lines": [
      {
        "id": 1573954,
        "order_id": 339189,
        "product_id": 191,
        "product_name": "Gold",
        "product_variant_id": 446,
        "product_variant_name": "Gold Milk 500ML",
        "product_variant_size": "0.5",
        "product_no_of_pouch": 24,
        "product_container_size": "12.00 L/CRATE",
        "product_container_type": "CRATE",
        "product_packaging_type_name": "PCS",
        "quantity": 3,
        "rate": 720,
        "amount": 2160,
        "quantity_in_pouch": 72,
        "quantity_in_ltr": 36,
        "packaging_type": "0",
        "is_allow": 0,
        "tally_export_type": 0,
        "order_date": "2024-06-10T08:05:17.000Z",
        "gst": null,
        "created_at": "2024-06-10T08:05:18.000Z",
        "updated_at": "2024-06-10T08:05:18.000Z",
        "organization_id": 6,
        "hsn_code": "1001",
        "per_ltr_kg": 60,
        "discount_per_unit": 0,
        "net_price": 60,
        "basic_price": 60,
        "gross_amount": 2160,
        "discount_amount": 0,
        "net_amount": 2160,
        "gst_amount": 0,
        "cgst_amount": 0,
        "unit_name": "LTR",
        "no_of_pouches": 72,
        "discount": 0,
        "final_amount": 2160,
        "free_scheme": 3,
        "free_scheme_text": "Free Toned Milk 500ML",
        "free_scheme_packaging_type": "PCS",
        "free_scheme_container_size": "L",
        "free_scheme_in_ltr": "1.5",
        "quantity_label": "CRATE"
      }
    ],
    "quantity": 61,
    "no_of_pouches": 683,
    "rate": 2546,
    "amount": 27820,
    "net_amount": 27820.01,
    "cgst": 0,
    "sgst": 0,
    "total_gst": 0,
    "igst": 0,
    "inter_state": 0,
    "tcs_amount": 0,
    "grand_total": 27820.01,
    "round_off": 0.01,
    "final_amount": 27820,
    "billing_amount_words": "Twenty Seven Thousand Eight Hundred And Twenty ",
    "gst_amount_words": "",
    "gst_paise_words": "",
    "taxable_values": {},
    "cgst_values": {},
    "sgst_values": {},
    "rate_values": {},
    "taxable_value_total": 0,
    "cgst_value_total": 0,
    "sgst_value_total": 0,
    "flat_incentive": 0,
    "bulkpack_incentive": 0,
    "total_incentive": 0,
    "is_tax_invoice": false,
    "party": {
      "store_name": "Demo Store C",
      "sap_code": "CUST-011",
      "address": "Plot 1, Industrial Area, Town A",
      "contact_no": "9876500002",
      "gstin": "0",
      "state_name": "State A",
      "state_code": "23",
      "route_name": "Route E",
      "route_no": "R005"
    },
    "order_code": "ORD0001003",
    "invoice_no": "ORD0001003-001"
  }
}
```

## GET /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**

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `date` | string | no | Day, YYYY-MM-DD or DD/MM/YYYY. Default: today in IST |

**Example request**

```bash
curl "https://api.spirestock.com/api/v1/accounts/gatepass?date=2024-06-10" \
  -H "X-API-Key: YOUR_API_KEY"
```

**Example response**

```json
{
  "response_code": 200,
  "date": "2024-06-10",
  "data": [
    {
      "id": 339254,
      "order_code": "ORD0001008",
      "user_id": 44658,
      "user_sap_id": "CUST-003",
      "order_date": "2024-06-10T13:26:11.000Z",
      "order_status": 3,
      "production_unit_id": 17,
      "first_name": "Sample",
      "middle_name": "",
      "last_name": "User",
      "store_name": "Demo Store F",
      "challan_id": null,
      "challan_no": null,
      "invoice_type": null,
      "name": "Sample User AM"
    }
  ],
  "production_units": [
    {
      "id": 18,
      "production_unit_name": "South Plant",
      "invoice_serial_no": null
    }
  ],
  "total": 73
}
```

## POST /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**

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `user_id` | number | yes | Party id |
| `order_date` | string | yes | YYYY-MM-DD or DD/MM/YYYY |
| `invoice_type` | string | no | Default challan |

**Example request**

```bash
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"
  }'
```

**Example response**

```json
{
  "response_code": 201,
  "message": "success",
  "data": {
    "id": 812,
    "organization_id": 6,
    "production_unit_id": 17,
    "invoice_no": "20241001",
    "user_id": 44663,
    "route_id": 82,
    "invoice_type": "challan",
    "created_date": "2024-06-10",
    "status": 0,
    "updatedAt": "2026-10-22T10:59:06.880Z",
    "createdAt": "2026-10-22T10:59:06.876Z",
    "invoice_path": "/api/v1/accounts/challans/812/pdf"
  }
}
```

## GET /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.

Paged (page and limit): see https://developers.spirestock.com/api-reference#pagination.

**Parameters**

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `search` | string | no | Case-insensitive contains on the customer's full name, store name or SAP id; max 100 characters, % and _ match literally |
| `page` | number | no | Page number; junk or a value below 1 reads as 1 (default 1) |
| `limit` | number | no | Page size, default 50, max 100 (larger values are clamped) (default 50) |

**Example request**

```bash
curl "https://api.spirestock.com/api/v1/accounts/ledger-summary?limit=50" \
  -H "X-API-Key: YOUR_API_KEY"
```

**Example response**

```json
{
  "response_code": 200,
  "data": [
    {
      "user_id": 44165,
      "first_name": "Sample",
      "last_name": "User A",
      "store_name": "Demo Store A",
      "emp_sap_id": "EMP-001",
      "balance": null,
      "total_credit": "0",
      "total_debit": "0"
    }
  ],
  "totals": {
    "total_outstanding": 0,
    "total_credit": 0,
    "total_debit": 0,
    "customers_with_balance": 0
  },
  "pagination": {
    "total": 10026,
    "page": 1,
    "limit": 2,
    "total_pages": 5013
  }
}
```
