---
title: "ResourceShark API: Supply"
description: "Add supply, list supply, get a supply entry, or reverse supply, with the ResourceShark API."
url: "https://agentpost.tools/docs/resourceshark/reference/supply"
kind: reference
---

# Supply

Record, read, and take back supply that is on hand or due.

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

## Add supply

`POST /supply`

Adds on-hand or expected supply. An added entry is on hand from its validFrom, or as it lands when that is unset or not after now, until its expiresAt; every take, hold, and read honors those times whether or not anything has written its movement yet. An added entry can fulfil an expected entry. On a resource with identity: instance, an entry adds the one unit its scope names, which must not be on hand or due anywhere else. A repeat under a sourceKey already used on the resource 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.supply.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 |  |
| `kind` | `"added"` or `"expected"` | Yes |  |
| `quantity` | `number` | Yes |  |
| `validFrom` | `string` | No | An ISO 8601 date and time. |
| `expiresAt` | `string` | No | An ISO 8601 date and time. |
| `drawOrder` | `integer` | No |  |
| `batchId` | `string` | No | 1–256 characters. |
| `fulfils` | `string` | No | 1–256 characters. |
| `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. |
| `batch` | `object` | No |  |
| `batch.code` | `string` | Yes | 1–200 characters. |
| `batch.expiresAt` | `string` | No | An ISO 8601 date and time. |
| `batch.attributes` | `object` | No | Each value is a `string`. |

### Response

`201 Created`, with [`SupplyResponse`](/docs/resourceshark/reference/supply.md#the-supplyresponse-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)

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/supply \
  -H "Authorization: Bearer sk_test_…" \
  -H "Idempotency-Key: add-credit-pack-1042" \
  -H "Content-Type: application/json" \
  -d '{
    "resourceId": "res_01M83PPH000000000000000003",
    "scope": {
      "holderRef": "principal:external:u_maya"
    },
    "kind": "added",
    "quantity": 12,
    "expiresAt": "2026-11-29T23:00:00.000Z",
    "attributes": {
      "program": "tasting-club"
    },
    "evidence": {
      "kind": "credit_pack",
      "ref": "pack_1042"
    },
    "sourceKey": "credit-pack:1042"
  }'
```

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

const client = createClient({ token: 'sk_test_…' });
const { supply, movement } = await client.supply.create(
  {
    resourceId: 'res_01M83PPH000000000000000003',
    scope: { holderRef: 'principal:external:u_maya' },
    kind: 'added',
    quantity: 12,
    expiresAt: '2026-11-29T23:00:00.000Z',
    attributes: { program: 'tasting-club' },
    evidence: { kind: 'credit_pack', ref: 'pack_1042' },
    sourceKey: 'credit-pack:1042',
  },
  { idempotencyKey: 'add-credit-pack-1042' },
);
```

```json title="Response"
{
  "supply": {
    "resourceId": "res_01M83PPH000000000000000003",
    "scope": {
      "holderRef": "principal:external:u_maya"
    },
    "kind": "added",
    "quantity": 12,
    "expiresAt": "2026-11-29T23:00:00.000Z",
    "attributes": {
      "program": "tasting-club"
    },
    "evidence": {
      "kind": "credit_pack",
      "ref": "pack_1042"
    },
    "sourceKey": "credit-pack:1042",
    "id": "sup_01M83PPH000000000000000003",
    "remaining": 12,
    "held": 0,
    "actor": {
      "id": "key:juniper-backend"
    },
    "status": "active",
    "createdAt": "2026-11-23T09:25:00.000Z"
  },
  "movement": {
    "id": "mov_01M83PPH000000000000000004",
    "seq": 4,
    "resourceId": "res_01M83PPH000000000000000003",
    "scope": {
      "holderRef": "principal:external:u_maya"
    },
    "reason": "add",
    "supplyId": "sup_01M83PPH000000000000000003",
    "evidence": {
      "kind": "credit_pack",
      "ref": "pack_1042"
    },
    "at": "2026-11-23T09:25:00.000Z",
    "quantity": 12,
    "before": 0,
    "after": 12,
    "actor": {
      "id": "key:juniper-backend"
    }
  }
}
```

## List supply

`GET /supply`

Lists supply entries, optionally filtered by resource, holder, batch, or status. A caller constrained to one holder lists only its own.

-   **Who may call:** Your server, with your project’s secret key or a signed-in principal, with a user token for their own `principal:<principal>` holder.
-   **Credential:** the examples send your project’s `dev` secret key, `sk_test_…`, as `Authorization: Bearer <token>`.
-   **SDK:** `client.supply.list(query)`
-   **Pages:** `limit`, 1 to 500, default 100, with `next` and `after`. [Lists](/docs/platform/api-basics.md#lists) has the rule.

### Query parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `resourceId` | `string` | No | 1–256 characters. |
| `holderRef` | `string` | No | 1–256 characters. |
| `batchId` | `string` | No | 1–256 characters. |
| `status` | `string` | No | One of `"pending"`, `"active"`, `"exhausted"`, `"expired"`, or `"reversed"`. |
| `after` | `string` | No | 1–200 characters. |
| `limit` | `integer` | No | 1–500; default `100`. |

### Response

`200 OK`, with [`SupplyPage`](/docs/resourceshark/reference/supply.md#the-supplypage-object).

### Errors

-   [`invalid_request`](/docs/resourceshark/errors.md#invalid_request) (400)

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/supply?resourceId=res_01M83PPH000000000000000003&holderRef=principal%3Aexternal%3Au_maya&status=active&limit=20' \
  -H "Authorization: Bearer sk_test_…"
```

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

const client = createClient({ token: 'sk_test_…' });
const { supply } = await client.supply.list({
  resourceId: 'res_01M83PPH000000000000000003',
  holderRef: 'principal:external:u_maya',
  status: 'active',
  limit: 20,
});
```

```json title="Response"
{
  "supply": [
    {
      "resourceId": "res_01M83PPH000000000000000003",
      "scope": {
        "holderRef": "principal:external:u_maya"
      },
      "kind": "added",
      "quantity": 12,
      "expiresAt": "2026-11-29T23:00:00.000Z",
      "attributes": {
        "program": "tasting-club"
      },
      "evidence": {
        "kind": "credit_pack",
        "ref": "pack_1042"
      },
      "sourceKey": "credit-pack:1042",
      "id": "sup_01M83PPH000000000000000003",
      "remaining": 8,
      "held": 0,
      "actor": {
        "id": "key:juniper-backend"
      },
      "status": "active",
      "createdAt": "2026-11-23T09:25:00.000Z"
    }
  ]
}
```

## Get a supply entry

`GET /supply/:id`

Reads a supply entry. A caller constrained to one holder reads only its own.

-   **Who may call:** Your server, with your project’s secret key or a signed-in principal, with a user token for their own `principal:<principal>` holder.
-   **Credential:** the examples send your project’s `dev` secret key, `sk_test_…`, as `Authorization: Bearer <token>`.
-   **SDK:** `client.supply.get(id)`

### Path parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | `string` | Yes | Supply ID, `sup_…`. The `id` of a [`SupplyEntry`](/docs/resourceshark/reference/supply.md#the-supplyentry-object). |

### Response

`200 OK`, with [`SupplyGetResponse`](/docs/resourceshark/reference/supply.md#the-supplygetresponse-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/supply/sup_01M83PPH000000000000000003 \
  -H "Authorization: Bearer sk_test_…"
```

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

const client = createClient({ token: 'sk_test_…' });
const { supply } = await client.supply.get('sup_01M83PPH000000000000000003');
```

```json title="Response"
{
  "supply": {
    "resourceId": "res_01M83PPH000000000000000003",
    "scope": {
      "holderRef": "principal:external:u_maya"
    },
    "kind": "added",
    "quantity": 12,
    "expiresAt": "2026-11-29T23:00:00.000Z",
    "attributes": {
      "program": "tasting-club"
    },
    "evidence": {
      "kind": "credit_pack",
      "ref": "pack_1042"
    },
    "sourceKey": "credit-pack:1042",
    "id": "sup_01M83PPH000000000000000003",
    "remaining": 8,
    "held": 0,
    "actor": {
      "id": "key:juniper-backend"
    },
    "status": "active",
    "createdAt": "2026-11-23T09:25:00.000Z"
  }
}
```

## Reverse supply

`POST /supply/:id/reverse`

Takes the requested quantity back from a supply entry in a reversal movement. On added supply that has not started, cancels that much of what would start, with no movement. If less is available than requested, the refusal gives the available quantity. A repeat under a sourceKey already used on the resource 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.supply.reverse(id, body, { idempotencyKey })`
-   **Idempotency-Key:** required. [Retrying a write](/docs/platform/api-basics.md#retrying-a-write) has the rule.

### Path parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | `string` | Yes | Supply ID, `sup_…`. The `id` of a [`SupplyEntry`](/docs/resourceshark/reference/supply.md#the-supplyentry-object). |

### Body

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `quantity` | `number` | Yes |  |
| `evidence` | `object` | Yes |  |
| `evidence.kind` | `string` | Yes | 1–256 characters. |
| `evidence.ref` | `string` | Yes | 1–256 characters. |
| `sourceKey` | `string` | Yes | 1–200 characters. |

### Response

`200 OK`, with [`SupplyReverseResponse`](/docs/resourceshark/reference/supply.md#the-supplyreverseresponse-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/supply/sup_01M83PPH000000000000000003/reverse \
  -H "Authorization: Bearer sk_test_…" \
  -H "Idempotency-Key: reverse-credit-pack-1042" \
  -H "Content-Type: application/json" \
  -d '{
    "quantity": 2,
    "evidence": {
      "kind": "refund",
      "ref": "refund_1042"
    },
    "sourceKey": "credit-pack:1042:partial-refund"
  }'
```

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

const client = createClient({ token: 'sk_test_…' });
const { supply, movement, taken } = await client.supply.reverse(
  'sup_01M83PPH000000000000000003',
  {
    quantity: 2,
    evidence: { kind: 'refund', ref: 'refund_1042' },
    sourceKey: 'credit-pack:1042:partial-refund',
  },
  { idempotencyKey: 'reverse-credit-pack-1042' },
);
```

```json title="Response"
{
  "supply": {
    "resourceId": "res_01M83PPH000000000000000003",
    "scope": {
      "holderRef": "principal:external:u_maya"
    },
    "kind": "added",
    "quantity": 12,
    "expiresAt": "2026-11-29T23:00:00.000Z",
    "attributes": {
      "program": "tasting-club"
    },
    "evidence": {
      "kind": "credit_pack",
      "ref": "pack_1042"
    },
    "sourceKey": "credit-pack:1042",
    "id": "sup_01M83PPH000000000000000003",
    "remaining": 8,
    "held": 0,
    "actor": {
      "id": "key:juniper-backend"
    },
    "status": "active",
    "createdAt": "2026-11-23T09:25:00.000Z"
  },
  "movement": {
    "id": "mov_01M83PPH000000000000000007",
    "seq": 7,
    "resourceId": "res_01M83PPH000000000000000003",
    "scope": {
      "holderRef": "principal:external:u_maya"
    },
    "reason": "reversal",
    "supplyId": "sup_01M83PPH000000000000000003",
    "pegs": [
      {
        "supplyId": "sup_01M83PPH000000000000000003",
        "quantity": 2
      }
    ],
    "evidence": {
      "kind": "refund",
      "ref": "refund_1042"
    },
    "at": "2026-11-23T09:45:00.000Z",
    "quantity": -2,
    "before": 10,
    "after": 8,
    "actor": {
      "id": "key:juniper-backend"
    }
  },
  "taken": 2
}
```

## The SupplyResponse object

What a supply write recorded, with its movement when there is one.

| Name | Type | Present | Description |
| --- | --- | --- | --- |
| `supply` | [`SupplyEntry`](/docs/resourceshark/reference/supply.md#the-supplyentry-object) | Always |  |
| `movement` | [`Movement`](/docs/resourceshark/reference/supply.md#the-movement-object) | When set | The movement that recorded what arrived or is expected. |
| `duplicate` | `true` | When set | Set when the `sourceKey` already named this request: nothing was added again. |

```json title="The SupplyResponse object"
{
  "supply": {
    "resourceId": "res_01M83PPH000000000000000003",
    "scope": {
      "holderRef": "principal:external:u_maya"
    },
    "kind": "added",
    "quantity": 12,
    "expiresAt": "2026-11-29T23:00:00.000Z",
    "attributes": {
      "program": "tasting-club"
    },
    "evidence": {
      "kind": "credit_pack",
      "ref": "pack_1042"
    },
    "sourceKey": "credit-pack:1042",
    "id": "sup_01M83PPH000000000000000003",
    "remaining": 12,
    "held": 0,
    "actor": {
      "id": "key:juniper-backend"
    },
    "status": "active",
    "createdAt": "2026-11-23T09:25:00.000Z"
  },
  "movement": {
    "id": "mov_01M83PPH000000000000000004",
    "seq": 4,
    "resourceId": "res_01M83PPH000000000000000003",
    "scope": {
      "holderRef": "principal:external:u_maya"
    },
    "reason": "add",
    "supplyId": "sup_01M83PPH000000000000000003",
    "evidence": {
      "kind": "credit_pack",
      "ref": "pack_1042"
    },
    "at": "2026-11-23T09:25:00.000Z",
    "quantity": 12,
    "before": 0,
    "after": 12,
    "actor": {
      "id": "key:juniper-backend"
    }
  }
}
```

## The SupplyPage object

One page of supply, with the cursor for the next page when there is one.

| Name | Type | Present | Description |
| --- | --- | --- | --- |
| `supply` | [`SupplyEntry`](/docs/resourceshark/reference/supply.md#the-supplyentry-object) array | Always |  |
| `next` | `string` | When set |  |

```json title="The SupplyPage object"
{
  "supply": [
    {
      "resourceId": "res_01M83PPH000000000000000003",
      "scope": {
        "holderRef": "principal:external:u_maya"
      },
      "kind": "added",
      "quantity": 12,
      "expiresAt": "2026-11-29T23:00:00.000Z",
      "attributes": {
        "program": "tasting-club"
      },
      "evidence": {
        "kind": "credit_pack",
        "ref": "pack_1042"
      },
      "sourceKey": "credit-pack:1042",
      "id": "sup_01M83PPH000000000000000003",
      "remaining": 8,
      "held": 0,
      "actor": {
        "id": "key:juniper-backend"
      },
      "status": "active",
      "createdAt": "2026-11-23T09:25:00.000Z"
    }
  ]
}
```

## The SupplyGetResponse object

The supply entry read by ID.

| Name | Type | Present | Description |
| --- | --- | --- | --- |
| `supply` | [`SupplyEntry`](/docs/resourceshark/reference/supply.md#the-supplyentry-object) | Always |  |

```json title="The SupplyGetResponse object"
{
  "supply": {
    "resourceId": "res_01M83PPH000000000000000003",
    "scope": {
      "holderRef": "principal:external:u_maya"
    },
    "kind": "added",
    "quantity": 12,
    "expiresAt": "2026-11-29T23:00:00.000Z",
    "attributes": {
      "program": "tasting-club"
    },
    "evidence": {
      "kind": "credit_pack",
      "ref": "pack_1042"
    },
    "sourceKey": "credit-pack:1042",
    "id": "sup_01M83PPH000000000000000003",
    "remaining": 8,
    "held": 0,
    "actor": {
      "id": "key:juniper-backend"
    },
    "status": "active",
    "createdAt": "2026-11-23T09:25:00.000Z"
  }
}
```

## The SupplyReverseResponse object

What a supply reversal took back.

| Name | Type | Present | Description |
| --- | --- | --- | --- |
| `supply` | [`SupplyEntry`](/docs/resourceshark/reference/supply.md#the-supplyentry-object) | Always |  |
| `movement` | [`Movement`](/docs/resourceshark/reference/supply.md#the-movement-object) | When set | The `reversal` movement, absent when the entry had not started. |
| `taken` | `number` | Always | What was taken back. |
| `duplicate` | `true` | When set | Set when the `sourceKey` already named this request: nothing was taken again. |

```json title="The SupplyReverseResponse object"
{
  "supply": {
    "resourceId": "res_01M83PPH000000000000000003",
    "scope": {
      "holderRef": "principal:external:u_maya"
    },
    "kind": "added",
    "quantity": 12,
    "expiresAt": "2026-11-29T23:00:00.000Z",
    "attributes": {
      "program": "tasting-club"
    },
    "evidence": {
      "kind": "credit_pack",
      "ref": "pack_1042"
    },
    "sourceKey": "credit-pack:1042",
    "id": "sup_01M83PPH000000000000000003",
    "remaining": 8,
    "held": 0,
    "actor": {
      "id": "key:juniper-backend"
    },
    "status": "active",
    "createdAt": "2026-11-23T09:25:00.000Z"
  },
  "movement": {
    "id": "mov_01M83PPH000000000000000007",
    "seq": 7,
    "resourceId": "res_01M83PPH000000000000000003",
    "scope": {
      "holderRef": "principal:external:u_maya"
    },
    "reason": "reversal",
    "supplyId": "sup_01M83PPH000000000000000003",
    "pegs": [
      {
        "supplyId": "sup_01M83PPH000000000000000003",
        "quantity": 2
      }
    ],
    "evidence": {
      "kind": "refund",
      "ref": "refund_1042"
    },
    "at": "2026-11-23T09:45:00.000Z",
    "quantity": -2,
    "before": 10,
    "after": 8,
    "actor": {
      "id": "key:juniper-backend"
    }
  },
  "taken": 2
}
```

## The SupplyEntry object

What arrived or is expected, and what remains of it.

| Name | Type | Present | Description |
| --- | --- | --- | --- |
| `id` | `string` | Always | Supply ID, `sup_…`. |
| `resourceId` | `string` | Always | Resource ID, `res_…`. |
| `scope` | [`Scope`](/docs/resourceshark/reference/supply.md#the-scope-object) | Always | The scope it was added to. |
| `kind` | `string` | Always | One of `"added"`, `"expected"`, or `"output"`. |
| `quantity` | `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`. |
| `remaining` | `number` | Always | What is free to take when pegging applies. Together with held, it is what the entry still has. For expected supply it is what is still due; for added supply that has not started, what will be on hand when it does; and otherwise it is the quantity the entry was made with. Where the balance owed something when the entry became on hand, what paid it is not remaining: one whose start has come reads so whether or not anything has landed it. |
| `held` | `number` | Always | What open holds have pegged here, or zero when pegging does not apply. |
| `fulfils` | `string` | When set | The expected entry this added entry fulfils. |
| `validFrom` | `string` | When set | For expected supply, when it is due. For added supply, when it starts: set when it was added to start later than it landed. |
| `expiresAt` | `string` | When set | When what it has left stops being on hand. |
| `batchId` | `string` | When set | Batch ID, `bat_…`. |
| `attributes` | `object` | When set | The business’s own labels for this entry. ResourceShark stores them and answers with them. Each value is a `string`. |
| `drawOrder` | `number` | When set | Lower numbers are drawn first; a missing value counts as 0. |
| `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 |  |
| `status` | `string` | Always | One of `"pending"`, `"active"`, `"exhausted"`, `"expired"`, or `"reversed"`. |
| `createdAt` | `string` | Always | An ISO 8601 date and time. |

```json title="The SupplyEntry object"
{
  "resourceId": "res_01M83PPH000000000000000003",
  "scope": {
    "holderRef": "principal:external:u_maya"
  },
  "kind": "added",
  "quantity": 12,
  "expiresAt": "2026-11-29T23:00:00.000Z",
  "attributes": {
    "program": "tasting-club"
  },
  "evidence": {
    "kind": "credit_pack",
    "ref": "pack_1042"
  },
  "sourceKey": "credit-pack:1042",
  "id": "sup_01M83PPH000000000000000003",
  "remaining": 12,
  "held": 0,
  "actor": {
    "id": "key:juniper-backend"
  },
  "status": "active",
  "createdAt": "2026-11-23T09:25:00.000Z"
}
```

## The Movement object

The history of one change to a balance.

| Name | Type | Present | Description |
| --- | --- | --- | --- |
| `quantity` | `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`. |
| `before` | `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`. |
| `after` | `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`. |
| `id` | `string` | Always | Movement ID, `mov_…`. |
| `seq` | `number` | Always | The project’s movement sequence: every movement in the project, in the order they committed. |
| `resourceId` | `string` | Always | Resource ID, `res_…`. |
| `scope` | [`Scope`](/docs/resourceshark/reference/supply.md#the-scope-object) | Always |  |
| `bucketStart` | `string` | When set | The bucket it moved, for a resource whose time is counted in buckets. |
| `held` | [`QuantityChange`](/docs/resourceshark/reference/supply.md#the-quantitychange-object) | When set | How held moved, when it did. |
| `expected` | [`QuantityChange`](/docs/resourceshark/reference/supply.md#the-quantitychange-object) | When set |  |
| `owed` | `object` | When set | How what the balance owes moved, when it did. On a take, what its `pegs` don’t cover was owed. On an `add`, what paid it down left the entry at once, so the entry keeps the rest. |
| `owed.quantity` | `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`. |
| `owed.before` | `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`. |
| `owed.after` | `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`. |
| `owed.pegs` | [`Peg`](/docs/resourceshark/reference/supply.md#the-peg-object) array | When set | The supply entries whose units paid it down, and how much each paid. What came down without them was a claim’s own debt given back. |
| `reason` | `string` | Always | One of `"add"`, `"expected"`, `"hold"`, `"release"`, `"expire_hold"`, `"commit"`, `"use"`, `"settle"`, `"transfer"`, `"count"`, `"adjustment"`, `"reversal"`, `"convert_in"`, `"convert_out"`, `"expire_supply"`, `"cancel"`, or `"capacity"`. |
| `supplyId` | `string` | When set | Supply ID, `sup_…`. |
| `pegs` | [`Peg`](/docs/resourceshark/reference/supply.md#the-peg-object) array | When set | The supply entries it drew from or returned to. |
| `batchId` | `string` | When set | Set when everything it moved was from or for the same batch. |
| `transformationId` | `string` | When set | The conversion this movement was part of. |
| `claimId` | `string` | When set | Claim ID, `clm_…`. |
| `holdId` | `string` | When set | Hold ID, `hld_…`. |
| `transferId` | `string` | When set | Transfer ID, `trf_…`. |
| `reversesId` | `string` | When set | Movement ID, `mov_…`. |
| `evidence` | [`Evidence`](/docs/resourceshark/reference/supply.md#the-evidence-object) | When set |  |
| `note` | `string` | When set |  |
| `actor` | [`PrincipalRef`](/docs/resourceshark/reference/supply.md#the-principalref-object) | Always | The principal that made the change with its own credential. Your project’s secret key is `key:` and the key’s name, with no `kind`; ResourceShark’s own changes are the `service` principal `resourceshark`. |
| `onBehalfOf` | [`PrincipalRef`](/docs/resourceshark/reference/supply.md#the-principalref-object) | When set | The delegator, when the actor acted under a delegation. |
| `at` | `string` | Always | An ISO 8601 date and time. |

```json title="The Movement object"
{
  "id": "mov_01M83PPH000000000000000005",
  "seq": 5,
  "resourceId": "res_01M83PPH000000000000000003",
  "scope": {
    "holderRef": "principal:external:u_maya"
  },
  "reason": "use",
  "claimId": "clm_01M83PPH000000000000000002",
  "supplyId": "sup_01M83PPH000000000000000003",
  "pegs": [
    {
      "supplyId": "sup_01M83PPH000000000000000003",
      "quantity": 3
    }
  ],
  "evidence": {
    "kind": "tasting",
    "ref": "tasting_1042"
  },
  "at": "2026-11-23T09:30:00.000Z",
  "quantity": -3,
  "before": 12,
  "after": 9,
  "actor": {
    "id": "key:juniper-backend"
  }
}
```

## The Scope object

Where a quantity sits. Each resource says which dimensions apply: stock has places, prepaid credits have holders, and a resource with `identity: instance` has units. A resource kept by place requires a `placeId` and can carry a free-form condition label. Omitting the condition selects the unlabeled balance. A resource that tells its units apart requires an `instanceId`: each unit has a balance of its own, in one place and under one label at a time, and a line on it moves one unit.

| Name | Type | Present | Description |
| --- | --- | --- | --- |
| `placeId` | `string` | When set | Place ID, `plc_…`. |
| `condition` | `string` | When set |  |
| `holderRef` | `string` | When set | Your app’s name for the holder, such as `principal:external:u_maya`. |
| `instanceId` | `string` | When set | Instance ID, `ins_…`. |

```json title="The Scope object"
{
  "placeId": "plc_01M83PPH000000000000000001"
}
```

## The Evidence object

What a change was made for, such as `{ kind: "order", ref: "ord_…" }`.

| Name | Type | Present | Description |
| --- | --- | --- | --- |
| `kind` | `string` | Always |  |
| `ref` | `string` | Always | An opaque reference to another system’s record, such as `ord_01J…`. ResourceShark stores it and answers with it. |

```json title="The Evidence object"
{
  "kind": "checkout",
  "ref": "checkout_109"
}
```

## The PrincipalRef object

A principal that acted, with the kind it declared for itself.

| Name | Type | Present | Description |
| --- | --- | --- | --- |
| `kind` | `string` | When set | The kind a principal may declare. A principal that declared none has no `kind`. One of `"human"`, `"agent"`, or `"service"`. |
| `id` | `string` | Always |  |

```json title="The PrincipalRef object"
{
  "id": "key:juniper-backend"
}
```

## The QuantityChange object

How one of a balance’s quantities moved: signed, with the value before and after.

| Name | Type | Present | Description |
| --- | --- | --- | --- |
| `quantity` | `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`. |
| `before` | `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`. |
| `after` | `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`. |

```json title="The QuantityChange object"
{
  "quantity": -1,
  "before": 1,
  "after": 0
}
```

## The Peg object

How much a claim or movement drew from one supply entry.

| Name | Type | Present | Description |
| --- | --- | --- | --- |
| `supplyId` | `string` | Always | Supply ID, `sup_…`. |
| `quantity` | `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`. |

```json title="The Peg object"
{
  "supplyId": "sup_01M83PPH000000000000000002",
  "quantity": 500
}
```
