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

# Get Receipt Stock Operations

> Retrieve the stock deductions ("Çıxarılan ehtiyat") generated by a receipt

## Purpose

Fetch the stock write-offs caused by a single receipt — the inventory deducted from your storages when the receipt's products were sold. Use it to reconcile a sale against the warehouse movements it produced ("Çıxarılan ehtiyat" / stock deduction by receipt id).

Only the deductions of the receipt itself are returned: each item has `operation_id = null` and a non-null `receipt_product_id`. Manual stock corrections or operations from other documents are excluded.

This endpoint requires the `receipts:read` scope.

## HTTP Request

```http theme={null}
GET https://integrations.clopos.com/open-api/v2/receipts/{id}/stock-operations
```

<Warning>
  This endpoint requires authentication. Include your JWT in the `x-token` header. See [Authentication](/authentication) for how to obtain a token and [Errors](/errors) for error responses.
</Warning>

## Path Parameters

| Parameter | Type   | Description                                                                  |
| --------- | ------ | ---------------------------------------------------------------------------- |
| `id`      | number | Unique identifier of the receipt whose stock deductions you want to inspect. |

## Request Example

<CodeGroup>
  ```bash curl theme={null}
  curl --location "https://integrations.clopos.com/open-api/v2/receipts/1/stock-operations" \
    -H "x-token: oauth_example_token"
  ```

  ```javascript javascript theme={null}
  const receiptId = 1;
  const headers = { 'x-token': 'oauth_example_token' };

  const response = await fetch(
    `https://integrations.clopos.com/open-api/v2/receipts/${receiptId}/stock-operations`,
    { headers }
  );
  const stockOperations = await response.json();
  ```

  ```python python theme={null}
  import requests

  receipt_id = 1
  url = f"https://integrations.clopos.com/open-api/v2/receipts/{receipt_id}/stock-operations"
  headers = {
      "x-token": "oauth_example_token",
  }

  response = requests.get(url, headers=headers)
  stock_operations = response.json()
  ```
</CodeGroup>

## Response

### 200 OK — Stock operations

```json theme={null}
{
  "data": [
    {
      "id": 1001,
      "receipt_id": 1,
      "receipt_product_id": 14,
      "product_id": 31042,
      "stock_id": 5001,
      "storage_id": 3,
      "quantity": 1,
      "before_quantity": 120,
      "after_quantity": 119,
      "cost": 8000,
      "before_cost": 8000,
      "total_cost": 8000,
      "operated_at": "2026-01-19 15:07:49",
      "product": {
        "id": 31042,
        "name": "Апельсинли реване"
      },
      "stock": {
        "id": 5001,
        "storage": {
          "id": 3,
          "name": "Main Storage"
        }
      }
    },
    {
      "id": 1002,
      "receipt_id": 1,
      "receipt_product_id": 15,
      "product_id": 31046,
      "stock_id": 5002,
      "storage_id": 3,
      "quantity": 2,
      "before_quantity": 50,
      "after_quantity": 48,
      "cost": 1500,
      "before_cost": 1500,
      "total_cost": 3000,
      "operated_at": "2026-01-19 15:07:49",
      "product": {
        "id": 31046,
        "name": "Ачма узум жевиз"
      },
      "stock": {
        "id": 5002,
        "storage": {
          "id": 3,
          "name": "Main Storage"
        }
      }
    }
  ]
}
```

### 404 Not Found — Invalid ID

```json theme={null}
{
  "success": false,
  "error": "not_found",
  "message": "Receipt not found"
}
```

## Field Reference

### Stock operation object

| Field                | Type   | Description                                                                           |
| -------------------- | ------ | ------------------------------------------------------------------------------------- |
| `id`                 | number | Stock operation identifier.                                                           |
| `receipt_id`         | number | Receipt the operation belongs to.                                                     |
| `receipt_product_id` | number | Receipt product line that produced the write-off (always set for receipt deductions). |
| `product_id`         | number | Product whose stock was deducted.                                                     |
| `stock_id`           | number | Stock record affected by the operation.                                               |
| `storage_id`         | number | Storage the stock belongs to.                                                         |
| `quantity`           | number | Quantity deducted from stock.                                                         |
| `before_quantity`    | number | Stock quantity before the operation.                                                  |
| `after_quantity`     | number | Stock quantity after the operation.                                                   |
| `cost`               | number | Unit cost applied to the deduction.                                                   |
| `before_cost`        | number | Stock cost before the operation.                                                      |
| `total_cost`         | number | Total cost of the deducted quantity.                                                  |
| `operated_at`        | string | When the operation was applied (YYYY-MM-DD HH:mm:ss).                                 |
| `product`            | object | Related product. Present even when the product was soft-deleted.                      |
| `stock`              | object | Affected stock together with its storage.                                             |

### `stock`

| Field     | Type   | Description                                  |
| --------- | ------ | -------------------------------------------- |
| `id`      | number | Stock identifier.                            |
| `storage` | object | Storage the stock belongs to (`id`, `name`). |

## Notes

* The endpoint returns only the receipt's own deductions (`operation_id = null`, `receipt_product_id != null`); inventory adjustments from other documents are not included.
* A `product` may be soft-deleted but is still returned so historical receipts remain fully reconcilable.
* Combine with [Get Receipt by ID](/api-reference/v2/receipts/get-receipt-by-id) to map each `receipt_product_id` back to its sold line item.
