---
title: "One stock count, with its totals and the variance it found"
method: GET
path: "/api/v1/stocktakes/{stocktake_id}"
tags: ["stocktakes"]
---

# One stock count, with its totals and the variance it found

`GET /api/v1/stocktakes/{stocktake_id}`

## Request

- Base URL: `https://api.app.tightly.io`
- URL: `https://api.app.tightly.io/api/v1/stocktakes/{stocktake_id}`
- Auth: HTTP bearer

One count by id, in the shape the table serves it: `status`, `counted_on`, the locations it covers, `line_count` and `counted_line_count`, and the totals, `system_total`, `counted_total`, `variance_total` and `variance_value_total`.

The totals cover COUNTED lines only, so `counted_total - system_total` is exactly `variance_total`. An uncounted line has no reading and is in `line_count` but not in `counted_line_count`, which is how a caller tells "counted and matched" from "not yet counted": the two are the same zero on a total and different facts about a shelf.

`variance_value_total` PRICES AN UNPRICED LINE AT ZERO. A counted line on a variant with no cost on file adds its units to `variance_total` and nothing to the money, so the money total under-reports by whatever those lines are worth. get_stocktake_lines_table serves `unit_cost` per line, and a null there is what the money is missing.

`status` is `open` while counting and `posted` once the count is closed, when `posted_at` is stamped and the figures stop moving. Use get_stocktake_lines_table for the lines behind these totals.

A count this organisation does not have is 404, never an empty body.

Scope: `stocktakes:read`.

## Path parameters

- `stocktake_id` integer, required

## Headers

- `Tightly-Version` string

## Response `200`

The count, with the locations it covers and the totals it found.

- object
  - `data` GetStocktakePayload
    - `counted_line_count` integer, required
    - `counted_on` string, required
    - `counted_total` integer, required
    - `id` string, required
    - `line_count` integer, required
    - `location_names` string[]
    - `name` string, required
    - `posted_at` string, nullable
    - `status` 'open' | 'posted', required
    - `system_total` integer, required
    - `variance_total` integer, required
    - `variance_value_total` number, required
  - `message` object: severity, service and desc.

## Other responses

- `401`: No usable key: malformed, unknown, revoked, expired or stopped. One refusal covers all five, telling a caller which is which maps the surface for them. A request with no Authorization header at all is refused 400 before any key is looked for.
- `403`: The key may not reach this operation. `scope_missing` when the key does not hold Stocktakes; `organization_mismatch` when the path names an organisation that is not the key's; `ip_not_allowed` when the caller's address is outside the key's allowlist.
- `404`: No count with this id in this organisation.
- `429`: The key has spent its allowance for this minute. 600 reads and 120 writes a minute, counted per key, refused calls included. `Retry-After` says how long to wait.
- `503`: The database is briefly out of reach, which is what a failover or a full connection pool looks like from outside. Wait the seconds `Retry-After` names and send the request again. A read is safe to repeat. A write is not, because the connection was lost in the middle of it, so read the object back before sending it a second time. Branch on the status rather than on `code`, which is `POSTGRES_UNAVAILABLE` from one of the two seams that raise this and `SERVICE_UNAVAILABLE` from the other.

---

[API](https://skmtc.dev/tightly/apis/tightly-api.md) · [All operations](https://skmtc.dev/tightly/apis/tightly-api/llms.txt) · [OpenAPI document](https://skmtc.dev/tightly/apis/tightly-api/revisions/199f7eb35afb?raw)
