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

# GET /v1/ecommerce/stock-movements

> List stock movements — sales, cancellations, adjustments, purchases, imports, syncs, and transfers — filtered by date, type, and branch.

Returns the paginated history of stock movements. Every change to stock leaves one: a sale, a cancelled sale, a manual adjustment, a transfer between branches, an import, or a sync from a connected store.

## Endpoint

```
GET https://api.keebai.com/v1/ecommerce/stock-movements
```

## Required scope

`ecommerce:stock:read`

## Headers

| Header | Required | Value |
| - | - | - |
| `Authorization` | Yes | `Bearer kbai_pk_<token>` |

## Query parameters

| Field | Type | Required | Description |
| - | - | - | - |
| `from` | `string` | No | Start date, `YYYY-MM-DD`. Send it together with `to`. |
| `to` | `string` | No | End date, `YYYY-MM-DD`. Send it together with `from`. |
| `types` | `string` | No | Comma-separated list of movement types. See below. |
| `branch_id` | `string` | No | Only movements of this branch. |
| `search` | `string` | No | Free-text search. |
| `limit` | `integer` | No | Page size, `1`–`200`. Defaults to 50. |
| `offset` | `integer` | No | Records to skip. Defaults to 0. |

### Movement types

| `type` | What moved the stock |
| - | - |
| `sale` | A sale. |
| `sale_cancel` | A cancelled sale giving the stock back. |
| `adjustment` | A manual adjustment, such as [`POST .../stock/adjust`](https://docs.keebai.com/dev/endpoints/ecommerce-stock-adjust). |
| `set` | Stock set to a fixed value. |
| `purchase` | A purchase. |
| `import` | An import. |
| `sync` | A sync from a connected store. |
| `transfer` | A transfer between the warehouse and branches, such as [`POST .../stock/transfer`](https://docs.keebai.com/dev/endpoints/ecommerce-stock-transfer). |

## Example request

```bash curl theme={"system"}
curl -G https://api.keebai.com/v1/ecommerce/stock-movements \
  -H "Authorization: Bearer kbai_pk_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" \
  --data-urlencode "from=2026-11-01" \
  --data-urlencode "to=2026-11-04" \
  --data-urlencode "types=adjustment,transfer" \
  --data-urlencode "limit=50"
```

```js JavaScript theme={"system"}
const params = new URLSearchParams({
  from: "2026-11-01",
  to: "2026-11-04",
  types: "adjustment,transfer",
  limit: "50",
});

const response = await fetch(
  `https://api.keebai.com/v1/ecommerce/stock-movements?${params}`,
  { headers: { Authorization: `Bearer ${process.env.KEEBAI_API_TOKEN}` } },
);
const { items, total } = await response.json();
```

```python Python theme={"system"}
import os, requests

resp = requests.get(
    "https://api.keebai.com/v1/ecommerce/stock-movements",
    headers={"Authorization": f"Bearer {os.environ['KEEBAI_API_TOKEN']}"},
    params={"from": "2026-11-01", "to": "2026-11-04", "types": "adjustment,transfer", "limit": 50},
    timeout=10,
)
resp.raise_for_status()
movements = resp.json()["items"]
```

## Response

### 200 OK

```json theme={"system"}
{
  "items": [
    {
      "variant_id": "65d3e4f5a6b7c8d9e0f1a2c1",
      "variant_name": "42 / Negro",
      "type": "transfer",
      "quantity": 3,
      "stock_after": 12,
      "from_branch_id": "br_01",
      "to_branch_id": "br_02",
      "note": "Reposición fin de semana",
      "created_at": "2026-11-03T18:22:10.402Z"
    }
  ],
  "total": 1,
  "limit": 50,
  "offset": 0
}
```

Each item is one movement. `type` is one of the values above, `quantity` is how much moved, and `stock_after` is the master stock left after it.

### 400 Bad Request

A date not in `YYYY-MM-DD`, an unknown value in `types`, `limit` outside `1`–`200`, or a negative `offset`.

`DATE_RANGE_INCOMPLETE` — only one of `from` and `to` was sent. They go together.

### 401 Unauthorized

Missing, invalid, revoked, or expired token.

### 403 Forbidden

The token does not have the `ecommerce:stock:read` scope.

### 502 Bad Gateway

`ECOMMERCE_UPSTREAM_ERROR` — the ecommerce service could not answer.

## Operational notes

* **This is the audit trail of stock.** To explain why a number changed, read the movements of that product instead of comparing two snapshots.
* **A transfer does not change the total.** It moves stock between the warehouse and branches; the master stock of the product stays the same.


## OpenAPI

````yaml GET /v1/ecommerce/stock-movements
openapi: 3.0.0
info:
  title: Keebai Public API
  description: Superficie pública REST autenticada con Personal Access Tokens (PAT).
  version: 1.0.0
  contact: {}
servers:
  - url: https://api.keebai.com
    description: Production
security: []
tags: []
paths:
  /v1/ecommerce/stock-movements:
    get:
      tags:
        - ecommerce
      summary: Listar movimientos de stock
      description: >-
        Movimientos de stock de todos los productos, del más reciente al más
        antiguo. Filtrable por rango de fechas, tipo, sucursal y producto.
      operationId: PublicEcommerceOperationsController_listStockMovements
      parameters:
        - name: from
          required: false
          in: query
          description: Desde (YYYY-MM-DD, inclusive, hora de Santiago). Va junto con `to`
          schema:
            example: '2026-11-01'
            type: string
        - name: to
          required: false
          in: query
          description: Hasta (YYYY-MM-DD, inclusive, hora de Santiago). Va junto con `from`
          schema:
            example: '2026-11-30'
            type: string
        - name: types
          required: false
          in: query
          description: >-
            Tipos separados por coma: sale, sale_cancel, adjustment, set,
            purchase, import, sync, transfer
          schema:
            example: sale,adjustment
            type: string
        - name: branch_id
          required: false
          in: query
          description: Solo movimientos de esta sucursal
          schema:
            type: string
        - name: search
          required: false
          in: query
          description: Busca por nombre o SKU del producto
          schema:
            type: string
        - name: limit
          required: false
          in: query
          schema:
            minimum: 1
            maximum: 200
            default: 50
            type: number
        - name: offset
          required: false
          in: query
          schema:
            minimum: 0
            default: 0
            type: number
      responses:
        '200':
          description: ''
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PublicStockMovementListResponseDto'
      security:
        - PAT: []
components:
  schemas:
    PublicStockMovementListResponseDto:
      type: object
      properties:
        items:
          type: array
          items:
            $ref: '#/components/schemas/PublicStockMovementDto'
        total:
          type: number
        limit:
          type: number
        offset:
          type: number
      required:
        - items
        - total
        - limit
        - offset
    PublicStockMovementDto:
      type: object
      properties:
        id:
          type: string
        product_id:
          type: string
        product:
          nullable: true
          type: object
          allOf:
            - $ref: '#/components/schemas/PublicStockMovementProductDto'
        variant_id:
          type: string
          nullable: true
        variant_name:
          type: string
          nullable: true
        type:
          type: string
          enum:
            - sale
            - sale_cancel
            - adjustment
            - set
            - purchase
            - import
            - sync
            - transfer
        quantity:
          type: number
          description: Unidades movidas, con signo
        stock_after:
          type: number
          description: Stock que quedó después del movimiento
        reference:
          $ref: '#/components/schemas/PublicStockMovementReferenceDto'
        user:
          $ref: '#/components/schemas/PublicStockMovementUserDto'
        note:
          type: string
        branch_id:
          type: string
        from_branch_id:
          type: string
        to_branch_id:
          type: string
        origin:
          type: string
          description: Desde dónde se hizo el movimiento
        created_at:
          type: string
      required:
        - id
        - product_id
        - product
        - variant_id
        - variant_name
        - type
        - quantity
        - stock_after
        - created_at
    PublicStockMovementProductDto:
      type: object
      properties:
        id:
          type: string
        name:
          type: string
        sku:
          type: string
        image_url:
          type: string
          nullable: true
      required:
        - id
        - name
        - sku
        - image_url
    PublicStockMovementReferenceDto:
      type: object
      properties:
        kind:
          type: string
          description: Tipo de documento que originó el movimiento
        id:
          type: string
        label:
          type: string
      required:
        - kind
        - id
    PublicStockMovementUserDto:
      type: object
      properties:
        id:
          type: string
        email:
          type: string
  securitySchemes:
    PAT:
      scheme: bearer
      bearerFormat: kbai_pk_<hex>
      type: http
      description: >-
        Personal Access Token con prefijo `kbai_pk_`. Generar desde el portal
        con permiso `developer.manage_tokens`.

````

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