> ## Documentation Index
> Fetch the complete documentation index at: https://spreecommerce.org/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# List stock movements

> Returns the stock ledger, newest first. Every row says what happened to
stock (`kind`) and carries a direct reference to what caused it, so a
merchant can answer "why is this number what it is?" from the data.

Kinds are `received` (goods arrived), `allocated` (stock promised to a
placed order), `shipped` (promised stock left), `released` (a promise
withdrawn) and `adjusted` (a manual correction, which always carries a
`reason`).

Movements are immutable — reversing one means writing its counterpart
through the resource that caused it, which is why there is no create,
update or delete here.

Filter with Ransack predicates such as `q[kind_eq]`,
`q[stock_level_id_eq]`, `q[order_id_eq]`, `q[fulfillment_id_eq]` or
`q[created_at_gteq]`.

`kind` is null on rows written before Spree 6.0 until
`spree:migrate_stock_movements_to_typed_rows` has run.


**Required scope:** `read_stock` (for API-key authentication).

## Filters

Filter with `q[<attribute>_<predicate>]=value`, for example `q[reason_cont]=…`. Send a list as `q[<attribute>_in][]=a&q[<attribute>_in][]=b`. [How filters work](/docs/api-reference/admin-api/querying.md#which-filters-an-endpoint-accepts).

| Attribute | Kind | Predicates |
| - | - | - |
| `created_at` | Date and time | `eq` `not_eq` `in` `not_in` `lt` `lteq` `gt` `gteq` `null` `not_null` |
| `exchange_id` | Prefixed ID | `eq` `not_eq` `in` `not_in` `null` `not_null` |
| `fulfillment_id` | Prefixed ID | `eq` `not_eq` `in` `not_in` `null` `not_null` |
| `id` | Prefixed ID | `eq` `not_eq` `in` `not_in` `null` `not_null` |
| `kind` | One of `received`, `allocated`, `shipped`, `released`, `adjusted` | `eq` `not_eq` `in` `not_in` `null` `not_null` |
| `order_id` | Prefixed ID | `eq` `not_eq` `in` `not_in` `null` `not_null` |
| `purchase_order_id` | Prefixed ID | `eq` `not_eq` `in` `not_in` `null` `not_null` |
| `quantity` | Number | `eq` `not_eq` `in` `not_in` `lt` `lteq` `gt` `gteq` `null` `not_null` |
| `reason` | Text | `eq` `not_eq` `in` `not_in` `cont` `i_cont` `not_cont` `start` `end` `null` `not_null` `present` `blank` |
| `return_id` | Prefixed ID | `eq` `not_eq` `in` `not_in` `null` `not_null` |
| `stock_level_id` | Prefixed ID | `eq` `not_eq` `in` `not_in` `null` `not_null` |
| `stock_receipt_id` | Prefixed ID | `eq` `not_eq` `in` `not_in` `null` `not_null` |
| `stock_transfer_id` | Prefixed ID | `eq` `not_eq` `in` `not_in` `null` `not_null` |
| `unit_cost` | Amount | `eq` `not_eq` `in` `not_in` `lt` `lteq` `gt` `gteq` `null` `not_null` |
| `updated_at` | Date and time | `eq` `not_eq` `in` `not_in` `lt` `lteq` `gt` `gteq` `null` `not_null` |

> **Filters through associations**
>
> Prefix an associated record's attribute with the association, as in `q[stock_level_id_eq]`. The same predicates apply.
>
> | Prefix | Attributes |
> | - | - |
> | `stock_level_` | `allocated_count`, `count_on_hand`, `created_at`, `id`, `incoming_count`, `reserved_count`, `stock_location_id`, `updated_at`, `variant_id` |
> | `stock_level_stock_location_` | `active`, `country_code`, `created_at`, `default`, `id`, `kind`, `name`, `pickup_enabled`, `returns_enabled`, `seller_id`, `state_code`, `updated_at` |
> | `stock_level_variant_` | `carton_package_type_id`, `carton_weight`, `cartons_per_pallet`, `cost_currency`, `cost_price`, `country_of_origin`, `created_at`, `deleted_at`, `depth`, `discontinue_on`, `height`, `hs_code`, `id`, `minimum_order_quantity`, `order_multiple`, `position`, `product_id`, `purchase_unit`, `sku`, `track_inventory`, `units_per_carton`, `updated_at`, `weight`, `width` |

**Sort by:** `created_at`, `exchange_id`, `fulfillment_id`, `id`, `kind`, `order_id`, `purchase_order_id`, `quantity`, `reason`, `return_id`, `stock_level_id`, `stock_receipt_id`, `stock_transfer_id`, `unit_cost`, `updated_at`. Prefix a field with `-` to sort descending.


## OpenAPI

````yaml /api-reference/admin.yaml get /api/v3/admin/stock_movements
openapi: 3.0.3
info:
  title: Admin API
  contact:
    name: Spree Commerce
    url: https://spreecommerce.org
    email: hello@spreecommerce.org
  description: >
    Spree Admin API v3 - Administrative API for managing products, orders, and
    store settings.


    ## Authentication


    The Admin API requires a secret API key passed in the `x-spree-api-key`
    header.

    Secret API keys can be generated in the Spree admin dashboard.


    ## Response Format


    All responses are JSON. List endpoints return paginated responses with
    `data` and `meta` keys.

    Single resource endpoints return a flat JSON object.


    ## Resource IDs


    Every resource is identified by an opaque string ID (e.g. `prod_86Rf07xd4z`,

    `variant_k5nR8xLq`, `or_UkLWZg9DAJ`). Use these IDs everywhere — URL paths,

    request bodies, and Ransack filters all accept them directly.


    ## Error Handling


    Errors return a consistent format:

    ```json

    {
      "error": {
        "code": "validation_error",
        "message": "Validation failed",
        "details": { "name": ["can't be blank"] }
      }
    }

    ```
  version: v3
servers:
  - url: http://{defaultHost}
    variables:
      defaultHost:
        default: localhost:3000
security: []
tags:
  - name: Authentication
    description: Admin user login, logout, token refresh, and current user profile
  - name: Allowed Origins
    description: CORS allowlist for storefront and admin client origins
  - name: API Keys
    description: Secret and publishable API keys
  - name: Categories
    description: >-
      Hierarchical product categories — tree management, repositioning, and
      product assignments
  - name: Channels
    description: >-
      Sales channels, product publication across channels, and per-channel order
      routing rules
  - name: Custom Fields
    description: >-
      Custom field definitions for products, variants, customers, and other
      resources
  - name: Customer Groups
    description: >-
      Customer groups for segmenting customers (e.g. wholesale, VIP) used by
      pricing and promotions
  - name: Customers
    description: Customer profiles, addresses, credit cards, and store credits
  - name: Email Templates
    description: >-
      Customer email templates, the email layout and shared partials: drafts,
      previews, publishing and history
  - name: Exports
    description: Async CSV exports of admin resources
  - name: Files
    description: Uploading the files that product media, imports, logos and documents use
  - name: Fulfillments
    description: Order fulfillments — shipments, fulfill, cancel, resume, split
  - name: Gift Cards
    description: Gift cards and gift card batches
  - name: Imports
    description: >-
      Async CSV imports of admin resources, with per-row status and failed-row
      retry
  - name: Markets
    description: >-
      Markets — geographic groupings of countries used for pricing, tax, and
      fulfillment rules
  - name: Option Types
    description: >-
      Option types and option values used to build product variants (e.g. Size,
      Color)
  - name: Orders
    description: Orders, order items, applied gift cards, and applied store credits
  - name: Payment Methods
    description: Configured payment providers and their available types
  - name: Payments
    description: Order payments — list, capture, void
  - name: Pricing
    description: >-
      Prices and price lists for currency-, market-, and customer-group-specific
      pricing
  - name: Products
    description: >-
      Products, taxons/categories, product custom field values, and bulk product
      operations
  - name: Policies
    description: The store's legal documents — terms of service, privacy, returns, shipping
  - name: Reasons
    description: >-
      Merchant-owned vocabularies for why a return, claim, refund, cancellation
      or tax exemption happened
  - name: Promotions
    description: Promotions, promotion rules, promotion actions, and coupon codes
  - name: Refunds
    description: Order refunds
  - name: Settings
    description: Store-level settings — store profile, tags, and configuration
  - name: Staff
    description: Admin users, roles, and invitations to the store
  - name: Stock Locations
    description: Warehouses and physical fulfillment locations
  - name: Store Credits
    description: Prepaid customer balances across all customers, and each balance's ledger
  - name: Variants
    description: >-
      Product variants — the individual SKUs (size/color combinations) sold
      under a product
  - name: Webhooks
    description: Webhook endpoints and webhook delivery history
paths:
  /api/v3/admin/stock_movements:
    get:
      tags:
        - Stock Movements
      summary: List stock movements
      description: |-
        Returns the stock ledger, newest first. Every row says what happened to
        stock (`kind`) and carries a direct reference to what caused it, so a
        merchant can answer "why is this number what it is?" from the data.

        Kinds are `received` (goods arrived), `allocated` (stock promised to a
        placed order), `shipped` (promised stock left), `released` (a promise
        withdrawn) and `adjusted` (a manual correction, which always carries a
        `reason`).

        Movements are immutable — reversing one means writing its counterpart
        through the resource that caused it, which is why there is no create,
        update or delete here.

        Filter with Ransack predicates such as `q[kind_eq]`,
        `q[stock_level_id_eq]`, `q[order_id_eq]`, `q[fulfillment_id_eq]` or
        `q[created_at_gteq]`.

        `kind` is null on rows written before Spree 6.0 until
        `spree:migrate_stock_movements_to_typed_rows` has run.


        **Required scope:** `read_stock` (for API-key authentication).
      parameters:
        - name: x-spree-api-key
          in: header
          required: true
          schema:
            type: string
        - name: Authorization
          in: header
          required: true
          description: Bearer token for admin authentication
          schema:
            type: string
        - name: page
          in: query
          required: false
          description: Page number
          schema:
            type: integer
        - name: limit
          in: query
          required: false
          description: Number of records per page
          schema:
            type: integer
        - name: q
          in: query
          required: false
          style: deepObject
          explode: true
          schema:
            type: object
            additionalProperties: true
          description: >-
            Attribute filters, as `q[<attribute>_<predicate>]=value`. See
            Filters above for the list.
        - name: fields
          in: query
          required: false
          description: Comma-separated list of fields to include. id is always included.
          schema:
            type: string
      responses:
        '200':
          description: stock movements found
          content:
            application/json:
              example:
                data:
                  - id: sm_UkLWZg9DAJ
                    quantity: 5
                    kind: adjusted
                    reason: Cycle count
                    created_at: '2026-01-15T12:00:00.000Z'
                    updated_at: '2026-01-15T12:00:00.000Z'
                    stock_level_id: sl_gbHJdmfrXB
                    stock_location_id: sloc_UkLWZg9DAJ
                    stock_location_name: Mona Hegmann
                    variant_id: variant_gbHJdmfrXB
                    variant_name: Product 1928513
                    variant_sku: SKU-241
                    order_id: null
                    fulfillment_id: null
                    return_id: null
                    exchange_id: null
                    stock_transfer_id: null
                    stock_receipt_id: null
                    purchase_order_id: null
                    order_number: null
                    return_number: null
                    exchange_number: null
                    stock_transfer_number: null
                    purchase_order_number: null
                    unit_cost: null
                meta:
                  page: 1
                  limit: 25
                  count: 1
                  pages: 1
                  from: 1
                  to: 1
                  in: 1
                  previous: null
                  next: null
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      $ref: '#/components/schemas/StockMovement'
                  meta:
                    $ref: '#/components/schemas/PaginationMeta'
                required:
                  - data
                  - meta
        '401':
          description: unauthorized
          content:
            application/json:
              example:
                error:
                  code: authentication_required
                  message: Authentication required
              schema:
                $ref: '#/components/schemas/ErrorResponse'
      security:
        - api_key: []
          bearer_auth: []
      x-codeSamples:
        - lang: javascript
          label: Spree Admin SDK
          source: |-
            import { createAdminClient } from '@spree/admin-sdk'

            const client = createAdminClient({
              baseUrl: 'https://your-store.com',
              secretKey: 'sk_xxx',
            })

            const { data: stockMovements } = await client.stockMovements.list({
              kind_eq: 'allocated',
            })
        - lang: bash
          label: Spree CLI
          source: spree api get /stock_movements -d '{"kind_eq":"allocated"}'
components:
  schemas:
    StockMovement:
      type: object
      properties:
        id:
          type: string
        quantity:
          type: number
        kind:
          type: string
          nullable: true
          enum:
            - received
            - allocated
            - shipped
            - released
            - adjusted
        reason:
          type: string
          nullable: true
        created_at:
          type: string
        updated_at:
          type: string
        stock_level_id:
          type: string
          nullable: true
        stock_location_id:
          type: string
          nullable: true
        stock_location_name:
          type: string
          nullable: true
        variant_id:
          type: string
          nullable: true
        variant_name:
          type: string
          nullable: true
        variant_sku:
          type: string
          nullable: true
        order_id:
          type: string
          nullable: true
        fulfillment_id:
          type: string
          nullable: true
        return_id:
          type: string
          nullable: true
        exchange_id:
          type: string
          nullable: true
        stock_transfer_id:
          type: string
          nullable: true
        stock_receipt_id:
          type: string
          nullable: true
        purchase_order_id:
          type: string
          nullable: true
        order_number:
          type: string
          nullable: true
        return_number:
          type: string
          nullable: true
        exchange_number:
          type: string
          nullable: true
        stock_transfer_number:
          type: string
          nullable: true
        purchase_order_number:
          type: string
          nullable: true
        unit_cost:
          type: string
          nullable: true
      required:
        - id
        - quantity
        - kind
        - reason
        - created_at
        - updated_at
        - stock_level_id
        - stock_location_id
        - stock_location_name
        - variant_id
        - variant_name
        - variant_sku
        - order_id
        - fulfillment_id
        - return_id
        - exchange_id
        - stock_transfer_id
        - stock_receipt_id
        - purchase_order_id
        - order_number
        - return_number
        - exchange_number
        - stock_transfer_number
        - purchase_order_number
        - unit_cost
      x-typelizer: true
    PaginationMeta:
      type: object
      properties:
        page:
          type: integer
          example: 1
        limit:
          type: integer
          example: 25
        count:
          type: integer
          example: 100
          description: Total number of records
        pages:
          type: integer
          example: 4
          description: Total number of pages
        from:
          type: integer
          example: 1
          description: Index of first record on this page
        to:
          type: integer
          example: 25
          description: Index of last record on this page
        in:
          type: integer
          example: 25
          description: Number of records on this page
        previous:
          type: integer
          nullable: true
          example: null
          description: Previous page number
        next:
          type: integer
          nullable: true
          example: 2
          description: Next page number
      required:
        - page
        - limit
        - count
        - pages
        - from
        - to
        - in
    ErrorResponse:
      type: object
      properties:
        error:
          type: object
          properties:
            code:
              type: string
              example: record_not_found
            message:
              type: string
              example: Record not found
            details:
              type: object
              description: Field-specific validation errors
              nullable: true
              example:
                name:
                  - is too short
                  - is required
                email:
                  - is invalid
          required:
            - code
            - message
      required:
        - error
      example:
        error:
          code: validation_error
          message: Validation failed
          details:
            name:
              - is too short
            email:
              - is invalid
  securitySchemes:
    api_key:
      type: apiKey
      name: x-spree-api-key
      in: header
      description: Secret API key for admin access
    bearer_auth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: JWT token for admin user authentication

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.