---
title: "ResourceShark API: Stock"
description: "Transfer stock, record a count, adjust stock, record a conversion, or get a conversion, with the ResourceShark API."
url: "https://agentpost.tools/docs/resourceshark/reference/stock"
kind: reference
---

# Stock

Transfer, count, adjust, or convert stock.

Paths are relative to `https://api.agentpost.tools/v1/resources`. [Who may call](/docs/resourceshark/reference.md#who-may-call) explains each credential.

## Transfer stock

`POST /transfers`

Moves stock between two scopes, such as two places, two condition labels, or two holders, writing both movements in one change. Only what is free moves. On a resource with identity: instance, both scopes name the same unit. A repeat under the same sourceKey answers with the first result.

-   **Who may call:** Your server, with your project’s secret key.
-   **Credential:** the examples send your project’s `dev` secret key, `sk_test_…`, as `Authorization: Bearer <token>`.
-   **SDK:** `client.transfers.create(body, { idempotencyKey })`
-   **Idempotency-Key:** required. [Retrying a write](/docs/platform/api-basics.md#retrying-a-write) has the rule.

### Body

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `resourceId` | `string` | Yes | 1–256 characters. |
| `from` | `object` | Yes |  |
| `from.placeId` | `string` | No |  |
| `from.condition` | `string` | No | 1–64 characters. |
| `from.holderRef` | `string` | No | 1–256 characters. |
| `from.instanceId` | `string` | No |  |
| `from.batchId` | `string` | No | 1–256 characters. |
| `from.supplyId` | `string` | No | 1–256 characters. |
| `to` | `object` | Yes |  |
| `to.placeId` | `string` | No |  |
| `to.condition` | `string` | No | 1–64 characters. |
| `to.holderRef` | `string` | No | 1–256 characters. |
| `to.instanceId` | `string` | No |  |
| `quantity` | `number` | Yes |  |
| `sourceKey` | `string` | Yes | 1–200 characters. |
| `evidence` | `object` | No |  |
| `evidence.kind` | `string` | Yes | 1–256 characters. |
| `evidence.ref` | `string` | Yes | 1–256 characters. |
| `note` | `string` | No | 1–200 characters. |

### Response

`201 Created`, with [`TransferResponse`](/docs/resourceshark/reference/stock.md#the-transferresponse-object).

### Errors

-   [`invalid_request`](/docs/resourceshark/errors.md#invalid_request) (400)
-   [`payload_too_large`](/docs/resourceshark/errors.md#payload_too_large) (413)
-   [`invalid_quantity`](/docs/resourceshark/errors.md#invalid_quantity) (422)
-   [`not_found`](/docs/resourceshark/errors.md#not_found) (404)
-   [`duplicate_source`](/docs/resourceshark/errors.md#duplicate_source) (409)
-   [`insufficient_supply`](/docs/resourceshark/errors.md#insufficient_supply) (409)
-   [`exhausted_until_supply`](/docs/resourceshark/errors.md#exhausted_until_supply) (409)
-   [`assignment_infeasible`](/docs/resourceshark/errors.md#assignment_infeasible) (409)

Any operation can also answer with the codes [Conventions](/docs/resourceshark/reference.md#conventions) lists.

```bash tab="curl"
curl -X POST https://api.agentpost.tools/v1/resources/transfers \
  -H "Authorization: Bearer sk_test_…" \
  -H "Idempotency-Key: market-restock-113" \
  -H "Content-Type: application/json" \
  -d '{
    "resourceId": "res_01M83PPH000000000000000001",
    "from": {
      "placeId": "plc_01M83PPH000000000000000001",
      "batchId": "bat_01M83PPH000000000000000001"
    },
    "to": {
      "placeId": "plc_01M83PPH000000000000000002"
    },
    "quantity": 2000,
    "sourceKey": "market:restock:113",
    "evidence": {
      "kind": "stock_move",
      "ref": "restock_113"
    }
  }'
```

```ts tab="SDK"
import { createClient } from '@agentpost-tools/resourceshark-sdk';

const client = createClient({ token: 'sk_test_…' });
const { transferId, movements } = await client.transfers.create(
  {
    resourceId: 'res_01M83PPH000000000000000001',
    from: {
      placeId: 'plc_01M83PPH000000000000000001',
      batchId: 'bat_01M83PPH000000000000000001',
    },
    to: { placeId: 'plc_01M83PPH000000000000000002' },
    quantity: 2000,
    sourceKey: 'market:restock:113',
    evidence: { kind: 'stock_move', ref: 'restock_113' },
  },
  { idempotencyKey: 'market-restock-113' },
);
```

```json title="Response"
{
  "transferId": "trf_01M83PPH000000000000000001",
  "movements": [
    {
      "id": "mov_01M83PPH00000000000000000A",
      "seq": 10,
      "resourceId": "res_01M83PPH000000000000000001",
      "scope": {
        "placeId": "plc_01M83PPH000000000000000001"
      },
      "reason": "transfer",
      "transferId": "trf_01M83PPH000000000000000001",
      "supplyId": "sup_01M83PPH000000000000000002",
      "batchId": "bat_01M83PPH000000000000000001",
      "pegs": [
        {
          "supplyId": "sup_01M83PPH000000000000000002",
          "quantity": 2000
        }
      ],
      "evidence": {
        "kind": "stock_move",
        "ref": "restock_113"
      },
      "at": "2026-11-23T10:10:00.000Z",
      "quantity": -2000,
      "before": 8500,
      "after": 6500,
      "actor": {
        "id": "key:juniper-backend"
      }
    },
    {
      "id": "mov_01M83PPH00000000000000000B",
      "seq": 11,
      "resourceId": "res_01M83PPH000000000000000001",
      "scope": {
        "placeId": "plc_01M83PPH000000000000000002"
      },
      "reason": "transfer",
      "transferId": "trf_01M83PPH000000000000000001",
      "supplyId": "sup_01M83PPH000000000000000004",
      "batchId": "bat_01M83PPH000000000000000001",
      "pegs": [
        {
          "supplyId": "sup_01M83PPH000000000000000004",
          "quantity": 2000
        }
      ],
      "evidence": {
        "kind": "stock_move",
        "ref": "restock_113"
      },
      "at": "2026-11-23T10:10:00.000Z",
      "quantity": 2000,
      "before": 0,
      "after": 2000,
      "actor": {
        "id": "key:juniper-backend"
      }
    }
  ]
}
```

## Record a count

`POST /counts`

Records a stock count against the balance version the counter read.

-   **Who may call:** Your server, with your project’s secret key.
-   **Credential:** the examples send your project’s `dev` secret key, `sk_test_…`, as `Authorization: Bearer <token>`.
-   **SDK:** `client.counts.create(body, { idempotencyKey })`
-   **Idempotency-Key:** required. [Retrying a write](/docs/platform/api-basics.md#retrying-a-write) has the rule.

### Body

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `resourceId` | `string` | Yes | 1–256 characters. |
| `scope` | `object` | No |  |
| `scope.placeId` | `string` | No |  |
| `scope.condition` | `string` | No | 1–64 characters. |
| `scope.holderRef` | `string` | No | 1–256 characters. |
| `scope.instanceId` | `string` | No |  |
| `quantity` | `number` | Yes |  |
| `from` | `object` | No |  |
| `from.batchId` | `string` | No | 1–256 characters. |
| `from.supplyId` | `string` | No | 1–256 characters. |
| `version` | `integer` | Yes | At least 0. |
| `evidence` | `object` | No |  |
| `evidence.kind` | `string` | Yes | 1–256 characters. |
| `evidence.ref` | `string` | Yes | 1–256 characters. |
| `note` | `string` | No | 1–200 characters. |

### Response

`201 Created`, with [`CountResponse`](/docs/resourceshark/reference/stock.md#the-countresponse-object).

### Errors

-   [`invalid_request`](/docs/resourceshark/errors.md#invalid_request) (400)
-   [`payload_too_large`](/docs/resourceshark/errors.md#payload_too_large) (413)
-   [`invalid_quantity`](/docs/resourceshark/errors.md#invalid_quantity) (422)
-   [`not_found`](/docs/resourceshark/errors.md#not_found) (404)
-   [`insufficient_supply`](/docs/resourceshark/errors.md#insufficient_supply) (409)
-   [`stale_version`](/docs/resourceshark/errors.md#stale_version) (409)

Any operation can also answer with the codes [Conventions](/docs/resourceshark/reference.md#conventions) lists.

```bash tab="curl"
curl -X POST https://api.agentpost.tools/v1/resources/counts \
  -H "Authorization: Bearer sk_test_…" \
  -H "Idempotency-Key: market-count-113" \
  -H "Content-Type: application/json" \
  -d '{
    "resourceId": "res_01M83PPH000000000000000001",
    "scope": {
      "placeId": "plc_01M83PPH000000000000000002"
    },
    "quantity": 1900,
    "version": 1,
    "evidence": {
      "kind": "stock_count",
      "ref": "market_count_113"
    }
  }'
```

```ts tab="SDK"
import { createClient } from '@agentpost-tools/resourceshark-sdk';

const client = createClient({ token: 'sk_test_…' });
const { onHand, version, movement } = await client.counts.create(
  {
    resourceId: 'res_01M83PPH000000000000000001',
    scope: { placeId: 'plc_01M83PPH000000000000000002' },
    quantity: 1900,
    version: 1,
    evidence: { kind: 'stock_count', ref: 'market_count_113' },
  },
  { idempotencyKey: 'market-count-113' },
);
```

```json title="Response"
{
  "onHand": 1900,
  "version": 2,
  "movement": {
    "id": "mov_01M83PPH00000000000000000C",
    "seq": 12,
    "resourceId": "res_01M83PPH000000000000000001",
    "scope": {
      "placeId": "plc_01M83PPH000000000000000002"
    },
    "reason": "count",
    "supplyId": "sup_01M83PPH000000000000000004",
    "batchId": "bat_01M83PPH000000000000000001",
    "pegs": [
      {
        "supplyId": "sup_01M83PPH000000000000000004",
        "quantity": 100
      }
    ],
    "evidence": {
      "kind": "stock_count",
      "ref": "market_count_113"
    },
    "at": "2026-11-23T10:20:00.000Z",
    "quantity": -100,
    "before": 2000,
    "after": 1900,
    "actor": {
      "id": "key:juniper-backend"
    }
  }
}
```

## Adjust stock

`POST /adjustments`

Records a signed adjustment with a reason, or reverses a movement. A repeat under the same sourceKey answers with the first result.

-   **Who may call:** Your server, with your project’s secret key.
-   **Credential:** the examples send your project’s `dev` secret key, `sk_test_…`, as `Authorization: Bearer <token>`.
-   **SDK:** `client.adjustments.create(body, { idempotencyKey })`
-   **Idempotency-Key:** required. [Retrying a write](/docs/platform/api-basics.md#retrying-a-write) has the rule.

### Body

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `resourceId` | `string` | No | 1–256 characters. |
| `scope` | `object` | No |  |
| `scope.placeId` | `string` | No |  |
| `scope.condition` | `string` | No | 1–64 characters. |
| `scope.holderRef` | `string` | No | 1–256 characters. |
| `scope.instanceId` | `string` | No |  |
| `quantity` | `number` | No |  |
| `from` | `object` | No |  |
| `from.batchId` | `string` | No | 1–256 characters. |
| `from.supplyId` | `string` | No | 1–256 characters. |
| `evidence` | `object` | No |  |
| `evidence.kind` | `string` | Yes | 1–256 characters. |
| `evidence.ref` | `string` | Yes | 1–256 characters. |
| `note` | `string` | No | 1–200 characters. |
| `sourceKey` | `string` | Yes | 1–200 characters. |
| `reverses` | `string` | No | 1–256 characters. |

### Response

`201 Created`, with [`AdjustmentResponse`](/docs/resourceshark/reference/stock.md#the-adjustmentresponse-object).

### Errors

-   [`invalid_request`](/docs/resourceshark/errors.md#invalid_request) (400)
-   [`payload_too_large`](/docs/resourceshark/errors.md#payload_too_large) (413)
-   [`invalid_quantity`](/docs/resourceshark/errors.md#invalid_quantity) (422)
-   [`not_found`](/docs/resourceshark/errors.md#not_found) (404)
-   [`duplicate_source`](/docs/resourceshark/errors.md#duplicate_source) (409)
-   [`insufficient_supply`](/docs/resourceshark/errors.md#insufficient_supply) (409)
-   [`exhausted_until_supply`](/docs/resourceshark/errors.md#exhausted_until_supply) (409)
-   [`assignment_infeasible`](/docs/resourceshark/errors.md#assignment_infeasible) (409)

Any operation can also answer with the codes [Conventions](/docs/resourceshark/reference.md#conventions) lists.

```bash tab="curl"
curl -X POST https://api.agentpost.tools/v1/resources/adjustments \
  -H "Authorization: Bearer sk_test_…" \
  -H "Idempotency-Key: market-spill-114" \
  -H "Content-Type: application/json" \
  -d '{
    "resourceId": "res_01M83PPH000000000000000001",
    "scope": {
      "placeId": "plc_01M83PPH000000000000000002"
    },
    "from": {
      "supplyId": "sup_01M83PPH000000000000000004"
    },
    "quantity": -100,
    "note": "Spilled during packing",
    "sourceKey": "market:spill:114"
  }'
```

```ts tab="SDK"
import { createClient } from '@agentpost-tools/resourceshark-sdk';

const client = createClient({ token: 'sk_test_…' });
const { movement } = await client.adjustments.create(
  {
    resourceId: 'res_01M83PPH000000000000000001',
    scope: { placeId: 'plc_01M83PPH000000000000000002' },
    from: { supplyId: 'sup_01M83PPH000000000000000004' },
    quantity: -100,
    note: 'Spilled during packing',
    sourceKey: 'market:spill:114',
  },
  { idempotencyKey: 'market-spill-114' },
);
```

```json title="Response"
{
  "movement": {
    "id": "mov_01M83PPH00000000000000000D",
    "seq": 13,
    "resourceId": "res_01M83PPH000000000000000001",
    "scope": {
      "placeId": "plc_01M83PPH000000000000000002"
    },
    "reason": "adjustment",
    "supplyId": "sup_01M83PPH000000000000000004",
    "batchId": "bat_01M83PPH000000000000000001",
    "pegs": [
      {
        "supplyId": "sup_01M83PPH000000000000000004",
        "quantity": 100
      }
    ],
    "note": "Spilled during packing",
    "at": "2026-11-23T10:25:00.000Z",
    "quantity": -100,
    "before": 1900,
    "after": 1800,
    "actor": {
      "id": "key:juniper-backend"
    }
  }
}
```

## Record a conversion

`POST /transformations`

Takes several quantities and adds several others in one change. A repeat under a sourceKey already used in the project answers with the first result.

-   **Who may call:** Your server, with your project’s secret key.
-   **Credential:** the examples send your project’s `dev` secret key, `sk_test_…`, as `Authorization: Bearer <token>`.
-   **SDK:** `client.transformations.create(body, { idempotencyKey })`
-   **Idempotency-Key:** required. [Retrying a write](/docs/platform/api-basics.md#retrying-a-write) has the rule.

### Body

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `takes` | `object[]` | Yes | 1–50 items. |
| `takes[].resourceId` | `string` | Yes | 1–256 characters. |
| `takes[].scope` | `object` | No |  |
| `takes[].scope.placeId` | `string` | No |  |
| `takes[].scope.condition` | `string` | No | 1–64 characters. |
| `takes[].scope.holderRef` | `string` | No | 1–256 characters. |
| `takes[].scope.instanceId` | `string` | No |  |
| `takes[].quantity` | `number` | Yes |  |
| `takes[].from` | `object` | No |  |
| `takes[].from.batchId` | `string` | No | 1–256 characters. |
| `takes[].from.supplyId` | `string` | No | 1–256 characters. |
| `takes[].span` | `object` | No |  |
| `takes[].span.start` | `string` | Yes | An ISO 8601 date and time. |
| `takes[].span.end` | `string` | Yes | An ISO 8601 date and time. |
| `adds` | `object[]` | Yes | 1–50 items. |
| `adds[].resourceId` | `string` | Yes | 1–256 characters. |
| `adds[].scope` | `object` | No |  |
| `adds[].scope.placeId` | `string` | No |  |
| `adds[].scope.condition` | `string` | No | 1–64 characters. |
| `adds[].scope.holderRef` | `string` | No | 1–256 characters. |
| `adds[].scope.instanceId` | `string` | No |  |
| `adds[].quantity` | `number` | Yes |  |
| `adds[].batchId` | `string` | No | 1–256 characters. |
| `adds[].batch` | `object` | No |  |
| `adds[].batch.code` | `string` | Yes | 1–200 characters. |
| `adds[].batch.expiresAt` | `string` | No | An ISO 8601 date and time. |
| `adds[].batch.attributes` | `object` | No | Each value is a `string`. |
| `adds[].expiresAt` | `string` | No | An ISO 8601 date and time. |
| `adds[].attributes` | `object` | No | Each value is a `string`. |
| `evidence` | `object` | Yes |  |
| `evidence.kind` | `string` | Yes | 1–256 characters. |
| `evidence.ref` | `string` | Yes | 1–256 characters. |
| `sourceKey` | `string` | Yes | 1–200 characters. |

### Response

`201 Created`, with [`TransformationResponse`](/docs/resourceshark/reference/stock.md#the-transformationresponse-object).

### Errors

-   [`invalid_request`](/docs/resourceshark/errors.md#invalid_request) (400)
-   [`payload_too_large`](/docs/resourceshark/errors.md#payload_too_large) (413)
-   [`invalid_quantity`](/docs/resourceshark/errors.md#invalid_quantity) (422)
-   [`not_found`](/docs/resourceshark/errors.md#not_found) (404)
-   [`duplicate_source`](/docs/resourceshark/errors.md#duplicate_source) (409)
-   [`insufficient_supply`](/docs/resourceshark/errors.md#insufficient_supply) (409)
-   [`exhausted_until_supply`](/docs/resourceshark/errors.md#exhausted_until_supply) (409)
-   [`assignment_infeasible`](/docs/resourceshark/errors.md#assignment_infeasible) (409)

Any operation can also answer with the codes [Conventions](/docs/resourceshark/reference.md#conventions) lists.

```bash tab="curl"
curl -X POST https://api.agentpost.tools/v1/resources/transformations \
  -H "Authorization: Bearer sk_test_…" \
  -H "Idempotency-Key: roast-104" \
  -H "Content-Type: application/json" \
  -d '{
    "takes": [
      {
        "resourceId": "res_01M83PPH000000000000000002",
        "scope": {
          "placeId": "plc_01M83PPH000000000000000001"
        },
        "quantity": 10000
      }
    ],
    "adds": [
      {
        "resourceId": "res_01M83PPH000000000000000001",
        "scope": {
          "placeId": "plc_01M83PPH000000000000000001"
        },
        "quantity": 8500,
        "batchId": "bat_01M83PPH000000000000000001"
      }
    ],
    "evidence": {
      "kind": "roast_log",
      "ref": "roast_104"
    },
    "sourceKey": "roast:104"
  }'
```

```ts tab="SDK"
import { createClient } from '@agentpost-tools/resourceshark-sdk';

const client = createClient({ token: 'sk_test_…' });
const { transformation, movements, supply } =
  await client.transformations.create(
    {
      takes: [
        {
          resourceId: 'res_01M83PPH000000000000000002',
          scope: { placeId: 'plc_01M83PPH000000000000000001' },
          quantity: 10000,
        },
      ],
      adds: [
        {
          resourceId: 'res_01M83PPH000000000000000001',
          scope: { placeId: 'plc_01M83PPH000000000000000001' },
          quantity: 8500,
          batchId: 'bat_01M83PPH000000000000000001',
        },
      ],
      evidence: { kind: 'roast_log', ref: 'roast_104' },
      sourceKey: 'roast:104',
    },
    { idempotencyKey: 'roast-104' },
  );
```

```json title="Response"
{
  "transformation": {
    "id": "tfm_01M83PPH000000000000000001",
    "takes": [
      {
        "claimId": "clm_01M83PPH000000000000000001",
        "movementId": "mov_01M83PPH000000000000000002"
      }
    ],
    "adds": [
      {
        "supplyId": "sup_01M83PPH000000000000000002",
        "movementId": "mov_01M83PPH000000000000000003"
      }
    ],
    "evidence": {
      "kind": "roast_log",
      "ref": "roast_104"
    },
    "sourceKey": "roast:104",
    "actor": {
      "id": "key:juniper-backend"
    },
    "createdAt": "2026-11-23T09:10:00.000Z"
  },
  "movements": [
    {
      "id": "mov_01M83PPH000000000000000002",
      "seq": 2,
      "resourceId": "res_01M83PPH000000000000000002",
      "scope": {
        "placeId": "plc_01M83PPH000000000000000001"
      },
      "reason": "convert_in",
      "transformationId": "tfm_01M83PPH000000000000000001",
      "claimId": "clm_01M83PPH000000000000000001",
      "evidence": {
        "kind": "roast_log",
        "ref": "roast_104"
      },
      "at": "2026-11-23T09:10:00.000Z",
      "quantity": -10000,
      "before": 10000,
      "after": 0,
      "actor": {
        "id": "key:juniper-backend"
      }
    },
    {
      "id": "mov_01M83PPH000000000000000003",
      "seq": 3,
      "resourceId": "res_01M83PPH000000000000000001",
      "scope": {
        "placeId": "plc_01M83PPH000000000000000001"
      },
      "reason": "convert_out",
      "transformationId": "tfm_01M83PPH000000000000000001",
      "supplyId": "sup_01M83PPH000000000000000002",
      "batchId": "bat_01M83PPH000000000000000001",
      "pegs": [
        {
          "supplyId": "sup_01M83PPH000000000000000002",
          "quantity": 8500
        }
      ],
      "evidence": {
        "kind": "roast_log",
        "ref": "roast_104"
      },
      "at": "2026-11-23T09:10:00.000Z",
      "quantity": 8500,
      "before": 0,
      "after": 8500,
      "actor": {
        "id": "key:juniper-backend"
      }
    }
  ],
  "supply": [
    {
      "resourceId": "res_01M83PPH000000000000000001",
      "scope": {
        "placeId": "plc_01M83PPH000000000000000001"
      },
      "quantity": 8500,
      "batchId": "bat_01M83PPH000000000000000001",
      "id": "sup_01M83PPH000000000000000002",
      "kind": "output",
      "remaining": 8500,
      "held": 0,
      "expiresAt": "2026-11-29T17:00:00.000Z",
      "evidence": {
        "kind": "roast_log",
        "ref": "roast_104"
      },
      "sourceKey": "transformation:tfm_01M83PPH000000000000000001:0",
      "status": "active",
      "actor": {
        "id": "key:juniper-backend"
      },
      "createdAt": "2026-11-23T09:10:00.000Z"
    }
  ]
}
```

## Get a conversion

`GET /transformations/:id`

Reads a conversion with its movements and the supply it added.

-   **Who may call:** Your server, with your project’s secret key.
-   **Credential:** the examples send your project’s `dev` secret key, `sk_test_…`, as `Authorization: Bearer <token>`.
-   **SDK:** `client.transformations.get(id)`

### Path parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | `string` | Yes | Transformation ID, `tfm_…`. The `id` of a [`Transformation`](/docs/resourceshark/reference/stock.md#the-transformation-object). |

### Response

`200 OK`, with [`TransformationResponse`](/docs/resourceshark/reference/stock.md#the-transformationresponse-object).

### Errors

-   [`not_found`](/docs/resourceshark/errors.md#not_found) (404)

Any operation can also answer with the codes [Conventions](/docs/resourceshark/reference.md#conventions) lists.

```bash tab="curl"
curl https://api.agentpost.tools/v1/resources/transformations/tfm_01M83PPH000000000000000001 \
  -H "Authorization: Bearer sk_test_…"
```

```ts tab="SDK"
import { createClient } from '@agentpost-tools/resourceshark-sdk';

const client = createClient({ token: 'sk_test_…' });
const { transformation, movements, supply } = await client.transformations.get(
  'tfm_01M83PPH000000000000000001',
);
```

```json title="Response"
{
  "transformation": {
    "id": "tfm_01M83PPH000000000000000001",
    "takes": [
      {
        "claimId": "clm_01M83PPH000000000000000001",
        "movementId": "mov_01M83PPH000000000000000002"
      }
    ],
    "adds": [
      {
        "supplyId": "sup_01M83PPH000000000000000002",
        "movementId": "mov_01M83PPH000000000000000003"
      }
    ],
    "evidence": {
      "kind": "roast_log",
      "ref": "roast_104"
    },
    "sourceKey": "roast:104",
    "actor": {
      "id": "key:juniper-backend"
    },
    "createdAt": "2026-11-23T09:10:00.000Z"
  },
  "movements": [
    {
      "id": "mov_01M83PPH000000000000000002",
      "seq": 2,
      "resourceId": "res_01M83PPH000000000000000002",
      "scope": {
        "placeId": "plc_01M83PPH000000000000000001"
      },
      "reason": "convert_in",
      "transformationId": "tfm_01M83PPH000000000000000001",
      "claimId": "clm_01M83PPH000000000000000001",
      "evidence": {
        "kind": "roast_log",
        "ref": "roast_104"
      },
      "at": "2026-11-23T09:10:00.000Z",
      "quantity": -10000,
      "before": 10000,
      "after": 0,
      "actor": {
        "id": "key:juniper-backend"
      }
    },
    {
      "id": "mov_01M83PPH000000000000000003",
      "seq": 3,
      "resourceId": "res_01M83PPH000000000000000001",
      "scope": {
        "placeId": "plc_01M83PPH000000000000000001"
      },
      "reason": "convert_out",
      "transformationId": "tfm_01M83PPH000000000000000001",
      "supplyId": "sup_01M83PPH000000000000000002",
      "batchId": "bat_01M83PPH000000000000000001",
      "pegs": [
        {
          "supplyId": "sup_01M83PPH000000000000000002",
          "quantity": 8500
        }
      ],
      "evidence": {
        "kind": "roast_log",
        "ref": "roast_104"
      },
      "at": "2026-11-23T09:10:00.000Z",
      "quantity": 8500,
      "before": 0,
      "after": 8500,
      "actor": {
        "id": "key:juniper-backend"
      }
    }
  ],
  "supply": [
    {
      "resourceId": "res_01M83PPH000000000000000001",
      "scope": {
        "placeId": "plc_01M83PPH000000000000000001"
      },
      "quantity": 8500,
      "batchId": "bat_01M83PPH000000000000000001",
      "id": "sup_01M83PPH000000000000000002",
      "kind": "output",
      "remaining": 6500,
      "held": 0,
      "expiresAt": "2026-11-29T17:00:00.000Z",
      "evidence": {
        "kind": "roast_log",
        "ref": "roast_104"
      },
      "sourceKey": "transformation:tfm_01M83PPH000000000000000001:0",
      "status": "active",
      "actor": {
        "id": "key:juniper-backend"
      },
      "createdAt": "2026-11-23T09:10:00.000Z"
    }
  ]
}
```

## The TransferResponse object

| Name | Type | Present | Description |
| --- | --- | --- | --- |
| `transferId` | `string` | Always | Transfer ID, `trf_…`. |
| `movements` | [`Movement`](/docs/resourceshark/reference/supply.md#the-movement-object) array | Always | The movement out, then the movement in; 2–2 items. |
| `duplicate` | `true` | When set | Set when the source key already named this request. |

```json title="The TransferResponse object"
{
  "transferId": "trf_01M83PPH000000000000000001",
  "movements": [
    {
      "id": "mov_01M83PPH00000000000000000A",
      "seq": 10,
      "resourceId": "res_01M83PPH000000000000000001",
      "scope": {
        "placeId": "plc_01M83PPH000000000000000001"
      },
      "reason": "transfer",
      "transferId": "trf_01M83PPH000000000000000001",
      "supplyId": "sup_01M83PPH000000000000000002",
      "batchId": "bat_01M83PPH000000000000000001",
      "pegs": [
        {
          "supplyId": "sup_01M83PPH000000000000000002",
          "quantity": 2000
        }
      ],
      "evidence": {
        "kind": "stock_move",
        "ref": "restock_113"
      },
      "at": "2026-11-23T10:10:00.000Z",
      "quantity": -2000,
      "before": 8500,
      "after": 6500,
      "actor": {
        "id": "key:juniper-backend"
      }
    },
    {
      "id": "mov_01M83PPH00000000000000000B",
      "seq": 11,
      "resourceId": "res_01M83PPH000000000000000001",
      "scope": {
        "placeId": "plc_01M83PPH000000000000000002"
      },
      "reason": "transfer",
      "transferId": "trf_01M83PPH000000000000000001",
      "supplyId": "sup_01M83PPH000000000000000004",
      "batchId": "bat_01M83PPH000000000000000001",
      "pegs": [
        {
          "supplyId": "sup_01M83PPH000000000000000004",
          "quantity": 2000
        }
      ],
      "evidence": {
        "kind": "stock_move",
        "ref": "restock_113"
      },
      "at": "2026-11-23T10:10:00.000Z",
      "quantity": 2000,
      "before": 0,
      "after": 2000,
      "actor": {
        "id": "key:juniper-backend"
      }
    }
  ]
}
```

## The CountResponse object

| Name | Type | Present | Description |
| --- | --- | --- | --- |
| `onHand` | `number` | Always | An integer in the resource’s base unit at its precision, as money is in cents: grams at precision 0, meters at precision 2, so 1 is 1 cm. A quantity with a fraction is refused with `invalid_quantity`. |
| `version` | `number` | Always |  |
| `movement` | [`Movement`](/docs/resourceshark/reference/supply.md#the-movement-object) | When set |  |

```json title="The CountResponse object"
{
  "onHand": 1900,
  "version": 2,
  "movement": {
    "id": "mov_01M83PPH00000000000000000C",
    "seq": 12,
    "resourceId": "res_01M83PPH000000000000000001",
    "scope": {
      "placeId": "plc_01M83PPH000000000000000002"
    },
    "reason": "count",
    "supplyId": "sup_01M83PPH000000000000000004",
    "batchId": "bat_01M83PPH000000000000000001",
    "pegs": [
      {
        "supplyId": "sup_01M83PPH000000000000000004",
        "quantity": 100
      }
    ],
    "evidence": {
      "kind": "stock_count",
      "ref": "market_count_113"
    },
    "at": "2026-11-23T10:20:00.000Z",
    "quantity": -100,
    "before": 2000,
    "after": 1900,
    "actor": {
      "id": "key:juniper-backend"
    }
  }
}
```

## The AdjustmentResponse object

| Name | Type | Present | Description |
| --- | --- | --- | --- |
| `movement` | [`Movement`](/docs/resourceshark/reference/supply.md#the-movement-object) | Always |  |
| `duplicate` | `true` | When set |  |

```json title="The AdjustmentResponse object"
{
  "movement": {
    "id": "mov_01M83PPH00000000000000000D",
    "seq": 13,
    "resourceId": "res_01M83PPH000000000000000001",
    "scope": {
      "placeId": "plc_01M83PPH000000000000000002"
    },
    "reason": "adjustment",
    "supplyId": "sup_01M83PPH000000000000000004",
    "batchId": "bat_01M83PPH000000000000000001",
    "pegs": [
      {
        "supplyId": "sup_01M83PPH000000000000000004",
        "quantity": 100
      }
    ],
    "note": "Spilled during packing",
    "at": "2026-11-23T10:25:00.000Z",
    "quantity": -100,
    "before": 1900,
    "after": 1800,
    "actor": {
      "id": "key:juniper-backend"
    }
  }
}
```

## The TransformationResponse object

A conversion with the movements and the supply it added.

| Name | Type | Present | Description |
| --- | --- | --- | --- |
| `transformation` | [`Transformation`](/docs/resourceshark/reference/stock.md#the-transformation-object) | Always |  |
| `movements` | [`Movement`](/docs/resourceshark/reference/supply.md#the-movement-object) array | Always |  |
| `supply` | [`SupplyEntry`](/docs/resourceshark/reference/supply.md#the-supplyentry-object) array | Always |  |
| `duplicate` | `true` | When set | Set when the source key already named this request. |

```json title="The TransformationResponse object"
{
  "transformation": {
    "id": "tfm_01M83PPH000000000000000001",
    "takes": [
      {
        "claimId": "clm_01M83PPH000000000000000001",
        "movementId": "mov_01M83PPH000000000000000002"
      }
    ],
    "adds": [
      {
        "supplyId": "sup_01M83PPH000000000000000002",
        "movementId": "mov_01M83PPH000000000000000003"
      }
    ],
    "evidence": {
      "kind": "roast_log",
      "ref": "roast_104"
    },
    "sourceKey": "roast:104",
    "actor": {
      "id": "key:juniper-backend"
    },
    "createdAt": "2026-11-23T09:10:00.000Z"
  },
  "movements": [
    {
      "id": "mov_01M83PPH000000000000000002",
      "seq": 2,
      "resourceId": "res_01M83PPH000000000000000002",
      "scope": {
        "placeId": "plc_01M83PPH000000000000000001"
      },
      "reason": "convert_in",
      "transformationId": "tfm_01M83PPH000000000000000001",
      "claimId": "clm_01M83PPH000000000000000001",
      "evidence": {
        "kind": "roast_log",
        "ref": "roast_104"
      },
      "at": "2026-11-23T09:10:00.000Z",
      "quantity": -10000,
      "before": 10000,
      "after": 0,
      "actor": {
        "id": "key:juniper-backend"
      }
    },
    {
      "id": "mov_01M83PPH000000000000000003",
      "seq": 3,
      "resourceId": "res_01M83PPH000000000000000001",
      "scope": {
        "placeId": "plc_01M83PPH000000000000000001"
      },
      "reason": "convert_out",
      "transformationId": "tfm_01M83PPH000000000000000001",
      "supplyId": "sup_01M83PPH000000000000000002",
      "batchId": "bat_01M83PPH000000000000000001",
      "pegs": [
        {
          "supplyId": "sup_01M83PPH000000000000000002",
          "quantity": 8500
        }
      ],
      "evidence": {
        "kind": "roast_log",
        "ref": "roast_104"
      },
      "at": "2026-11-23T09:10:00.000Z",
      "quantity": 8500,
      "before": 0,
      "after": 8500,
      "actor": {
        "id": "key:juniper-backend"
      }
    }
  ],
  "supply": [
    {
      "resourceId": "res_01M83PPH000000000000000001",
      "scope": {
        "placeId": "plc_01M83PPH000000000000000001"
      },
      "quantity": 8500,
      "batchId": "bat_01M83PPH000000000000000001",
      "id": "sup_01M83PPH000000000000000002",
      "kind": "output",
      "remaining": 8500,
      "held": 0,
      "expiresAt": "2026-11-29T17:00:00.000Z",
      "evidence": {
        "kind": "roast_log",
        "ref": "roast_104"
      },
      "sourceKey": "transformation:tfm_01M83PPH000000000000000001:0",
      "status": "active",
      "actor": {
        "id": "key:juniper-backend"
      },
      "createdAt": "2026-11-23T09:10:00.000Z"
    }
  ]
}
```

## The Transformation object

The record that links a conversion’s inputs, outputs, and evidence.

| Name | Type | Present | Description |
| --- | --- | --- | --- |
| `id` | `string` | Always | Transformation ID, `tfm_…`. |
| `takes` | `object[]` | Always |  |
| `takes[].claimId` | `string` | Always | Claim ID, `clm_…`. |
| `takes[].movementId` | `string` | Always | Movement ID, `mov_…`. |
| `adds` | `object[]` | Always |  |
| `adds[].supplyId` | `string` | Always | Supply ID, `sup_…`. |
| `adds[].movementId` | `string` | Always | Movement ID, `mov_…`. |
| `evidence` | [`Evidence`](/docs/resourceshark/reference/supply.md#the-evidence-object) | Always |  |
| `sourceKey` | `string` | Always |  |
| `actor` | [`PrincipalRef`](/docs/resourceshark/reference/supply.md#the-principalref-object) | Always |  |
| `onBehalfOf` | [`PrincipalRef`](/docs/resourceshark/reference/supply.md#the-principalref-object) | When set |  |
| `createdAt` | `string` | Always | An ISO 8601 date and time. |

```json title="The Transformation object"
{
  "id": "tfm_01M83PPH000000000000000001",
  "takes": [
    {
      "claimId": "clm_01M83PPH000000000000000001",
      "movementId": "mov_01M83PPH000000000000000002"
    }
  ],
  "adds": [
    {
      "supplyId": "sup_01M83PPH000000000000000002",
      "movementId": "mov_01M83PPH000000000000000003"
    }
  ],
  "evidence": {
    "kind": "roast_log",
    "ref": "roast_104"
  },
  "sourceKey": "roast:104",
  "actor": {
    "id": "key:juniper-backend"
  },
  "createdAt": "2026-11-23T09:10:00.000Z"
}
```
