Stock counts

Stock counts of a location: coverage, blind counting and status from draft to posted. Lines come in a feed of their own.

Loading the search index…

Stock counts

Objects

Stocktake

  • idintegerrequired

    ID of the record, unique among records of its kind in the store.

  • numberstring or nullrequired

    Stock count number in the store.

  • location_idintegerrequired

    ID of the counted location (/v1/locations).

  • statusstringrequired

    draft — counting is in progress; committing — adjustments are being written in the background; committed — posted, the adjustments are stock movements with document.type = stocktake; voided — the draft was cancelled, there are no movements. A failed posting returns the count to draft.

    Values:
    draftcommittingcommittedvoided
  • blindbooleanrequired

    Blind count: while the count is a draft, expected and variance of its lines are null.

  • coverageobjectrequired

    What is counted.

    Fields · 2
    • typestringrequired

      full — the whole location; category — selected categories; selection — items added while counting.

      Values:
      fullcategoryselection
    • category_idsarray of integer or nullrequired

      Category IDs (/v1/categories) for the category coverage; null otherwise.

  • notestring or nullrequired

    Note on the count; null if there is none.

  • submitted_atstring (date-time) or nullrequired

    When the counter handed the count over for posting; null if not handed over.

  • committed_atstring (date-time) or nullrequired

    When the adjustments were applied; null if the count is not posted.

  • voided_atstring (date-time) or nullrequired

    When the draft was cancelled; null if it was not.

  • created_atstring (date-time)required

    When the record was created.

  • updated_atstring (date-time)required

    When the record last changed.

Endpoints

Stock counts: coverage, status and dates, changed since a given moment

get/stocktakes

Scope: inventory:read

Parameters

Query

  • limitinteger

    Page size: up to 250 records; 50 by default.

    Minimum:
    1
    Maximum:
    250
  • cursorstring

    Opaque cursor: next_cursor of the previous page, or sync_cursor of the last page saved by the previous sync. The list goes in commit order, so the sync cursor later returns only what changed after it.

    Max length:
    4096
  • updated_sincestring (date-time)

    Only records changed after this moment, ISO 8601 with a time zone. A filter for the first sync; continue with the cursor.

    Pattern:
    ^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d{1,6})?(Z|[+-]\d{2}:\d{2})$
  • location_idinteger

    Only stock counts of this location.

    Minimum:
    1

Responses

200Success

application/json

  • dataarray of Stocktakerequired

    Records of the page.

  • deletedarray of objectrequired

    Records erased from the database since the cursor, as tombstones: only with include_deleted=true in the continuation by the sync cursor.

    Fields · 2
    • idintegerrequired

      ID of the erased record.

    • deleted_atstring (date-time)required

      When the record was erased.

  • next_cursorstring or nullrequired

    Cursor of the next page; null on the last page.

  • has_morebooleanrequired

    true when there is a next page.

  • sync_cursorstring or nullrequired

    On the last page — the cursor to continue from later: it returns only what changed after this page. null on other pages.

401The token is missing, invalid, expired or revoked

Headers

  • WWW-Authenticatestringrequired

    Authentication scheme (RFC 6750).

    Example:
    Bearer

application/problem+json

Returns Problem

403The plan, the IP address or the token scopes do not allow the request

Headers

  • WWW-Authenticatestring

    Authentication scheme (RFC 6750).

    Example:
    Bearer error="insufficient_scope", scope="locations:read"

application/problem+json

Returns ForbiddenProblem

410The sync cursor is older than the deletion retention period or was issued before the database was restored

application/problem+json

Returns Problem

422A parameter is invalid or unknown

application/problem+json

Returns ValidationProblem

429The rate limit is exhausted

Headers

  • Retry-Afterintegerrequired

    Seconds to wait before retrying.

    Minimum:
    0

application/problem+json

Returns RateLimitProblem

503The store is temporarily unavailable

Headers

  • Retry-Afterinteger

    Seconds to wait before retrying.

    Minimum:
    0

application/problem+json

Returns Problem

Errors of this endpoint

Common errors such as token, access, input validation and rate limit can come from any endpoint; they are listed in the catalog: Errors

Example request
curl "https://api.saleya.app/v1/stocktakes" \
  -H "Authorization: Bearer $SALEYA_API_TOKEN"
Example response · 200
{
  "data": [
    {
      "id": 0,
      "number": "string",
      "location_id": 0,
      "status": "draft",
      "blind": true,
      "coverage": {
        "type": "full",
        "category_ids": [
          0
        ]
      },
      "note": "string",
      "submitted_at": "2026-01-15T12:00:00Z",
      "committed_at": "2026-01-15T12:00:00Z",
      "voided_at": "2026-01-15T12:00:00Z",
      "created_at": "2026-01-15T12:00:00Z",
      "updated_at": "2026-01-15T12:00:00Z"
    }
  ],
  "deleted": [
    {
      "id": 0,
      "deleted_at": "2026-01-15T12:00:00Z"
    }
  ],
  "next_cursor": "string",
  "has_more": true,
  "sync_cursor": "string"
}

Stock count

get/stocktakes/{stocktake}

Scope: inventory:read

Parameters

Path

  • stocktakeintegerrequired

    Stock count ID.

Responses

200Success

application/json

Returns Stocktake

401The token is missing, invalid, expired or revoked

Headers

  • WWW-Authenticatestringrequired

    Authentication scheme (RFC 6750).

    Example:
    Bearer

application/problem+json

Returns Problem

403The plan, the IP address or the token scopes do not allow the request

Headers

  • WWW-Authenticatestring

    Authentication scheme (RFC 6750).

    Example:
    Bearer error="insufficient_scope", scope="locations:read"

application/problem+json

Returns ForbiddenProblem

404The object does not exist or is not available to the app

application/problem+json

Returns Problem

422A parameter is invalid or unknown

application/problem+json

Returns ValidationProblem

429The rate limit is exhausted

Headers

  • Retry-Afterintegerrequired

    Seconds to wait before retrying.

    Minimum:
    0

application/problem+json

Returns RateLimitProblem

503The store is temporarily unavailable

Headers

  • Retry-Afterinteger

    Seconds to wait before retrying.

    Minimum:
    0

application/problem+json

Returns Problem

Common errors such as token, access, input validation and rate limit can come from any endpoint; they are listed in the catalog: Errors

Example request
curl "https://api.saleya.app/v1/stocktakes/{stocktake}" \
  -H "Authorization: Bearer $SALEYA_API_TOKEN"
Example response · 200
{
  "id": 0,
  "number": "string",
  "location_id": 0,
  "status": "draft",
  "blind": true,
  "coverage": {
    "type": "full",
    "category_ids": [
      0
    ]
  },
  "note": "string",
  "submitted_at": "2026-01-15T12:00:00Z",
  "committed_at": "2026-01-15T12:00:00Z",
  "voided_at": "2026-01-15T12:00:00Z",
  "created_at": "2026-01-15T12:00:00Z",
  "updated_at": "2026-01-15T12:00:00Z"
}