{
  "openapi": "3.1.1",
  "info": {
    "title": "ResourceShark API",
    "version": "v1",
    "description": "Every operation of the ResourceShark API, generated with its [API reference](https://agentpost.tools/docs/resourceshark/reference) from the code that serves it, so the two agree.\n\n- **Base URL:** every path starts with `https://api.agentpost.tools/v1/resources`.\n- **Credentials:** send one as `Authorization: Bearer <token>`. Each operation lists the ones it takes, and [Platform credentials](https://agentpost.tools/docs/platform/concepts/credentials) explains each.\n- **Idempotency:** Every write (`POST`, `PUT`, `PATCH`, `DELETE`) takes `Idempotency-Key`, except [Check availability](https://agentpost.tools/docs/resourceshark/reference/availability#check-availability), whose entries say why. A key's first answer is kept for 24 hours. It is required on [Add supply](https://agentpost.tools/docs/resourceshark/reference/supply#add-supply), [Reverse supply](https://agentpost.tools/docs/resourceshark/reference/supply#reverse-supply), [Place a hold](https://agentpost.tools/docs/resourceshark/reference/holds#place-a-hold), [Extend a hold](https://agentpost.tools/docs/resourceshark/reference/holds#extend-a-hold), [Commit a hold](https://agentpost.tools/docs/resourceshark/reference/holds#commit-a-hold), [Release a hold](https://agentpost.tools/docs/resourceshark/reference/holds#release-a-hold), [Cancel a committed hold](https://agentpost.tools/docs/resourceshark/reference/holds#cancel-a-committed-hold), [Reschedule a hold](https://agentpost.tools/docs/resourceshark/reference/holds#reschedule-a-hold), [Consume supply](https://agentpost.tools/docs/resourceshark/reference/claims#consume-supply), [Settle an estimated claim](https://agentpost.tools/docs/resourceshark/reference/claims#settle-an-estimated-claim), [Create a schedule exception](https://agentpost.tools/docs/resourceshark/reference/schedules#create-a-schedule-exception), [Transfer stock](https://agentpost.tools/docs/resourceshark/reference/stock#transfer-stock), [Record a count](https://agentpost.tools/docs/resourceshark/reference/stock#record-a-count), [Adjust stock](https://agentpost.tools/docs/resourceshark/reference/stock#adjust-stock), [Record a conversion](https://agentpost.tools/docs/resourceshark/reference/stock#record-a-conversion). [Retrying a write](https://agentpost.tools/docs/platform/api-basics#retrying-a-write) has the rule, with the codes [`idempotency_mismatch`](https://agentpost.tools/docs/resourceshark/errors#idempotency_mismatch) and [`conflict`](https://agentpost.tools/docs/resourceshark/errors#conflict) it answers with.\n- **Lists:** Every paginated list takes `limit`, 1 to 500, default 100. [List resources](https://agentpost.tools/docs/resourceshark/reference/resources#list-resources), [List places](https://agentpost.tools/docs/resourceshark/reference/places#list-places), [List instances](https://agentpost.tools/docs/resourceshark/reference/instances#list-instances), [List free instances](https://agentpost.tools/docs/resourceshark/reference/instances#list-free-instances), [List supply](https://agentpost.tools/docs/resourceshark/reference/supply#list-supply), [List batches](https://agentpost.tools/docs/resourceshark/reference/batches#list-batches), [List a holder's balances](https://agentpost.tools/docs/resourceshark/reference/availability#list-a-holders-balances), [List holds](https://agentpost.tools/docs/resourceshark/reference/holds#list-holds), and [List claims](https://agentpost.tools/docs/resourceshark/reference/claims#list-claims) page with `next` and `after`. [List movements](https://agentpost.tools/docs/resourceshark/reference/movements#list-movements) and [Read events](https://agentpost.tools/docs/resourceshark/reference/events#read-events) are feeds. [List schedule exceptions](https://agentpost.tools/docs/resourceshark/reference/schedules#list-schedule-exceptions) and [List slots](https://agentpost.tools/docs/resourceshark/reference/slots#list-slots) answer in one response. [Lists](https://agentpost.tools/docs/platform/api-basics#lists) has the rule.\n- **IDs:** Each ID starts with its kind's prefix, such as `plc_…`. [ResourceShark's ID prefixes](https://agentpost.tools/docs/resourceshark/reference#ids) lists them.\n- **Errors:** An error's `docs` link goes to its code's entry on [ResourceShark errors](https://agentpost.tools/docs/resourceshark/errors). Any operation can answer with [`unauthenticated`](https://agentpost.tools/docs/resourceshark/errors#unauthenticated), [`forbidden`](https://agentpost.tools/docs/resourceshark/errors#forbidden), or [`internal_error`](https://agentpost.tools/docs/resourceshark/errors#internal_error); each operation lists the other codes it can answer with. [Errors](https://agentpost.tools/docs/platform/api-basics#errors) describes the body.\n- **Rules every API shares:** [API basics](https://agentpost.tools/docs/platform/api-basics).",
    "termsOfService": "https://agentpost.tools/terms"
  },
  "servers": [
    {
      "url": "https://api.agentpost.tools/v1/resources"
    }
  ],
  "externalDocs": {
    "description": "The ResourceShark API reference",
    "url": "https://agentpost.tools/docs/resourceshark/reference"
  },
  "tags": [
    {
      "name": "Config",
      "description": "Read or replace the project’s versioned retention settings.",
      "externalDocs": {
        "url": "https://agentpost.tools/docs/resourceshark/reference/config"
      }
    },
    {
      "name": "Resources",
      "description": "Define what you count, how it is measured, and which scopes hold it. Read, edit, or archive a resource.",
      "externalDocs": {
        "url": "https://agentpost.tools/docs/resourceshark/reference/resources"
      }
    },
    {
      "name": "Places",
      "description": "Create, list, and edit the places where stock is kept.",
      "externalDocs": {
        "url": "https://agentpost.tools/docs/resourceshark/reference/places"
      }
    },
    {
      "name": "Instances",
      "description": "Track individual units of a resource. Set when a unit is unavailable and find units that are free for a request.",
      "externalDocs": {
        "url": "https://agentpost.tools/docs/resourceshark/reference/instances"
      }
    },
    {
      "name": "Supply",
      "description": "Record, read, and take back supply that is on hand or due.",
      "externalDocs": {
        "url": "https://agentpost.tools/docs/resourceshark/reference/supply"
      }
    },
    {
      "name": "Batches",
      "description": "Group supply entries for a resource by batch and manage their expiry.",
      "externalDocs": {
        "url": "https://agentpost.tools/docs/resourceshark/reference/batches"
      }
    },
    {
      "name": "Availability",
      "description": "Check how much a request could take, or read balances by resource, scope, or holder.",
      "externalDocs": {
        "url": "https://agentpost.tools/docs/resourceshark/reference/availability"
      }
    },
    {
      "name": "Holds",
      "description": "Reserve supply until a hold expires. Extend or release a hold, commit what it reserves, or cancel or reschedule lines where allowed.",
      "externalDocs": {
        "url": "https://agentpost.tools/docs/resourceshark/reference/holds"
      }
    },
    {
      "name": "Claims",
      "description": "Take supply, settle an estimated quantity, or read claim records.",
      "externalDocs": {
        "url": "https://agentpost.tools/docs/resourceshark/reference/claims"
      }
    },
    {
      "name": "Schedules",
      "description": "Read or set a resource’s recurring capacity, and manage dated exceptions to it.",
      "externalDocs": {
        "url": "https://agentpost.tools/docs/resourceshark/reference/schedules"
      }
    },
    {
      "name": "Slots",
      "description": "See how much capacity is held, taken, or free in each time bucket for a resource.",
      "externalDocs": {
        "url": "https://agentpost.tools/docs/resourceshark/reference/slots"
      }
    },
    {
      "name": "Stock",
      "description": "Transfer, count, adjust, or convert stock.",
      "externalDocs": {
        "url": "https://agentpost.tools/docs/resourceshark/reference/stock"
      }
    },
    {
      "name": "Movements",
      "description": "Read the movements that record changes to balances.",
      "externalDocs": {
        "url": "https://agentpost.tools/docs/resourceshark/reference/movements"
      }
    },
    {
      "name": "Reports",
      "description": "Read balance totals and sum movements by reason over a period.",
      "externalDocs": {
        "url": "https://agentpost.tools/docs/resourceshark/reference/reports"
      }
    },
    {
      "name": "Events",
      "description": "Read the project’s change feed in order from a cursor.",
      "externalDocs": {
        "url": "https://agentpost.tools/docs/resourceshark/reference/events"
      }
    }
  ],
  "paths": {
    "/config": {
      "get": {
        "operationId": "config.get",
        "summary": "Get the config",
        "description": "Reads the project’s config and its version.\n\n- **Who may call:** Your server, with your project’s secret key.",
        "tags": ["Config"],
        "externalDocs": {
          "description": "Get the config, in the API reference",
          "url": "https://agentpost.tools/docs/resourceshark/reference/config#get-the-config"
        },
        "security": [
          {
            "secretKey": []
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ConfigResponse"
                },
                "example": {
                  "config": {
                    "retention": {
                      "events": "30d",
                      "resolvedHolds": "3d"
                    },
                    "version": 1,
                    "updatedAt": "2026-11-23T08:00:00.000Z",
                    "updatedBy": "service:juniper-backend"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized, with `error.code` [`unauthenticated`](https://agentpost.tools/docs/resourceshark/errors#unauthenticated).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["unauthenticated"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden, with `error.code` [`forbidden`](https://agentpost.tools/docs/resourceshark/errors#forbidden).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["forbidden"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error, with `error.code` [`internal_error`](https://agentpost.tools/docs/resourceshark/errors#internal_error).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["internal_error"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      },
      "put": {
        "operationId": "config.put",
        "summary": "Update the config",
        "description": "Replaces the project’s config. Send the version you read in If-Match.\n\n- **Who may call:** Your server, with your project’s secret key.\n- **Idempotency-Key:** optional. ",
        "tags": ["Config"],
        "externalDocs": {
          "description": "Update the config, in the API reference",
          "url": "https://agentpost.tools/docs/resourceshark/reference/config#update-the-config"
        },
        "security": [
          {
            "secretKey": []
          }
        ],
        "parameters": [
          {
            "name": "If-Match",
            "in": "header",
            "required": true,
            "description": "Required. Send the version you read.",
            "schema": {
              "type": "string"
            },
            "example": "1"
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "A key of your choosing for this request. A retry with the same key and the same request within 24 hours answers with the first answer, while you may still make the request; the same key with a different request answers [`idempotency_mismatch`](https://agentpost.tools/docs/resourceshark/errors#idempotency_mismatch), and one whose first request is still running answers [`conflict`](https://agentpost.tools/docs/resourceshark/errors#conflict).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "retention": {
                    "type": "object",
                    "properties": {
                      "events": {
                        "type": "string",
                        "description": "A duration, such as \"10m\" or \"7d\""
                      },
                      "resolvedHolds": {
                        "type": "string",
                        "description": "A duration, such as \"10m\" or \"7d\""
                      }
                    },
                    "required": ["events", "resolvedHolds"]
                  }
                },
                "required": ["retention"],
                "additionalProperties": false
              },
              "example": {
                "retention": {
                  "events": "60d",
                  "resolvedHolds": "3d"
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ConfigResponse"
                },
                "example": {
                  "config": {
                    "retention": {
                      "events": "60d",
                      "resolvedHolds": "3d"
                    },
                    "version": 2,
                    "updatedAt": "2026-11-23T08:10:00.000Z",
                    "updatedBy": "service:juniper-backend"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad Request, with `error.code` [`invalid_request`](https://agentpost.tools/docs/resourceshark/errors#invalid_request).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["invalid_request"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized, with `error.code` [`unauthenticated`](https://agentpost.tools/docs/resourceshark/errors#unauthenticated).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["unauthenticated"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden, with `error.code` [`forbidden`](https://agentpost.tools/docs/resourceshark/errors#forbidden).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["forbidden"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "409": {
            "description": "Conflict, with `error.code` [`stale_version`](https://agentpost.tools/docs/resourceshark/errors#stale_version).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["stale_version"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "413": {
            "description": "Payload Too Large, with `error.code` [`payload_too_large`](https://agentpost.tools/docs/resourceshark/errors#payload_too_large).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["payload_too_large"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error, with `error.code` [`internal_error`](https://agentpost.tools/docs/resourceshark/errors#internal_error).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["internal_error"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/resources": {
      "post": {
        "operationId": "resources.create",
        "summary": "Create a resource",
        "description": "Creates a resource under a key unique in the project. Send both scope flags, places and holders.\n\n- **Who may call:** Your server, with your project’s secret key.\n- **Idempotency-Key:** optional. ",
        "tags": ["Resources"],
        "externalDocs": {
          "description": "Create a resource, in the API reference",
          "url": "https://agentpost.tools/docs/resourceshark/reference/resources#create-a-resource"
        },
        "security": [
          {
            "secretKey": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "A key of your choosing for this request. A retry with the same key and the same request within 24 hours answers with the first answer, while you may still make the request; the same key with a different request answers [`idempotency_mismatch`](https://agentpost.tools/docs/resourceshark/errors#idempotency_mismatch), and one whose first request is still running answers [`conflict`](https://agentpost.tools/docs/resourceshark/errors#conflict).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "key": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 200
                  },
                  "name": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 200
                  },
                  "unit": {
                    "type": "object",
                    "properties": {
                      "code": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 40
                      },
                      "singular": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 80
                      },
                      "plural": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 80
                      },
                      "precision": {
                        "type": "integer",
                        "minimum": 0,
                        "maximum": 6
                      }
                    },
                    "required": ["code", "singular", "plural", "precision"]
                  },
                  "settings": {
                    "type": "object",
                    "properties": {
                      "time": {
                        "type": "string",
                        "enum": ["none", "buckets"]
                      },
                      "bucket": {
                        "oneOf": [
                          {
                            "type": "object",
                            "properties": {
                              "size": {
                                "type": "string",
                                "const": "step"
                              },
                              "stepMinutes": {
                                "type": "integer",
                                "exclusiveMinimum": 0,
                                "maximum": 1440
                              },
                              "timeZone": {
                                "type": "string"
                              }
                            },
                            "required": ["size", "stepMinutes", "timeZone"],
                            "additionalProperties": false
                          },
                          {
                            "type": "object",
                            "properties": {
                              "size": {
                                "type": "string",
                                "enum": ["day", "month"]
                              },
                              "stepMinutes": {
                                "type": "integer",
                                "exclusiveMinimum": 0,
                                "maximum": 1440
                              },
                              "timeZone": {
                                "type": "string"
                              }
                            },
                            "required": ["size", "timeZone"],
                            "additionalProperties": false
                          }
                        ]
                      },
                      "identity": {
                        "type": "string",
                        "enum": ["count", "instance"]
                      },
                      "supplyExpiry": {
                        "type": "string",
                        "enum": ["none", "expiring"]
                      }
                    },
                    "required": ["time", "identity", "supplyExpiry"],
                    "additionalProperties": false
                  },
                  "scope": {
                    "type": "object",
                    "properties": {
                      "places": {
                        "type": "boolean"
                      },
                      "holders": {
                        "type": "boolean"
                      }
                    },
                    "required": ["places", "holders"],
                    "additionalProperties": false
                  },
                  "tracking": {
                    "type": "string",
                    "enum": ["none", "batch"]
                  },
                  "shortage": {
                    "type": "string",
                    "enum": ["deny", "backorder", "negative"]
                  },
                  "capacity": {
                    "type": "number"
                  },
                  "tags": {
                    "default": [],
                    "type": "array",
                    "items": {
                      "type": "string",
                      "minLength": 1,
                      "maxLength": 200
                    }
                  },
                  "attributes": {
                    "type": "object",
                    "propertyNames": {
                      "type": "string",
                      "minLength": 1,
                      "maxLength": 64,
                      "pattern": "^[A-Za-z0-9_-]+$"
                    },
                    "additionalProperties": {
                      "type": "string",
                      "maxLength": 200
                    }
                  },
                  "contentRef": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 256
                  },
                  "externalRef": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 256
                  }
                },
                "required": [
                  "key",
                  "name",
                  "unit",
                  "settings",
                  "scope",
                  "tracking",
                  "shortage"
                ],
                "additionalProperties": false
              },
              "example": {
                "key": "roasted-coffee",
                "name": "Roasted coffee",
                "unit": {
                  "code": "g",
                  "singular": "gram",
                  "plural": "grams",
                  "precision": 0
                },
                "settings": {
                  "time": "none",
                  "identity": "count",
                  "supplyExpiry": "expiring"
                },
                "scope": {
                  "places": true,
                  "holders": false
                },
                "tracking": "batch",
                "shortage": "deny",
                "tags": ["coffee"]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ResourceResponse"
                },
                "example": {
                  "resource": {
                    "key": "roasted-coffee",
                    "name": "Roasted coffee",
                    "unit": {
                      "code": "g",
                      "singular": "gram",
                      "plural": "grams",
                      "precision": 0
                    },
                    "settings": {
                      "time": "none",
                      "identity": "count",
                      "supplyExpiry": "expiring"
                    },
                    "scope": {
                      "places": true,
                      "holders": false
                    },
                    "tracking": "batch",
                    "shortage": "deny",
                    "tags": ["coffee"],
                    "id": "res_01M83PPH000000000000000001",
                    "version": 1
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad Request, with `error.code` [`invalid_request`](https://agentpost.tools/docs/resourceshark/errors#invalid_request).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["invalid_request"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized, with `error.code` [`unauthenticated`](https://agentpost.tools/docs/resourceshark/errors#unauthenticated).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["unauthenticated"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden, with `error.code` [`forbidden`](https://agentpost.tools/docs/resourceshark/errors#forbidden).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["forbidden"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "409": {
            "description": "Conflict, with `error.code` [`key_in_use`](https://agentpost.tools/docs/resourceshark/errors#key_in_use).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["key_in_use"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "413": {
            "description": "Payload Too Large, with `error.code` [`payload_too_large`](https://agentpost.tools/docs/resourceshark/errors#payload_too_large).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["payload_too_large"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "422": {
            "description": "Unprocessable Entity, with `error.code` [`invalid_quantity`](https://agentpost.tools/docs/resourceshark/errors#invalid_quantity).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["invalid_quantity"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error, with `error.code` [`internal_error`](https://agentpost.tools/docs/resourceshark/errors#internal_error).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["internal_error"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      },
      "get": {
        "operationId": "resources.list",
        "summary": "List resources",
        "description": "Lists active resources, optionally filtered by tag, key, or both.\n\n- **Who may call:** Your server, with your project’s secret key.\n- **Pages:** `limit`, 1 to 500, default 100, with `next` and `after`. [Lists](https://agentpost.tools/docs/platform/api-basics#lists) has the rule.",
        "tags": ["Resources"],
        "externalDocs": {
          "description": "List resources, in the API reference",
          "url": "https://agentpost.tools/docs/resourceshark/reference/resources#list-resources"
        },
        "security": [
          {
            "secretKey": []
          }
        ],
        "parameters": [
          {
            "name": "after",
            "in": "query",
            "required": false,
            "description": "1–200 characters.",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 200
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "1–500; default `100`.",
            "schema": {
              "default": 100,
              "type": "integer",
              "exclusiveMinimum": 0,
              "maximum": 500
            },
            "example": 20
          },
          {
            "name": "key",
            "in": "query",
            "required": false,
            "description": "1–200 characters.",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 200
            }
          },
          {
            "name": "tag",
            "in": "query",
            "required": false,
            "description": "1–200 characters.",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 200
            },
            "example": "coffee"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ResourcesPage"
                },
                "example": {
                  "resources": [
                    {
                      "key": "roasted-coffee",
                      "name": "Juniper roasted coffee",
                      "unit": {
                        "code": "g",
                        "singular": "gram",
                        "plural": "grams",
                        "precision": 0
                      },
                      "settings": {
                        "time": "none",
                        "identity": "count",
                        "supplyExpiry": "expiring"
                      },
                      "scope": {
                        "places": true,
                        "holders": false
                      },
                      "tracking": "batch",
                      "shortage": "deny",
                      "tags": ["coffee"],
                      "id": "res_01M83PPH000000000000000001",
                      "version": 2
                    },
                    {
                      "key": "green-coffee",
                      "name": "Green coffee",
                      "unit": {
                        "code": "g",
                        "singular": "gram",
                        "plural": "grams",
                        "precision": 0
                      },
                      "settings": {
                        "time": "none",
                        "identity": "count",
                        "supplyExpiry": "none"
                      },
                      "scope": {
                        "places": true,
                        "holders": false
                      },
                      "tracking": "none",
                      "shortage": "deny",
                      "tags": ["coffee"],
                      "id": "res_01M83PPH000000000000000002",
                      "version": 1
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad Request, with `error.code` [`invalid_request`](https://agentpost.tools/docs/resourceshark/errors#invalid_request).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["invalid_request"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized, with `error.code` [`unauthenticated`](https://agentpost.tools/docs/resourceshark/errors#unauthenticated).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["unauthenticated"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden, with `error.code` [`forbidden`](https://agentpost.tools/docs/resourceshark/errors#forbidden).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["forbidden"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error, with `error.code` [`internal_error`](https://agentpost.tools/docs/resourceshark/errors#internal_error).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["internal_error"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/resources/{id}": {
      "get": {
        "operationId": "resources.get",
        "summary": "Get a resource",
        "description": "Reads a resource by ID, including an archived resource.\n\n- **Who may call:** Your server, with your project’s secret key.",
        "tags": ["Resources"],
        "externalDocs": {
          "description": "Get a resource, in the API reference",
          "url": "https://agentpost.tools/docs/resourceshark/reference/resources#get-a-resource"
        },
        "security": [
          {
            "secretKey": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Resource ID, `res_…`. The `id` of a [`Resource`](https://agentpost.tools/docs/resourceshark/reference/resources#the-resource-object).",
            "schema": {
              "type": "string"
            },
            "example": "res_01M83PPH000000000000000001"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ResourceResponse"
                },
                "example": {
                  "resource": {
                    "key": "roasted-coffee",
                    "name": "Juniper roasted coffee",
                    "unit": {
                      "code": "g",
                      "singular": "gram",
                      "plural": "grams",
                      "precision": 0
                    },
                    "settings": {
                      "time": "none",
                      "identity": "count",
                      "supplyExpiry": "expiring"
                    },
                    "scope": {
                      "places": true,
                      "holders": false
                    },
                    "tracking": "batch",
                    "shortage": "deny",
                    "tags": ["coffee"],
                    "id": "res_01M83PPH000000000000000001",
                    "version": 2
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized, with `error.code` [`unauthenticated`](https://agentpost.tools/docs/resourceshark/errors#unauthenticated).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["unauthenticated"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden, with `error.code` [`forbidden`](https://agentpost.tools/docs/resourceshark/errors#forbidden).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["forbidden"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Not Found, with `error.code` [`not_found`](https://agentpost.tools/docs/resourceshark/errors#not_found).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["not_found"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error, with `error.code` [`internal_error`](https://agentpost.tools/docs/resourceshark/errors#internal_error).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["internal_error"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      },
      "patch": {
        "operationId": "resources.patch",
        "summary": "Update a resource",
        "description": "Edits an active resource at the version in If-Match. The first supply, stock write, claim, schedule save, or exception save locks the settings, unit code and precision, scope, and tracking. A change to a bucketed resource’s capacity lands whatever is already held or taken, and answers with overCapacity: the buckets now over it, with the claims in each.\n\n- **Who may call:** Your server, with your project’s secret key.\n- **Idempotency-Key:** optional. ",
        "tags": ["Resources"],
        "externalDocs": {
          "description": "Update a resource, in the API reference",
          "url": "https://agentpost.tools/docs/resourceshark/reference/resources#update-a-resource"
        },
        "security": [
          {
            "secretKey": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Resource ID, `res_…`. The `id` of a [`Resource`](https://agentpost.tools/docs/resourceshark/reference/resources#the-resource-object).",
            "schema": {
              "type": "string"
            },
            "example": "res_01M83PPH000000000000000001"
          },
          {
            "name": "If-Match",
            "in": "header",
            "required": true,
            "description": "Required. Send the version you read.",
            "schema": {
              "type": "string"
            },
            "example": "1"
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "A key of your choosing for this request. A retry with the same key and the same request within 24 hours answers with the first answer, while you may still make the request; the same key with a different request answers [`idempotency_mismatch`](https://agentpost.tools/docs/resourceshark/errors#idempotency_mismatch), and one whose first request is still running answers [`conflict`](https://agentpost.tools/docs/resourceshark/errors#conflict).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "key": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 200
                  },
                  "name": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 200
                  },
                  "unit": {
                    "type": "object",
                    "properties": {
                      "code": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 40
                      },
                      "singular": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 80
                      },
                      "plural": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 80
                      },
                      "precision": {
                        "type": "integer",
                        "minimum": 0,
                        "maximum": 6
                      }
                    }
                  },
                  "settings": {
                    "type": "object",
                    "properties": {
                      "time": {
                        "type": "string",
                        "enum": ["none", "buckets"]
                      },
                      "bucket": {
                        "anyOf": [
                          {
                            "oneOf": [
                              {
                                "type": "object",
                                "properties": {
                                  "size": {
                                    "type": "string",
                                    "const": "step"
                                  },
                                  "stepMinutes": {
                                    "type": "integer",
                                    "exclusiveMinimum": 0,
                                    "maximum": 1440
                                  },
                                  "timeZone": {
                                    "type": "string"
                                  }
                                },
                                "required": ["size", "stepMinutes", "timeZone"],
                                "additionalProperties": false
                              },
                              {
                                "type": "object",
                                "properties": {
                                  "size": {
                                    "type": "string",
                                    "enum": ["day", "month"]
                                  },
                                  "stepMinutes": {
                                    "type": "integer",
                                    "exclusiveMinimum": 0,
                                    "maximum": 1440
                                  },
                                  "timeZone": {
                                    "type": "string"
                                  }
                                },
                                "required": ["size", "timeZone"],
                                "additionalProperties": false
                              }
                            ]
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "identity": {
                        "type": "string",
                        "enum": ["count", "instance"]
                      },
                      "supplyExpiry": {
                        "type": "string",
                        "enum": ["none", "expiring"]
                      }
                    },
                    "additionalProperties": false
                  },
                  "scope": {
                    "type": "object",
                    "properties": {
                      "places": {
                        "type": "boolean"
                      },
                      "holders": {
                        "type": "boolean"
                      }
                    },
                    "additionalProperties": false
                  },
                  "tracking": {
                    "type": "string",
                    "enum": ["none", "batch"]
                  },
                  "shortage": {
                    "type": "string",
                    "enum": ["deny", "backorder", "negative"]
                  },
                  "capacity": {
                    "type": ["number", "null"]
                  },
                  "tags": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "minLength": 1,
                      "maxLength": 200
                    }
                  },
                  "attributes": {
                    "anyOf": [
                      {
                        "type": "object",
                        "propertyNames": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 64,
                          "pattern": "^[A-Za-z0-9_-]+$"
                        },
                        "additionalProperties": {
                          "type": "string",
                          "maxLength": 200
                        }
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "contentRef": {
                    "anyOf": [
                      {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 256
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "externalRef": {
                    "anyOf": [
                      {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 256
                      },
                      {
                        "type": "null"
                      }
                    ]
                  }
                },
                "additionalProperties": false
              },
              "example": {
                "name": "Juniper roasted coffee"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ResourceResponse"
                },
                "example": {
                  "resource": {
                    "key": "roasted-coffee",
                    "name": "Juniper roasted coffee",
                    "unit": {
                      "code": "g",
                      "singular": "gram",
                      "plural": "grams",
                      "precision": 0
                    },
                    "settings": {
                      "time": "none",
                      "identity": "count",
                      "supplyExpiry": "expiring"
                    },
                    "scope": {
                      "places": true,
                      "holders": false
                    },
                    "tracking": "batch",
                    "shortage": "deny",
                    "tags": ["coffee"],
                    "id": "res_01M83PPH000000000000000001",
                    "version": 2
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad Request, with `error.code` [`invalid_request`](https://agentpost.tools/docs/resourceshark/errors#invalid_request).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["invalid_request"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized, with `error.code` [`unauthenticated`](https://agentpost.tools/docs/resourceshark/errors#unauthenticated).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["unauthenticated"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden, with `error.code` [`forbidden`](https://agentpost.tools/docs/resourceshark/errors#forbidden).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["forbidden"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Not Found, with `error.code` [`not_found`](https://agentpost.tools/docs/resourceshark/errors#not_found).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["not_found"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "409": {
            "description": "Conflict, with `error.code` [`key_in_use`](https://agentpost.tools/docs/resourceshark/errors#key_in_use), [`stale_version`](https://agentpost.tools/docs/resourceshark/errors#stale_version), or [`settings_locked`](https://agentpost.tools/docs/resourceshark/errors#settings_locked).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": [
                                "key_in_use",
                                "stale_version",
                                "settings_locked"
                              ]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "413": {
            "description": "Payload Too Large, with `error.code` [`payload_too_large`](https://agentpost.tools/docs/resourceshark/errors#payload_too_large).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["payload_too_large"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "422": {
            "description": "Unprocessable Entity, with `error.code` [`invalid_quantity`](https://agentpost.tools/docs/resourceshark/errors#invalid_quantity).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["invalid_quantity"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error, with `error.code` [`internal_error`](https://agentpost.tools/docs/resourceshark/errors#internal_error).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["internal_error"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/resources/{id}/archive": {
      "post": {
        "operationId": "resources.archive",
        "summary": "Archive a resource",
        "description": "Archives a resource, keeping its key and making it read-only.\n\n- **Who may call:** Your server, with your project’s secret key.\n- **Idempotency-Key:** optional. ",
        "tags": ["Resources"],
        "externalDocs": {
          "description": "Archive a resource, in the API reference",
          "url": "https://agentpost.tools/docs/resourceshark/reference/resources#archive-a-resource"
        },
        "security": [
          {
            "secretKey": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Resource ID, `res_…`. The `id` of a [`Resource`](https://agentpost.tools/docs/resourceshark/reference/resources#the-resource-object).",
            "schema": {
              "type": "string"
            },
            "example": "res_01M83PPH000000000000000002"
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "A key of your choosing for this request. A retry with the same key and the same request within 24 hours answers with the first answer, while you may still make the request; the same key with a different request answers [`idempotency_mismatch`](https://agentpost.tools/docs/resourceshark/errors#idempotency_mismatch), and one whose first request is still running answers [`conflict`](https://agentpost.tools/docs/resourceshark/errors#conflict).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ResourceResponse"
                },
                "example": {
                  "resource": {
                    "key": "green-coffee",
                    "name": "Green coffee",
                    "unit": {
                      "code": "g",
                      "singular": "gram",
                      "plural": "grams",
                      "precision": 0
                    },
                    "settings": {
                      "time": "none",
                      "identity": "count",
                      "supplyExpiry": "none"
                    },
                    "scope": {
                      "places": true,
                      "holders": false
                    },
                    "tracking": "none",
                    "shortage": "deny",
                    "tags": ["coffee"],
                    "id": "res_01M83PPH000000000000000002",
                    "version": 2,
                    "archivedAt": "2026-11-27T17:00:00.000Z"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized, with `error.code` [`unauthenticated`](https://agentpost.tools/docs/resourceshark/errors#unauthenticated).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["unauthenticated"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden, with `error.code` [`forbidden`](https://agentpost.tools/docs/resourceshark/errors#forbidden).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["forbidden"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Not Found, with `error.code` [`not_found`](https://agentpost.tools/docs/resourceshark/errors#not_found).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["not_found"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error, with `error.code` [`internal_error`](https://agentpost.tools/docs/resourceshark/errors#internal_error).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["internal_error"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/places": {
      "post": {
        "operationId": "places.create",
        "summary": "Create a place",
        "description": "Creates a place.\n\n- **Who may call:** Your server, with your project’s secret key.\n- **Idempotency-Key:** optional. ",
        "tags": ["Places"],
        "externalDocs": {
          "description": "Create a place, in the API reference",
          "url": "https://agentpost.tools/docs/resourceshark/reference/places#create-a-place"
        },
        "security": [
          {
            "secretKey": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "A key of your choosing for this request. A retry with the same key and the same request within 24 hours answers with the first answer, while you may still make the request; the same key with a different request answers [`idempotency_mismatch`](https://agentpost.tools/docs/resourceshark/errors#idempotency_mismatch), and one whose first request is still running answers [`conflict`](https://agentpost.tools/docs/resourceshark/errors#conflict).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "key": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 200
                  },
                  "name": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 200
                  },
                  "attributes": {
                    "type": "object",
                    "propertyNames": {
                      "type": "string",
                      "minLength": 1,
                      "maxLength": 64,
                      "pattern": "^[A-Za-z0-9_-]+$"
                    },
                    "additionalProperties": {
                      "type": "string",
                      "maxLength": 200
                    }
                  }
                },
                "required": ["key", "name"],
                "additionalProperties": false
              },
              "example": {
                "key": "roastery",
                "name": "Juniper Roastery"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PlaceResponse"
                },
                "example": {
                  "place": {
                    "key": "roastery",
                    "name": "Juniper Roastery",
                    "id": "plc_01M83PPH000000000000000001"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad Request, with `error.code` [`invalid_request`](https://agentpost.tools/docs/resourceshark/errors#invalid_request).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["invalid_request"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized, with `error.code` [`unauthenticated`](https://agentpost.tools/docs/resourceshark/errors#unauthenticated).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["unauthenticated"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden, with `error.code` [`forbidden`](https://agentpost.tools/docs/resourceshark/errors#forbidden).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["forbidden"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "409": {
            "description": "Conflict, with `error.code` [`key_in_use`](https://agentpost.tools/docs/resourceshark/errors#key_in_use).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["key_in_use"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "413": {
            "description": "Payload Too Large, with `error.code` [`payload_too_large`](https://agentpost.tools/docs/resourceshark/errors#payload_too_large).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["payload_too_large"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error, with `error.code` [`internal_error`](https://agentpost.tools/docs/resourceshark/errors#internal_error).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["internal_error"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      },
      "get": {
        "operationId": "places.list",
        "summary": "List places",
        "description": "Lists the places in the project.\n\n- **Who may call:** Your server, with your project’s secret key.\n- **Pages:** `limit`, 1 to 500, default 100, with `next` and `after`. [Lists](https://agentpost.tools/docs/platform/api-basics#lists) has the rule.",
        "tags": ["Places"],
        "externalDocs": {
          "description": "List places, in the API reference",
          "url": "https://agentpost.tools/docs/resourceshark/reference/places#list-places"
        },
        "security": [
          {
            "secretKey": []
          }
        ],
        "parameters": [
          {
            "name": "after",
            "in": "query",
            "required": false,
            "description": "1–200 characters.",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 200
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "1–500; default `100`.",
            "schema": {
              "default": 100,
              "type": "integer",
              "exclusiveMinimum": 0,
              "maximum": 500
            },
            "example": 20
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PlacesPage"
                },
                "example": {
                  "places": [
                    {
                      "key": "roastery",
                      "name": "Juniper Roastery",
                      "id": "plc_01M83PPH000000000000000001"
                    },
                    {
                      "id": "plc_01M83PPH000000000000000002",
                      "key": "market-stall",
                      "name": "Juniper Market Stall"
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad Request, with `error.code` [`invalid_request`](https://agentpost.tools/docs/resourceshark/errors#invalid_request).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["invalid_request"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized, with `error.code` [`unauthenticated`](https://agentpost.tools/docs/resourceshark/errors#unauthenticated).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["unauthenticated"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden, with `error.code` [`forbidden`](https://agentpost.tools/docs/resourceshark/errors#forbidden).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["forbidden"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error, with `error.code` [`internal_error`](https://agentpost.tools/docs/resourceshark/errors#internal_error).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["internal_error"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/places/{id}": {
      "patch": {
        "operationId": "places.patch",
        "summary": "Update a place",
        "description": "Edits a place.\n\n- **Who may call:** Your server, with your project’s secret key.\n- **Idempotency-Key:** optional. ",
        "tags": ["Places"],
        "externalDocs": {
          "description": "Update a place, in the API reference",
          "url": "https://agentpost.tools/docs/resourceshark/reference/places#update-a-place"
        },
        "security": [
          {
            "secretKey": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Place ID, `plc_…`. The `id` of a [`Place`](https://agentpost.tools/docs/resourceshark/reference/places#the-place-object).",
            "schema": {
              "type": "string"
            },
            "example": "plc_01M83PPH000000000000000002"
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "A key of your choosing for this request. A retry with the same key and the same request within 24 hours answers with the first answer, while you may still make the request; the same key with a different request answers [`idempotency_mismatch`](https://agentpost.tools/docs/resourceshark/errors#idempotency_mismatch), and one whose first request is still running answers [`conflict`](https://agentpost.tools/docs/resourceshark/errors#conflict).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "key": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 200
                  },
                  "name": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 200
                  },
                  "attributes": {
                    "anyOf": [
                      {
                        "type": "object",
                        "propertyNames": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 64,
                          "pattern": "^[A-Za-z0-9_-]+$"
                        },
                        "additionalProperties": {
                          "type": "string",
                          "maxLength": 200
                        }
                      },
                      {
                        "type": "null"
                      }
                    ]
                  }
                },
                "additionalProperties": false
              },
              "example": {
                "name": "Juniper Market Stall"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PlaceResponse"
                },
                "example": {
                  "place": {
                    "id": "plc_01M83PPH000000000000000002",
                    "key": "market-stall",
                    "name": "Juniper Market Stall"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad Request, with `error.code` [`invalid_request`](https://agentpost.tools/docs/resourceshark/errors#invalid_request).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["invalid_request"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized, with `error.code` [`unauthenticated`](https://agentpost.tools/docs/resourceshark/errors#unauthenticated).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["unauthenticated"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden, with `error.code` [`forbidden`](https://agentpost.tools/docs/resourceshark/errors#forbidden).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["forbidden"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Not Found, with `error.code` [`not_found`](https://agentpost.tools/docs/resourceshark/errors#not_found).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["not_found"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "409": {
            "description": "Conflict, with `error.code` [`key_in_use`](https://agentpost.tools/docs/resourceshark/errors#key_in_use).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["key_in_use"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "413": {
            "description": "Payload Too Large, with `error.code` [`payload_too_large`](https://agentpost.tools/docs/resourceshark/errors#payload_too_large).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["payload_too_large"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error, with `error.code` [`internal_error`](https://agentpost.tools/docs/resourceshark/errors#internal_error).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["internal_error"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/resources/{id}/instances": {
      "post": {
        "operationId": "instances.create",
        "summary": "Create an instance",
        "description": "Creates an instance with a code unique within its resource.\n\n- **Who may call:** Your server, with your project’s secret key.\n- **Idempotency-Key:** optional. ",
        "tags": ["Instances"],
        "externalDocs": {
          "description": "Create an instance, in the API reference",
          "url": "https://agentpost.tools/docs/resourceshark/reference/instances#create-an-instance"
        },
        "security": [
          {
            "secretKey": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Resource ID, `res_…`. The `id` of a [`Resource`](https://agentpost.tools/docs/resourceshark/reference/resources#the-resource-object).",
            "schema": {
              "type": "string"
            },
            "example": "res_01M83PPH000000000000000004"
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "A key of your choosing for this request. A retry with the same key and the same request within 24 hours answers with the first answer, while you may still make the request; the same key with a different request answers [`idempotency_mismatch`](https://agentpost.tools/docs/resourceshark/errors#idempotency_mismatch), and one whose first request is still running answers [`conflict`](https://agentpost.tools/docs/resourceshark/errors#conflict).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "code": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 200
                  },
                  "status": {
                    "type": "string",
                    "enum": ["active", "retired"]
                  },
                  "unavailable": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "start": {
                          "type": "string",
                          "format": "date-time"
                        },
                        "end": {
                          "type": "string",
                          "format": "date-time"
                        }
                      },
                      "required": ["start", "end"]
                    }
                  },
                  "attributes": {
                    "type": "object",
                    "propertyNames": {
                      "type": "string",
                      "minLength": 1,
                      "maxLength": 64,
                      "pattern": "^[A-Za-z0-9_-]+$"
                    },
                    "additionalProperties": {
                      "type": "string",
                      "maxLength": 200
                    }
                  }
                },
                "required": ["code", "status"],
                "additionalProperties": false
              },
              "example": {
                "code": "Court 1",
                "status": "active"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InstanceResponse"
                },
                "example": {
                  "instance": {
                    "code": "Court 1",
                    "status": "active",
                    "id": "ins_01M83PPH000000000000000001",
                    "resourceId": "res_01M83PPH000000000000000004"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad Request, with `error.code` [`invalid_request`](https://agentpost.tools/docs/resourceshark/errors#invalid_request).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["invalid_request"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized, with `error.code` [`unauthenticated`](https://agentpost.tools/docs/resourceshark/errors#unauthenticated).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["unauthenticated"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden, with `error.code` [`forbidden`](https://agentpost.tools/docs/resourceshark/errors#forbidden).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["forbidden"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Not Found, with `error.code` [`not_found`](https://agentpost.tools/docs/resourceshark/errors#not_found).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["not_found"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "409": {
            "description": "Conflict, with `error.code` [`key_in_use`](https://agentpost.tools/docs/resourceshark/errors#key_in_use).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["key_in_use"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "413": {
            "description": "Payload Too Large, with `error.code` [`payload_too_large`](https://agentpost.tools/docs/resourceshark/errors#payload_too_large).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["payload_too_large"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error, with `error.code` [`internal_error`](https://agentpost.tools/docs/resourceshark/errors#internal_error).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["internal_error"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      },
      "get": {
        "operationId": "instances.list",
        "summary": "List instances",
        "description": "Lists the resource’s instances in ID order, or the one with the code sent.\n\n- **Who may call:** Your server, with your project’s secret key.\n- **Pages:** `limit`, 1 to 500, default 100, with `next` and `after`. [Lists](https://agentpost.tools/docs/platform/api-basics#lists) has the rule.",
        "tags": ["Instances"],
        "externalDocs": {
          "description": "List instances, in the API reference",
          "url": "https://agentpost.tools/docs/resourceshark/reference/instances#list-instances"
        },
        "security": [
          {
            "secretKey": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Resource ID, `res_…`. The `id` of a [`Resource`](https://agentpost.tools/docs/resourceshark/reference/resources#the-resource-object).",
            "schema": {
              "type": "string"
            },
            "example": "res_01M83PPH000000000000000004"
          },
          {
            "name": "after",
            "in": "query",
            "required": false,
            "description": "1–200 characters.",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 200
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "1–500; default `100`.",
            "schema": {
              "default": 100,
              "type": "integer",
              "exclusiveMinimum": 0,
              "maximum": 500
            },
            "example": 20
          },
          {
            "name": "code",
            "in": "query",
            "required": false,
            "description": "1–200 characters.",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 200
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InstancesPage"
                },
                "example": {
                  "instances": [
                    {
                      "code": "Court 1",
                      "status": "active",
                      "id": "ins_01M83PPH000000000000000001",
                      "resourceId": "res_01M83PPH000000000000000004"
                    },
                    {
                      "code": "Court 2",
                      "status": "active",
                      "id": "ins_01M83PPH000000000000000002",
                      "resourceId": "res_01M83PPH000000000000000004",
                      "unavailable": [
                        {
                          "start": "2026-11-23T20:00:00.000Z",
                          "end": "2026-11-23T21:00:00.000Z"
                        }
                      ]
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad Request, with `error.code` [`invalid_request`](https://agentpost.tools/docs/resourceshark/errors#invalid_request).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["invalid_request"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized, with `error.code` [`unauthenticated`](https://agentpost.tools/docs/resourceshark/errors#unauthenticated).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["unauthenticated"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden, with `error.code` [`forbidden`](https://agentpost.tools/docs/resourceshark/errors#forbidden).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["forbidden"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Not Found, with `error.code` [`not_found`](https://agentpost.tools/docs/resourceshark/errors#not_found).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["not_found"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error, with `error.code` [`internal_error`](https://agentpost.tools/docs/resourceshark/errors#internal_error).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["internal_error"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/resources/{id}/instances/{iid}": {
      "patch": {
        "operationId": "instances.patch",
        "summary": "Update an instance",
        "description": "Edits an instance, including its status and the spans it is unavailable. When its resource is bucketed, a change to either lands whatever is already held or taken, and answers with overCapacity: the buckets now over capacity, with the claims in each.\n\n- **Who may call:** Your server, with your project’s secret key.\n- **Idempotency-Key:** optional. ",
        "tags": ["Instances"],
        "externalDocs": {
          "description": "Update an instance, in the API reference",
          "url": "https://agentpost.tools/docs/resourceshark/reference/instances#update-an-instance"
        },
        "security": [
          {
            "secretKey": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Resource ID, `res_…`. The `id` of a [`Resource`](https://agentpost.tools/docs/resourceshark/reference/resources#the-resource-object).",
            "schema": {
              "type": "string"
            },
            "example": "res_01M83PPH000000000000000004"
          },
          {
            "name": "iid",
            "in": "path",
            "required": true,
            "description": "Instance ID, `ins_…`. The `id` of a [`Instance`](https://agentpost.tools/docs/resourceshark/reference/instances#the-instance-object).",
            "schema": {
              "type": "string"
            },
            "example": "ins_01M83PPH000000000000000002"
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "A key of your choosing for this request. A retry with the same key and the same request within 24 hours answers with the first answer, while you may still make the request; the same key with a different request answers [`idempotency_mismatch`](https://agentpost.tools/docs/resourceshark/errors#idempotency_mismatch), and one whose first request is still running answers [`conflict`](https://agentpost.tools/docs/resourceshark/errors#conflict).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "code": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 200
                  },
                  "status": {
                    "type": "string",
                    "enum": ["active", "retired"]
                  },
                  "unavailable": {
                    "anyOf": [
                      {
                        "type": "array",
                        "items": {
                          "type": "object",
                          "properties": {
                            "start": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "end": {
                              "type": "string",
                              "format": "date-time"
                            }
                          },
                          "required": ["start", "end"]
                        }
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "attributes": {
                    "anyOf": [
                      {
                        "type": "object",
                        "propertyNames": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 64,
                          "pattern": "^[A-Za-z0-9_-]+$"
                        },
                        "additionalProperties": {
                          "type": "string",
                          "maxLength": 200
                        }
                      },
                      {
                        "type": "null"
                      }
                    ]
                  }
                },
                "additionalProperties": false
              },
              "example": {
                "unavailable": [
                  {
                    "start": "2026-11-23T20:00:00.000Z",
                    "end": "2026-11-23T21:00:00.000Z"
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InstanceResponse"
                },
                "example": {
                  "instance": {
                    "code": "Court 2",
                    "status": "active",
                    "id": "ins_01M83PPH000000000000000002",
                    "resourceId": "res_01M83PPH000000000000000004",
                    "unavailable": [
                      {
                        "start": "2026-11-23T20:00:00.000Z",
                        "end": "2026-11-23T21:00:00.000Z"
                      }
                    ]
                  },
                  "overCapacity": {
                    "buckets": [],
                    "more": false
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad Request, with `error.code` [`invalid_request`](https://agentpost.tools/docs/resourceshark/errors#invalid_request).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["invalid_request"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized, with `error.code` [`unauthenticated`](https://agentpost.tools/docs/resourceshark/errors#unauthenticated).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["unauthenticated"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden, with `error.code` [`forbidden`](https://agentpost.tools/docs/resourceshark/errors#forbidden).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["forbidden"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Not Found, with `error.code` [`not_found`](https://agentpost.tools/docs/resourceshark/errors#not_found).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["not_found"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "409": {
            "description": "Conflict, with `error.code` [`key_in_use`](https://agentpost.tools/docs/resourceshark/errors#key_in_use).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["key_in_use"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "413": {
            "description": "Payload Too Large, with `error.code` [`payload_too_large`](https://agentpost.tools/docs/resourceshark/errors#payload_too_large).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["payload_too_large"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error, with `error.code` [`internal_error`](https://agentpost.tools/docs/resourceshark/errors#internal_error).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["internal_error"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/resources/{id}/free-instances": {
      "get": {
        "operationId": "freeInstances.list",
        "summary": "List free instances",
        "description": "Lists the units of a resource with identity: instance that a line naming each could take now, in ID order, so the app can name one. Send the scope a line would name, without its instanceId, and on a resource counted in buckets the span from and to. Advisory: nothing is reserved. A page reads at most 1,000 units, so it can hold fewer than limit and still give next.\n\n- **Who may call:** Your server, with your project’s secret key.\n- **Pages:** `limit`, 1 to 500, default 100, with `next` and `after`. [Lists](https://agentpost.tools/docs/platform/api-basics#lists) has the rule.",
        "tags": ["Instances"],
        "externalDocs": {
          "description": "List free instances, in the API reference",
          "url": "https://agentpost.tools/docs/resourceshark/reference/instances#list-free-instances"
        },
        "security": [
          {
            "secretKey": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Resource ID, `res_…`. The `id` of a [`Resource`](https://agentpost.tools/docs/resourceshark/reference/resources#the-resource-object).",
            "schema": {
              "type": "string"
            },
            "example": "res_01M83PPH000000000000000004"
          },
          {
            "name": "after",
            "in": "query",
            "required": false,
            "description": "1–200 characters.",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 200
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "1–500; default `100`.",
            "schema": {
              "default": 100,
              "type": "integer",
              "exclusiveMinimum": 0,
              "maximum": 500
            },
            "example": 20
          },
          {
            "name": "placeId",
            "in": "query",
            "required": false,
            "description": "1–256 characters.",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 256
            }
          },
          {
            "name": "condition",
            "in": "query",
            "required": false,
            "description": "1–64 characters.",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 64,
              "pattern": "^[a-z0-9_-]+$"
            }
          },
          {
            "name": "holderRef",
            "in": "query",
            "required": false,
            "description": "1–256 characters.",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 256
            }
          },
          {
            "name": "from",
            "in": "query",
            "required": false,
            "description": "An ISO 8601 date and time.",
            "schema": {
              "type": "string",
              "format": "date-time"
            },
            "example": "2026-11-23T17:00:00.000Z"
          },
          {
            "name": "to",
            "in": "query",
            "required": false,
            "description": "An ISO 8601 date and time.",
            "schema": {
              "type": "string",
              "format": "date-time"
            },
            "example": "2026-11-23T18:00:00.000Z"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InstancesPage"
                },
                "example": {
                  "instances": [
                    {
                      "code": "Court 2",
                      "status": "active",
                      "id": "ins_01M83PPH000000000000000002",
                      "resourceId": "res_01M83PPH000000000000000004",
                      "unavailable": [
                        {
                          "start": "2026-11-23T20:00:00.000Z",
                          "end": "2026-11-23T21:00:00.000Z"
                        }
                      ]
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad Request, with `error.code` [`invalid_request`](https://agentpost.tools/docs/resourceshark/errors#invalid_request).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["invalid_request"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized, with `error.code` [`unauthenticated`](https://agentpost.tools/docs/resourceshark/errors#unauthenticated).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["unauthenticated"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden, with `error.code` [`forbidden`](https://agentpost.tools/docs/resourceshark/errors#forbidden).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["forbidden"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Not Found, with `error.code` [`not_found`](https://agentpost.tools/docs/resourceshark/errors#not_found).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["not_found"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error, with `error.code` [`internal_error`](https://agentpost.tools/docs/resourceshark/errors#internal_error).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["internal_error"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/supply": {
      "post": {
        "operationId": "supply.create",
        "summary": "Add supply",
        "description": "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.\n\n- **Who may call:** Your server, with your project’s secret key.\n- **Idempotency-Key:** required. ",
        "tags": ["Supply"],
        "externalDocs": {
          "description": "Add supply, in the API reference",
          "url": "https://agentpost.tools/docs/resourceshark/reference/supply#add-supply"
        },
        "security": [
          {
            "secretKey": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "description": "A key of your choosing for this request. A retry with the same key and the same request within 24 hours answers with the first answer, while you may still make the request; the same key with a different request answers [`idempotency_mismatch`](https://agentpost.tools/docs/resourceshark/errors#idempotency_mismatch), and one whose first request is still running answers [`conflict`](https://agentpost.tools/docs/resourceshark/errors#conflict).",
            "schema": {
              "type": "string"
            },
            "example": "add-credit-pack-1042"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "resourceId": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 256
                  },
                  "scope": {
                    "default": {},
                    "type": "object",
                    "properties": {
                      "placeId": {
                        "type": "string"
                      },
                      "condition": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 64,
                        "pattern": "^[a-z0-9_-]+$"
                      },
                      "holderRef": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 256
                      },
                      "instanceId": {
                        "type": "string"
                      }
                    },
                    "additionalProperties": false
                  },
                  "kind": {
                    "type": "string",
                    "enum": ["added", "expected"]
                  },
                  "quantity": {
                    "type": "number"
                  },
                  "validFrom": {
                    "type": "string",
                    "format": "date-time"
                  },
                  "expiresAt": {
                    "type": "string",
                    "format": "date-time"
                  },
                  "drawOrder": {
                    "type": "integer",
                    "minimum": -9007199254740991,
                    "maximum": 9007199254740991
                  },
                  "batchId": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 256
                  },
                  "fulfils": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 256
                  },
                  "attributes": {
                    "type": "object",
                    "propertyNames": {
                      "type": "string",
                      "minLength": 1,
                      "maxLength": 64,
                      "pattern": "^[A-Za-z0-9_-]+$"
                    },
                    "additionalProperties": {
                      "type": "string",
                      "maxLength": 200
                    }
                  },
                  "evidence": {
                    "type": "object",
                    "properties": {
                      "kind": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 256
                      },
                      "ref": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 256
                      }
                    },
                    "required": ["kind", "ref"]
                  },
                  "sourceKey": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 200
                  },
                  "batch": {
                    "type": "object",
                    "properties": {
                      "code": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 200
                      },
                      "expiresAt": {
                        "type": "string",
                        "format": "date-time"
                      },
                      "attributes": {
                        "type": "object",
                        "propertyNames": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 64,
                          "pattern": "^[A-Za-z0-9_-]+$"
                        },
                        "additionalProperties": {
                          "type": "string",
                          "maxLength": 200
                        }
                      }
                    },
                    "required": ["code"],
                    "additionalProperties": false
                  }
                },
                "required": [
                  "resourceId",
                  "kind",
                  "quantity",
                  "evidence",
                  "sourceKey"
                ],
                "additionalProperties": false
              },
              "example": {
                "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"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupplyResponse"
                },
                "example": {
                  "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"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad Request, with `error.code` [`invalid_request`](https://agentpost.tools/docs/resourceshark/errors#invalid_request).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["invalid_request"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized, with `error.code` [`unauthenticated`](https://agentpost.tools/docs/resourceshark/errors#unauthenticated).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["unauthenticated"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden, with `error.code` [`forbidden`](https://agentpost.tools/docs/resourceshark/errors#forbidden).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["forbidden"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Not Found, with `error.code` [`not_found`](https://agentpost.tools/docs/resourceshark/errors#not_found).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["not_found"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "409": {
            "description": "Conflict, with `error.code` [`duplicate_source`](https://agentpost.tools/docs/resourceshark/errors#duplicate_source).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["duplicate_source"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "413": {
            "description": "Payload Too Large, with `error.code` [`payload_too_large`](https://agentpost.tools/docs/resourceshark/errors#payload_too_large).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["payload_too_large"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "422": {
            "description": "Unprocessable Entity, with `error.code` [`invalid_quantity`](https://agentpost.tools/docs/resourceshark/errors#invalid_quantity).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["invalid_quantity"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error, with `error.code` [`internal_error`](https://agentpost.tools/docs/resourceshark/errors#internal_error).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["internal_error"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      },
      "get": {
        "operationId": "supply.list",
        "summary": "List supply",
        "description": "Lists supply entries, optionally filtered by resource, holder, batch, or status. A caller constrained to one holder lists only its own.\n\n- **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.\n- **Pages:** `limit`, 1 to 500, default 100, with `next` and `after`. [Lists](https://agentpost.tools/docs/platform/api-basics#lists) has the rule.",
        "tags": ["Supply"],
        "externalDocs": {
          "description": "List supply, in the API reference",
          "url": "https://agentpost.tools/docs/resourceshark/reference/supply#list-supply"
        },
        "security": [
          {
            "secretKey": []
          },
          {
            "userToken": []
          }
        ],
        "parameters": [
          {
            "name": "resourceId",
            "in": "query",
            "required": false,
            "description": "1–256 characters.",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 256
            },
            "example": "res_01M83PPH000000000000000003"
          },
          {
            "name": "holderRef",
            "in": "query",
            "required": false,
            "description": "1–256 characters.",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 256
            },
            "example": "principal:external:u_maya"
          },
          {
            "name": "batchId",
            "in": "query",
            "required": false,
            "description": "1–256 characters.",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 256
            }
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": ["pending", "active", "exhausted", "expired", "reversed"]
            },
            "example": "active"
          },
          {
            "name": "after",
            "in": "query",
            "required": false,
            "description": "1–200 characters.",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 200
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "1–500; default `100`.",
            "schema": {
              "default": 100,
              "type": "integer",
              "exclusiveMinimum": 0,
              "maximum": 500
            },
            "example": 20
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupplyPage"
                },
                "example": {
                  "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"
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad Request, with `error.code` [`invalid_request`](https://agentpost.tools/docs/resourceshark/errors#invalid_request).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["invalid_request"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized, with `error.code` [`unauthenticated`](https://agentpost.tools/docs/resourceshark/errors#unauthenticated).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["unauthenticated"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden, with `error.code` [`forbidden`](https://agentpost.tools/docs/resourceshark/errors#forbidden).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["forbidden"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error, with `error.code` [`internal_error`](https://agentpost.tools/docs/resourceshark/errors#internal_error).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["internal_error"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/supply/{id}": {
      "get": {
        "operationId": "supply.get",
        "summary": "Get a supply entry",
        "description": "Reads a supply entry. A caller constrained to one holder reads only its own.\n\n- **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.",
        "tags": ["Supply"],
        "externalDocs": {
          "description": "Get a supply entry, in the API reference",
          "url": "https://agentpost.tools/docs/resourceshark/reference/supply#get-a-supply-entry"
        },
        "security": [
          {
            "secretKey": []
          },
          {
            "userToken": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Supply ID, `sup_…`. The `id` of a [`SupplyEntry`](https://agentpost.tools/docs/resourceshark/reference/supply#the-supplyentry-object).",
            "schema": {
              "type": "string"
            },
            "example": "sup_01M83PPH000000000000000003"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupplyGetResponse"
                },
                "example": {
                  "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"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized, with `error.code` [`unauthenticated`](https://agentpost.tools/docs/resourceshark/errors#unauthenticated).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["unauthenticated"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden, with `error.code` [`forbidden`](https://agentpost.tools/docs/resourceshark/errors#forbidden).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["forbidden"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Not Found, with `error.code` [`not_found`](https://agentpost.tools/docs/resourceshark/errors#not_found).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["not_found"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error, with `error.code` [`internal_error`](https://agentpost.tools/docs/resourceshark/errors#internal_error).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["internal_error"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/supply/{id}/reverse": {
      "post": {
        "operationId": "supply.reverse",
        "summary": "Reverse supply",
        "description": "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.\n\n- **Who may call:** Your server, with your project’s secret key.\n- **Idempotency-Key:** required. ",
        "tags": ["Supply"],
        "externalDocs": {
          "description": "Reverse supply, in the API reference",
          "url": "https://agentpost.tools/docs/resourceshark/reference/supply#reverse-supply"
        },
        "security": [
          {
            "secretKey": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Supply ID, `sup_…`. The `id` of a [`SupplyEntry`](https://agentpost.tools/docs/resourceshark/reference/supply#the-supplyentry-object).",
            "schema": {
              "type": "string"
            },
            "example": "sup_01M83PPH000000000000000003"
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "description": "A key of your choosing for this request. A retry with the same key and the same request within 24 hours answers with the first answer, while you may still make the request; the same key with a different request answers [`idempotency_mismatch`](https://agentpost.tools/docs/resourceshark/errors#idempotency_mismatch), and one whose first request is still running answers [`conflict`](https://agentpost.tools/docs/resourceshark/errors#conflict).",
            "schema": {
              "type": "string"
            },
            "example": "reverse-credit-pack-1042"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "quantity": {
                    "type": "number"
                  },
                  "evidence": {
                    "type": "object",
                    "properties": {
                      "kind": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 256
                      },
                      "ref": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 256
                      }
                    },
                    "required": ["kind", "ref"]
                  },
                  "sourceKey": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 200
                  }
                },
                "required": ["quantity", "evidence", "sourceKey"],
                "additionalProperties": false
              },
              "example": {
                "quantity": 2,
                "evidence": {
                  "kind": "refund",
                  "ref": "refund_1042"
                },
                "sourceKey": "credit-pack:1042:partial-refund"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SupplyReverseResponse"
                },
                "example": {
                  "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
                }
              }
            }
          },
          "400": {
            "description": "Bad Request, with `error.code` [`invalid_request`](https://agentpost.tools/docs/resourceshark/errors#invalid_request).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["invalid_request"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized, with `error.code` [`unauthenticated`](https://agentpost.tools/docs/resourceshark/errors#unauthenticated).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["unauthenticated"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden, with `error.code` [`forbidden`](https://agentpost.tools/docs/resourceshark/errors#forbidden).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["forbidden"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Not Found, with `error.code` [`not_found`](https://agentpost.tools/docs/resourceshark/errors#not_found).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["not_found"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "409": {
            "description": "Conflict, with `error.code` [`duplicate_source`](https://agentpost.tools/docs/resourceshark/errors#duplicate_source), [`insufficient_supply`](https://agentpost.tools/docs/resourceshark/errors#insufficient_supply), [`exhausted_until_supply`](https://agentpost.tools/docs/resourceshark/errors#exhausted_until_supply), or [`assignment_infeasible`](https://agentpost.tools/docs/resourceshark/errors#assignment_infeasible).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": [
                                "duplicate_source",
                                "insufficient_supply",
                                "exhausted_until_supply",
                                "assignment_infeasible"
                              ]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "413": {
            "description": "Payload Too Large, with `error.code` [`payload_too_large`](https://agentpost.tools/docs/resourceshark/errors#payload_too_large).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["payload_too_large"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "422": {
            "description": "Unprocessable Entity, with `error.code` [`invalid_quantity`](https://agentpost.tools/docs/resourceshark/errors#invalid_quantity).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["invalid_quantity"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error, with `error.code` [`internal_error`](https://agentpost.tools/docs/resourceshark/errors#internal_error).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["internal_error"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/batches": {
      "post": {
        "operationId": "batches.create",
        "summary": "Create a batch",
        "description": "Creates a batch with a code unique within its resource.\n\n- **Who may call:** Your server, with your project’s secret key.\n- **Idempotency-Key:** optional. ",
        "tags": ["Batches"],
        "externalDocs": {
          "description": "Create a batch, in the API reference",
          "url": "https://agentpost.tools/docs/resourceshark/reference/batches#create-a-batch"
        },
        "security": [
          {
            "secretKey": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "A key of your choosing for this request. A retry with the same key and the same request within 24 hours answers with the first answer, while you may still make the request; the same key with a different request answers [`idempotency_mismatch`](https://agentpost.tools/docs/resourceshark/errors#idempotency_mismatch), and one whose first request is still running answers [`conflict`](https://agentpost.tools/docs/resourceshark/errors#conflict).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "resourceId": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 256
                  },
                  "code": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 200
                  },
                  "expiresAt": {
                    "type": "string",
                    "format": "date-time"
                  },
                  "attributes": {
                    "type": "object",
                    "propertyNames": {
                      "type": "string",
                      "minLength": 1,
                      "maxLength": 64,
                      "pattern": "^[A-Za-z0-9_-]+$"
                    },
                    "additionalProperties": {
                      "type": "string",
                      "maxLength": 200
                    }
                  }
                },
                "required": ["resourceId", "code"],
                "additionalProperties": false
              },
              "example": {
                "resourceId": "res_01M83PPH000000000000000001",
                "code": "ROAST-2026-11-23",
                "expiresAt": "2026-11-28T17:00:00.000Z",
                "attributes": {
                  "origin": "Colombia"
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BatchResponse"
                },
                "example": {
                  "batch": {
                    "resourceId": "res_01M83PPH000000000000000001",
                    "code": "ROAST-2026-11-23",
                    "expiresAt": "2026-11-28T17:00:00.000Z",
                    "attributes": {
                      "origin": "Colombia"
                    },
                    "id": "bat_01M83PPH000000000000000001",
                    "version": 1,
                    "createdAt": "2026-11-23T08:00:00.000Z",
                    "updatedAt": "2026-11-23T08:00:00.000Z"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad Request, with `error.code` [`invalid_request`](https://agentpost.tools/docs/resourceshark/errors#invalid_request).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["invalid_request"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized, with `error.code` [`unauthenticated`](https://agentpost.tools/docs/resourceshark/errors#unauthenticated).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["unauthenticated"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden, with `error.code` [`forbidden`](https://agentpost.tools/docs/resourceshark/errors#forbidden).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["forbidden"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Not Found, with `error.code` [`not_found`](https://agentpost.tools/docs/resourceshark/errors#not_found).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["not_found"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "409": {
            "description": "Conflict, with `error.code` [`key_in_use`](https://agentpost.tools/docs/resourceshark/errors#key_in_use).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["key_in_use"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "413": {
            "description": "Payload Too Large, with `error.code` [`payload_too_large`](https://agentpost.tools/docs/resourceshark/errors#payload_too_large).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["payload_too_large"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error, with `error.code` [`internal_error`](https://agentpost.tools/docs/resourceshark/errors#internal_error).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["internal_error"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      },
      "get": {
        "operationId": "batches.list",
        "summary": "List batches",
        "description": "Lists batches, optionally filtered by resource.\n\n- **Who may call:** Your server, with your project’s secret key.\n- **Pages:** `limit`, 1 to 500, default 100, with `next` and `after`. [Lists](https://agentpost.tools/docs/platform/api-basics#lists) has the rule.",
        "tags": ["Batches"],
        "externalDocs": {
          "description": "List batches, in the API reference",
          "url": "https://agentpost.tools/docs/resourceshark/reference/batches#list-batches"
        },
        "security": [
          {
            "secretKey": []
          }
        ],
        "parameters": [
          {
            "name": "resourceId",
            "in": "query",
            "required": false,
            "description": "1–256 characters.",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 256
            },
            "example": "res_01M83PPH000000000000000001"
          },
          {
            "name": "after",
            "in": "query",
            "required": false,
            "description": "1–200 characters.",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 200
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "1–500; default `100`.",
            "schema": {
              "default": 100,
              "type": "integer",
              "exclusiveMinimum": 0,
              "maximum": 500
            },
            "example": 20
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BatchesPage"
                },
                "example": {
                  "batches": [
                    {
                      "resourceId": "res_01M83PPH000000000000000001",
                      "code": "ROAST-2026-11-23",
                      "expiresAt": "2026-11-29T17:00:00.000Z",
                      "attributes": {
                        "origin": "Colombia"
                      },
                      "id": "bat_01M83PPH000000000000000001",
                      "version": 2,
                      "createdAt": "2026-11-23T08:00:00.000Z",
                      "updatedAt": "2026-11-23T08:25:00.000Z"
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad Request, with `error.code` [`invalid_request`](https://agentpost.tools/docs/resourceshark/errors#invalid_request).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["invalid_request"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized, with `error.code` [`unauthenticated`](https://agentpost.tools/docs/resourceshark/errors#unauthenticated).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["unauthenticated"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden, with `error.code` [`forbidden`](https://agentpost.tools/docs/resourceshark/errors#forbidden).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["forbidden"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error, with `error.code` [`internal_error`](https://agentpost.tools/docs/resourceshark/errors#internal_error).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["internal_error"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/batches/{id}": {
      "get": {
        "operationId": "batches.get",
        "summary": "Get a batch",
        "description": "Reads a batch by ID.\n\n- **Who may call:** Your server, with your project’s secret key.",
        "tags": ["Batches"],
        "externalDocs": {
          "description": "Get a batch, in the API reference",
          "url": "https://agentpost.tools/docs/resourceshark/reference/batches#get-a-batch"
        },
        "security": [
          {
            "secretKey": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Batch ID, `bat_…`. The `id` of a [`Batch`](https://agentpost.tools/docs/resourceshark/reference/batches#the-batch-object).",
            "schema": {
              "type": "string"
            },
            "example": "bat_01M83PPH000000000000000001"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BatchResponse"
                },
                "example": {
                  "batch": {
                    "resourceId": "res_01M83PPH000000000000000001",
                    "code": "ROAST-2026-11-23",
                    "expiresAt": "2026-11-29T17:00:00.000Z",
                    "attributes": {
                      "origin": "Colombia"
                    },
                    "id": "bat_01M83PPH000000000000000001",
                    "version": 2,
                    "createdAt": "2026-11-23T08:00:00.000Z",
                    "updatedAt": "2026-11-23T08:25:00.000Z"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized, with `error.code` [`unauthenticated`](https://agentpost.tools/docs/resourceshark/errors#unauthenticated).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["unauthenticated"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden, with `error.code` [`forbidden`](https://agentpost.tools/docs/resourceshark/errors#forbidden).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["forbidden"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Not Found, with `error.code` [`not_found`](https://agentpost.tools/docs/resourceshark/errors#not_found).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["not_found"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error, with `error.code` [`internal_error`](https://agentpost.tools/docs/resourceshark/errors#internal_error).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["internal_error"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      },
      "patch": {
        "operationId": "batches.patch",
        "summary": "Update a batch",
        "description": "Edits a batch and keeps its live supply in step with its expiry.\n\n- **Who may call:** Your server, with your project’s secret key.\n- **Idempotency-Key:** optional. ",
        "tags": ["Batches"],
        "externalDocs": {
          "description": "Update a batch, in the API reference",
          "url": "https://agentpost.tools/docs/resourceshark/reference/batches#update-a-batch"
        },
        "security": [
          {
            "secretKey": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Batch ID, `bat_…`. The `id` of a [`Batch`](https://agentpost.tools/docs/resourceshark/reference/batches#the-batch-object).",
            "schema": {
              "type": "string"
            },
            "example": "bat_01M83PPH000000000000000001"
          },
          {
            "name": "If-Match",
            "in": "header",
            "required": true,
            "description": "Required. Send the version you read.",
            "schema": {
              "type": "string"
            },
            "example": "1"
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "A key of your choosing for this request. A retry with the same key and the same request within 24 hours answers with the first answer, while you may still make the request; the same key with a different request answers [`idempotency_mismatch`](https://agentpost.tools/docs/resourceshark/errors#idempotency_mismatch), and one whose first request is still running answers [`conflict`](https://agentpost.tools/docs/resourceshark/errors#conflict).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "resourceId": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 256
                  },
                  "code": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 200
                  },
                  "expiresAt": {
                    "anyOf": [
                      {
                        "type": "string",
                        "format": "date-time"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "attributes": {
                    "anyOf": [
                      {
                        "type": "object",
                        "propertyNames": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 64,
                          "pattern": "^[A-Za-z0-9_-]+$"
                        },
                        "additionalProperties": {
                          "type": "string",
                          "maxLength": 200
                        }
                      },
                      {
                        "type": "null"
                      }
                    ]
                  }
                },
                "additionalProperties": false
              },
              "example": {
                "expiresAt": "2026-11-29T17:00:00.000Z"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BatchResponse"
                },
                "example": {
                  "batch": {
                    "resourceId": "res_01M83PPH000000000000000001",
                    "code": "ROAST-2026-11-23",
                    "expiresAt": "2026-11-29T17:00:00.000Z",
                    "attributes": {
                      "origin": "Colombia"
                    },
                    "id": "bat_01M83PPH000000000000000001",
                    "version": 2,
                    "createdAt": "2026-11-23T08:00:00.000Z",
                    "updatedAt": "2026-11-23T08:25:00.000Z"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad Request, with `error.code` [`invalid_request`](https://agentpost.tools/docs/resourceshark/errors#invalid_request).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["invalid_request"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized, with `error.code` [`unauthenticated`](https://agentpost.tools/docs/resourceshark/errors#unauthenticated).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["unauthenticated"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden, with `error.code` [`forbidden`](https://agentpost.tools/docs/resourceshark/errors#forbidden).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["forbidden"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Not Found, with `error.code` [`not_found`](https://agentpost.tools/docs/resourceshark/errors#not_found).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["not_found"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "409": {
            "description": "Conflict, with `error.code` [`key_in_use`](https://agentpost.tools/docs/resourceshark/errors#key_in_use) or [`stale_version`](https://agentpost.tools/docs/resourceshark/errors#stale_version).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["key_in_use", "stale_version"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "413": {
            "description": "Payload Too Large, with `error.code` [`payload_too_large`](https://agentpost.tools/docs/resourceshark/errors#payload_too_large).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["payload_too_large"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error, with `error.code` [`internal_error`](https://agentpost.tools/docs/resourceshark/errors#internal_error).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["internal_error"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/availability": {
      "post": {
        "operationId": "availability.query",
        "summary": "Check availability",
        "description": "Gives the requested and available quantities for each line. Advisory: nothing is reserved. A line on a resource counted in buckets names its span, and one that starts in a bucket that has ended is refused, as a hold refuses it. A hold past its expiry no longer counts as held.\n\n- **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.\n- **Idempotency-Key:** not taken. undefined",
        "tags": ["Availability"],
        "externalDocs": {
          "description": "Check availability, in the API reference",
          "url": "https://agentpost.tools/docs/resourceshark/reference/availability#check-availability"
        },
        "security": [
          {
            "secretKey": []
          },
          {
            "userToken": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "lines": {
                    "minItems": 1,
                    "maxItems": 50,
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "resourceId": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 256
                        },
                        "scope": {
                          "type": "object",
                          "properties": {
                            "placeId": {
                              "type": "string"
                            },
                            "condition": {
                              "type": "string",
                              "minLength": 1,
                              "maxLength": 64,
                              "pattern": "^[a-z0-9_-]+$"
                            },
                            "holderRef": {
                              "type": "string",
                              "minLength": 1,
                              "maxLength": 256
                            },
                            "instanceId": {
                              "type": "string"
                            }
                          },
                          "additionalProperties": false
                        },
                        "quantity": {
                          "type": "number"
                        },
                        "from": {
                          "type": "object",
                          "properties": {
                            "batchId": {
                              "type": "string",
                              "minLength": 1,
                              "maxLength": 256
                            },
                            "supplyId": {
                              "type": "string",
                              "minLength": 1,
                              "maxLength": 256
                            }
                          },
                          "additionalProperties": false
                        },
                        "span": {
                          "type": "object",
                          "properties": {
                            "start": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "end": {
                              "type": "string",
                              "format": "date-time"
                            }
                          },
                          "required": ["start", "end"]
                        }
                      },
                      "required": ["resourceId", "quantity"],
                      "additionalProperties": false
                    }
                  }
                },
                "required": ["lines"],
                "additionalProperties": false
              },
              "example": {
                "lines": [
                  {
                    "resourceId": "res_01M83PPH000000000000000001",
                    "scope": {
                      "placeId": "plc_01M83PPH000000000000000001"
                    },
                    "quantity": 500
                  },
                  {
                    "resourceId": "res_01M83PPH000000000000000004",
                    "scope": {
                      "instanceId": "ins_01M83PPH000000000000000001"
                    },
                    "quantity": 1,
                    "span": {
                      "start": "2026-11-23T17:00:00.000Z",
                      "end": "2026-11-23T18:00:00.000Z"
                    }
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AvailabilityResponse"
                },
                "example": {
                  "lines": [
                    {
                      "resourceId": "res_01M83PPH000000000000000001",
                      "scope": {
                        "placeId": "plc_01M83PPH000000000000000001"
                      },
                      "quantity": 500,
                      "available": 8500,
                      "expected": 0,
                      "version": 1,
                      "asOf": "2026-11-23T09:55:00.000Z"
                    },
                    {
                      "resourceId": "res_01M83PPH000000000000000004",
                      "scope": {
                        "instanceId": "ins_01M83PPH000000000000000001"
                      },
                      "quantity": 1,
                      "available": 1,
                      "expected": 0,
                      "version": 0,
                      "asOf": "2026-11-23T09:55:00.000Z"
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad Request, with `error.code` [`invalid_request`](https://agentpost.tools/docs/resourceshark/errors#invalid_request).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["invalid_request"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized, with `error.code` [`unauthenticated`](https://agentpost.tools/docs/resourceshark/errors#unauthenticated).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["unauthenticated"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden, with `error.code` [`forbidden`](https://agentpost.tools/docs/resourceshark/errors#forbidden).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["forbidden"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Not Found, with `error.code` [`not_found`](https://agentpost.tools/docs/resourceshark/errors#not_found).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["not_found"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "413": {
            "description": "Payload Too Large, with `error.code` [`payload_too_large`](https://agentpost.tools/docs/resourceshark/errors#payload_too_large).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["payload_too_large"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "422": {
            "description": "Unprocessable Entity, with `error.code` [`invalid_quantity`](https://agentpost.tools/docs/resourceshark/errors#invalid_quantity).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["invalid_quantity"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error, with `error.code` [`internal_error`](https://agentpost.tools/docs/resourceshark/errors#internal_error).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["internal_error"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/resources/{id}/balance": {
      "get": {
        "operationId": "balances.get",
        "summary": "Get a balance",
        "description": "Reads one scope’s balance: on hand, held, expected, and available. On a resource with identity: instance, send the unit’s instanceId. Send by=batch for each batch’s share. A hold past its expiry no longer counts as held. A caller constrained to one holder reads only its own.\n\n- **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.",
        "tags": ["Availability"],
        "externalDocs": {
          "description": "Get a balance, in the API reference",
          "url": "https://agentpost.tools/docs/resourceshark/reference/availability#get-a-balance"
        },
        "security": [
          {
            "secretKey": []
          },
          {
            "userToken": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Resource ID, `res_…`. The `id` of a [`Resource`](https://agentpost.tools/docs/resourceshark/reference/resources#the-resource-object).",
            "schema": {
              "type": "string"
            },
            "example": "res_01M83PPH000000000000000001"
          },
          {
            "name": "placeId",
            "in": "query",
            "required": false,
            "description": "1–256 characters.",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 256
            },
            "example": "plc_01M83PPH000000000000000001"
          },
          {
            "name": "condition",
            "in": "query",
            "required": false,
            "description": "1–64 characters.",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 64,
              "pattern": "^[a-z0-9_-]+$"
            }
          },
          {
            "name": "holderRef",
            "in": "query",
            "required": false,
            "description": "1–256 characters.",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 256
            }
          },
          {
            "name": "instanceId",
            "in": "query",
            "required": false,
            "description": "1–256 characters.",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 256
            }
          },
          {
            "name": "by",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": ["batch"]
            },
            "example": "batch"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BalanceResponse"
                },
                "example": {
                  "balance": {
                    "resourceId": "res_01M83PPH000000000000000001",
                    "scope": {
                      "placeId": "plc_01M83PPH000000000000000001"
                    },
                    "onHand": 6500,
                    "held": 0,
                    "expected": 0,
                    "available": 6500,
                    "version": 4,
                    "asOf": "2026-11-23T10:30:00.000Z",
                    "batches": [
                      {
                        "batchId": "bat_01M83PPH000000000000000001",
                        "code": "ROAST-2026-11-23",
                        "onHand": 6500,
                        "held": 0,
                        "available": 6500,
                        "expiresAt": "2026-11-29T17:00:00.000Z"
                      }
                    ]
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad Request, with `error.code` [`invalid_request`](https://agentpost.tools/docs/resourceshark/errors#invalid_request).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["invalid_request"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized, with `error.code` [`unauthenticated`](https://agentpost.tools/docs/resourceshark/errors#unauthenticated).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["unauthenticated"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden, with `error.code` [`forbidden`](https://agentpost.tools/docs/resourceshark/errors#forbidden).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["forbidden"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Not Found, with `error.code` [`not_found`](https://agentpost.tools/docs/resourceshark/errors#not_found).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["not_found"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error, with `error.code` [`internal_error`](https://agentpost.tools/docs/resourceshark/errors#internal_error).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["internal_error"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/holders/{ref}/balances": {
      "get": {
        "operationId": "holderBalances.list",
        "summary": "List a holder's balances",
        "description": "Lists a holder’s balances on resources kept without places. Send placeId to list balances at that place, and condition to select a label there. Omitting condition selects unlabeled balances. Lists one balance per resource in resource ID order, with its supply on hand and when more starts. A caller constrained to one holder lists only its own.\n\n- **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.\n- **Pages:** `limit`, 1 to 500, default 100, with `next` and `after`. [Lists](https://agentpost.tools/docs/platform/api-basics#lists) has the rule.",
        "tags": ["Availability"],
        "externalDocs": {
          "description": "List a holder's balances, in the API reference",
          "url": "https://agentpost.tools/docs/resourceshark/reference/availability#list-a-holders-balances"
        },
        "security": [
          {
            "secretKey": []
          },
          {
            "userToken": []
          }
        ],
        "parameters": [
          {
            "name": "ref",
            "in": "path",
            "required": true,
            "description": "The holder reference, such as `principal:external:u_maya`. A signed-in principal can read only their own holder.",
            "schema": {
              "type": "string"
            },
            "example": "principal:external:u_maya"
          },
          {
            "name": "placeId",
            "in": "query",
            "required": false,
            "description": "1–256 characters.",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 256
            }
          },
          {
            "name": "condition",
            "in": "query",
            "required": false,
            "description": "1–64 characters.",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 64,
              "pattern": "^[a-z0-9_-]+$"
            }
          },
          {
            "name": "after",
            "in": "query",
            "required": false,
            "description": "1–200 characters.",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 200
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "1–500; default `100`.",
            "schema": {
              "default": 100,
              "type": "integer",
              "exclusiveMinimum": 0,
              "maximum": 500
            },
            "example": 20
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HolderBalancesPage"
                },
                "example": {
                  "balances": [
                    {
                      "resourceId": "res_01M83PPH000000000000000003",
                      "holderRef": "principal:external:u_maya",
                      "onHand": 8,
                      "held": 0,
                      "available": 8,
                      "version": 4,
                      "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"
                        }
                      ]
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad Request, with `error.code` [`invalid_request`](https://agentpost.tools/docs/resourceshark/errors#invalid_request).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["invalid_request"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized, with `error.code` [`unauthenticated`](https://agentpost.tools/docs/resourceshark/errors#unauthenticated).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["unauthenticated"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden, with `error.code` [`forbidden`](https://agentpost.tools/docs/resourceshark/errors#forbidden).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["forbidden"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Not Found, with `error.code` [`not_found`](https://agentpost.tools/docs/resourceshark/errors#not_found).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["not_found"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error, with `error.code` [`internal_error`](https://agentpost.tools/docs/resourceshark/errors#internal_error).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["internal_error"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/holders/{ref}/balances/{resourceId}": {
      "get": {
        "operationId": "holderBalances.get",
        "summary": "Get a holder's balance",
        "description": "Reads a holder’s balance on one resource held per holder: on hand, held, and available, its supply on hand, and when its next supply starts. Send placeId for a resource kept by place, and condition to select a label there. Omitting condition selects the unlabeled balance. A caller constrained to one holder reads only its own.\n\n- **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.",
        "tags": ["Availability"],
        "externalDocs": {
          "description": "Get a holder's balance, in the API reference",
          "url": "https://agentpost.tools/docs/resourceshark/reference/availability#get-a-holders-balance"
        },
        "security": [
          {
            "secretKey": []
          },
          {
            "userToken": []
          }
        ],
        "parameters": [
          {
            "name": "ref",
            "in": "path",
            "required": true,
            "description": "The holder reference, such as `principal:external:u_maya`. A signed-in principal can read only their own holder.",
            "schema": {
              "type": "string"
            },
            "example": "principal:external:u_maya"
          },
          {
            "name": "resourceId",
            "in": "path",
            "required": true,
            "description": "Resource ID, `res_…`. The `id` of a [`Resource`](https://agentpost.tools/docs/resourceshark/reference/resources#the-resource-object).",
            "schema": {
              "type": "string"
            },
            "example": "res_01M83PPH000000000000000003"
          },
          {
            "name": "placeId",
            "in": "query",
            "required": false,
            "description": "1–256 characters.",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 256
            }
          },
          {
            "name": "condition",
            "in": "query",
            "required": false,
            "description": "1–64 characters.",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 64,
              "pattern": "^[a-z0-9_-]+$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HolderBalanceResponse"
                },
                "example": {
                  "balance": {
                    "resourceId": "res_01M83PPH000000000000000003",
                    "holderRef": "principal:external:u_maya",
                    "onHand": 8,
                    "held": 0,
                    "available": 8,
                    "version": 4,
                    "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"
                      }
                    ]
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad Request, with `error.code` [`invalid_request`](https://agentpost.tools/docs/resourceshark/errors#invalid_request).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["invalid_request"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized, with `error.code` [`unauthenticated`](https://agentpost.tools/docs/resourceshark/errors#unauthenticated).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["unauthenticated"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden, with `error.code` [`forbidden`](https://agentpost.tools/docs/resourceshark/errors#forbidden).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["forbidden"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Not Found, with `error.code` [`not_found`](https://agentpost.tools/docs/resourceshark/errors#not_found).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["not_found"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error, with `error.code` [`internal_error`](https://agentpost.tools/docs/resourceshark/errors#internal_error).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["internal_error"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/holds": {
      "post": {
        "operationId": "holds.create",
        "summary": "Place a hold",
        "description": "Sets each line aside, all or nothing, until the hold is committed, released, or runs out at expiresAt. Several lines may name a resource counted in buckets, with disjoint spans in each scope, or a resource with identity: instance, each naming a different unit in scope.instanceId. A refusal names each short line and how much is available for it, and is assignment_infeasible when a unit a line names isn’t free. Send the hold length in ttl, such as \"1h\". A line on a resource held per holder names its holder in scope.holderRef. A repeat under a sourceKey already used in the project answers with the same hold, for ever.\n\n- **Who may call:** Your server, with your project’s secret key.\n- **Idempotency-Key:** required. ",
        "tags": ["Holds"],
        "externalDocs": {
          "description": "Place a hold, in the API reference",
          "url": "https://agentpost.tools/docs/resourceshark/reference/holds#place-a-hold"
        },
        "security": [
          {
            "secretKey": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "description": "A key of your choosing for this request. A retry with the same key and the same request within 24 hours answers with the first answer, while you may still make the request; the same key with a different request answers [`idempotency_mismatch`](https://agentpost.tools/docs/resourceshark/errors#idempotency_mismatch), and one whose first request is still running answers [`conflict`](https://agentpost.tools/docs/resourceshark/errors#conflict).",
            "schema": {
              "type": "string"
            },
            "example": "hold-coffee-109"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "lines": {
                    "minItems": 1,
                    "maxItems": 50,
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "resourceId": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 256
                        },
                        "scope": {
                          "type": "object",
                          "properties": {
                            "placeId": {
                              "type": "string"
                            },
                            "condition": {
                              "type": "string",
                              "minLength": 1,
                              "maxLength": 64,
                              "pattern": "^[a-z0-9_-]+$"
                            },
                            "holderRef": {
                              "type": "string",
                              "minLength": 1,
                              "maxLength": 256
                            },
                            "instanceId": {
                              "type": "string"
                            }
                          },
                          "additionalProperties": false
                        },
                        "quantity": {
                          "type": "number"
                        },
                        "from": {
                          "type": "object",
                          "properties": {
                            "batchId": {
                              "type": "string",
                              "minLength": 1,
                              "maxLength": 256
                            },
                            "supplyId": {
                              "type": "string",
                              "minLength": 1,
                              "maxLength": 256
                            }
                          },
                          "additionalProperties": false
                        },
                        "span": {
                          "type": "object",
                          "properties": {
                            "start": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "end": {
                              "type": "string",
                              "format": "date-time"
                            }
                          },
                          "required": ["start", "end"]
                        }
                      },
                      "required": ["resourceId", "quantity"],
                      "additionalProperties": false
                    }
                  },
                  "ttl": {
                    "type": "string",
                    "description": "A duration, such as \"10m\" or \"7d\""
                  },
                  "label": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 200
                  },
                  "holderRef": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 256
                  },
                  "reference": {
                    "type": "object",
                    "properties": {
                      "kind": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 256
                      },
                      "ref": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 256
                      }
                    },
                    "required": ["kind", "ref"]
                  },
                  "sourceKey": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 200
                  }
                },
                "required": ["lines", "ttl", "sourceKey"],
                "additionalProperties": false
              },
              "example": {
                "lines": [
                  {
                    "resourceId": "res_01M83PPH000000000000000001",
                    "scope": {
                      "placeId": "plc_01M83PPH000000000000000001"
                    },
                    "quantity": 500,
                    "from": {
                      "batchId": "bat_01M83PPH000000000000000001"
                    }
                  }
                ],
                "ttl": "15m",
                "holderRef": "principal:external:u_maya",
                "label": "coffee-pickup",
                "reference": {
                  "kind": "checkout",
                  "ref": "checkout_109"
                },
                "sourceKey": "checkout:109:hold"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HoldResponse"
                },
                "example": {
                  "hold": {
                    "id": "hld_01M83PPH000000000000000001",
                    "holderRef": "principal:external:u_maya",
                    "label": "coffee-pickup",
                    "reference": {
                      "kind": "checkout",
                      "ref": "checkout_109"
                    },
                    "expiresAt": "2026-11-23T10:15:00.000Z",
                    "lines": [
                      {
                        "claimId": "clm_01M83PPH000000000000000003",
                        "resourceId": "res_01M83PPH000000000000000001",
                        "scope": {
                          "placeId": "plc_01M83PPH000000000000000001"
                        },
                        "quantity": 500,
                        "status": "held",
                        "pegs": [
                          {
                            "supplyId": "sup_01M83PPH000000000000000002",
                            "quantity": 500
                          }
                        ]
                      }
                    ],
                    "status": "open",
                    "sourceKey": "checkout:109:hold",
                    "actor": {
                      "id": "key:juniper-backend"
                    },
                    "createdAt": "2026-11-23T10:00:00.000Z",
                    "updatedAt": "2026-11-23T10:00:00.000Z"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad Request, with `error.code` [`invalid_request`](https://agentpost.tools/docs/resourceshark/errors#invalid_request).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["invalid_request"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized, with `error.code` [`unauthenticated`](https://agentpost.tools/docs/resourceshark/errors#unauthenticated).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["unauthenticated"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden, with `error.code` [`forbidden`](https://agentpost.tools/docs/resourceshark/errors#forbidden).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["forbidden"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Not Found, with `error.code` [`not_found`](https://agentpost.tools/docs/resourceshark/errors#not_found).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["not_found"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "409": {
            "description": "Conflict, with `error.code` [`duplicate_source`](https://agentpost.tools/docs/resourceshark/errors#duplicate_source), [`insufficient_supply`](https://agentpost.tools/docs/resourceshark/errors#insufficient_supply), [`exhausted_until_supply`](https://agentpost.tools/docs/resourceshark/errors#exhausted_until_supply), or [`assignment_infeasible`](https://agentpost.tools/docs/resourceshark/errors#assignment_infeasible).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": [
                                "duplicate_source",
                                "insufficient_supply",
                                "exhausted_until_supply",
                                "assignment_infeasible"
                              ]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "413": {
            "description": "Payload Too Large, with `error.code` [`payload_too_large`](https://agentpost.tools/docs/resourceshark/errors#payload_too_large).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["payload_too_large"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "422": {
            "description": "Unprocessable Entity, with `error.code` [`invalid_quantity`](https://agentpost.tools/docs/resourceshark/errors#invalid_quantity).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["invalid_quantity"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error, with `error.code` [`internal_error`](https://agentpost.tools/docs/resourceshark/errors#internal_error).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["internal_error"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      },
      "get": {
        "operationId": "holds.list",
        "summary": "List holds",
        "description": "Lists holds, optionally filtered by holder, label, and status. A caller constrained to one holder lists only its own. A hold whose detail retention removed is not listed.\n\n- **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.\n- **Pages:** `limit`, 1 to 500, default 100, with `next` and `after`. [Lists](https://agentpost.tools/docs/platform/api-basics#lists) has the rule.",
        "tags": ["Holds"],
        "externalDocs": {
          "description": "List holds, in the API reference",
          "url": "https://agentpost.tools/docs/resourceshark/reference/holds#list-holds"
        },
        "security": [
          {
            "secretKey": []
          },
          {
            "userToken": []
          }
        ],
        "parameters": [
          {
            "name": "holderRef",
            "in": "query",
            "required": false,
            "description": "1–256 characters.",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 256
            },
            "example": "principal:external:u_maya"
          },
          {
            "name": "label",
            "in": "query",
            "required": false,
            "description": "1–200 characters.",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 200
            },
            "example": "coffee-pickup"
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "open",
                "committed",
                "partially_committed",
                "released",
                "expired",
                "cancelled"
              ]
            },
            "example": "open"
          },
          {
            "name": "after",
            "in": "query",
            "required": false,
            "description": "1–200 characters.",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 200
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "1–500; default `100`.",
            "schema": {
              "default": 100,
              "type": "integer",
              "exclusiveMinimum": 0,
              "maximum": 500
            },
            "example": 20
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HoldsPage"
                },
                "example": {
                  "holds": [
                    {
                      "id": "hld_01M83PPH000000000000000001",
                      "holderRef": "principal:external:u_maya",
                      "label": "coffee-pickup",
                      "reference": {
                        "kind": "checkout",
                        "ref": "checkout_109"
                      },
                      "expiresAt": "2026-11-23T10:15:00.000Z",
                      "lines": [
                        {
                          "claimId": "clm_01M83PPH000000000000000003",
                          "resourceId": "res_01M83PPH000000000000000001",
                          "scope": {
                            "placeId": "plc_01M83PPH000000000000000001"
                          },
                          "quantity": 500,
                          "status": "held",
                          "pegs": [
                            {
                              "supplyId": "sup_01M83PPH000000000000000002",
                              "quantity": 500
                            }
                          ]
                        }
                      ],
                      "status": "open",
                      "sourceKey": "checkout:109:hold",
                      "actor": {
                        "id": "key:juniper-backend"
                      },
                      "createdAt": "2026-11-23T10:00:00.000Z",
                      "updatedAt": "2026-11-23T10:00:00.000Z"
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad Request, with `error.code` [`invalid_request`](https://agentpost.tools/docs/resourceshark/errors#invalid_request).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["invalid_request"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized, with `error.code` [`unauthenticated`](https://agentpost.tools/docs/resourceshark/errors#unauthenticated).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["unauthenticated"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden, with `error.code` [`forbidden`](https://agentpost.tools/docs/resourceshark/errors#forbidden).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["forbidden"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error, with `error.code` [`internal_error`](https://agentpost.tools/docs/resourceshark/errors#internal_error).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["internal_error"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/holds/{id}": {
      "get": {
        "operationId": "holds.get",
        "summary": "Get a hold",
        "description": "Reads a hold with its lines. A caller constrained to one holder reads only its own. Once retention has removed a hold’s detail, it reads as its RetainedHold, and only to a caller constrained to no holder.\n\n- **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.",
        "tags": ["Holds"],
        "externalDocs": {
          "description": "Get a hold, in the API reference",
          "url": "https://agentpost.tools/docs/resourceshark/reference/holds#get-a-hold"
        },
        "security": [
          {
            "secretKey": []
          },
          {
            "userToken": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Hold ID, `hld_…`. The `id` of a [`Hold`](https://agentpost.tools/docs/resourceshark/reference/holds#the-hold-object).",
            "schema": {
              "type": "string"
            },
            "example": "hld_01M83PPH000000000000000001"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HoldResponse"
                },
                "example": {
                  "hold": {
                    "id": "hld_01M83PPH000000000000000001",
                    "holderRef": "principal:external:u_maya",
                    "label": "coffee-pickup",
                    "reference": {
                      "kind": "checkout",
                      "ref": "checkout_109"
                    },
                    "expiresAt": "2026-11-23T10:15:00.000Z",
                    "lines": [
                      {
                        "claimId": "clm_01M83PPH000000000000000003",
                        "resourceId": "res_01M83PPH000000000000000001",
                        "scope": {
                          "placeId": "plc_01M83PPH000000000000000001"
                        },
                        "quantity": 500,
                        "status": "held",
                        "pegs": [
                          {
                            "supplyId": "sup_01M83PPH000000000000000002",
                            "quantity": 500
                          }
                        ]
                      }
                    ],
                    "status": "open",
                    "sourceKey": "checkout:109:hold",
                    "actor": {
                      "id": "key:juniper-backend"
                    },
                    "createdAt": "2026-11-23T10:00:00.000Z",
                    "updatedAt": "2026-11-23T10:00:00.000Z"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized, with `error.code` [`unauthenticated`](https://agentpost.tools/docs/resourceshark/errors#unauthenticated).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["unauthenticated"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden, with `error.code` [`forbidden`](https://agentpost.tools/docs/resourceshark/errors#forbidden).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["forbidden"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Not Found, with `error.code` [`not_found`](https://agentpost.tools/docs/resourceshark/errors#not_found).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["not_found"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error, with `error.code` [`internal_error`](https://agentpost.tools/docs/resourceshark/errors#internal_error).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["internal_error"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/holds/{id}/extend": {
      "post": {
        "operationId": "holds.extend",
        "summary": "Extend a hold",
        "description": "Extends the hold from now by the required ttl, such as \"15m\". The expiry can only move later.\n\n- **Who may call:** Your server, with your project’s secret key.\n- **Idempotency-Key:** required. ",
        "tags": ["Holds"],
        "externalDocs": {
          "description": "Extend a hold, in the API reference",
          "url": "https://agentpost.tools/docs/resourceshark/reference/holds#extend-a-hold"
        },
        "security": [
          {
            "secretKey": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Hold ID, `hld_…`. The `id` of a [`Hold`](https://agentpost.tools/docs/resourceshark/reference/holds#the-hold-object).",
            "schema": {
              "type": "string"
            },
            "example": "hld_01M83PPH000000000000000002"
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "description": "A key of your choosing for this request. A retry with the same key and the same request within 24 hours answers with the first answer, while you may still make the request; the same key with a different request answers [`idempotency_mismatch`](https://agentpost.tools/docs/resourceshark/errors#idempotency_mismatch), and one whose first request is still running answers [`conflict`](https://agentpost.tools/docs/resourceshark/errors#conflict).",
            "schema": {
              "type": "string"
            },
            "example": "extend-court-217"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "ttl": {
                    "type": "string",
                    "description": "A duration, such as \"10m\" or \"7d\""
                  }
                },
                "required": ["ttl"],
                "additionalProperties": false
              },
              "example": {
                "ttl": "15m"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HoldResponse"
                },
                "example": {
                  "hold": {
                    "id": "hld_01M83PPH000000000000000002",
                    "holderRef": "principal:external:u_maya",
                    "label": "court-booking",
                    "reference": {
                      "kind": "booking_request",
                      "ref": "court_request_217"
                    },
                    "expiresAt": "2026-11-23T11:25:00.000Z",
                    "lines": [
                      {
                        "claimId": "clm_01M83PPH000000000000000004",
                        "resourceId": "res_01M83PPH000000000000000004",
                        "scope": {
                          "instanceId": "ins_01M83PPH000000000000000001"
                        },
                        "quantity": 1,
                        "span": {
                          "start": "2026-11-23T17:00:00.000Z",
                          "end": "2026-11-23T18:00:00.000Z"
                        },
                        "status": "held"
                      }
                    ],
                    "status": "open",
                    "sourceKey": "court:217:hold",
                    "actor": {
                      "id": "key:juniper-backend"
                    },
                    "createdAt": "2026-11-23T11:00:00.000Z",
                    "updatedAt": "2026-11-23T11:10:00.000Z"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad Request, with `error.code` [`invalid_request`](https://agentpost.tools/docs/resourceshark/errors#invalid_request).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["invalid_request"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized, with `error.code` [`unauthenticated`](https://agentpost.tools/docs/resourceshark/errors#unauthenticated).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["unauthenticated"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden, with `error.code` [`forbidden`](https://agentpost.tools/docs/resourceshark/errors#forbidden).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["forbidden"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Not Found, with `error.code` [`not_found`](https://agentpost.tools/docs/resourceshark/errors#not_found).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["not_found"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "409": {
            "description": "Conflict, with `error.code` [`hold_expired`](https://agentpost.tools/docs/resourceshark/errors#hold_expired) or [`hold_resolved`](https://agentpost.tools/docs/resourceshark/errors#hold_resolved).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["hold_expired", "hold_resolved"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "413": {
            "description": "Payload Too Large, with `error.code` [`payload_too_large`](https://agentpost.tools/docs/resourceshark/errors#payload_too_large).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["payload_too_large"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error, with `error.code` [`internal_error`](https://agentpost.tools/docs/resourceshark/errors#internal_error).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["internal_error"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/holds/{id}/commit": {
      "post": {
        "operationId": "holds.commit",
        "summary": "Commit a hold",
        "description": "Takes every line in full when lines is omitted or empty. A nonempty list names each line and the quantity to take, and the rest is released. An expired hold is refused with hold_expired and the available quantity on each line the service still retains. Use POST /consume to make a separate purchase with the same lines. A repeat under a sourceKey that already committed the hold answers with the first result.\n\n- **Who may call:** Your server, with your project’s secret key.\n- **Idempotency-Key:** required. ",
        "tags": ["Holds"],
        "externalDocs": {
          "description": "Commit a hold, in the API reference",
          "url": "https://agentpost.tools/docs/resourceshark/reference/holds#commit-a-hold"
        },
        "security": [
          {
            "secretKey": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Hold ID, `hld_…`. The `id` of a [`Hold`](https://agentpost.tools/docs/resourceshark/reference/holds#the-hold-object).",
            "schema": {
              "type": "string"
            },
            "example": "hld_01M83PPH000000000000000002"
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "description": "A key of your choosing for this request. A retry with the same key and the same request within 24 hours answers with the first answer, while you may still make the request; the same key with a different request answers [`idempotency_mismatch`](https://agentpost.tools/docs/resourceshark/errors#idempotency_mismatch), and one whose first request is still running answers [`conflict`](https://agentpost.tools/docs/resourceshark/errors#conflict).",
            "schema": {
              "type": "string"
            },
            "example": "commit-court-217"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "evidence": {
                    "type": "object",
                    "properties": {
                      "kind": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 256
                      },
                      "ref": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 256
                      }
                    },
                    "required": ["kind", "ref"]
                  },
                  "sourceKey": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 200
                  },
                  "lines": {
                    "maxItems": 50,
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "claimId": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 256
                        },
                        "quantity": {
                          "type": "number"
                        }
                      },
                      "required": ["claimId", "quantity"],
                      "additionalProperties": false
                    }
                  }
                },
                "required": ["evidence", "sourceKey"],
                "additionalProperties": false
              },
              "example": {
                "evidence": {
                  "kind": "booking",
                  "ref": "court_booking_217"
                },
                "sourceKey": "court:217:book",
                "lines": [
                  {
                    "claimId": "clm_01M83PPH000000000000000004",
                    "quantity": 1
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HoldCommitResponse"
                },
                "example": {
                  "hold": {
                    "id": "hld_01M83PPH000000000000000002",
                    "holderRef": "principal:external:u_maya",
                    "label": "court-booking",
                    "reference": {
                      "kind": "booking_request",
                      "ref": "court_request_217"
                    },
                    "expiresAt": "2026-11-23T11:25:00.000Z",
                    "lines": [
                      {
                        "claimId": "clm_01M83PPH000000000000000004",
                        "resourceId": "res_01M83PPH000000000000000004",
                        "scope": {
                          "instanceId": "ins_01M83PPH000000000000000001"
                        },
                        "quantity": 1,
                        "span": {
                          "start": "2026-11-23T17:00:00.000Z",
                          "end": "2026-11-23T18:00:00.000Z"
                        },
                        "status": "committed",
                        "committed": 1
                      }
                    ],
                    "status": "committed",
                    "sourceKey": "court:217:hold",
                    "actor": {
                      "id": "key:juniper-backend"
                    },
                    "createdAt": "2026-11-23T11:00:00.000Z",
                    "updatedAt": "2026-11-23T11:15:00.000Z",
                    "resolution": {
                      "at": "2026-11-23T11:15:00.000Z",
                      "evidence": {
                        "kind": "booking",
                        "ref": "court_booking_217"
                      },
                      "sourceKey": "court:217:book"
                    }
                  },
                  "movements": [
                    {
                      "id": "mov_01M83PPH00000000000000000G",
                      "seq": 16,
                      "resourceId": "res_01M83PPH000000000000000004",
                      "scope": {
                        "instanceId": "ins_01M83PPH000000000000000001"
                      },
                      "bucketStart": "2026-11-23T17:00:00.000Z",
                      "reason": "commit",
                      "held": {
                        "quantity": -1,
                        "before": 1,
                        "after": 0
                      },
                      "claimId": "clm_01M83PPH000000000000000004",
                      "holdId": "hld_01M83PPH000000000000000002",
                      "evidence": {
                        "kind": "booking",
                        "ref": "court_booking_217"
                      },
                      "at": "2026-11-23T11:15:00.000Z",
                      "quantity": -1,
                      "before": 1,
                      "after": 0,
                      "actor": {
                        "id": "key:juniper-backend"
                      }
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad Request, with `error.code` [`invalid_request`](https://agentpost.tools/docs/resourceshark/errors#invalid_request).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["invalid_request"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized, with `error.code` [`unauthenticated`](https://agentpost.tools/docs/resourceshark/errors#unauthenticated).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["unauthenticated"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden, with `error.code` [`forbidden`](https://agentpost.tools/docs/resourceshark/errors#forbidden).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["forbidden"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Not Found, with `error.code` [`not_found`](https://agentpost.tools/docs/resourceshark/errors#not_found).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["not_found"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "409": {
            "description": "Conflict, with `error.code` [`duplicate_source`](https://agentpost.tools/docs/resourceshark/errors#duplicate_source), [`hold_expired`](https://agentpost.tools/docs/resourceshark/errors#hold_expired), or [`hold_resolved`](https://agentpost.tools/docs/resourceshark/errors#hold_resolved).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": [
                                "duplicate_source",
                                "hold_expired",
                                "hold_resolved"
                              ]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "413": {
            "description": "Payload Too Large, with `error.code` [`payload_too_large`](https://agentpost.tools/docs/resourceshark/errors#payload_too_large).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["payload_too_large"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "422": {
            "description": "Unprocessable Entity, with `error.code` [`invalid_quantity`](https://agentpost.tools/docs/resourceshark/errors#invalid_quantity).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["invalid_quantity"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error, with `error.code` [`internal_error`](https://agentpost.tools/docs/resourceshark/errors#internal_error).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["internal_error"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/holds/{id}/release": {
      "post": {
        "operationId": "holds.release",
        "summary": "Release a hold",
        "description": "Lets go of everything the hold holds. A hold already released is returned as it is.\n\n- **Who may call:** Your server, with your project’s secret key.\n- **Idempotency-Key:** required. ",
        "tags": ["Holds"],
        "externalDocs": {
          "description": "Release a hold, in the API reference",
          "url": "https://agentpost.tools/docs/resourceshark/reference/holds#release-a-hold"
        },
        "security": [
          {
            "secretKey": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Hold ID, `hld_…`. The `id` of a [`Hold`](https://agentpost.tools/docs/resourceshark/reference/holds#the-hold-object).",
            "schema": {
              "type": "string"
            },
            "example": "hld_01M83PPH000000000000000001"
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "description": "A key of your choosing for this request. A retry with the same key and the same request within 24 hours answers with the first answer, while you may still make the request; the same key with a different request answers [`idempotency_mismatch`](https://agentpost.tools/docs/resourceshark/errors#idempotency_mismatch), and one whose first request is still running answers [`conflict`](https://agentpost.tools/docs/resourceshark/errors#conflict).",
            "schema": {
              "type": "string"
            },
            "example": "release-coffee-109"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HoldResponse"
                },
                "example": {
                  "hold": {
                    "id": "hld_01M83PPH000000000000000001",
                    "holderRef": "principal:external:u_maya",
                    "label": "coffee-pickup",
                    "reference": {
                      "kind": "checkout",
                      "ref": "checkout_109"
                    },
                    "expiresAt": "2026-11-23T10:15:00.000Z",
                    "lines": [
                      {
                        "claimId": "clm_01M83PPH000000000000000003",
                        "resourceId": "res_01M83PPH000000000000000001",
                        "scope": {
                          "placeId": "plc_01M83PPH000000000000000001"
                        },
                        "quantity": 500,
                        "status": "released",
                        "pegs": [
                          {
                            "supplyId": "sup_01M83PPH000000000000000002",
                            "quantity": 500
                          }
                        ]
                      }
                    ],
                    "status": "released",
                    "sourceKey": "checkout:109:hold",
                    "actor": {
                      "id": "key:juniper-backend"
                    },
                    "createdAt": "2026-11-23T10:00:00.000Z",
                    "updatedAt": "2026-11-23T10:05:00.000Z",
                    "resolution": {
                      "at": "2026-11-23T10:05:00.000Z"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad Request, with `error.code` [`invalid_request`](https://agentpost.tools/docs/resourceshark/errors#invalid_request).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["invalid_request"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized, with `error.code` [`unauthenticated`](https://agentpost.tools/docs/resourceshark/errors#unauthenticated).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["unauthenticated"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden, with `error.code` [`forbidden`](https://agentpost.tools/docs/resourceshark/errors#forbidden).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["forbidden"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Not Found, with `error.code` [`not_found`](https://agentpost.tools/docs/resourceshark/errors#not_found).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["not_found"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "409": {
            "description": "Conflict, with `error.code` [`hold_resolved`](https://agentpost.tools/docs/resourceshark/errors#hold_resolved).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["hold_resolved"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error, with `error.code` [`internal_error`](https://agentpost.tools/docs/resourceshark/errors#internal_error).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["internal_error"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/holds/{id}/cancel": {
      "post": {
        "operationId": "holds.cancel",
        "summary": "Cancel a committed hold",
        "description": "Gives back the committed lines it names, or all of them, all or nothing: a span’s buckets return, and what a used-up line took goes back where its pegs say. The hold reads cancelled once every line its commit took from is. A repeat under a sourceKey already used in the project answers with the first result.\n\n- **Who may call:** Your server, with your project’s secret key.\n- **Idempotency-Key:** required. ",
        "tags": ["Holds"],
        "externalDocs": {
          "description": "Cancel a committed hold, in the API reference",
          "url": "https://agentpost.tools/docs/resourceshark/reference/holds#cancel-a-committed-hold"
        },
        "security": [
          {
            "secretKey": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Hold ID, `hld_…`. The `id` of a [`Hold`](https://agentpost.tools/docs/resourceshark/reference/holds#the-hold-object).",
            "schema": {
              "type": "string"
            },
            "example": "hld_01M83PPH000000000000000002"
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "description": "A key of your choosing for this request. A retry with the same key and the same request within 24 hours answers with the first answer, while you may still make the request; the same key with a different request answers [`idempotency_mismatch`](https://agentpost.tools/docs/resourceshark/errors#idempotency_mismatch), and one whose first request is still running answers [`conflict`](https://agentpost.tools/docs/resourceshark/errors#conflict).",
            "schema": {
              "type": "string"
            },
            "example": "cancel-court-217"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "lines": {
                    "minItems": 1,
                    "maxItems": 50,
                    "type": "array",
                    "items": {
                      "type": "string",
                      "minLength": 1,
                      "maxLength": 256
                    }
                  },
                  "evidence": {
                    "type": "object",
                    "properties": {
                      "kind": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 256
                      },
                      "ref": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 256
                      }
                    },
                    "required": ["kind", "ref"]
                  },
                  "sourceKey": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 200
                  }
                },
                "required": ["sourceKey"],
                "additionalProperties": false
              },
              "example": {
                "lines": ["clm_01M83PPH000000000000000004"],
                "evidence": {
                  "kind": "cancellation",
                  "ref": "court_booking_217"
                },
                "sourceKey": "court:217:cancel"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HoldCancelResponse"
                },
                "example": {
                  "hold": {
                    "id": "hld_01M83PPH000000000000000002",
                    "holderRef": "principal:external:u_maya",
                    "label": "court-booking",
                    "reference": {
                      "kind": "booking_request",
                      "ref": "court_request_217"
                    },
                    "expiresAt": "2026-11-23T11:25:00.000Z",
                    "lines": [
                      {
                        "claimId": "clm_01M83PPH000000000000000004",
                        "resourceId": "res_01M83PPH000000000000000004",
                        "scope": {
                          "instanceId": "ins_01M83PPH000000000000000001"
                        },
                        "quantity": 1,
                        "span": {
                          "start": "2026-11-23T18:00:00.000Z",
                          "end": "2026-11-23T19:00:00.000Z"
                        },
                        "status": "cancelled",
                        "committed": 1
                      }
                    ],
                    "status": "cancelled",
                    "sourceKey": "court:217:hold",
                    "actor": {
                      "id": "key:juniper-backend"
                    },
                    "createdAt": "2026-11-23T11:00:00.000Z",
                    "updatedAt": "2026-11-23T11:30:00.000Z",
                    "resolution": {
                      "at": "2026-11-23T11:15:00.000Z",
                      "evidence": {
                        "kind": "booking",
                        "ref": "court_booking_217"
                      },
                      "sourceKey": "court:217:book"
                    },
                    "cancellations": [
                      {
                        "at": "2026-11-23T11:30:00.000Z",
                        "claimIds": ["clm_01M83PPH000000000000000004"],
                        "evidence": {
                          "kind": "cancellation",
                          "ref": "court_booking_217"
                        },
                        "sourceKey": "court:217:cancel"
                      }
                    ]
                  },
                  "movements": [
                    {
                      "id": "mov_01M83PPH00000000000000000P",
                      "seq": 22,
                      "resourceId": "res_01M83PPH000000000000000004",
                      "scope": {
                        "instanceId": "ins_01M83PPH000000000000000001"
                      },
                      "bucketStart": "2026-11-23T18:00:00.000Z",
                      "reason": "cancel",
                      "claimId": "clm_01M83PPH000000000000000004",
                      "holdId": "hld_01M83PPH000000000000000002",
                      "evidence": {
                        "kind": "cancellation",
                        "ref": "court_booking_217"
                      },
                      "at": "2026-11-23T11:30:00.000Z",
                      "quantity": 1,
                      "before": 0,
                      "after": 1,
                      "actor": {
                        "id": "key:juniper-backend"
                      }
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad Request, with `error.code` [`invalid_request`](https://agentpost.tools/docs/resourceshark/errors#invalid_request).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["invalid_request"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized, with `error.code` [`unauthenticated`](https://agentpost.tools/docs/resourceshark/errors#unauthenticated).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["unauthenticated"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden, with `error.code` [`forbidden`](https://agentpost.tools/docs/resourceshark/errors#forbidden).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["forbidden"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Not Found, with `error.code` [`not_found`](https://agentpost.tools/docs/resourceshark/errors#not_found).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["not_found"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "409": {
            "description": "Conflict, with `error.code` [`duplicate_source`](https://agentpost.tools/docs/resourceshark/errors#duplicate_source) or [`hold_resolved`](https://agentpost.tools/docs/resourceshark/errors#hold_resolved).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["duplicate_source", "hold_resolved"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "413": {
            "description": "Payload Too Large, with `error.code` [`payload_too_large`](https://agentpost.tools/docs/resourceshark/errors#payload_too_large).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["payload_too_large"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error, with `error.code` [`internal_error`](https://agentpost.tools/docs/resourceshark/errors#internal_error).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["internal_error"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/reschedule": {
      "post": {
        "operationId": "holds.reschedule",
        "summary": "Reschedule a hold",
        "description": "Moves hold lines on resources counted in buckets, from one hold or several, to another resource, another unit, another span, or any mix, in one write: every old position is given back and every new one taken, or nothing changes, so two bookings on two full resources can swap. Each line stays held or committed. A line that omits resourceId keeps its resource and scope. A line that names a resource gives its full scope there. If the destination differs from the original resource in unit code or precision, the API answers invalid_request. A short move is refused with what each short line has available, and a unit that isn’t free with assignment_infeasible. A line already where it is asked to be is left alone. The answer shows each hold a line belongs to in full, so authorize is asked about each claim, each resource a line names, and each hold. A repeat under a sourceKey already used in the project answers with the first result, with each hold as it now is.\n\n- **Who may call:** Your server, with your project’s secret key.\n- **Idempotency-Key:** required. ",
        "tags": ["Holds"],
        "externalDocs": {
          "description": "Reschedule a hold, in the API reference",
          "url": "https://agentpost.tools/docs/resourceshark/reference/holds#reschedule-a-hold"
        },
        "security": [
          {
            "secretKey": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "description": "A key of your choosing for this request. A retry with the same key and the same request within 24 hours answers with the first answer, while you may still make the request; the same key with a different request answers [`idempotency_mismatch`](https://agentpost.tools/docs/resourceshark/errors#idempotency_mismatch), and one whose first request is still running answers [`conflict`](https://agentpost.tools/docs/resourceshark/errors#conflict).",
            "schema": {
              "type": "string"
            },
            "example": "reschedule-court-217"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "lines": {
                    "minItems": 1,
                    "maxItems": 50,
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "claimId": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 256
                        },
                        "resourceId": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 256
                        },
                        "scope": {
                          "type": "object",
                          "properties": {
                            "placeId": {
                              "type": "string"
                            },
                            "condition": {
                              "type": "string",
                              "minLength": 1,
                              "maxLength": 64,
                              "pattern": "^[a-z0-9_-]+$"
                            },
                            "holderRef": {
                              "type": "string",
                              "minLength": 1,
                              "maxLength": 256
                            },
                            "instanceId": {
                              "type": "string"
                            }
                          },
                          "additionalProperties": false
                        },
                        "span": {
                          "type": "object",
                          "properties": {
                            "start": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "end": {
                              "type": "string",
                              "format": "date-time"
                            }
                          },
                          "required": ["start", "end"]
                        }
                      },
                      "required": ["claimId"],
                      "additionalProperties": false
                    }
                  },
                  "evidence": {
                    "type": "object",
                    "properties": {
                      "kind": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 256
                      },
                      "ref": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 256
                      }
                    },
                    "required": ["kind", "ref"]
                  },
                  "sourceKey": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 200
                  }
                },
                "required": ["lines", "sourceKey"],
                "additionalProperties": false
              },
              "example": {
                "lines": [
                  {
                    "claimId": "clm_01M83PPH000000000000000004",
                    "span": {
                      "start": "2026-11-23T18:00:00.000Z",
                      "end": "2026-11-23T19:00:00.000Z"
                    }
                  }
                ],
                "evidence": {
                  "kind": "booking",
                  "ref": "court_booking_217"
                },
                "sourceKey": "court:217:reschedule"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HoldRescheduleResponse"
                },
                "example": {
                  "holds": [
                    {
                      "id": "hld_01M83PPH000000000000000002",
                      "holderRef": "principal:external:u_maya",
                      "label": "court-booking",
                      "reference": {
                        "kind": "booking_request",
                        "ref": "court_request_217"
                      },
                      "expiresAt": "2026-11-23T11:25:00.000Z",
                      "lines": [
                        {
                          "claimId": "clm_01M83PPH000000000000000004",
                          "resourceId": "res_01M83PPH000000000000000004",
                          "scope": {
                            "instanceId": "ins_01M83PPH000000000000000001"
                          },
                          "quantity": 1,
                          "span": {
                            "start": "2026-11-23T18:00:00.000Z",
                            "end": "2026-11-23T19:00:00.000Z"
                          },
                          "status": "committed",
                          "committed": 1
                        }
                      ],
                      "status": "committed",
                      "sourceKey": "court:217:hold",
                      "actor": {
                        "id": "key:juniper-backend"
                      },
                      "createdAt": "2026-11-23T11:00:00.000Z",
                      "updatedAt": "2026-11-23T11:20:00.000Z",
                      "resolution": {
                        "at": "2026-11-23T11:15:00.000Z",
                        "evidence": {
                          "kind": "booking",
                          "ref": "court_booking_217"
                        },
                        "sourceKey": "court:217:book"
                      }
                    }
                  ],
                  "lines": [
                    {
                      "claimId": "clm_01M83PPH000000000000000004",
                      "holdId": "hld_01M83PPH000000000000000002",
                      "before": {
                        "resourceId": "res_01M83PPH000000000000000004",
                        "scope": {
                          "instanceId": "ins_01M83PPH000000000000000001"
                        },
                        "span": {
                          "start": "2026-11-23T17:00:00.000Z",
                          "end": "2026-11-23T18:00:00.000Z"
                        }
                      },
                      "after": {
                        "resourceId": "res_01M83PPH000000000000000004",
                        "scope": {
                          "instanceId": "ins_01M83PPH000000000000000001"
                        },
                        "span": {
                          "start": "2026-11-23T18:00:00.000Z",
                          "end": "2026-11-23T19:00:00.000Z"
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad Request, with `error.code` [`invalid_request`](https://agentpost.tools/docs/resourceshark/errors#invalid_request).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["invalid_request"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized, with `error.code` [`unauthenticated`](https://agentpost.tools/docs/resourceshark/errors#unauthenticated).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["unauthenticated"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden, with `error.code` [`forbidden`](https://agentpost.tools/docs/resourceshark/errors#forbidden).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["forbidden"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Not Found, with `error.code` [`not_found`](https://agentpost.tools/docs/resourceshark/errors#not_found).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["not_found"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "409": {
            "description": "Conflict, with `error.code` [`duplicate_source`](https://agentpost.tools/docs/resourceshark/errors#duplicate_source), [`insufficient_supply`](https://agentpost.tools/docs/resourceshark/errors#insufficient_supply), [`exhausted_until_supply`](https://agentpost.tools/docs/resourceshark/errors#exhausted_until_supply), [`assignment_infeasible`](https://agentpost.tools/docs/resourceshark/errors#assignment_infeasible), or [`hold_resolved`](https://agentpost.tools/docs/resourceshark/errors#hold_resolved).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": [
                                "duplicate_source",
                                "insufficient_supply",
                                "exhausted_until_supply",
                                "assignment_infeasible",
                                "hold_resolved"
                              ]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "413": {
            "description": "Payload Too Large, with `error.code` [`payload_too_large`](https://agentpost.tools/docs/resourceshark/errors#payload_too_large).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["payload_too_large"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error, with `error.code` [`internal_error`](https://agentpost.tools/docs/resourceshark/errors#internal_error).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["internal_error"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/consume": {
      "post": {
        "operationId": "claims.consume",
        "summary": "Consume supply",
        "description": "Takes each line from what is available, for good, all or nothing. Several lines may name a resource counted in buckets, with disjoint spans in each scope, or a resource with identity: instance, each naming a different unit. A line naming a unit that isn’t free refuses the request with assignment_infeasible. Repeating the same request with its sourceKey answers with the first result.\n\n- **Who may call:** Your server, with your project’s secret key.\n- **Idempotency-Key:** required. ",
        "tags": ["Claims"],
        "externalDocs": {
          "description": "Consume supply, in the API reference",
          "url": "https://agentpost.tools/docs/resourceshark/reference/claims#consume-supply"
        },
        "security": [
          {
            "secretKey": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "description": "A key of your choosing for this request. A retry with the same key and the same request within 24 hours answers with the first answer, while you may still make the request; the same key with a different request answers [`idempotency_mismatch`](https://agentpost.tools/docs/resourceshark/errors#idempotency_mismatch), and one whose first request is still running answers [`conflict`](https://agentpost.tools/docs/resourceshark/errors#conflict).",
            "schema": {
              "type": "string"
            },
            "example": "estimate-tasting-1042"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "lines": {
                    "minItems": 1,
                    "maxItems": 50,
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "resourceId": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 256
                        },
                        "scope": {
                          "type": "object",
                          "properties": {
                            "placeId": {
                              "type": "string"
                            },
                            "condition": {
                              "type": "string",
                              "minLength": 1,
                              "maxLength": 64,
                              "pattern": "^[a-z0-9_-]+$"
                            },
                            "holderRef": {
                              "type": "string",
                              "minLength": 1,
                              "maxLength": 256
                            },
                            "instanceId": {
                              "type": "string"
                            }
                          },
                          "additionalProperties": false
                        },
                        "quantity": {
                          "type": "number"
                        },
                        "from": {
                          "type": "object",
                          "properties": {
                            "batchId": {
                              "type": "string",
                              "minLength": 1,
                              "maxLength": 256
                            },
                            "supplyId": {
                              "type": "string",
                              "minLength": 1,
                              "maxLength": 256
                            }
                          },
                          "additionalProperties": false
                        },
                        "span": {
                          "type": "object",
                          "properties": {
                            "start": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "end": {
                              "type": "string",
                              "format": "date-time"
                            }
                          },
                          "required": ["start", "end"]
                        }
                      },
                      "required": ["resourceId", "quantity"],
                      "additionalProperties": false
                    }
                  },
                  "estimate": {
                    "type": "boolean"
                  },
                  "evidence": {
                    "type": "object",
                    "properties": {
                      "kind": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 256
                      },
                      "ref": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 256
                      }
                    },
                    "required": ["kind", "ref"]
                  },
                  "sourceKey": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 200
                  }
                },
                "required": ["lines", "evidence", "sourceKey"],
                "additionalProperties": false
              },
              "example": {
                "lines": [
                  {
                    "resourceId": "res_01M83PPH000000000000000003",
                    "scope": {
                      "holderRef": "principal:external:u_maya"
                    },
                    "quantity": 3
                  }
                ],
                "estimate": true,
                "evidence": {
                  "kind": "tasting",
                  "ref": "tasting_1042"
                },
                "sourceKey": "tasting:1042:estimate"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ConsumeResponse"
                },
                "example": {
                  "claims": [
                    {
                      "id": "clm_01M83PPH000000000000000002",
                      "resourceId": "res_01M83PPH000000000000000003",
                      "scope": {
                        "holderRef": "principal:external:u_maya"
                      },
                      "span": {
                        "start": "2026-11-23T09:30:00.000Z",
                        "end": null
                      },
                      "quantity": 3,
                      "kind": "consumption",
                      "status": "committed",
                      "estimate": 3,
                      "pegs": [
                        {
                          "supplyId": "sup_01M83PPH000000000000000003",
                          "quantity": 3
                        }
                      ],
                      "holderRef": "principal:external:u_maya",
                      "evidence": {
                        "kind": "tasting",
                        "ref": "tasting_1042"
                      },
                      "sourceKey": "tasting:1042:estimate",
                      "actor": {
                        "id": "key:juniper-backend"
                      },
                      "createdAt": "2026-11-23T09:30:00.000Z",
                      "updatedAt": "2026-11-23T09:30:00.000Z"
                    }
                  ],
                  "movements": [
                    {
                      "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"
                      }
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad Request, with `error.code` [`invalid_request`](https://agentpost.tools/docs/resourceshark/errors#invalid_request).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["invalid_request"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized, with `error.code` [`unauthenticated`](https://agentpost.tools/docs/resourceshark/errors#unauthenticated).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["unauthenticated"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden, with `error.code` [`forbidden`](https://agentpost.tools/docs/resourceshark/errors#forbidden).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["forbidden"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Not Found, with `error.code` [`not_found`](https://agentpost.tools/docs/resourceshark/errors#not_found).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["not_found"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "409": {
            "description": "Conflict, with `error.code` [`duplicate_source`](https://agentpost.tools/docs/resourceshark/errors#duplicate_source), [`insufficient_supply`](https://agentpost.tools/docs/resourceshark/errors#insufficient_supply), [`exhausted_until_supply`](https://agentpost.tools/docs/resourceshark/errors#exhausted_until_supply), or [`assignment_infeasible`](https://agentpost.tools/docs/resourceshark/errors#assignment_infeasible).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": [
                                "duplicate_source",
                                "insufficient_supply",
                                "exhausted_until_supply",
                                "assignment_infeasible"
                              ]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "413": {
            "description": "Payload Too Large, with `error.code` [`payload_too_large`](https://agentpost.tools/docs/resourceshark/errors#payload_too_large).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["payload_too_large"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "422": {
            "description": "Unprocessable Entity, with `error.code` [`invalid_quantity`](https://agentpost.tools/docs/resourceshark/errors#invalid_quantity).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["invalid_quantity"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error, with `error.code` [`internal_error`](https://agentpost.tools/docs/resourceshark/errors#internal_error).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["internal_error"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/settle": {
      "post": {
        "operationId": "claims.settle",
        "summary": "Settle an estimated claim",
        "description": "Settles estimated consumptions at their real quantities, each once, all or nothing: gives back the difference or takes more, in a settle movement on each claim. An identical repeat under the same sourceKey answers with the first result and duplicate: true. A different request that reuses that sourceKey on one of its resources answers duplicate_source. A new sourceKey for a claim that is already settled answers invalid_request.\n\n- **Who may call:** Your server, with your project’s secret key.\n- **Idempotency-Key:** required. ",
        "tags": ["Claims"],
        "externalDocs": {
          "description": "Settle an estimated claim, in the API reference",
          "url": "https://agentpost.tools/docs/resourceshark/reference/claims#settle-an-estimated-claim"
        },
        "security": [
          {
            "secretKey": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "description": "A key of your choosing for this request. A retry with the same key and the same request within 24 hours answers with the first answer, while you may still make the request; the same key with a different request answers [`idempotency_mismatch`](https://agentpost.tools/docs/resourceshark/errors#idempotency_mismatch), and one whose first request is still running answers [`conflict`](https://agentpost.tools/docs/resourceshark/errors#conflict).",
            "schema": {
              "type": "string"
            },
            "example": "settle-tasting-1042"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "lines": {
                    "minItems": 1,
                    "maxItems": 50,
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "claimId": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 256
                        },
                        "quantity": {
                          "type": "number"
                        }
                      },
                      "required": ["claimId", "quantity"],
                      "additionalProperties": false
                    }
                  },
                  "evidence": {
                    "type": "object",
                    "properties": {
                      "kind": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 256
                      },
                      "ref": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 256
                      }
                    },
                    "required": ["kind", "ref"]
                  },
                  "sourceKey": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 200
                  }
                },
                "required": ["lines", "sourceKey"],
                "additionalProperties": false
              },
              "example": {
                "lines": [
                  {
                    "claimId": "clm_01M83PPH000000000000000002",
                    "quantity": 2
                  }
                ],
                "evidence": {
                  "kind": "attendance",
                  "ref": "tasting_1042"
                },
                "sourceKey": "tasting:1042:attendance"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SettleResponse"
                },
                "example": {
                  "claims": [
                    {
                      "id": "clm_01M83PPH000000000000000002",
                      "resourceId": "res_01M83PPH000000000000000003",
                      "scope": {
                        "holderRef": "principal:external:u_maya"
                      },
                      "span": {
                        "start": "2026-11-23T09:30:00.000Z",
                        "end": null
                      },
                      "quantity": 2,
                      "kind": "consumption",
                      "status": "committed",
                      "estimate": 3,
                      "pegs": [
                        {
                          "supplyId": "sup_01M83PPH000000000000000003",
                          "quantity": 2
                        }
                      ],
                      "holderRef": "principal:external:u_maya",
                      "evidence": {
                        "kind": "tasting",
                        "ref": "tasting_1042"
                      },
                      "sourceKey": "tasting:1042:estimate",
                      "actor": {
                        "id": "key:juniper-backend"
                      },
                      "createdAt": "2026-11-23T09:30:00.000Z",
                      "updatedAt": "2026-11-23T09:40:00.000Z",
                      "settled": 2
                    }
                  ],
                  "movements": [
                    {
                      "id": "mov_01M83PPH000000000000000006",
                      "seq": 6,
                      "resourceId": "res_01M83PPH000000000000000003",
                      "scope": {
                        "holderRef": "principal:external:u_maya"
                      },
                      "reason": "settle",
                      "claimId": "clm_01M83PPH000000000000000002",
                      "supplyId": "sup_01M83PPH000000000000000003",
                      "pegs": [
                        {
                          "supplyId": "sup_01M83PPH000000000000000003",
                          "quantity": 1
                        }
                      ],
                      "evidence": {
                        "kind": "attendance",
                        "ref": "tasting_1042"
                      },
                      "at": "2026-11-23T09:40:00.000Z",
                      "quantity": 1,
                      "before": 9,
                      "after": 10,
                      "actor": {
                        "id": "key:juniper-backend"
                      }
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad Request, with `error.code` [`invalid_request`](https://agentpost.tools/docs/resourceshark/errors#invalid_request).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["invalid_request"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized, with `error.code` [`unauthenticated`](https://agentpost.tools/docs/resourceshark/errors#unauthenticated).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["unauthenticated"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden, with `error.code` [`forbidden`](https://agentpost.tools/docs/resourceshark/errors#forbidden).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["forbidden"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Not Found, with `error.code` [`not_found`](https://agentpost.tools/docs/resourceshark/errors#not_found).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["not_found"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "409": {
            "description": "Conflict, with `error.code` [`duplicate_source`](https://agentpost.tools/docs/resourceshark/errors#duplicate_source), [`insufficient_supply`](https://agentpost.tools/docs/resourceshark/errors#insufficient_supply), [`exhausted_until_supply`](https://agentpost.tools/docs/resourceshark/errors#exhausted_until_supply), or [`assignment_infeasible`](https://agentpost.tools/docs/resourceshark/errors#assignment_infeasible).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": [
                                "duplicate_source",
                                "insufficient_supply",
                                "exhausted_until_supply",
                                "assignment_infeasible"
                              ]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "413": {
            "description": "Payload Too Large, with `error.code` [`payload_too_large`](https://agentpost.tools/docs/resourceshark/errors#payload_too_large).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["payload_too_large"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "422": {
            "description": "Unprocessable Entity, with `error.code` [`invalid_quantity`](https://agentpost.tools/docs/resourceshark/errors#invalid_quantity).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["invalid_quantity"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error, with `error.code` [`internal_error`](https://agentpost.tools/docs/resourceshark/errors#internal_error).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["internal_error"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/claims": {
      "get": {
        "operationId": "claims.list",
        "summary": "List claims",
        "description": "Lists claims, optionally filtered by resource, holder, status, and kind, and by a range their span overlaps, so a resource’s claims from and to are its hours booked then. A caller constrained to one holder lists only its own.\n\n- **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.\n- **Pages:** `limit`, 1 to 500, default 100, with `next` and `after`. [Lists](https://agentpost.tools/docs/platform/api-basics#lists) has the rule.",
        "tags": ["Claims"],
        "externalDocs": {
          "description": "List claims, in the API reference",
          "url": "https://agentpost.tools/docs/resourceshark/reference/claims#list-claims"
        },
        "security": [
          {
            "secretKey": []
          },
          {
            "userToken": []
          }
        ],
        "parameters": [
          {
            "name": "resourceId",
            "in": "query",
            "required": false,
            "description": "1–256 characters.",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 256
            },
            "example": "res_01M83PPH000000000000000003"
          },
          {
            "name": "holderRef",
            "in": "query",
            "required": false,
            "description": "1–256 characters.",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 256
            },
            "example": "principal:external:u_maya"
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": ["held", "committed", "released", "expired", "cancelled"]
            }
          },
          {
            "name": "kind",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": ["hold", "consumption", "booking"]
            },
            "example": "consumption"
          },
          {
            "name": "from",
            "in": "query",
            "required": false,
            "description": "An ISO 8601 date and time.",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "to",
            "in": "query",
            "required": false,
            "description": "An ISO 8601 date and time.",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "after",
            "in": "query",
            "required": false,
            "description": "1–200 characters.",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 200
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "1–500; default `100`.",
            "schema": {
              "default": 100,
              "type": "integer",
              "exclusiveMinimum": 0,
              "maximum": 500
            },
            "example": 20
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ClaimsPage"
                },
                "example": {
                  "claims": [
                    {
                      "id": "clm_01M83PPH000000000000000002",
                      "resourceId": "res_01M83PPH000000000000000003",
                      "scope": {
                        "holderRef": "principal:external:u_maya"
                      },
                      "span": {
                        "start": "2026-11-23T09:30:00.000Z",
                        "end": null
                      },
                      "quantity": 2,
                      "kind": "consumption",
                      "status": "committed",
                      "estimate": 3,
                      "pegs": [
                        {
                          "supplyId": "sup_01M83PPH000000000000000003",
                          "quantity": 2
                        }
                      ],
                      "holderRef": "principal:external:u_maya",
                      "evidence": {
                        "kind": "tasting",
                        "ref": "tasting_1042"
                      },
                      "sourceKey": "tasting:1042:estimate",
                      "actor": {
                        "id": "key:juniper-backend"
                      },
                      "createdAt": "2026-11-23T09:30:00.000Z",
                      "updatedAt": "2026-11-23T09:40:00.000Z",
                      "settled": 2
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad Request, with `error.code` [`invalid_request`](https://agentpost.tools/docs/resourceshark/errors#invalid_request).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["invalid_request"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized, with `error.code` [`unauthenticated`](https://agentpost.tools/docs/resourceshark/errors#unauthenticated).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["unauthenticated"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden, with `error.code` [`forbidden`](https://agentpost.tools/docs/resourceshark/errors#forbidden).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["forbidden"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error, with `error.code` [`internal_error`](https://agentpost.tools/docs/resourceshark/errors#internal_error).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["internal_error"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/claims/{id}": {
      "get": {
        "operationId": "claims.get",
        "summary": "Get a claim",
        "description": "Reads a claim. A caller constrained to one holder reads only its own.\n\n- **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.",
        "tags": ["Claims"],
        "externalDocs": {
          "description": "Get a claim, in the API reference",
          "url": "https://agentpost.tools/docs/resourceshark/reference/claims#get-a-claim"
        },
        "security": [
          {
            "secretKey": []
          },
          {
            "userToken": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Claim ID, `clm_…`. The `id` of a [`Claim`](https://agentpost.tools/docs/resourceshark/reference/claims#the-claim-object).",
            "schema": {
              "type": "string"
            },
            "example": "clm_01M83PPH000000000000000002"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ClaimResponse"
                },
                "example": {
                  "claim": {
                    "id": "clm_01M83PPH000000000000000002",
                    "resourceId": "res_01M83PPH000000000000000003",
                    "scope": {
                      "holderRef": "principal:external:u_maya"
                    },
                    "span": {
                      "start": "2026-11-23T09:30:00.000Z",
                      "end": null
                    },
                    "quantity": 2,
                    "kind": "consumption",
                    "status": "committed",
                    "estimate": 3,
                    "pegs": [
                      {
                        "supplyId": "sup_01M83PPH000000000000000003",
                        "quantity": 2
                      }
                    ],
                    "holderRef": "principal:external:u_maya",
                    "evidence": {
                      "kind": "tasting",
                      "ref": "tasting_1042"
                    },
                    "sourceKey": "tasting:1042:estimate",
                    "actor": {
                      "id": "key:juniper-backend"
                    },
                    "createdAt": "2026-11-23T09:30:00.000Z",
                    "updatedAt": "2026-11-23T09:40:00.000Z",
                    "settled": 2
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized, with `error.code` [`unauthenticated`](https://agentpost.tools/docs/resourceshark/errors#unauthenticated).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["unauthenticated"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden, with `error.code` [`forbidden`](https://agentpost.tools/docs/resourceshark/errors#forbidden).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["forbidden"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Not Found, with `error.code` [`not_found`](https://agentpost.tools/docs/resourceshark/errors#not_found).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["not_found"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error, with `error.code` [`internal_error`](https://agentpost.tools/docs/resourceshark/errors#internal_error).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["internal_error"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/resources/{id}/schedule": {
      "put": {
        "operationId": "schedules.put",
        "summary": "Save a schedule",
        "description": "Saves a bucketed resource’s weekly schedule. Each pattern takes effect from a local date. A pattern that has taken effect stays as it is; to change the hours from a date, add a pattern that starts then, and patterns from tomorrow on can be changed or removed. The first save requires timeZone, which is fixed thereafter, and sends no If-Match. Once it has a schedule, send the version you read in If-Match. Reads and claims count the new capacity at once, and the nearest 1,000 buckets a claim has touched move to it in the save, with a capacity movement each. What is already held or taken stays as it is: overCapacity lists the buckets now over capacity, with the claims in each.\n\n- **Who may call:** Your server, with your project’s secret key.\n- **Idempotency-Key:** optional. ",
        "tags": ["Schedules"],
        "externalDocs": {
          "description": "Save a schedule, in the API reference",
          "url": "https://agentpost.tools/docs/resourceshark/reference/schedules#save-a-schedule"
        },
        "security": [
          {
            "secretKey": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Resource ID, `res_…`. The `id` of a [`Resource`](https://agentpost.tools/docs/resourceshark/reference/resources#the-resource-object).",
            "schema": {
              "type": "string"
            },
            "example": "res_01M83PPH000000000000000004"
          },
          {
            "name": "If-Match",
            "in": "header",
            "required": false,
            "description": "Send the version you read when replacing an existing schedule.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "A key of your choosing for this request. A retry with the same key and the same request within 24 hours answers with the first answer, while you may still make the request; the same key with a different request answers [`idempotency_mismatch`](https://agentpost.tools/docs/resourceshark/errors#idempotency_mismatch), and one whose first request is still running answers [`conflict`](https://agentpost.tools/docs/resourceshark/errors#conflict).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "timeZone": {
                    "type": "string"
                  },
                  "patterns": {
                    "minItems": 1,
                    "maxItems": 100,
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "from": {
                          "type": "string",
                          "format": "date",
                          "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))$"
                        },
                        "weekly": {
                          "maxItems": 100,
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "day": {
                                "type": "integer",
                                "minimum": 0,
                                "maximum": 6
                              },
                              "start": {
                                "type": "string",
                                "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$"
                              },
                              "end": {
                                "type": "string",
                                "pattern": "^(([01]\\d|2[0-3]):[0-5]\\d|24:00)$"
                              },
                              "capacity": {
                                "type": "number"
                              }
                            },
                            "required": ["day", "start", "end"],
                            "additionalProperties": false
                          }
                        }
                      },
                      "required": ["weekly"],
                      "additionalProperties": false
                    }
                  }
                },
                "required": ["patterns"],
                "additionalProperties": false
              },
              "example": {
                "timeZone": "America/Los_Angeles",
                "patterns": [
                  {
                    "weekly": [
                      {
                        "day": 1,
                        "start": "09:00",
                        "end": "17:00"
                      }
                    ]
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ScheduleSaveResponse"
                },
                "example": {
                  "schedule": {
                    "timeZone": "America/Los_Angeles",
                    "patterns": [
                      {
                        "weekly": [
                          {
                            "day": 1,
                            "start": "09:00",
                            "end": "17:00"
                          }
                        ]
                      }
                    ],
                    "resourceId": "res_01M83PPH000000000000000004",
                    "version": 1,
                    "updatedAt": "2026-11-23T08:30:00.000Z"
                  },
                  "overCapacity": {
                    "buckets": [],
                    "more": false
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad Request, with `error.code` [`invalid_request`](https://agentpost.tools/docs/resourceshark/errors#invalid_request).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["invalid_request"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized, with `error.code` [`unauthenticated`](https://agentpost.tools/docs/resourceshark/errors#unauthenticated).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["unauthenticated"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden, with `error.code` [`forbidden`](https://agentpost.tools/docs/resourceshark/errors#forbidden).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["forbidden"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Not Found, with `error.code` [`not_found`](https://agentpost.tools/docs/resourceshark/errors#not_found).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["not_found"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "409": {
            "description": "Conflict, with `error.code` [`stale_version`](https://agentpost.tools/docs/resourceshark/errors#stale_version).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["stale_version"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "413": {
            "description": "Payload Too Large, with `error.code` [`payload_too_large`](https://agentpost.tools/docs/resourceshark/errors#payload_too_large).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["payload_too_large"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "422": {
            "description": "Unprocessable Entity, with `error.code` [`invalid_quantity`](https://agentpost.tools/docs/resourceshark/errors#invalid_quantity).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["invalid_quantity"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error, with `error.code` [`internal_error`](https://agentpost.tools/docs/resourceshark/errors#internal_error).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["internal_error"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      },
      "get": {
        "operationId": "schedules.get",
        "summary": "Get a schedule",
        "description": "Reads a resource’s schedule and its version.\n\n- **Who may call:** Your server, with your project’s secret key.",
        "tags": ["Schedules"],
        "externalDocs": {
          "description": "Get a schedule, in the API reference",
          "url": "https://agentpost.tools/docs/resourceshark/reference/schedules#get-a-schedule"
        },
        "security": [
          {
            "secretKey": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Resource ID, `res_…`. The `id` of a [`Resource`](https://agentpost.tools/docs/resourceshark/reference/resources#the-resource-object).",
            "schema": {
              "type": "string"
            },
            "example": "res_01M83PPH000000000000000004"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ScheduleResponse"
                },
                "example": {
                  "schedule": {
                    "timeZone": "America/Los_Angeles",
                    "patterns": [
                      {
                        "weekly": [
                          {
                            "day": 1,
                            "start": "09:00",
                            "end": "17:00"
                          }
                        ]
                      }
                    ],
                    "resourceId": "res_01M83PPH000000000000000004",
                    "version": 1,
                    "updatedAt": "2026-11-23T08:30:00.000Z"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized, with `error.code` [`unauthenticated`](https://agentpost.tools/docs/resourceshark/errors#unauthenticated).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["unauthenticated"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden, with `error.code` [`forbidden`](https://agentpost.tools/docs/resourceshark/errors#forbidden).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["forbidden"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Not Found, with `error.code` [`not_found`](https://agentpost.tools/docs/resourceshark/errors#not_found).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["not_found"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error, with `error.code` [`internal_error`](https://agentpost.tools/docs/resourceshark/errors#internal_error).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["internal_error"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/resources/{id}/exceptions": {
      "post": {
        "operationId": "exceptions.create",
        "summary": "Create a schedule exception",
        "description": "Adds an exception to a bucketed resource: over its span, each bucket it overlaps holds its capacity in place of the weekly pattern’s, and 0 makes it unavailable. Where exceptions overlap, the lowest capacity wins. What is already held or taken stays as it is: overCapacity lists the buckets now over capacity, with the claims in each. A resource has at most 500. A repeat under the same sourceKey answers with the first result.\n\n- **Who may call:** Your server, with your project’s secret key.\n- **Idempotency-Key:** required. ",
        "tags": ["Schedules"],
        "externalDocs": {
          "description": "Create a schedule exception, in the API reference",
          "url": "https://agentpost.tools/docs/resourceshark/reference/schedules#create-a-schedule-exception"
        },
        "security": [
          {
            "secretKey": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Resource ID, `res_…`. The `id` of a [`Resource`](https://agentpost.tools/docs/resourceshark/reference/resources#the-resource-object).",
            "schema": {
              "type": "string"
            },
            "example": "res_01M83PPH000000000000000004"
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "description": "A key of your choosing for this request. A retry with the same key and the same request within 24 hours answers with the first answer, while you may still make the request; the same key with a different request answers [`idempotency_mismatch`](https://agentpost.tools/docs/resourceshark/errors#idempotency_mismatch), and one whose first request is still running answers [`conflict`](https://agentpost.tools/docs/resourceshark/errors#conflict).",
            "schema": {
              "type": "string"
            },
            "example": "close-courts-23"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "span": {
                    "type": "object",
                    "properties": {
                      "start": {
                        "type": "string",
                        "format": "date-time"
                      },
                      "end": {
                        "type": "string",
                        "format": "date-time"
                      }
                    },
                    "required": ["start", "end"]
                  },
                  "capacity": {
                    "type": "number"
                  },
                  "reason": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 200
                  },
                  "sourceKey": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 200
                  }
                },
                "required": ["span", "capacity", "sourceKey"],
                "additionalProperties": false
              },
              "example": {
                "span": {
                  "start": "2026-11-23T18:00:00.000Z",
                  "end": "2026-11-23T19:00:00.000Z"
                },
                "capacity": 0,
                "reason": "Court resurfacing",
                "sourceKey": "courts:resurfacing:23"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ExceptionCreateResponse"
                },
                "example": {
                  "exception": {
                    "id": "exc_01M83PPH000000000000000001",
                    "resourceId": "res_01M83PPH000000000000000004",
                    "span": {
                      "start": "2026-11-23T18:00:00.000Z",
                      "end": "2026-11-23T19:00:00.000Z"
                    },
                    "capacity": 0,
                    "reason": "Court resurfacing",
                    "version": 1,
                    "createdAt": "2026-11-23T11:22:00.000Z",
                    "updatedAt": "2026-11-23T11:22:00.000Z"
                  },
                  "overCapacity": {
                    "buckets": [
                      {
                        "span": {
                          "start": "2026-11-23T18:00:00.000Z",
                          "end": "2026-11-23T19:00:00.000Z"
                        },
                        "scope": {
                          "instanceId": "ins_01M83PPH000000000000000001"
                        },
                        "capacity": 0,
                        "taken": 1,
                        "held": 0,
                        "claims": [
                          {
                            "id": "clm_01M83PPH000000000000000004",
                            "kind": "booking",
                            "status": "committed",
                            "quantity": 1,
                            "holdId": "hld_01M83PPH000000000000000002",
                            "holderRef": "principal:external:u_maya"
                          }
                        ]
                      }
                    ],
                    "more": false
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad Request, with `error.code` [`invalid_request`](https://agentpost.tools/docs/resourceshark/errors#invalid_request).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["invalid_request"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized, with `error.code` [`unauthenticated`](https://agentpost.tools/docs/resourceshark/errors#unauthenticated).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["unauthenticated"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden, with `error.code` [`forbidden`](https://agentpost.tools/docs/resourceshark/errors#forbidden).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["forbidden"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Not Found, with `error.code` [`not_found`](https://agentpost.tools/docs/resourceshark/errors#not_found).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["not_found"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "409": {
            "description": "Conflict, with `error.code` [`duplicate_source`](https://agentpost.tools/docs/resourceshark/errors#duplicate_source).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["duplicate_source"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "413": {
            "description": "Payload Too Large, with `error.code` [`payload_too_large`](https://agentpost.tools/docs/resourceshark/errors#payload_too_large).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["payload_too_large"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "422": {
            "description": "Unprocessable Entity, with `error.code` [`invalid_quantity`](https://agentpost.tools/docs/resourceshark/errors#invalid_quantity).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["invalid_quantity"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error, with `error.code` [`internal_error`](https://agentpost.tools/docs/resourceshark/errors#internal_error).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["internal_error"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      },
      "get": {
        "operationId": "exceptions.list",
        "summary": "List schedule exceptions",
        "description": "Lists a resource’s exceptions that overlap [from, to), or all of them, by start.\n\n- **Who may call:** Your server, with your project’s secret key.",
        "tags": ["Schedules"],
        "externalDocs": {
          "description": "List schedule exceptions, in the API reference",
          "url": "https://agentpost.tools/docs/resourceshark/reference/schedules#list-schedule-exceptions"
        },
        "security": [
          {
            "secretKey": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Resource ID, `res_…`. The `id` of a [`Resource`](https://agentpost.tools/docs/resourceshark/reference/resources#the-resource-object).",
            "schema": {
              "type": "string"
            },
            "example": "res_01M83PPH000000000000000004"
          },
          {
            "name": "from",
            "in": "query",
            "required": false,
            "description": "An ISO 8601 date and time.",
            "schema": {
              "type": "string",
              "format": "date-time"
            },
            "example": "2026-11-23T17:00:00.000Z"
          },
          {
            "name": "to",
            "in": "query",
            "required": false,
            "description": "An ISO 8601 date and time.",
            "schema": {
              "type": "string",
              "format": "date-time"
            },
            "example": "2026-11-23T21:00:00.000Z"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ExceptionsList"
                },
                "example": {
                  "exceptions": [
                    {
                      "id": "exc_01M83PPH000000000000000001",
                      "resourceId": "res_01M83PPH000000000000000004",
                      "span": {
                        "start": "2026-11-23T18:00:00.000Z",
                        "end": "2026-11-23T19:00:00.000Z"
                      },
                      "capacity": 0,
                      "reason": "Court resurfacing",
                      "version": 1,
                      "createdAt": "2026-11-23T11:22:00.000Z",
                      "updatedAt": "2026-11-23T11:22:00.000Z"
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad Request, with `error.code` [`invalid_request`](https://agentpost.tools/docs/resourceshark/errors#invalid_request).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["invalid_request"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized, with `error.code` [`unauthenticated`](https://agentpost.tools/docs/resourceshark/errors#unauthenticated).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["unauthenticated"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden, with `error.code` [`forbidden`](https://agentpost.tools/docs/resourceshark/errors#forbidden).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["forbidden"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Not Found, with `error.code` [`not_found`](https://agentpost.tools/docs/resourceshark/errors#not_found).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["not_found"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error, with `error.code` [`internal_error`](https://agentpost.tools/docs/resourceshark/errors#internal_error).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["internal_error"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/resources/{id}/exceptions/{eid}": {
      "patch": {
        "operationId": "exceptions.patch",
        "summary": "Update a schedule exception",
        "description": "Moves an exception’s span or changes its capacity, at the version in If-Match. overCapacity lists the buckets now over capacity, with the claims in each.\n\n- **Who may call:** Your server, with your project’s secret key.\n- **Idempotency-Key:** optional. ",
        "tags": ["Schedules"],
        "externalDocs": {
          "description": "Update a schedule exception, in the API reference",
          "url": "https://agentpost.tools/docs/resourceshark/reference/schedules#update-a-schedule-exception"
        },
        "security": [
          {
            "secretKey": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Resource ID, `res_…`. The `id` of a [`Resource`](https://agentpost.tools/docs/resourceshark/reference/resources#the-resource-object).",
            "schema": {
              "type": "string"
            },
            "example": "res_01M83PPH000000000000000004"
          },
          {
            "name": "eid",
            "in": "path",
            "required": true,
            "description": "Exception ID, `exc_…`. The `id` of a [`ScheduleException`](https://agentpost.tools/docs/resourceshark/reference/schedules#the-scheduleexception-object).",
            "schema": {
              "type": "string"
            },
            "example": "exc_01M83PPH000000000000000001"
          },
          {
            "name": "If-Match",
            "in": "header",
            "required": true,
            "description": "Required. Send the version you read.",
            "schema": {
              "type": "string"
            },
            "example": "1"
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "A key of your choosing for this request. A retry with the same key and the same request within 24 hours answers with the first answer, while you may still make the request; the same key with a different request answers [`idempotency_mismatch`](https://agentpost.tools/docs/resourceshark/errors#idempotency_mismatch), and one whose first request is still running answers [`conflict`](https://agentpost.tools/docs/resourceshark/errors#conflict).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "span": {
                    "type": "object",
                    "properties": {
                      "start": {
                        "type": "string",
                        "format": "date-time"
                      },
                      "end": {
                        "type": "string",
                        "format": "date-time"
                      }
                    },
                    "required": ["start", "end"]
                  },
                  "capacity": {
                    "type": "number"
                  },
                  "reason": {
                    "anyOf": [
                      {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 200
                      },
                      {
                        "type": "null"
                      }
                    ]
                  }
                },
                "additionalProperties": false
              },
              "example": {
                "span": {
                  "start": "2026-11-23T19:00:00.000Z",
                  "end": "2026-11-23T20:00:00.000Z"
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ExceptionResponse"
                },
                "example": {
                  "exception": {
                    "id": "exc_01M83PPH000000000000000001",
                    "resourceId": "res_01M83PPH000000000000000004",
                    "span": {
                      "start": "2026-11-23T19:00:00.000Z",
                      "end": "2026-11-23T20:00:00.000Z"
                    },
                    "capacity": 0,
                    "reason": "Court resurfacing",
                    "version": 2,
                    "createdAt": "2026-11-23T11:22:00.000Z",
                    "updatedAt": "2026-11-23T11:25:00.000Z"
                  },
                  "overCapacity": {
                    "buckets": [],
                    "more": false
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad Request, with `error.code` [`invalid_request`](https://agentpost.tools/docs/resourceshark/errors#invalid_request).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["invalid_request"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized, with `error.code` [`unauthenticated`](https://agentpost.tools/docs/resourceshark/errors#unauthenticated).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["unauthenticated"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden, with `error.code` [`forbidden`](https://agentpost.tools/docs/resourceshark/errors#forbidden).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["forbidden"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Not Found, with `error.code` [`not_found`](https://agentpost.tools/docs/resourceshark/errors#not_found).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["not_found"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "409": {
            "description": "Conflict, with `error.code` [`stale_version`](https://agentpost.tools/docs/resourceshark/errors#stale_version).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["stale_version"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "413": {
            "description": "Payload Too Large, with `error.code` [`payload_too_large`](https://agentpost.tools/docs/resourceshark/errors#payload_too_large).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["payload_too_large"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "422": {
            "description": "Unprocessable Entity, with `error.code` [`invalid_quantity`](https://agentpost.tools/docs/resourceshark/errors#invalid_quantity).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["invalid_quantity"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error, with `error.code` [`internal_error`](https://agentpost.tools/docs/resourceshark/errors#internal_error).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["internal_error"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "exceptions.delete",
        "summary": "Delete a schedule exception",
        "description": "Removes an exception, so its span takes the weekly pattern’s capacity again: removing a closure reopens it. overCapacity lists the buckets now over capacity, with the claims in each.\n\n- **Who may call:** Your server, with your project’s secret key.\n- **Idempotency-Key:** optional. ",
        "tags": ["Schedules"],
        "externalDocs": {
          "description": "Delete a schedule exception, in the API reference",
          "url": "https://agentpost.tools/docs/resourceshark/reference/schedules#delete-a-schedule-exception"
        },
        "security": [
          {
            "secretKey": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Resource ID, `res_…`. The `id` of a [`Resource`](https://agentpost.tools/docs/resourceshark/reference/resources#the-resource-object).",
            "schema": {
              "type": "string"
            },
            "example": "res_01M83PPH000000000000000004"
          },
          {
            "name": "eid",
            "in": "path",
            "required": true,
            "description": "Exception ID, `exc_…`. The `id` of a [`ScheduleException`](https://agentpost.tools/docs/resourceshark/reference/schedules#the-scheduleexception-object).",
            "schema": {
              "type": "string"
            },
            "example": "exc_01M83PPH000000000000000001"
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "A key of your choosing for this request. A retry with the same key and the same request within 24 hours answers with the first answer, while you may still make the request; the same key with a different request answers [`idempotency_mismatch`](https://agentpost.tools/docs/resourceshark/errors#idempotency_mismatch), and one whose first request is still running answers [`conflict`](https://agentpost.tools/docs/resourceshark/errors#conflict).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ExceptionDeleteResponse"
                },
                "example": {
                  "overCapacity": {
                    "buckets": [],
                    "more": false
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad Request, with `error.code` [`invalid_request`](https://agentpost.tools/docs/resourceshark/errors#invalid_request).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["invalid_request"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized, with `error.code` [`unauthenticated`](https://agentpost.tools/docs/resourceshark/errors#unauthenticated).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["unauthenticated"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden, with `error.code` [`forbidden`](https://agentpost.tools/docs/resourceshark/errors#forbidden).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["forbidden"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Not Found, with `error.code` [`not_found`](https://agentpost.tools/docs/resourceshark/errors#not_found).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["not_found"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error, with `error.code` [`internal_error`](https://agentpost.tools/docs/resourceshark/errors#internal_error).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["internal_error"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/slots": {
      "get": {
        "operationId": "slots.list",
        "summary": "List slots",
        "description": "Lists the buckets that start in [from, to) for one resource and have capacity or claims. Each gives its local time in the resource’s bucket time zone, its capacity, what is taken and held, and what is free, never below 0. Send placeId for a resource kept by place, and condition to select a label there. Omitting condition selects the unlabeled scope. On a resource with identity: instance, send the unit’s instanceId: each bucket holds the unit or nothing. A bucket over capacity is listed with its claims’ total above its capacity. A hold past its expiry no longer counts. At most 2,000 buckets per request.\n\n- **Who may call:** Your server, with your project’s secret key.",
        "tags": ["Slots"],
        "externalDocs": {
          "description": "List slots, in the API reference",
          "url": "https://agentpost.tools/docs/resourceshark/reference/slots#list-slots"
        },
        "security": [
          {
            "secretKey": []
          }
        ],
        "parameters": [
          {
            "name": "resourceId",
            "in": "query",
            "required": true,
            "description": "1–256 characters.",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 256
            },
            "example": "res_01M83PPH000000000000000004"
          },
          {
            "name": "placeId",
            "in": "query",
            "required": false,
            "description": "1–256 characters.",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 256
            }
          },
          {
            "name": "condition",
            "in": "query",
            "required": false,
            "description": "1–64 characters.",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 64,
              "pattern": "^[a-z0-9_-]+$"
            }
          },
          {
            "name": "instanceId",
            "in": "query",
            "required": false,
            "description": "1–256 characters.",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 256
            },
            "example": "ins_01M83PPH000000000000000001"
          },
          {
            "name": "from",
            "in": "query",
            "required": true,
            "description": "An ISO 8601 date and time.",
            "schema": {
              "type": "string",
              "format": "date-time"
            },
            "example": "2026-11-23T17:00:00.000Z"
          },
          {
            "name": "to",
            "in": "query",
            "required": true,
            "description": "An ISO 8601 date and time.",
            "schema": {
              "type": "string",
              "format": "date-time"
            },
            "example": "2026-11-23T19:00:00.000Z"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SlotsResponse"
                },
                "example": {
                  "slots": [
                    {
                      "start": "2026-11-23T17:00:00.000Z",
                      "end": "2026-11-23T18:00:00.000Z",
                      "timeZone": "America/Los_Angeles",
                      "local": {
                        "date": "2026-11-23",
                        "time": "09:00"
                      },
                      "capacity": 1,
                      "taken": 1,
                      "held": 0,
                      "available": 0
                    },
                    {
                      "start": "2026-11-23T18:00:00.000Z",
                      "end": "2026-11-23T19:00:00.000Z",
                      "timeZone": "America/Los_Angeles",
                      "local": {
                        "date": "2026-11-23",
                        "time": "10:00"
                      },
                      "capacity": 1,
                      "taken": 0,
                      "held": 0,
                      "available": 1
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad Request, with `error.code` [`invalid_request`](https://agentpost.tools/docs/resourceshark/errors#invalid_request).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["invalid_request"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized, with `error.code` [`unauthenticated`](https://agentpost.tools/docs/resourceshark/errors#unauthenticated).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["unauthenticated"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden, with `error.code` [`forbidden`](https://agentpost.tools/docs/resourceshark/errors#forbidden).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["forbidden"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Not Found, with `error.code` [`not_found`](https://agentpost.tools/docs/resourceshark/errors#not_found).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["not_found"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error, with `error.code` [`internal_error`](https://agentpost.tools/docs/resourceshark/errors#internal_error).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["internal_error"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/transfers": {
      "post": {
        "operationId": "transfers.create",
        "summary": "Transfer stock",
        "description": "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.\n\n- **Who may call:** Your server, with your project’s secret key.\n- **Idempotency-Key:** required. ",
        "tags": ["Stock"],
        "externalDocs": {
          "description": "Transfer stock, in the API reference",
          "url": "https://agentpost.tools/docs/resourceshark/reference/stock#transfer-stock"
        },
        "security": [
          {
            "secretKey": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "description": "A key of your choosing for this request. A retry with the same key and the same request within 24 hours answers with the first answer, while you may still make the request; the same key with a different request answers [`idempotency_mismatch`](https://agentpost.tools/docs/resourceshark/errors#idempotency_mismatch), and one whose first request is still running answers [`conflict`](https://agentpost.tools/docs/resourceshark/errors#conflict).",
            "schema": {
              "type": "string"
            },
            "example": "market-restock-113"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "resourceId": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 256
                  },
                  "from": {
                    "type": "object",
                    "properties": {
                      "placeId": {
                        "type": "string"
                      },
                      "condition": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 64,
                        "pattern": "^[a-z0-9_-]+$"
                      },
                      "holderRef": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 256
                      },
                      "instanceId": {
                        "type": "string"
                      },
                      "batchId": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 256
                      },
                      "supplyId": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 256
                      }
                    },
                    "additionalProperties": false
                  },
                  "to": {
                    "type": "object",
                    "properties": {
                      "placeId": {
                        "type": "string"
                      },
                      "condition": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 64,
                        "pattern": "^[a-z0-9_-]+$"
                      },
                      "holderRef": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 256
                      },
                      "instanceId": {
                        "type": "string"
                      }
                    },
                    "additionalProperties": false
                  },
                  "quantity": {
                    "type": "number"
                  },
                  "sourceKey": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 200
                  },
                  "evidence": {
                    "type": "object",
                    "properties": {
                      "kind": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 256
                      },
                      "ref": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 256
                      }
                    },
                    "required": ["kind", "ref"]
                  },
                  "note": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 200
                  }
                },
                "required": [
                  "resourceId",
                  "from",
                  "to",
                  "quantity",
                  "sourceKey"
                ],
                "additionalProperties": false
              },
              "example": {
                "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"
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TransferResponse"
                },
                "example": {
                  "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"
                      }
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad Request, with `error.code` [`invalid_request`](https://agentpost.tools/docs/resourceshark/errors#invalid_request).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["invalid_request"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized, with `error.code` [`unauthenticated`](https://agentpost.tools/docs/resourceshark/errors#unauthenticated).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["unauthenticated"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden, with `error.code` [`forbidden`](https://agentpost.tools/docs/resourceshark/errors#forbidden).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["forbidden"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Not Found, with `error.code` [`not_found`](https://agentpost.tools/docs/resourceshark/errors#not_found).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["not_found"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "409": {
            "description": "Conflict, with `error.code` [`duplicate_source`](https://agentpost.tools/docs/resourceshark/errors#duplicate_source), [`insufficient_supply`](https://agentpost.tools/docs/resourceshark/errors#insufficient_supply), [`exhausted_until_supply`](https://agentpost.tools/docs/resourceshark/errors#exhausted_until_supply), or [`assignment_infeasible`](https://agentpost.tools/docs/resourceshark/errors#assignment_infeasible).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": [
                                "duplicate_source",
                                "insufficient_supply",
                                "exhausted_until_supply",
                                "assignment_infeasible"
                              ]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "413": {
            "description": "Payload Too Large, with `error.code` [`payload_too_large`](https://agentpost.tools/docs/resourceshark/errors#payload_too_large).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["payload_too_large"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "422": {
            "description": "Unprocessable Entity, with `error.code` [`invalid_quantity`](https://agentpost.tools/docs/resourceshark/errors#invalid_quantity).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["invalid_quantity"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error, with `error.code` [`internal_error`](https://agentpost.tools/docs/resourceshark/errors#internal_error).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["internal_error"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/counts": {
      "post": {
        "operationId": "counts.create",
        "summary": "Record a count",
        "description": "Records a stock count against the balance version the counter read.\n\n- **Who may call:** Your server, with your project’s secret key.\n- **Idempotency-Key:** required. ",
        "tags": ["Stock"],
        "externalDocs": {
          "description": "Record a count, in the API reference",
          "url": "https://agentpost.tools/docs/resourceshark/reference/stock#record-a-count"
        },
        "security": [
          {
            "secretKey": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "description": "A key of your choosing for this request. A retry with the same key and the same request within 24 hours answers with the first answer, while you may still make the request; the same key with a different request answers [`idempotency_mismatch`](https://agentpost.tools/docs/resourceshark/errors#idempotency_mismatch), and one whose first request is still running answers [`conflict`](https://agentpost.tools/docs/resourceshark/errors#conflict).",
            "schema": {
              "type": "string"
            },
            "example": "market-count-113"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "resourceId": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 256
                  },
                  "scope": {
                    "default": {},
                    "type": "object",
                    "properties": {
                      "placeId": {
                        "type": "string"
                      },
                      "condition": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 64,
                        "pattern": "^[a-z0-9_-]+$"
                      },
                      "holderRef": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 256
                      },
                      "instanceId": {
                        "type": "string"
                      }
                    },
                    "additionalProperties": false
                  },
                  "quantity": {
                    "type": "number"
                  },
                  "from": {
                    "type": "object",
                    "properties": {
                      "batchId": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 256
                      },
                      "supplyId": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 256
                      }
                    },
                    "additionalProperties": false
                  },
                  "version": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 9007199254740991
                  },
                  "evidence": {
                    "type": "object",
                    "properties": {
                      "kind": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 256
                      },
                      "ref": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 256
                      }
                    },
                    "required": ["kind", "ref"]
                  },
                  "note": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 200
                  }
                },
                "required": ["resourceId", "quantity", "version"],
                "additionalProperties": false
              },
              "example": {
                "resourceId": "res_01M83PPH000000000000000001",
                "scope": {
                  "placeId": "plc_01M83PPH000000000000000002"
                },
                "quantity": 1900,
                "version": 1,
                "evidence": {
                  "kind": "stock_count",
                  "ref": "market_count_113"
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CountResponse"
                },
                "example": {
                  "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"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad Request, with `error.code` [`invalid_request`](https://agentpost.tools/docs/resourceshark/errors#invalid_request).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["invalid_request"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized, with `error.code` [`unauthenticated`](https://agentpost.tools/docs/resourceshark/errors#unauthenticated).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["unauthenticated"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden, with `error.code` [`forbidden`](https://agentpost.tools/docs/resourceshark/errors#forbidden).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["forbidden"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Not Found, with `error.code` [`not_found`](https://agentpost.tools/docs/resourceshark/errors#not_found).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["not_found"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "409": {
            "description": "Conflict, with `error.code` [`insufficient_supply`](https://agentpost.tools/docs/resourceshark/errors#insufficient_supply) or [`stale_version`](https://agentpost.tools/docs/resourceshark/errors#stale_version).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["insufficient_supply", "stale_version"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "413": {
            "description": "Payload Too Large, with `error.code` [`payload_too_large`](https://agentpost.tools/docs/resourceshark/errors#payload_too_large).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["payload_too_large"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "422": {
            "description": "Unprocessable Entity, with `error.code` [`invalid_quantity`](https://agentpost.tools/docs/resourceshark/errors#invalid_quantity).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["invalid_quantity"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error, with `error.code` [`internal_error`](https://agentpost.tools/docs/resourceshark/errors#internal_error).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["internal_error"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/adjustments": {
      "post": {
        "operationId": "adjustments.create",
        "summary": "Adjust stock",
        "description": "Records a signed adjustment with a reason, or reverses a movement. A repeat under the same sourceKey answers with the first result.\n\n- **Who may call:** Your server, with your project’s secret key.\n- **Idempotency-Key:** required. ",
        "tags": ["Stock"],
        "externalDocs": {
          "description": "Adjust stock, in the API reference",
          "url": "https://agentpost.tools/docs/resourceshark/reference/stock#adjust-stock"
        },
        "security": [
          {
            "secretKey": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "description": "A key of your choosing for this request. A retry with the same key and the same request within 24 hours answers with the first answer, while you may still make the request; the same key with a different request answers [`idempotency_mismatch`](https://agentpost.tools/docs/resourceshark/errors#idempotency_mismatch), and one whose first request is still running answers [`conflict`](https://agentpost.tools/docs/resourceshark/errors#conflict).",
            "schema": {
              "type": "string"
            },
            "example": "market-spill-114"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "anyOf": [
                  {
                    "type": "object",
                    "properties": {
                      "resourceId": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 256
                      },
                      "scope": {
                        "default": {},
                        "type": "object",
                        "properties": {
                          "placeId": {
                            "type": "string"
                          },
                          "condition": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 64,
                            "pattern": "^[a-z0-9_-]+$"
                          },
                          "holderRef": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 256
                          },
                          "instanceId": {
                            "type": "string"
                          }
                        },
                        "additionalProperties": false
                      },
                      "quantity": {
                        "type": "number"
                      },
                      "from": {
                        "type": "object",
                        "properties": {
                          "batchId": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 256
                          },
                          "supplyId": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 256
                          }
                        },
                        "additionalProperties": false
                      },
                      "evidence": {
                        "type": "object",
                        "properties": {
                          "kind": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 256
                          },
                          "ref": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 256
                          }
                        },
                        "required": ["kind", "ref"]
                      },
                      "note": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 200
                      },
                      "sourceKey": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 200
                      }
                    },
                    "required": ["resourceId", "quantity", "note", "sourceKey"],
                    "additionalProperties": false
                  },
                  {
                    "type": "object",
                    "properties": {
                      "reverses": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 256
                      },
                      "sourceKey": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 200
                      },
                      "evidence": {
                        "type": "object",
                        "properties": {
                          "kind": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 256
                          },
                          "ref": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 256
                          }
                        },
                        "required": ["kind", "ref"]
                      },
                      "note": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 200
                      }
                    },
                    "required": ["reverses", "sourceKey"],
                    "additionalProperties": false
                  }
                ]
              },
              "example": {
                "resourceId": "res_01M83PPH000000000000000001",
                "scope": {
                  "placeId": "plc_01M83PPH000000000000000002"
                },
                "from": {
                  "supplyId": "sup_01M83PPH000000000000000004"
                },
                "quantity": -100,
                "note": "Spilled during packing",
                "sourceKey": "market:spill:114"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AdjustmentResponse"
                },
                "example": {
                  "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"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad Request, with `error.code` [`invalid_request`](https://agentpost.tools/docs/resourceshark/errors#invalid_request).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["invalid_request"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized, with `error.code` [`unauthenticated`](https://agentpost.tools/docs/resourceshark/errors#unauthenticated).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["unauthenticated"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden, with `error.code` [`forbidden`](https://agentpost.tools/docs/resourceshark/errors#forbidden).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["forbidden"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Not Found, with `error.code` [`not_found`](https://agentpost.tools/docs/resourceshark/errors#not_found).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["not_found"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "409": {
            "description": "Conflict, with `error.code` [`duplicate_source`](https://agentpost.tools/docs/resourceshark/errors#duplicate_source), [`insufficient_supply`](https://agentpost.tools/docs/resourceshark/errors#insufficient_supply), [`exhausted_until_supply`](https://agentpost.tools/docs/resourceshark/errors#exhausted_until_supply), or [`assignment_infeasible`](https://agentpost.tools/docs/resourceshark/errors#assignment_infeasible).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": [
                                "duplicate_source",
                                "insufficient_supply",
                                "exhausted_until_supply",
                                "assignment_infeasible"
                              ]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "413": {
            "description": "Payload Too Large, with `error.code` [`payload_too_large`](https://agentpost.tools/docs/resourceshark/errors#payload_too_large).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["payload_too_large"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "422": {
            "description": "Unprocessable Entity, with `error.code` [`invalid_quantity`](https://agentpost.tools/docs/resourceshark/errors#invalid_quantity).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["invalid_quantity"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error, with `error.code` [`internal_error`](https://agentpost.tools/docs/resourceshark/errors#internal_error).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["internal_error"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/transformations": {
      "post": {
        "operationId": "transformations.create",
        "summary": "Record a conversion",
        "description": "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.\n\n- **Who may call:** Your server, with your project’s secret key.\n- **Idempotency-Key:** required. ",
        "tags": ["Stock"],
        "externalDocs": {
          "description": "Record a conversion, in the API reference",
          "url": "https://agentpost.tools/docs/resourceshark/reference/stock#record-a-conversion"
        },
        "security": [
          {
            "secretKey": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "description": "A key of your choosing for this request. A retry with the same key and the same request within 24 hours answers with the first answer, while you may still make the request; the same key with a different request answers [`idempotency_mismatch`](https://agentpost.tools/docs/resourceshark/errors#idempotency_mismatch), and one whose first request is still running answers [`conflict`](https://agentpost.tools/docs/resourceshark/errors#conflict).",
            "schema": {
              "type": "string"
            },
            "example": "roast-104"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "takes": {
                    "minItems": 1,
                    "maxItems": 50,
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "resourceId": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 256
                        },
                        "scope": {
                          "type": "object",
                          "properties": {
                            "placeId": {
                              "type": "string"
                            },
                            "condition": {
                              "type": "string",
                              "minLength": 1,
                              "maxLength": 64,
                              "pattern": "^[a-z0-9_-]+$"
                            },
                            "holderRef": {
                              "type": "string",
                              "minLength": 1,
                              "maxLength": 256
                            },
                            "instanceId": {
                              "type": "string"
                            }
                          },
                          "additionalProperties": false
                        },
                        "quantity": {
                          "type": "number"
                        },
                        "from": {
                          "type": "object",
                          "properties": {
                            "batchId": {
                              "type": "string",
                              "minLength": 1,
                              "maxLength": 256
                            },
                            "supplyId": {
                              "type": "string",
                              "minLength": 1,
                              "maxLength": 256
                            }
                          },
                          "additionalProperties": false
                        },
                        "span": {
                          "type": "object",
                          "properties": {
                            "start": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "end": {
                              "type": "string",
                              "format": "date-time"
                            }
                          },
                          "required": ["start", "end"]
                        }
                      },
                      "required": ["resourceId", "quantity"],
                      "additionalProperties": false
                    }
                  },
                  "adds": {
                    "minItems": 1,
                    "maxItems": 50,
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "resourceId": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 256
                        },
                        "scope": {
                          "type": "object",
                          "properties": {
                            "placeId": {
                              "type": "string"
                            },
                            "condition": {
                              "type": "string",
                              "minLength": 1,
                              "maxLength": 64,
                              "pattern": "^[a-z0-9_-]+$"
                            },
                            "holderRef": {
                              "type": "string",
                              "minLength": 1,
                              "maxLength": 256
                            },
                            "instanceId": {
                              "type": "string"
                            }
                          },
                          "additionalProperties": false
                        },
                        "quantity": {
                          "type": "number"
                        },
                        "batchId": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 256
                        },
                        "batch": {
                          "type": "object",
                          "properties": {
                            "code": {
                              "type": "string",
                              "minLength": 1,
                              "maxLength": 200
                            },
                            "expiresAt": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "attributes": {
                              "type": "object",
                              "propertyNames": {
                                "type": "string",
                                "minLength": 1,
                                "maxLength": 64,
                                "pattern": "^[A-Za-z0-9_-]+$"
                              },
                              "additionalProperties": {
                                "type": "string",
                                "maxLength": 200
                              }
                            }
                          },
                          "required": ["code"],
                          "additionalProperties": false
                        },
                        "expiresAt": {
                          "type": "string",
                          "format": "date-time"
                        },
                        "attributes": {
                          "type": "object",
                          "propertyNames": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 64,
                            "pattern": "^[A-Za-z0-9_-]+$"
                          },
                          "additionalProperties": {
                            "type": "string",
                            "maxLength": 200
                          }
                        }
                      },
                      "required": ["resourceId", "quantity"],
                      "additionalProperties": false
                    }
                  },
                  "evidence": {
                    "type": "object",
                    "properties": {
                      "kind": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 256
                      },
                      "ref": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 256
                      }
                    },
                    "required": ["kind", "ref"]
                  },
                  "sourceKey": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 200
                  }
                },
                "required": ["takes", "adds", "evidence", "sourceKey"],
                "additionalProperties": false
              },
              "example": {
                "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"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TransformationResponse"
                },
                "example": {
                  "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"
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad Request, with `error.code` [`invalid_request`](https://agentpost.tools/docs/resourceshark/errors#invalid_request).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["invalid_request"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized, with `error.code` [`unauthenticated`](https://agentpost.tools/docs/resourceshark/errors#unauthenticated).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["unauthenticated"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden, with `error.code` [`forbidden`](https://agentpost.tools/docs/resourceshark/errors#forbidden).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["forbidden"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Not Found, with `error.code` [`not_found`](https://agentpost.tools/docs/resourceshark/errors#not_found).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["not_found"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "409": {
            "description": "Conflict, with `error.code` [`duplicate_source`](https://agentpost.tools/docs/resourceshark/errors#duplicate_source), [`insufficient_supply`](https://agentpost.tools/docs/resourceshark/errors#insufficient_supply), [`exhausted_until_supply`](https://agentpost.tools/docs/resourceshark/errors#exhausted_until_supply), or [`assignment_infeasible`](https://agentpost.tools/docs/resourceshark/errors#assignment_infeasible).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": [
                                "duplicate_source",
                                "insufficient_supply",
                                "exhausted_until_supply",
                                "assignment_infeasible"
                              ]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "413": {
            "description": "Payload Too Large, with `error.code` [`payload_too_large`](https://agentpost.tools/docs/resourceshark/errors#payload_too_large).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["payload_too_large"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "422": {
            "description": "Unprocessable Entity, with `error.code` [`invalid_quantity`](https://agentpost.tools/docs/resourceshark/errors#invalid_quantity).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["invalid_quantity"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error, with `error.code` [`internal_error`](https://agentpost.tools/docs/resourceshark/errors#internal_error).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["internal_error"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/transformations/{id}": {
      "get": {
        "operationId": "transformations.get",
        "summary": "Get a conversion",
        "description": "Reads a conversion with its movements and the supply it added.\n\n- **Who may call:** Your server, with your project’s secret key.",
        "tags": ["Stock"],
        "externalDocs": {
          "description": "Get a conversion, in the API reference",
          "url": "https://agentpost.tools/docs/resourceshark/reference/stock#get-a-conversion"
        },
        "security": [
          {
            "secretKey": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Transformation ID, `tfm_…`. The `id` of a [`Transformation`](https://agentpost.tools/docs/resourceshark/reference/stock#the-transformation-object).",
            "schema": {
              "type": "string"
            },
            "example": "tfm_01M83PPH000000000000000001"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TransformationResponse"
                },
                "example": {
                  "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"
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized, with `error.code` [`unauthenticated`](https://agentpost.tools/docs/resourceshark/errors#unauthenticated).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["unauthenticated"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden, with `error.code` [`forbidden`](https://agentpost.tools/docs/resourceshark/errors#forbidden).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["forbidden"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Not Found, with `error.code` [`not_found`](https://agentpost.tools/docs/resourceshark/errors#not_found).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["not_found"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error, with `error.code` [`internal_error`](https://agentpost.tools/docs/resourceshark/errors#internal_error).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["internal_error"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/movements": {
      "get": {
        "operationId": "movements.list",
        "summary": "List movements",
        "description": "Lists movements in sequence, oldest first by default or newest first with `order=desc`. Filter by resource, place, holder, batch, or unit to read its history.\n\n- **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.\n- **Pages:** `limit`, 1 to 500, default 100. A feed: every answer has `next`, to send as `after`. [Lists](https://agentpost.tools/docs/platform/api-basics#lists) has the rule.",
        "tags": ["Movements"],
        "externalDocs": {
          "description": "List movements, in the API reference",
          "url": "https://agentpost.tools/docs/resourceshark/reference/movements#list-movements"
        },
        "security": [
          {
            "secretKey": []
          },
          {
            "userToken": []
          }
        ],
        "parameters": [
          {
            "name": "resourceId",
            "in": "query",
            "required": false,
            "description": "1–256 characters.",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 256
            },
            "example": "res_01M83PPH000000000000000003"
          },
          {
            "name": "placeId",
            "in": "query",
            "required": false,
            "description": "1–256 characters.",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 256
            }
          },
          {
            "name": "holderRef",
            "in": "query",
            "required": false,
            "description": "1–256 characters.",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 256
            },
            "example": "principal:external:u_maya"
          },
          {
            "name": "batchId",
            "in": "query",
            "required": false,
            "description": "1–256 characters.",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 256
            }
          },
          {
            "name": "instanceId",
            "in": "query",
            "required": false,
            "description": "1–256 characters.",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 256
            }
          },
          {
            "name": "order",
            "in": "query",
            "required": false,
            "description": "`asc` is oldest first by default. `desc` is newest first.",
            "schema": {
              "type": "string",
              "enum": ["asc", "desc"]
            }
          },
          {
            "name": "after",
            "in": "query",
            "required": false,
            "description": "Pass `next` from a page with the same order and filters. Use `0` to start; at least 0; default `0`.",
            "schema": {
              "default": 0,
              "type": "integer",
              "minimum": 0,
              "maximum": 9007199254740991
            },
            "example": 3
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "1–500; default `100`.",
            "schema": {
              "default": 100,
              "type": "integer",
              "exclusiveMinimum": 0,
              "maximum": 500
            },
            "example": 4
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MovementsPage"
                },
                "example": {
                  "movements": [
                    {
                      "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"
                      }
                    },
                    {
                      "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"
                      }
                    },
                    {
                      "id": "mov_01M83PPH000000000000000006",
                      "seq": 6,
                      "resourceId": "res_01M83PPH000000000000000003",
                      "scope": {
                        "holderRef": "principal:external:u_maya"
                      },
                      "reason": "settle",
                      "claimId": "clm_01M83PPH000000000000000002",
                      "supplyId": "sup_01M83PPH000000000000000003",
                      "pegs": [
                        {
                          "supplyId": "sup_01M83PPH000000000000000003",
                          "quantity": 1
                        }
                      ],
                      "evidence": {
                        "kind": "attendance",
                        "ref": "tasting_1042"
                      },
                      "at": "2026-11-23T09:40:00.000Z",
                      "quantity": 1,
                      "before": 9,
                      "after": 10,
                      "actor": {
                        "id": "key:juniper-backend"
                      }
                    },
                    {
                      "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"
                      }
                    }
                  ],
                  "next": 7
                }
              }
            }
          },
          "400": {
            "description": "Bad Request, with `error.code` [`invalid_request`](https://agentpost.tools/docs/resourceshark/errors#invalid_request).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["invalid_request"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized, with `error.code` [`unauthenticated`](https://agentpost.tools/docs/resourceshark/errors#unauthenticated).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["unauthenticated"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden, with `error.code` [`forbidden`](https://agentpost.tools/docs/resourceshark/errors#forbidden).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["forbidden"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error, with `error.code` [`internal_error`](https://agentpost.tools/docs/resourceshark/errors#internal_error).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["internal_error"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/movements/{id}": {
      "get": {
        "operationId": "movements.get",
        "summary": "Get a movement",
        "description": "Reads a movement. A caller constrained to one holder reads only its own.\n\n- **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.",
        "tags": ["Movements"],
        "externalDocs": {
          "description": "Get a movement, in the API reference",
          "url": "https://agentpost.tools/docs/resourceshark/reference/movements#get-a-movement"
        },
        "security": [
          {
            "secretKey": []
          },
          {
            "userToken": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Movement ID, `mov_…`. The `id` of a [`Movement`](https://agentpost.tools/docs/resourceshark/reference/supply#the-movement-object).",
            "schema": {
              "type": "string"
            },
            "example": "mov_01M83PPH000000000000000005"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MovementResponse"
                },
                "example": {
                  "movement": {
                    "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"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized, with `error.code` [`unauthenticated`](https://agentpost.tools/docs/resourceshark/errors#unauthenticated).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["unauthenticated"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden, with `error.code` [`forbidden`](https://agentpost.tools/docs/resourceshark/errors#forbidden).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["forbidden"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Not Found, with `error.code` [`not_found`](https://agentpost.tools/docs/resourceshark/errors#not_found).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["not_found"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error, with `error.code` [`internal_error`](https://agentpost.tools/docs/resourceshark/errors#internal_error).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["internal_error"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/reports/totals": {
      "get": {
        "operationId": "reports.totals",
        "summary": "Get totals",
        "description": "Sums for each resource matched by a resource ID, a tag, or `attribute.<name>` parameters, including archived resources. Each row gives its balance over its scopes and, for a period from `from` to `to`, its movements summed by reason. `groupBy` breaks the totals down by an attribute of the supply entries on a resource that keeps its supply apart, and `holderRef` totals one holder’s scopes. A write that lands while the read runs may or may not be counted.\n\n- **Who may call:** Your server, with your project’s secret key.",
        "tags": ["Reports"],
        "externalDocs": {
          "description": "Get totals, in the API reference",
          "url": "https://agentpost.tools/docs/resourceshark/reference/reports#get-totals"
        },
        "security": [
          {
            "secretKey": []
          }
        ],
        "parameters": [
          {
            "name": "resourceId",
            "in": "query",
            "required": false,
            "description": "1–256 characters.",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 256
            },
            "example": "res_01M83PPH000000000000000003"
          },
          {
            "name": "tag",
            "in": "query",
            "required": false,
            "description": "1–200 characters.",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 200
            }
          },
          {
            "name": "from",
            "in": "query",
            "required": false,
            "description": "An ISO 8601 date and time.",
            "schema": {
              "type": "string",
              "format": "date-time"
            },
            "example": "2026-11-23T09:20:00.000Z"
          },
          {
            "name": "to",
            "in": "query",
            "required": false,
            "description": "An ISO 8601 date and time.",
            "schema": {
              "type": "string",
              "format": "date-time"
            },
            "example": "2026-11-23T09:55:00.000Z"
          },
          {
            "name": "groupBy",
            "in": "query",
            "required": false,
            "description": "1–64 characters.",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 64,
              "pattern": "^[A-Za-z0-9_-]+$"
            },
            "example": "program"
          },
          {
            "name": "holderRef",
            "in": "query",
            "required": false,
            "description": "1–256 characters.",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 256
            },
            "example": "principal:external:u_maya"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TotalsReport"
                },
                "example": {
                  "asOf": "2026-11-23T09:55:00.000Z",
                  "from": "2026-11-23T09:20:00.000Z",
                  "to": "2026-11-23T09:55:00.000Z",
                  "groupBy": "program",
                  "holderRef": "principal:external:u_maya",
                  "resources": [
                    {
                      "resourceId": "res_01M83PPH000000000000000003",
                      "key": "tasting-credits",
                      "name": "Prepaid tasting credits",
                      "unit": {
                        "code": "credit",
                        "singular": "credit",
                        "plural": "credits",
                        "precision": 0
                      },
                      "balance": {
                        "onHand": 8,
                        "held": 0,
                        "available": 8
                      },
                      "movements": {
                        "add": 12,
                        "use": -3,
                        "settle": 1,
                        "reversal": -2
                      },
                      "groups": [
                        {
                          "value": "tasting-club",
                          "balance": {
                            "onHand": 8,
                            "held": 0,
                            "available": 8
                          },
                          "movements": {
                            "add": 12,
                            "use": -3,
                            "settle": 1,
                            "reversal": -2
                          }
                        }
                      ]
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad Request, with `error.code` [`invalid_request`](https://agentpost.tools/docs/resourceshark/errors#invalid_request).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["invalid_request"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized, with `error.code` [`unauthenticated`](https://agentpost.tools/docs/resourceshark/errors#unauthenticated).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["unauthenticated"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden, with `error.code` [`forbidden`](https://agentpost.tools/docs/resourceshark/errors#forbidden).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["forbidden"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error, with `error.code` [`internal_error`](https://agentpost.tools/docs/resourceshark/errors#internal_error).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["internal_error"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/events": {
      "get": {
        "operationId": "events.read",
        "summary": "Read events",
        "description": "Lists the project’s retained changes in order after a cursor and gives the next cursor. Send after=latest to start from now. A cursor behind the oldest change kept is refused with cursor_expired, whose details give the oldest and latest seq. [Change feed retention](https://agentpost.tools/docs/resourceshark/concepts/change-feed#retention) explains which changes the feed keeps. For your server’s secret key: a credential confined to one holder, such as a user token, is refused.\n\n- **Who may call:** Your server, with your project’s secret key.\n- **Pages:** `limit`, 1 to 500, default 100. A feed: every answer has `next`, to send as `after`. [Lists](https://agentpost.tools/docs/platform/api-basics#lists) has the rule.",
        "tags": ["Events"],
        "externalDocs": {
          "description": "Read events, in the API reference",
          "url": "https://agentpost.tools/docs/resourceshark/reference/events#read-events"
        },
        "security": [
          {
            "secretKey": []
          }
        ],
        "parameters": [
          {
            "name": "after",
            "in": "query",
            "required": false,
            "description": "The `seq` to read after, or `latest` to start from now: no events, and `next` set to the newest `seq`. Start at 0, then pass each page’s `next`.",
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "const": "latest"
                },
                {
                  "anyOf": [
                    {
                      "type": "integer",
                      "minimum": 0,
                      "maximum": 9007199254740991
                    },
                    {
                      "type": "string",
                      "pattern": "^\\d+$"
                    }
                  ]
                }
              ]
            },
            "example": 36
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "The most events to answer with, from 1 to 500; 1–500; default `100`.",
            "schema": {
              "default": 100,
              "type": "integer",
              "minimum": 1,
              "maximum": 500
            },
            "example": 20
          },
          {
            "name": "types",
            "in": "query",
            "required": false,
            "description": "Full event types to keep, separated by commas. Without it, every type.",
            "schema": {
              "type": "string"
            },
            "example": "tools.agentpost.resources.hold.placed"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EventsPage"
                },
                "example": {
                  "events": [
                    {
                      "id": "01M83PPH00000000000000000E",
                      "seq": 37,
                      "specversion": "1.0",
                      "type": "tools.agentpost.resources.hold.placed",
                      "source": "/resourceshark",
                      "subject": "hld_01M83PPH000000000000000002",
                      "time": "2026-11-23T11:00:00.000Z",
                      "datacontenttype": "application/json",
                      "data": {
                        "context": {
                          "actor": {
                            "id": "key:juniper-backend"
                          }
                        },
                        "holdId": "hld_01M83PPH000000000000000002",
                        "reason": "hold",
                        "evidence": {
                          "kind": "booking_request",
                          "ref": "court_request_217"
                        },
                        "movementIds": ["mov_01M83PPH00000000000000000F"],
                        "holderRef": "principal:external:u_maya",
                        "label": "court-booking",
                        "reference": {
                          "kind": "booking_request",
                          "ref": "court_request_217"
                        },
                        "expiresAt": "2026-11-23T11:15:00.000Z",
                        "lines": [
                          {
                            "claimId": "clm_01M83PPH000000000000000004",
                            "resourceId": "res_01M83PPH000000000000000004",
                            "scope": {
                              "instanceId": "ins_01M83PPH000000000000000001"
                            },
                            "quantity": 1,
                            "span": {
                              "start": "2026-11-23T17:00:00.000Z",
                              "end": "2026-11-23T18:00:00.000Z"
                            },
                            "status": "held"
                          }
                        ],
                        "status": "open",
                        "sourceKey": "court:217:hold",
                        "actor": {
                          "id": "key:juniper-backend"
                        },
                        "createdAt": "2026-11-23T11:00:00.000Z",
                        "updatedAt": "2026-11-23T11:00:00.000Z"
                      }
                    }
                  ],
                  "next": 37
                }
              }
            }
          },
          "400": {
            "description": "Bad Request, with `error.code` [`invalid_request`](https://agentpost.tools/docs/resourceshark/errors#invalid_request).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["invalid_request"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized, with `error.code` [`unauthenticated`](https://agentpost.tools/docs/resourceshark/errors#unauthenticated).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["unauthenticated"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Forbidden, with `error.code` [`forbidden`](https://agentpost.tools/docs/resourceshark/errors#forbidden).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["forbidden"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "410": {
            "description": "Gone, with `error.code` [`cursor_expired`](https://agentpost.tools/docs/resourceshark/errors#cursor_expired).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["cursor_expired"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error, with `error.code` [`internal_error`](https://agentpost.tools/docs/resourceshark/errors#internal_error).",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "properties": {
                        "error": {
                          "properties": {
                            "code": {
                              "enum": ["internal_error"]
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "ConfigResponse": {
        "type": "object",
        "properties": {
          "config": {
            "$ref": "#/components/schemas/ConfigRecord"
          }
        },
        "required": ["config"],
        "examples": [
          {
            "config": {
              "retention": {
                "events": "30d",
                "resolvedHolds": "3d"
              },
              "version": 1,
              "updatedAt": "2026-11-23T08:00:00.000Z",
              "updatedBy": "service:juniper-backend"
            }
          }
        ]
      },
      "ResourceResponse": {
        "type": "object",
        "properties": {
          "resource": {
            "$ref": "#/components/schemas/Resource"
          },
          "overCapacity": {
            "$ref": "#/components/schemas/OverCapacity",
            "description": "With a change to a bucketed resource's `capacity`: the buckets now over it."
          }
        },
        "required": ["resource"],
        "examples": [
          {
            "resource": {
              "key": "roasted-coffee",
              "name": "Juniper roasted coffee",
              "unit": {
                "code": "g",
                "singular": "gram",
                "plural": "grams",
                "precision": 0
              },
              "settings": {
                "time": "none",
                "identity": "count",
                "supplyExpiry": "expiring"
              },
              "scope": {
                "places": true,
                "holders": false
              },
              "tracking": "batch",
              "shortage": "deny",
              "tags": ["coffee"],
              "id": "res_01M83PPH000000000000000001",
              "version": 2
            }
          }
        ]
      },
      "ResourcesPage": {
        "type": "object",
        "properties": {
          "resources": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Resource"
            }
          },
          "next": {
            "type": "string"
          }
        },
        "required": ["resources"],
        "examples": [
          {
            "resources": [
              {
                "key": "roasted-coffee",
                "name": "Juniper roasted coffee",
                "unit": {
                  "code": "g",
                  "singular": "gram",
                  "plural": "grams",
                  "precision": 0
                },
                "settings": {
                  "time": "none",
                  "identity": "count",
                  "supplyExpiry": "expiring"
                },
                "scope": {
                  "places": true,
                  "holders": false
                },
                "tracking": "batch",
                "shortage": "deny",
                "tags": ["coffee"],
                "id": "res_01M83PPH000000000000000001",
                "version": 2
              },
              {
                "key": "green-coffee",
                "name": "Green coffee",
                "unit": {
                  "code": "g",
                  "singular": "gram",
                  "plural": "grams",
                  "precision": 0
                },
                "settings": {
                  "time": "none",
                  "identity": "count",
                  "supplyExpiry": "none"
                },
                "scope": {
                  "places": true,
                  "holders": false
                },
                "tracking": "none",
                "shortage": "deny",
                "tags": ["coffee"],
                "id": "res_01M83PPH000000000000000002",
                "version": 1
              }
            ]
          }
        ]
      },
      "PlaceResponse": {
        "type": "object",
        "properties": {
          "place": {
            "$ref": "#/components/schemas/Place"
          }
        },
        "required": ["place"],
        "examples": [
          {
            "place": {
              "key": "roastery",
              "name": "Juniper Roastery",
              "id": "plc_01M83PPH000000000000000001"
            }
          }
        ]
      },
      "PlacesPage": {
        "type": "object",
        "properties": {
          "places": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Place"
            }
          },
          "next": {
            "type": "string"
          }
        },
        "required": ["places"],
        "examples": [
          {
            "places": [
              {
                "key": "roastery",
                "name": "Juniper Roastery",
                "id": "plc_01M83PPH000000000000000001"
              },
              {
                "id": "plc_01M83PPH000000000000000002",
                "key": "market-stall",
                "name": "Juniper Market Stall"
              }
            ]
          }
        ]
      },
      "InstanceResponse": {
        "type": "object",
        "properties": {
          "instance": {
            "$ref": "#/components/schemas/Instance"
          },
          "overCapacity": {
            "$ref": "#/components/schemas/OverCapacity",
            "description": "With a change to the status or unavailable spans of an instance of a bucketed resource: the buckets now over capacity."
          }
        },
        "required": ["instance"],
        "examples": [
          {
            "instance": {
              "code": "Court 1",
              "status": "active",
              "id": "ins_01M83PPH000000000000000001",
              "resourceId": "res_01M83PPH000000000000000004"
            }
          }
        ]
      },
      "InstancesPage": {
        "description": "A page of instances. A page of free units reads at most `MAX_FREE_SCAN` units, so it can hold fewer than `limit`, even none, and still give `next`.",
        "type": "object",
        "properties": {
          "instances": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Instance"
            }
          },
          "next": {
            "type": "string"
          }
        },
        "required": ["instances"],
        "examples": [
          {
            "instances": [
              {
                "code": "Court 1",
                "status": "active",
                "id": "ins_01M83PPH000000000000000001",
                "resourceId": "res_01M83PPH000000000000000004"
              },
              {
                "code": "Court 2",
                "status": "active",
                "id": "ins_01M83PPH000000000000000002",
                "resourceId": "res_01M83PPH000000000000000004",
                "unavailable": [
                  {
                    "start": "2026-11-23T20:00:00.000Z",
                    "end": "2026-11-23T21:00:00.000Z"
                  }
                ]
              }
            ]
          }
        ]
      },
      "SupplyResponse": {
        "description": "What a supply write recorded, with its movement when there is one.",
        "type": "object",
        "properties": {
          "supply": {
            "$ref": "#/components/schemas/SupplyEntry"
          },
          "movement": {
            "$ref": "#/components/schemas/Movement",
            "description": "The movement that recorded what arrived or is expected."
          },
          "duplicate": {
            "const": true,
            "description": "Set when the `sourceKey` already named this request: nothing was added again."
          }
        },
        "required": ["supply"],
        "examples": [
          {
            "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"
              }
            }
          }
        ]
      },
      "SupplyPage": {
        "description": "One page of supply, with the cursor for the next page when there is one.",
        "type": "object",
        "properties": {
          "supply": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SupplyEntry"
            }
          },
          "next": {
            "type": "string"
          }
        },
        "required": ["supply"],
        "examples": [
          {
            "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"
              }
            ]
          }
        ]
      },
      "SupplyGetResponse": {
        "description": "The supply entry read by ID.",
        "type": "object",
        "properties": {
          "supply": {
            "$ref": "#/components/schemas/SupplyEntry"
          }
        },
        "required": ["supply"],
        "examples": [
          {
            "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"
            }
          }
        ]
      },
      "SupplyReverseResponse": {
        "description": "What a supply reversal took back.",
        "type": "object",
        "properties": {
          "supply": {
            "$ref": "#/components/schemas/SupplyEntry"
          },
          "movement": {
            "$ref": "#/components/schemas/Movement",
            "description": "The `reversal` movement, absent when the entry had not started."
          },
          "taken": {
            "type": "number",
            "description": "What was taken back."
          },
          "duplicate": {
            "const": true,
            "description": "Set when the `sourceKey` already named this request: nothing was taken again."
          }
        },
        "required": ["supply", "taken"],
        "examples": [
          {
            "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
          }
        ]
      },
      "BatchResponse": {
        "description": "A batch read or returned from a write.",
        "type": "object",
        "properties": {
          "batch": {
            "$ref": "#/components/schemas/Batch"
          }
        },
        "required": ["batch"],
        "examples": [
          {
            "batch": {
              "resourceId": "res_01M83PPH000000000000000001",
              "code": "ROAST-2026-11-23",
              "expiresAt": "2026-11-29T17:00:00.000Z",
              "attributes": {
                "origin": "Colombia"
              },
              "id": "bat_01M83PPH000000000000000001",
              "version": 2,
              "createdAt": "2026-11-23T08:00:00.000Z",
              "updatedAt": "2026-11-23T08:25:00.000Z"
            }
          }
        ]
      },
      "BatchesPage": {
        "description": "One page of batches, with the cursor for the next page when there is one.",
        "type": "object",
        "properties": {
          "batches": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Batch"
            }
          },
          "next": {
            "type": "string"
          }
        },
        "required": ["batches"],
        "examples": [
          {
            "batches": [
              {
                "resourceId": "res_01M83PPH000000000000000001",
                "code": "ROAST-2026-11-23",
                "expiresAt": "2026-11-29T17:00:00.000Z",
                "attributes": {
                  "origin": "Colombia"
                },
                "id": "bat_01M83PPH000000000000000001",
                "version": 2,
                "createdAt": "2026-11-23T08:00:00.000Z",
                "updatedAt": "2026-11-23T08:25:00.000Z"
              }
            ]
          }
        ]
      },
      "ConsumeResponse": {
        "type": "object",
        "properties": {
          "claims": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Claim"
            },
            "description": "One per line, in the order of the lines."
          },
          "movements": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Movement"
            },
            "description": "One per line in the same order. On a bucketed resource, this is the first bucket's movement."
          },
          "duplicate": {
            "const": true,
            "description": "Set when the `sourceKey` already named this request: nothing was taken again."
          }
        },
        "required": ["claims", "movements"],
        "examples": [
          {
            "claims": [
              {
                "id": "clm_01M83PPH000000000000000002",
                "resourceId": "res_01M83PPH000000000000000003",
                "scope": {
                  "holderRef": "principal:external:u_maya"
                },
                "span": {
                  "start": "2026-11-23T09:30:00.000Z",
                  "end": null
                },
                "quantity": 3,
                "kind": "consumption",
                "status": "committed",
                "estimate": 3,
                "pegs": [
                  {
                    "supplyId": "sup_01M83PPH000000000000000003",
                    "quantity": 3
                  }
                ],
                "holderRef": "principal:external:u_maya",
                "evidence": {
                  "kind": "tasting",
                  "ref": "tasting_1042"
                },
                "sourceKey": "tasting:1042:estimate",
                "actor": {
                  "id": "key:juniper-backend"
                },
                "createdAt": "2026-11-23T09:30:00.000Z",
                "updatedAt": "2026-11-23T09:30:00.000Z"
              }
            ],
            "movements": [
              {
                "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"
                }
              }
            ]
          }
        ]
      },
      "SettleResponse": {
        "description": "What a settle wrote.",
        "type": "object",
        "properties": {
          "claims": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Claim"
            },
            "description": "One per line, settled, in the order of the lines."
          },
          "movements": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Movement"
            },
            "description": "The `settle` movements, in the order of the lines, one for each claim whose real quantity differs from its estimate. Each names its claim."
          },
          "duplicate": {
            "const": true,
            "description": "Set when the `sourceKey` already named this request: nothing was settled again."
          }
        },
        "required": ["claims", "movements"],
        "examples": [
          {
            "claims": [
              {
                "id": "clm_01M83PPH000000000000000002",
                "resourceId": "res_01M83PPH000000000000000003",
                "scope": {
                  "holderRef": "principal:external:u_maya"
                },
                "span": {
                  "start": "2026-11-23T09:30:00.000Z",
                  "end": null
                },
                "quantity": 2,
                "kind": "consumption",
                "status": "committed",
                "estimate": 3,
                "pegs": [
                  {
                    "supplyId": "sup_01M83PPH000000000000000003",
                    "quantity": 2
                  }
                ],
                "holderRef": "principal:external:u_maya",
                "evidence": {
                  "kind": "tasting",
                  "ref": "tasting_1042"
                },
                "sourceKey": "tasting:1042:estimate",
                "actor": {
                  "id": "key:juniper-backend"
                },
                "createdAt": "2026-11-23T09:30:00.000Z",
                "updatedAt": "2026-11-23T09:40:00.000Z",
                "settled": 2
              }
            ],
            "movements": [
              {
                "id": "mov_01M83PPH000000000000000006",
                "seq": 6,
                "resourceId": "res_01M83PPH000000000000000003",
                "scope": {
                  "holderRef": "principal:external:u_maya"
                },
                "reason": "settle",
                "claimId": "clm_01M83PPH000000000000000002",
                "supplyId": "sup_01M83PPH000000000000000003",
                "pegs": [
                  {
                    "supplyId": "sup_01M83PPH000000000000000003",
                    "quantity": 1
                  }
                ],
                "evidence": {
                  "kind": "attendance",
                  "ref": "tasting_1042"
                },
                "at": "2026-11-23T09:40:00.000Z",
                "quantity": 1,
                "before": 9,
                "after": 10,
                "actor": {
                  "id": "key:juniper-backend"
                }
              }
            ]
          }
        ]
      },
      "ClaimsPage": {
        "description": "One page of claims, with the cursor for the next page when there is one.",
        "type": "object",
        "properties": {
          "claims": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Claim"
            }
          },
          "next": {
            "type": "string"
          }
        },
        "required": ["claims"],
        "examples": [
          {
            "claims": [
              {
                "id": "clm_01M83PPH000000000000000002",
                "resourceId": "res_01M83PPH000000000000000003",
                "scope": {
                  "holderRef": "principal:external:u_maya"
                },
                "span": {
                  "start": "2026-11-23T09:30:00.000Z",
                  "end": null
                },
                "quantity": 2,
                "kind": "consumption",
                "status": "committed",
                "estimate": 3,
                "pegs": [
                  {
                    "supplyId": "sup_01M83PPH000000000000000003",
                    "quantity": 2
                  }
                ],
                "holderRef": "principal:external:u_maya",
                "evidence": {
                  "kind": "tasting",
                  "ref": "tasting_1042"
                },
                "sourceKey": "tasting:1042:estimate",
                "actor": {
                  "id": "key:juniper-backend"
                },
                "createdAt": "2026-11-23T09:30:00.000Z",
                "updatedAt": "2026-11-23T09:40:00.000Z",
                "settled": 2
              }
            ]
          }
        ]
      },
      "ClaimResponse": {
        "description": "The claim read by ID.",
        "type": "object",
        "properties": {
          "claim": {
            "$ref": "#/components/schemas/Claim"
          }
        },
        "required": ["claim"],
        "examples": [
          {
            "claim": {
              "id": "clm_01M83PPH000000000000000002",
              "resourceId": "res_01M83PPH000000000000000003",
              "scope": {
                "holderRef": "principal:external:u_maya"
              },
              "span": {
                "start": "2026-11-23T09:30:00.000Z",
                "end": null
              },
              "quantity": 2,
              "kind": "consumption",
              "status": "committed",
              "estimate": 3,
              "pegs": [
                {
                  "supplyId": "sup_01M83PPH000000000000000003",
                  "quantity": 2
                }
              ],
              "holderRef": "principal:external:u_maya",
              "evidence": {
                "kind": "tasting",
                "ref": "tasting_1042"
              },
              "sourceKey": "tasting:1042:estimate",
              "actor": {
                "id": "key:juniper-backend"
              },
              "createdAt": "2026-11-23T09:30:00.000Z",
              "updatedAt": "2026-11-23T09:40:00.000Z",
              "settled": 2
            }
          }
        ]
      },
      "HoldResponse": {
        "type": "object",
        "properties": {
          "hold": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/Hold"
              },
              {
                "$ref": "#/components/schemas/RetainedHold"
              }
            ],
            "description": "A `RetainedHold`, with `retainedAt`, once retention has removed the hold's detail."
          },
          "duplicate": {
            "const": true,
            "description": "Set when the `sourceKey` already named this request: nothing was held again."
          }
        },
        "required": ["hold"],
        "examples": [
          {
            "hold": {
              "id": "hld_01M83PPH000000000000000001",
              "holderRef": "principal:external:u_maya",
              "label": "coffee-pickup",
              "reference": {
                "kind": "checkout",
                "ref": "checkout_109"
              },
              "expiresAt": "2026-11-23T10:15:00.000Z",
              "lines": [
                {
                  "claimId": "clm_01M83PPH000000000000000003",
                  "resourceId": "res_01M83PPH000000000000000001",
                  "scope": {
                    "placeId": "plc_01M83PPH000000000000000001"
                  },
                  "quantity": 500,
                  "status": "held",
                  "pegs": [
                    {
                      "supplyId": "sup_01M83PPH000000000000000002",
                      "quantity": 500
                    }
                  ]
                }
              ],
              "status": "open",
              "sourceKey": "checkout:109:hold",
              "actor": {
                "id": "key:juniper-backend"
              },
              "createdAt": "2026-11-23T10:00:00.000Z",
              "updatedAt": "2026-11-23T10:00:00.000Z"
            }
          }
        ]
      },
      "HoldsPage": {
        "type": "object",
        "properties": {
          "holds": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Hold"
            }
          },
          "next": {
            "type": "string"
          }
        },
        "required": ["holds"],
        "examples": [
          {
            "holds": [
              {
                "id": "hld_01M83PPH000000000000000001",
                "holderRef": "principal:external:u_maya",
                "label": "coffee-pickup",
                "reference": {
                  "kind": "checkout",
                  "ref": "checkout_109"
                },
                "expiresAt": "2026-11-23T10:15:00.000Z",
                "lines": [
                  {
                    "claimId": "clm_01M83PPH000000000000000003",
                    "resourceId": "res_01M83PPH000000000000000001",
                    "scope": {
                      "placeId": "plc_01M83PPH000000000000000001"
                    },
                    "quantity": 500,
                    "status": "held",
                    "pegs": [
                      {
                        "supplyId": "sup_01M83PPH000000000000000002",
                        "quantity": 500
                      }
                    ]
                  }
                ],
                "status": "open",
                "sourceKey": "checkout:109:hold",
                "actor": {
                  "id": "key:juniper-backend"
                },
                "createdAt": "2026-11-23T10:00:00.000Z",
                "updatedAt": "2026-11-23T10:00:00.000Z"
              }
            ]
          }
        ]
      },
      "HoldCommitResponse": {
        "type": "object",
        "properties": {
          "hold": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/Hold"
              },
              {
                "$ref": "#/components/schemas/RetainedHold"
              }
            ],
            "description": "A `RetainedHold`, with `retainedAt`, when the commit is repeated after retention has removed the hold's detail."
          },
          "movements": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Movement"
            },
            "description": "What the commit moved, in the order of the lines: one for each line it took from or let go."
          },
          "duplicate": {
            "const": true,
            "description": "Set when the `sourceKey` already named this commit: nothing was taken again."
          }
        },
        "required": ["hold", "movements"],
        "examples": [
          {
            "hold": {
              "id": "hld_01M83PPH000000000000000002",
              "holderRef": "principal:external:u_maya",
              "label": "court-booking",
              "reference": {
                "kind": "booking_request",
                "ref": "court_request_217"
              },
              "expiresAt": "2026-11-23T11:25:00.000Z",
              "lines": [
                {
                  "claimId": "clm_01M83PPH000000000000000004",
                  "resourceId": "res_01M83PPH000000000000000004",
                  "scope": {
                    "instanceId": "ins_01M83PPH000000000000000001"
                  },
                  "quantity": 1,
                  "span": {
                    "start": "2026-11-23T17:00:00.000Z",
                    "end": "2026-11-23T18:00:00.000Z"
                  },
                  "status": "committed",
                  "committed": 1
                }
              ],
              "status": "committed",
              "sourceKey": "court:217:hold",
              "actor": {
                "id": "key:juniper-backend"
              },
              "createdAt": "2026-11-23T11:00:00.000Z",
              "updatedAt": "2026-11-23T11:15:00.000Z",
              "resolution": {
                "at": "2026-11-23T11:15:00.000Z",
                "evidence": {
                  "kind": "booking",
                  "ref": "court_booking_217"
                },
                "sourceKey": "court:217:book"
              }
            },
            "movements": [
              {
                "id": "mov_01M83PPH00000000000000000G",
                "seq": 16,
                "resourceId": "res_01M83PPH000000000000000004",
                "scope": {
                  "instanceId": "ins_01M83PPH000000000000000001"
                },
                "bucketStart": "2026-11-23T17:00:00.000Z",
                "reason": "commit",
                "held": {
                  "quantity": -1,
                  "before": 1,
                  "after": 0
                },
                "claimId": "clm_01M83PPH000000000000000004",
                "holdId": "hld_01M83PPH000000000000000002",
                "evidence": {
                  "kind": "booking",
                  "ref": "court_booking_217"
                },
                "at": "2026-11-23T11:15:00.000Z",
                "quantity": -1,
                "before": 1,
                "after": 0,
                "actor": {
                  "id": "key:juniper-backend"
                }
              }
            ]
          }
        ]
      },
      "HoldCancelResponse": {
        "type": "object",
        "properties": {
          "hold": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/Hold"
              },
              {
                "$ref": "#/components/schemas/RetainedHold"
              }
            ],
            "description": "A `RetainedHold`, with `retainedAt`, when the cancel is repeated after retention has removed the hold's detail."
          },
          "movements": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Movement"
            },
            "description": "What the cancel gave back, one for each line, in the order the hold lists them: on buckets, its first bucket's."
          },
          "duplicate": {
            "const": true,
            "description": "Set when the `sourceKey` already named this cancel: nothing was given back again."
          }
        },
        "required": ["hold", "movements"],
        "examples": [
          {
            "hold": {
              "id": "hld_01M83PPH000000000000000002",
              "holderRef": "principal:external:u_maya",
              "label": "court-booking",
              "reference": {
                "kind": "booking_request",
                "ref": "court_request_217"
              },
              "expiresAt": "2026-11-23T11:25:00.000Z",
              "lines": [
                {
                  "claimId": "clm_01M83PPH000000000000000004",
                  "resourceId": "res_01M83PPH000000000000000004",
                  "scope": {
                    "instanceId": "ins_01M83PPH000000000000000001"
                  },
                  "quantity": 1,
                  "span": {
                    "start": "2026-11-23T18:00:00.000Z",
                    "end": "2026-11-23T19:00:00.000Z"
                  },
                  "status": "cancelled",
                  "committed": 1
                }
              ],
              "status": "cancelled",
              "sourceKey": "court:217:hold",
              "actor": {
                "id": "key:juniper-backend"
              },
              "createdAt": "2026-11-23T11:00:00.000Z",
              "updatedAt": "2026-11-23T11:30:00.000Z",
              "resolution": {
                "at": "2026-11-23T11:15:00.000Z",
                "evidence": {
                  "kind": "booking",
                  "ref": "court_booking_217"
                },
                "sourceKey": "court:217:book"
              },
              "cancellations": [
                {
                  "at": "2026-11-23T11:30:00.000Z",
                  "claimIds": ["clm_01M83PPH000000000000000004"],
                  "evidence": {
                    "kind": "cancellation",
                    "ref": "court_booking_217"
                  },
                  "sourceKey": "court:217:cancel"
                }
              ]
            },
            "movements": [
              {
                "id": "mov_01M83PPH00000000000000000P",
                "seq": 22,
                "resourceId": "res_01M83PPH000000000000000004",
                "scope": {
                  "instanceId": "ins_01M83PPH000000000000000001"
                },
                "bucketStart": "2026-11-23T18:00:00.000Z",
                "reason": "cancel",
                "claimId": "clm_01M83PPH000000000000000004",
                "holdId": "hld_01M83PPH000000000000000002",
                "evidence": {
                  "kind": "cancellation",
                  "ref": "court_booking_217"
                },
                "at": "2026-11-23T11:30:00.000Z",
                "quantity": 1,
                "before": 0,
                "after": 1,
                "actor": {
                  "id": "key:juniper-backend"
                }
              }
            ]
          }
        ]
      },
      "HoldRescheduleResponse": {
        "type": "object",
        "properties": {
          "holds": {
            "type": "array",
            "items": {
              "anyOf": [
                {
                  "$ref": "#/components/schemas/Hold"
                },
                {
                  "$ref": "#/components/schemas/RetainedHold"
                }
              ]
            },
            "description": "Each hold a line belongs to, in the order first named, in full and as it now is, which the caller is asked to be allowed to reschedule as a whole. A repeat under the `sourceKey` shows each as it is at the repeat, after any later change, and a `RetainedHold` once retention has removed its detail."
          },
          "lines": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/RescheduledLine"
            },
            "description": "The lines that moved, in request order, as they moved then, a repeat included; a line already where it was asked to be isn't listed."
          },
          "duplicate": {
            "const": true,
            "description": "Set when the `sourceKey` already named this reschedule: nothing moved again."
          }
        },
        "required": ["holds", "lines"],
        "examples": [
          {
            "holds": [
              {
                "id": "hld_01M83PPH000000000000000002",
                "holderRef": "principal:external:u_maya",
                "label": "court-booking",
                "reference": {
                  "kind": "booking_request",
                  "ref": "court_request_217"
                },
                "expiresAt": "2026-11-23T11:25:00.000Z",
                "lines": [
                  {
                    "claimId": "clm_01M83PPH000000000000000004",
                    "resourceId": "res_01M83PPH000000000000000004",
                    "scope": {
                      "instanceId": "ins_01M83PPH000000000000000001"
                    },
                    "quantity": 1,
                    "span": {
                      "start": "2026-11-23T18:00:00.000Z",
                      "end": "2026-11-23T19:00:00.000Z"
                    },
                    "status": "committed",
                    "committed": 1
                  }
                ],
                "status": "committed",
                "sourceKey": "court:217:hold",
                "actor": {
                  "id": "key:juniper-backend"
                },
                "createdAt": "2026-11-23T11:00:00.000Z",
                "updatedAt": "2026-11-23T11:20:00.000Z",
                "resolution": {
                  "at": "2026-11-23T11:15:00.000Z",
                  "evidence": {
                    "kind": "booking",
                    "ref": "court_booking_217"
                  },
                  "sourceKey": "court:217:book"
                }
              }
            ],
            "lines": [
              {
                "claimId": "clm_01M83PPH000000000000000004",
                "holdId": "hld_01M83PPH000000000000000002",
                "before": {
                  "resourceId": "res_01M83PPH000000000000000004",
                  "scope": {
                    "instanceId": "ins_01M83PPH000000000000000001"
                  },
                  "span": {
                    "start": "2026-11-23T17:00:00.000Z",
                    "end": "2026-11-23T18:00:00.000Z"
                  }
                },
                "after": {
                  "resourceId": "res_01M83PPH000000000000000004",
                  "scope": {
                    "instanceId": "ins_01M83PPH000000000000000001"
                  },
                  "span": {
                    "start": "2026-11-23T18:00:00.000Z",
                    "end": "2026-11-23T19:00:00.000Z"
                  }
                }
              }
            ]
          }
        ]
      },
      "AvailabilityResponse": {
        "type": "object",
        "properties": {
          "lines": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/AvailabilityLine"
            },
            "description": "One per line asked about, in the same order."
          }
        },
        "required": ["lines"],
        "examples": [
          {
            "lines": [
              {
                "resourceId": "res_01M83PPH000000000000000001",
                "scope": {
                  "placeId": "plc_01M83PPH000000000000000001"
                },
                "quantity": 500,
                "available": 8500,
                "expected": 0,
                "version": 1,
                "asOf": "2026-11-23T09:55:00.000Z"
              },
              {
                "resourceId": "res_01M83PPH000000000000000004",
                "scope": {
                  "instanceId": "ins_01M83PPH000000000000000001"
                },
                "quantity": 1,
                "available": 1,
                "expected": 0,
                "version": 0,
                "asOf": "2026-11-23T09:55:00.000Z"
              }
            ]
          }
        ]
      },
      "BalanceResponse": {
        "description": "A balance as returned by a scope read.",
        "type": "object",
        "properties": {
          "balance": {
            "$ref": "#/components/schemas/Balance"
          }
        },
        "required": ["balance"],
        "examples": [
          {
            "balance": {
              "resourceId": "res_01M83PPH000000000000000001",
              "scope": {
                "placeId": "plc_01M83PPH000000000000000001"
              },
              "onHand": 6500,
              "held": 0,
              "expected": 0,
              "available": 6500,
              "version": 4,
              "asOf": "2026-11-23T10:30:00.000Z",
              "batches": [
                {
                  "batchId": "bat_01M83PPH000000000000000001",
                  "code": "ROAST-2026-11-23",
                  "onHand": 6500,
                  "held": 0,
                  "available": 6500,
                  "expiresAt": "2026-11-29T17:00:00.000Z"
                }
              ]
            }
          }
        ]
      },
      "HolderBalancesPage": {
        "description": "One page of a holder's balances, with the cursor for the next page when there is one.",
        "type": "object",
        "properties": {
          "balances": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/HolderBalance"
            }
          },
          "next": {
            "type": "string"
          }
        },
        "required": ["balances"],
        "examples": [
          {
            "balances": [
              {
                "resourceId": "res_01M83PPH000000000000000003",
                "holderRef": "principal:external:u_maya",
                "onHand": 8,
                "held": 0,
                "available": 8,
                "version": 4,
                "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"
                  }
                ]
              }
            ]
          }
        ]
      },
      "HolderBalanceResponse": {
        "description": "A holder's balance on one resource.",
        "type": "object",
        "properties": {
          "balance": {
            "$ref": "#/components/schemas/HolderBalance"
          }
        },
        "required": ["balance"],
        "examples": [
          {
            "balance": {
              "resourceId": "res_01M83PPH000000000000000003",
              "holderRef": "principal:external:u_maya",
              "onHand": 8,
              "held": 0,
              "available": 8,
              "version": 4,
              "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"
                }
              ]
            }
          }
        ]
      },
      "ScheduleSaveResponse": {
        "type": "object",
        "properties": {
          "schedule": {
            "$ref": "#/components/schemas/Schedule"
          },
          "overCapacity": {
            "$ref": "#/components/schemas/OverCapacity"
          }
        },
        "required": ["schedule", "overCapacity"],
        "examples": [
          {
            "schedule": {
              "timeZone": "America/Los_Angeles",
              "patterns": [
                {
                  "weekly": [
                    {
                      "day": 1,
                      "start": "09:00",
                      "end": "17:00"
                    }
                  ]
                }
              ],
              "resourceId": "res_01M83PPH000000000000000004",
              "version": 1,
              "updatedAt": "2026-11-23T08:30:00.000Z"
            },
            "overCapacity": {
              "buckets": [],
              "more": false
            }
          }
        ]
      },
      "ScheduleResponse": {
        "type": "object",
        "properties": {
          "schedule": {
            "$ref": "#/components/schemas/Schedule"
          }
        },
        "required": ["schedule"],
        "examples": [
          {
            "schedule": {
              "timeZone": "America/Los_Angeles",
              "patterns": [
                {
                  "weekly": [
                    {
                      "day": 1,
                      "start": "09:00",
                      "end": "17:00"
                    }
                  ]
                }
              ],
              "resourceId": "res_01M83PPH000000000000000004",
              "version": 1,
              "updatedAt": "2026-11-23T08:30:00.000Z"
            }
          }
        ]
      },
      "ExceptionCreateResponse": {
        "type": "object",
        "properties": {
          "exception": {
            "$ref": "#/components/schemas/ScheduleException"
          },
          "overCapacity": {
            "$ref": "#/components/schemas/OverCapacity"
          },
          "duplicate": {
            "const": true,
            "description": "Set when the source key already named this request."
          }
        },
        "required": ["exception", "overCapacity"],
        "examples": [
          {
            "exception": {
              "id": "exc_01M83PPH000000000000000001",
              "resourceId": "res_01M83PPH000000000000000004",
              "span": {
                "start": "2026-11-23T18:00:00.000Z",
                "end": "2026-11-23T19:00:00.000Z"
              },
              "capacity": 0,
              "reason": "Court resurfacing",
              "version": 1,
              "createdAt": "2026-11-23T11:22:00.000Z",
              "updatedAt": "2026-11-23T11:22:00.000Z"
            },
            "overCapacity": {
              "buckets": [
                {
                  "span": {
                    "start": "2026-11-23T18:00:00.000Z",
                    "end": "2026-11-23T19:00:00.000Z"
                  },
                  "scope": {
                    "instanceId": "ins_01M83PPH000000000000000001"
                  },
                  "capacity": 0,
                  "taken": 1,
                  "held": 0,
                  "claims": [
                    {
                      "id": "clm_01M83PPH000000000000000004",
                      "kind": "booking",
                      "status": "committed",
                      "quantity": 1,
                      "holdId": "hld_01M83PPH000000000000000002",
                      "holderRef": "principal:external:u_maya"
                    }
                  ]
                }
              ],
              "more": false
            }
          }
        ]
      },
      "ExceptionsList": {
        "description": "At most `MAX_EXCEPTIONS`, so one answer holds them all, by start.",
        "type": "object",
        "properties": {
          "exceptions": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ScheduleException"
            }
          }
        },
        "required": ["exceptions"],
        "examples": [
          {
            "exceptions": [
              {
                "id": "exc_01M83PPH000000000000000001",
                "resourceId": "res_01M83PPH000000000000000004",
                "span": {
                  "start": "2026-11-23T18:00:00.000Z",
                  "end": "2026-11-23T19:00:00.000Z"
                },
                "capacity": 0,
                "reason": "Court resurfacing",
                "version": 1,
                "createdAt": "2026-11-23T11:22:00.000Z",
                "updatedAt": "2026-11-23T11:22:00.000Z"
              }
            ]
          }
        ]
      },
      "ExceptionResponse": {
        "type": "object",
        "properties": {
          "exception": {
            "$ref": "#/components/schemas/ScheduleException"
          },
          "overCapacity": {
            "$ref": "#/components/schemas/OverCapacity"
          }
        },
        "required": ["exception", "overCapacity"],
        "examples": [
          {
            "exception": {
              "id": "exc_01M83PPH000000000000000001",
              "resourceId": "res_01M83PPH000000000000000004",
              "span": {
                "start": "2026-11-23T18:00:00.000Z",
                "end": "2026-11-23T19:00:00.000Z"
              },
              "capacity": 0,
              "reason": "Court resurfacing",
              "version": 1,
              "createdAt": "2026-11-23T11:22:00.000Z",
              "updatedAt": "2026-11-23T11:22:00.000Z"
            },
            "overCapacity": {
              "buckets": [
                {
                  "span": {
                    "start": "2026-11-23T18:00:00.000Z",
                    "end": "2026-11-23T19:00:00.000Z"
                  },
                  "scope": {
                    "instanceId": "ins_01M83PPH000000000000000001"
                  },
                  "capacity": 0,
                  "taken": 1,
                  "held": 0,
                  "claims": [
                    {
                      "id": "clm_01M83PPH000000000000000004",
                      "kind": "booking",
                      "status": "committed",
                      "quantity": 1,
                      "holdId": "hld_01M83PPH000000000000000002",
                      "holderRef": "principal:external:u_maya"
                    }
                  ]
                }
              ],
              "more": false
            }
          }
        ]
      },
      "ExceptionDeleteResponse": {
        "type": "object",
        "properties": {
          "overCapacity": {
            "$ref": "#/components/schemas/OverCapacity"
          }
        },
        "required": ["overCapacity"],
        "examples": [
          {
            "overCapacity": {
              "buckets": [],
              "more": false
            }
          }
        ]
      },
      "SlotsResponse": {
        "type": "object",
        "properties": {
          "slots": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Slot"
            }
          }
        },
        "required": ["slots"],
        "examples": [
          {
            "slots": [
              {
                "start": "2026-11-23T17:00:00.000Z",
                "end": "2026-11-23T18:00:00.000Z",
                "timeZone": "America/Los_Angeles",
                "local": {
                  "date": "2026-11-23",
                  "time": "09:00"
                },
                "capacity": 1,
                "taken": 1,
                "held": 0,
                "available": 0
              },
              {
                "start": "2026-11-23T18:00:00.000Z",
                "end": "2026-11-23T19:00:00.000Z",
                "timeZone": "America/Los_Angeles",
                "local": {
                  "date": "2026-11-23",
                  "time": "10:00"
                },
                "capacity": 1,
                "taken": 0,
                "held": 0,
                "available": 1
              }
            ]
          }
        ]
      },
      "TransferResponse": {
        "type": "object",
        "properties": {
          "transferId": {
            "type": "string",
            "description": "Transfer ID, `trf_…`."
          },
          "movements": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Movement"
            },
            "minItems": 2,
            "maxItems": 2,
            "description": "The movement out, then the movement in."
          },
          "duplicate": {
            "const": true,
            "description": "Set when the source key already named this request."
          }
        },
        "required": ["transferId", "movements"],
        "examples": [
          {
            "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"
                }
              }
            ]
          }
        ]
      },
      "CountResponse": {
        "type": "object",
        "properties": {
          "onHand": {
            "type": "number",
            "description": "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": {
            "type": "number"
          },
          "movement": {
            "$ref": "#/components/schemas/Movement"
          }
        },
        "required": ["onHand", "version"],
        "examples": [
          {
            "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"
              }
            }
          }
        ]
      },
      "AdjustmentResponse": {
        "type": "object",
        "properties": {
          "movement": {
            "$ref": "#/components/schemas/Movement"
          },
          "duplicate": {
            "const": true
          }
        },
        "required": ["movement"],
        "examples": [
          {
            "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"
              }
            }
          }
        ]
      },
      "TransformationResponse": {
        "description": "A conversion with the movements and the supply it added.",
        "type": "object",
        "properties": {
          "transformation": {
            "$ref": "#/components/schemas/Transformation"
          },
          "movements": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Movement"
            }
          },
          "supply": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SupplyEntry"
            }
          },
          "duplicate": {
            "const": true,
            "description": "Set when the source key already named this request."
          }
        },
        "required": ["transformation", "movements", "supply"],
        "examples": [
          {
            "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"
              }
            ]
          }
        ]
      },
      "MovementsPage": {
        "type": "object",
        "properties": {
          "movements": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Movement"
            }
          },
          "next": {
            "type": "number",
            "description": "Pass as `after` to continue. The last movement's seq, or `after` on an empty page."
          }
        },
        "required": ["movements", "next"],
        "examples": [
          {
            "movements": [
              {
                "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"
                }
              },
              {
                "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"
                }
              },
              {
                "id": "mov_01M83PPH000000000000000006",
                "seq": 6,
                "resourceId": "res_01M83PPH000000000000000003",
                "scope": {
                  "holderRef": "principal:external:u_maya"
                },
                "reason": "settle",
                "claimId": "clm_01M83PPH000000000000000002",
                "supplyId": "sup_01M83PPH000000000000000003",
                "pegs": [
                  {
                    "supplyId": "sup_01M83PPH000000000000000003",
                    "quantity": 1
                  }
                ],
                "evidence": {
                  "kind": "attendance",
                  "ref": "tasting_1042"
                },
                "at": "2026-11-23T09:40:00.000Z",
                "quantity": 1,
                "before": 9,
                "after": 10,
                "actor": {
                  "id": "key:juniper-backend"
                }
              },
              {
                "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"
                }
              }
            ],
            "next": 7
          }
        ]
      },
      "MovementResponse": {
        "type": "object",
        "properties": {
          "movement": {
            "$ref": "#/components/schemas/Movement"
          }
        },
        "required": ["movement"],
        "examples": [
          {
            "movement": {
              "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"
              }
            }
          }
        ]
      },
      "TotalsReport": {
        "description": "Sums for each selected resource.",
        "type": "object",
        "properties": {
          "asOf": {
            "type": "string",
            "format": "date-time",
            "description": "When the totals were read. A balance counts what had expired by then; a write that landed while the read ran may or may not be counted."
          },
          "from": {
            "type": "string",
            "format": "date-time",
            "description": "The period, when one was asked for. `from` is in it and `to` is not."
          },
          "to": {
            "type": "string",
            "format": "date-time"
          },
          "groupBy": {
            "type": "string"
          },
          "holderRef": {
            "type": "string",
            "description": "Your app's name for the holder, such as `principal:external:u_maya`."
          },
          "resources": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ResourceTotals"
            },
            "description": "The resources the selection matched, in the order they were created."
          }
        },
        "required": ["asOf", "resources"],
        "examples": [
          {
            "asOf": "2026-11-23T09:55:00.000Z",
            "from": "2026-11-23T09:20:00.000Z",
            "to": "2026-11-23T09:55:00.000Z",
            "groupBy": "program",
            "holderRef": "principal:external:u_maya",
            "resources": [
              {
                "resourceId": "res_01M83PPH000000000000000003",
                "key": "tasting-credits",
                "name": "Prepaid tasting credits",
                "unit": {
                  "code": "credit",
                  "singular": "credit",
                  "plural": "credits",
                  "precision": 0
                },
                "balance": {
                  "onHand": 8,
                  "held": 0,
                  "available": 8
                },
                "movements": {
                  "add": 12,
                  "use": -3,
                  "settle": 1,
                  "reversal": -2
                },
                "groups": [
                  {
                    "value": "tasting-club",
                    "balance": {
                      "onHand": 8,
                      "held": 0,
                      "available": 8
                    },
                    "movements": {
                      "add": 12,
                      "use": -3,
                      "settle": 1,
                      "reversal": -2
                    }
                  }
                ]
              }
            ]
          }
        ]
      },
      "EventsPage": {
        "description": "One page of the feed. `after=latest` answers no events and the newest `seq` as `next`; a cursor behind the oldest event kept is `cursor_expired`.",
        "type": "object",
        "properties": {
          "events": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ChangeEvent"
            }
          },
          "next": {
            "type": "number",
            "description": "Pass as `after` to continue. Always present. A full page gives its last event's `seq`. A shorter page has caught up, so it gives the newest `seq` read, past any events a `types` filter skipped."
          }
        },
        "required": ["events", "next"],
        "examples": [
          {
            "events": [
              {
                "id": "01M83PPH00000000000000000E",
                "seq": 37,
                "specversion": "1.0",
                "type": "tools.agentpost.resources.hold.placed",
                "source": "/resourceshark",
                "subject": "hld_01M83PPH000000000000000002",
                "time": "2026-11-23T11:00:00.000Z",
                "datacontenttype": "application/json",
                "data": {
                  "context": {
                    "actor": {
                      "id": "key:juniper-backend"
                    }
                  },
                  "holdId": "hld_01M83PPH000000000000000002",
                  "reason": "hold",
                  "evidence": {
                    "kind": "booking_request",
                    "ref": "court_request_217"
                  },
                  "movementIds": ["mov_01M83PPH00000000000000000F"],
                  "holderRef": "principal:external:u_maya",
                  "label": "court-booking",
                  "reference": {
                    "kind": "booking_request",
                    "ref": "court_request_217"
                  },
                  "expiresAt": "2026-11-23T11:15:00.000Z",
                  "lines": [
                    {
                      "claimId": "clm_01M83PPH000000000000000004",
                      "resourceId": "res_01M83PPH000000000000000004",
                      "scope": {
                        "instanceId": "ins_01M83PPH000000000000000001"
                      },
                      "quantity": 1,
                      "span": {
                        "start": "2026-11-23T17:00:00.000Z",
                        "end": "2026-11-23T18:00:00.000Z"
                      },
                      "status": "held"
                    }
                  ],
                  "status": "open",
                  "sourceKey": "court:217:hold",
                  "actor": {
                    "id": "key:juniper-backend"
                  },
                  "createdAt": "2026-11-23T11:00:00.000Z",
                  "updatedAt": "2026-11-23T11:00:00.000Z"
                }
              }
            ],
            "next": 37
          }
        ]
      },
      "ConfigRecord": {
        "type": "object",
        "properties": {
          "retention": {
            "type": "object",
            "properties": {
              "events": {
                "type": "string",
                "description": "A duration, such as \"10m\" or \"7d\""
              },
              "resolvedHolds": {
                "type": "string",
                "description": "A duration, such as \"10m\" or \"7d\""
              }
            },
            "required": ["events", "resolvedHolds"],
            "additionalProperties": false
          },
          "version": {
            "type": "number"
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time"
          },
          "updatedBy": {
            "type": "string"
          }
        },
        "required": ["retention", "version", "updatedAt", "updatedBy"],
        "examples": [
          {
            "retention": {
              "events": "30d",
              "resolvedHolds": "3d"
            },
            "version": 1,
            "updatedAt": "2026-11-23T08:00:00.000Z",
            "updatedBy": "service:juniper-backend"
          }
        ]
      },
      "Resource": {
        "type": "object",
        "properties": {
          "key": {
            "type": "string",
            "minLength": 1,
            "maxLength": 200
          },
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 200
          },
          "unit": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string",
                "minLength": 1,
                "maxLength": 40
              },
              "singular": {
                "type": "string",
                "minLength": 1,
                "maxLength": 80
              },
              "plural": {
                "type": "string",
                "minLength": 1,
                "maxLength": 80
              },
              "precision": {
                "type": "integer",
                "minimum": 0,
                "maximum": 6
              }
            },
            "required": ["code", "singular", "plural", "precision"],
            "additionalProperties": false
          },
          "settings": {
            "type": "object",
            "properties": {
              "time": {
                "type": "string",
                "enum": ["none", "buckets"]
              },
              "bucket": {
                "oneOf": [
                  {
                    "type": "object",
                    "properties": {
                      "size": {
                        "type": "string",
                        "const": "step"
                      },
                      "stepMinutes": {
                        "type": "integer",
                        "exclusiveMinimum": 0,
                        "maximum": 1440
                      },
                      "timeZone": {
                        "type": "string"
                      }
                    },
                    "required": ["size", "stepMinutes", "timeZone"],
                    "additionalProperties": false
                  },
                  {
                    "type": "object",
                    "properties": {
                      "size": {
                        "type": "string",
                        "enum": ["day", "month"]
                      },
                      "stepMinutes": {
                        "type": "integer",
                        "exclusiveMinimum": 0,
                        "maximum": 1440
                      },
                      "timeZone": {
                        "type": "string"
                      }
                    },
                    "required": ["size", "timeZone"],
                    "additionalProperties": false
                  }
                ]
              },
              "identity": {
                "type": "string",
                "enum": ["count", "instance"]
              },
              "supplyExpiry": {
                "type": "string",
                "enum": ["none", "expiring"]
              }
            },
            "required": ["time", "identity", "supplyExpiry"],
            "additionalProperties": false
          },
          "scope": {
            "type": "object",
            "properties": {
              "places": {
                "type": "boolean"
              },
              "holders": {
                "type": "boolean"
              }
            },
            "required": ["places", "holders"],
            "additionalProperties": false
          },
          "tracking": {
            "type": "string",
            "enum": ["none", "batch"]
          },
          "shortage": {
            "type": "string",
            "enum": ["deny", "backorder", "negative"]
          },
          "tags": {
            "default": [],
            "type": "array",
            "items": {
              "type": "string",
              "minLength": 1,
              "maxLength": 200
            }
          },
          "attributes": {
            "type": "object",
            "propertyNames": {
              "type": "string",
              "minLength": 1,
              "maxLength": 64,
              "pattern": "^[A-Za-z0-9_-]+$"
            },
            "additionalProperties": {
              "type": "string",
              "maxLength": 200
            }
          },
          "contentRef": {
            "type": "string",
            "minLength": 1,
            "maxLength": 256
          },
          "externalRef": {
            "type": "string",
            "minLength": 1,
            "maxLength": 256
          },
          "id": {
            "type": "string",
            "description": "Resource ID, `res_…`."
          },
          "capacity": {
            "type": "number",
            "description": "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": {
            "type": "number"
          },
          "archivedAt": {
            "type": "string",
            "format": "date-time"
          }
        },
        "required": [
          "key",
          "name",
          "unit",
          "settings",
          "scope",
          "tracking",
          "shortage",
          "tags",
          "id",
          "version"
        ],
        "examples": [
          {
            "key": "roasted-coffee",
            "name": "Juniper roasted coffee",
            "unit": {
              "code": "g",
              "singular": "gram",
              "plural": "grams",
              "precision": 0
            },
            "settings": {
              "time": "none",
              "identity": "count",
              "supplyExpiry": "expiring"
            },
            "scope": {
              "places": true,
              "holders": false
            },
            "tracking": "batch",
            "shortage": "deny",
            "tags": ["coffee"],
            "id": "res_01M83PPH000000000000000001",
            "version": 2
          }
        ]
      },
      "OverCapacity": {
        "description": "What a change that moves capacity leaves over it, in buckets that have not ended, nearest first. `more` is true when there may be more than the answer lists: past `MAX_OVER_CAPACITY_BUCKETS` buckets or `MAX_OVER_CAPACITY_CLAIMS` claims, or past the nearest 1,000 buckets a claim has touched. `GET /slots` and `GET /claims` over a range read the rest.",
        "type": "object",
        "properties": {
          "buckets": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/OverCapacityBucket"
            }
          },
          "more": {
            "type": "boolean"
          }
        },
        "required": ["buckets", "more"],
        "examples": [
          {
            "buckets": [
              {
                "span": {
                  "start": "2026-11-23T18:00:00.000Z",
                  "end": "2026-11-23T19:00:00.000Z"
                },
                "scope": {
                  "instanceId": "ins_01M83PPH000000000000000001"
                },
                "capacity": 0,
                "taken": 1,
                "held": 0,
                "claims": [
                  {
                    "id": "clm_01M83PPH000000000000000004",
                    "kind": "booking",
                    "status": "committed",
                    "quantity": 1,
                    "holdId": "hld_01M83PPH000000000000000002",
                    "holderRef": "principal:external:u_maya"
                  }
                ]
              }
            ],
            "more": false
          }
        ]
      },
      "Place": {
        "type": "object",
        "properties": {
          "key": {
            "type": "string",
            "minLength": 1,
            "maxLength": 200
          },
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 200
          },
          "attributes": {
            "type": "object",
            "propertyNames": {
              "type": "string",
              "minLength": 1,
              "maxLength": 64,
              "pattern": "^[A-Za-z0-9_-]+$"
            },
            "additionalProperties": {
              "type": "string",
              "maxLength": 200
            }
          },
          "id": {
            "type": "string",
            "description": "Place ID, `plc_…`."
          }
        },
        "required": ["key", "name", "id"],
        "examples": [
          {
            "key": "roastery",
            "name": "Juniper Roastery",
            "id": "plc_01M83PPH000000000000000001"
          }
        ]
      },
      "Instance": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "minLength": 1,
            "maxLength": 200
          },
          "status": {
            "type": "string",
            "enum": ["active", "retired"]
          },
          "attributes": {
            "type": "object",
            "propertyNames": {
              "type": "string",
              "minLength": 1,
              "maxLength": 64,
              "pattern": "^[A-Za-z0-9_-]+$"
            },
            "additionalProperties": {
              "type": "string",
              "maxLength": 200
            }
          },
          "id": {
            "type": "string",
            "description": "Instance ID, `ins_…`."
          },
          "resourceId": {
            "type": "string",
            "description": "Resource ID, `res_…`."
          },
          "unavailable": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/UnavailableSpan"
            }
          }
        },
        "required": ["code", "status", "id", "resourceId"],
        "examples": [
          {
            "code": "Court 1",
            "status": "active",
            "id": "ins_01M83PPH000000000000000001",
            "resourceId": "res_01M83PPH000000000000000004"
          }
        ]
      },
      "SupplyEntry": {
        "description": "What arrived or is expected, and what remains of it.",
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "Supply ID, `sup_…`."
          },
          "resourceId": {
            "type": "string",
            "description": "Resource ID, `res_…`."
          },
          "scope": {
            "$ref": "#/components/schemas/Scope",
            "description": "The scope it was added to."
          },
          "kind": {
            "type": "string",
            "enum": ["added", "expected", "output"]
          },
          "quantity": {
            "type": "number",
            "description": "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": {
            "type": "number",
            "description": "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": {
            "type": "number",
            "description": "What open holds have pegged here, or zero when pegging does not apply."
          },
          "fulfils": {
            "type": "string",
            "description": "The expected entry this added entry fulfils."
          },
          "validFrom": {
            "type": "string",
            "format": "date-time",
            "description": "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": {
            "type": "string",
            "format": "date-time",
            "description": "When what it has left stops being on hand."
          },
          "batchId": {
            "type": "string",
            "description": "Batch ID, `bat_…`."
          },
          "attributes": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            },
            "description": "The business's own labels for this entry. ResourceShark stores them and answers with them."
          },
          "drawOrder": {
            "type": "number",
            "description": "Lower numbers are drawn first; a missing value counts as 0."
          },
          "evidence": {
            "$ref": "#/components/schemas/Evidence"
          },
          "sourceKey": {
            "type": "string"
          },
          "actor": {
            "$ref": "#/components/schemas/PrincipalRef"
          },
          "onBehalfOf": {
            "$ref": "#/components/schemas/PrincipalRef"
          },
          "status": {
            "type": "string",
            "enum": ["pending", "active", "exhausted", "expired", "reversed"]
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          }
        },
        "required": [
          "id",
          "resourceId",
          "scope",
          "kind",
          "quantity",
          "remaining",
          "held",
          "evidence",
          "sourceKey",
          "actor",
          "status",
          "createdAt"
        ],
        "examples": [
          {
            "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": {
        "description": "The history of one change to a balance.",
        "type": "object",
        "properties": {
          "quantity": {
            "type": "number",
            "description": "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": {
            "type": "number",
            "description": "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": {
            "type": "number",
            "description": "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": {
            "type": "string",
            "description": "Movement ID, `mov_…`."
          },
          "seq": {
            "type": "number",
            "description": "The project's movement sequence: every movement in the project, in the order they committed."
          },
          "resourceId": {
            "type": "string",
            "description": "Resource ID, `res_…`."
          },
          "scope": {
            "$ref": "#/components/schemas/Scope"
          },
          "bucketStart": {
            "type": "string",
            "format": "date-time",
            "description": "The bucket it moved, for a resource whose time is counted in buckets."
          },
          "held": {
            "$ref": "#/components/schemas/QuantityChange",
            "description": "How held moved, when it did."
          },
          "expected": {
            "$ref": "#/components/schemas/QuantityChange"
          },
          "owed": {
            "type": "object",
            "properties": {
              "quantity": {
                "type": "number",
                "description": "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": {
                "type": "number",
                "description": "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": {
                "type": "number",
                "description": "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`."
              },
              "pegs": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Peg"
                },
                "description": "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."
              }
            },
            "required": ["quantity", "before", "after"],
            "description": "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."
          },
          "reason": {
            "type": "string",
            "enum": [
              "add",
              "expected",
              "hold",
              "release",
              "expire_hold",
              "commit",
              "use",
              "settle",
              "transfer",
              "count",
              "adjustment",
              "reversal",
              "convert_in",
              "convert_out",
              "expire_supply",
              "cancel",
              "capacity"
            ]
          },
          "supplyId": {
            "type": "string",
            "description": "Supply ID, `sup_…`."
          },
          "pegs": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Peg"
            },
            "description": "The supply entries it drew from or returned to."
          },
          "batchId": {
            "type": "string",
            "description": "Set when everything it moved was from or for the same batch."
          },
          "transformationId": {
            "type": "string",
            "description": "The conversion this movement was part of."
          },
          "claimId": {
            "type": "string",
            "description": "Claim ID, `clm_…`."
          },
          "holdId": {
            "type": "string",
            "description": "Hold ID, `hld_…`."
          },
          "transferId": {
            "type": "string",
            "description": "Transfer ID, `trf_…`."
          },
          "reversesId": {
            "type": "string",
            "description": "Movement ID, `mov_…`."
          },
          "evidence": {
            "$ref": "#/components/schemas/Evidence"
          },
          "note": {
            "type": "string"
          },
          "actor": {
            "$ref": "#/components/schemas/PrincipalRef",
            "description": "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": {
            "$ref": "#/components/schemas/PrincipalRef",
            "description": "The delegator, when the actor acted under a delegation."
          },
          "at": {
            "type": "string",
            "format": "date-time"
          }
        },
        "required": [
          "quantity",
          "before",
          "after",
          "id",
          "seq",
          "resourceId",
          "scope",
          "reason",
          "actor",
          "at"
        ],
        "examples": [
          {
            "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"
            }
          }
        ]
      },
      "Batch": {
        "description": "The batch a resource's supply can name.",
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "Batch ID, `bat_…`."
          },
          "resourceId": {
            "type": "string",
            "description": "Resource ID, `res_…`."
          },
          "code": {
            "type": "string"
          },
          "expiresAt": {
            "type": "string",
            "format": "date-time"
          },
          "attributes": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            },
            "description": "The business's own labels. ResourceShark stores them and answers with them."
          },
          "version": {
            "type": "number"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time"
          }
        },
        "required": [
          "id",
          "resourceId",
          "code",
          "version",
          "createdAt",
          "updatedAt"
        ],
        "examples": [
          {
            "resourceId": "res_01M83PPH000000000000000001",
            "code": "ROAST-2026-11-23",
            "expiresAt": "2026-11-29T17:00:00.000Z",
            "attributes": {
              "origin": "Colombia"
            },
            "id": "bat_01M83PPH000000000000000001",
            "version": 2,
            "createdAt": "2026-11-23T08:00:00.000Z",
            "updatedAt": "2026-11-23T08:25:00.000Z"
          }
        ]
      },
      "Claim": {
        "description": "What one line held or took from a resource.",
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "Claim ID, `clm_…`."
          },
          "resourceId": {
            "type": "string",
            "description": "Resource ID, `res_…`."
          },
          "scope": {
            "$ref": "#/components/schemas/Scope",
            "description": "The scope it takes from."
          },
          "span": {
            "$ref": "#/components/schemas/Span",
            "description": "Half-open, UTC. A consumption starts when it was taken and never ends; so does a hold's claim, from when it was placed. A claim on a resource counted in buckets has the span its line asked for, with an end."
          },
          "quantity": {
            "type": "number",
            "description": "What it takes. For a hold's claim, what it holds, or held until its hold was resolved."
          },
          "kind": {
            "type": "string",
            "enum": ["hold", "consumption", "booking"],
            "description": "A claim with a span that ends, on a resource counted in buckets, is a `booking` once it is taken: a consumption there, or a hold's line once its hold is committed. A hold's line is `hold` until then."
          },
          "status": {
            "type": "string",
            "enum": ["held", "committed", "released", "expired", "cancelled"]
          },
          "holdId": {
            "type": "string",
            "description": "The hold it is a line of, for a claim of kind `hold`."
          },
          "committed": {
            "type": "number",
            "description": "What its hold's commit took for good; the rest of `quantity` was released."
          },
          "pegs": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Peg"
            },
            "description": "The entries it drew from, when the resource keeps its supply apart. On a resource that lets its balance go below zero, they can cover less than the claim: the rest was owed, or a hold's line holds it with no entry until its commit takes it."
          },
          "transformationId": {
            "type": "string",
            "description": "The conversion that took this claim's quantity."
          },
          "estimate": {
            "type": "number",
            "description": "What an estimate first took, kept once it is settled; `quantity` is then the real quantity."
          },
          "settled": {
            "type": "number",
            "description": "The real quantity an estimate was settled at. Set once, by the settle."
          },
          "holderRef": {
            "type": "string",
            "description": "Your app's name for the holder, such as `principal:external:u_maya`."
          },
          "evidence": {
            "$ref": "#/components/schemas/Evidence",
            "description": "What it was taken for. A claim taken by a hold commit carries the commit's evidence."
          },
          "sourceKey": {
            "type": "string",
            "description": "For a consume or hold commit, kept on the first claim that takes from each resource."
          },
          "actor": {
            "$ref": "#/components/schemas/PrincipalRef"
          },
          "onBehalfOf": {
            "$ref": "#/components/schemas/PrincipalRef"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time"
          }
        },
        "required": [
          "id",
          "resourceId",
          "scope",
          "span",
          "quantity",
          "kind",
          "status",
          "actor",
          "createdAt",
          "updatedAt"
        ],
        "examples": [
          {
            "id": "clm_01M83PPH000000000000000002",
            "resourceId": "res_01M83PPH000000000000000003",
            "scope": {
              "holderRef": "principal:external:u_maya"
            },
            "span": {
              "start": "2026-11-23T09:30:00.000Z",
              "end": null
            },
            "quantity": 2,
            "kind": "consumption",
            "status": "committed",
            "estimate": 3,
            "pegs": [
              {
                "supplyId": "sup_01M83PPH000000000000000003",
                "quantity": 2
              }
            ],
            "holderRef": "principal:external:u_maya",
            "evidence": {
              "kind": "tasting",
              "ref": "tasting_1042"
            },
            "sourceKey": "tasting:1042:estimate",
            "actor": {
              "id": "key:juniper-backend"
            },
            "createdAt": "2026-11-23T09:30:00.000Z",
            "updatedAt": "2026-11-23T09:40:00.000Z",
            "settled": 2
          }
        ]
      },
      "Hold": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "Hold ID, `hld_…`."
          },
          "label": {
            "type": "string",
            "description": "A label supplied by the app for grouping holds."
          },
          "expiresAt": {
            "type": "string",
            "format": "date-time",
            "description": "When it runs out, set by the server."
          },
          "holderRef": {
            "type": "string",
            "description": "Whom it holds for."
          },
          "reference": {
            "$ref": "#/components/schemas/Evidence",
            "description": "What it was placed for, such as the checkout or the order."
          },
          "lines": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/HoldLine"
            },
            "description": "One per line asked for, in the same order."
          },
          "status": {
            "type": "string",
            "enum": [
              "open",
              "committed",
              "partially_committed",
              "released",
              "expired",
              "cancelled"
            ],
            "description": "`expired` from `expiresAt` on if the hold was still open."
          },
          "resolution": {
            "$ref": "#/components/schemas/HoldResolution",
            "description": "Set once the hold is no longer open."
          },
          "cancellations": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/HoldCancellation"
            },
            "description": "Each cancel of the committed hold, in order."
          },
          "sourceKey": {
            "type": "string"
          },
          "actor": {
            "$ref": "#/components/schemas/PrincipalRef",
            "description": "The principal that placed it with its own credential."
          },
          "onBehalfOf": {
            "$ref": "#/components/schemas/PrincipalRef"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time"
          }
        },
        "required": [
          "id",
          "expiresAt",
          "lines",
          "status",
          "sourceKey",
          "actor",
          "createdAt",
          "updatedAt"
        ],
        "examples": [
          {
            "id": "hld_01M83PPH000000000000000001",
            "holderRef": "principal:external:u_maya",
            "label": "coffee-pickup",
            "reference": {
              "kind": "checkout",
              "ref": "checkout_109"
            },
            "expiresAt": "2026-11-23T10:15:00.000Z",
            "lines": [
              {
                "claimId": "clm_01M83PPH000000000000000003",
                "resourceId": "res_01M83PPH000000000000000001",
                "scope": {
                  "placeId": "plc_01M83PPH000000000000000001"
                },
                "quantity": 500,
                "status": "held",
                "pegs": [
                  {
                    "supplyId": "sup_01M83PPH000000000000000002",
                    "quantity": 500
                  }
                ]
              }
            ],
            "status": "open",
            "sourceKey": "checkout:109:hold",
            "actor": {
              "id": "key:juniper-backend"
            },
            "createdAt": "2026-11-23T10:00:00.000Z",
            "updatedAt": "2026-11-23T10:00:00.000Z"
          }
        ]
      },
      "RetainedHold": {
        "description": "A resolved hold once retention has removed its detail: what its `sourceKey` and its commit's still answer with. Its lines are the ones a commit took from, which stay as the record of what was taken.",
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "Hold ID, `hld_…`."
          },
          "status": {
            "type": "string",
            "enum": [
              "committed",
              "partially_committed",
              "released",
              "expired",
              "cancelled"
            ],
            "description": "How it ended."
          },
          "resolution": {
            "$ref": "#/components/schemas/HoldResolution"
          },
          "sourceKey": {
            "type": "string"
          },
          "lines": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/HoldLine"
            }
          },
          "retainedAt": {
            "type": "string",
            "format": "date-time",
            "description": "When retention removed the rest, including the label, holder, and lines that took nothing."
          }
        },
        "required": [
          "id",
          "status",
          "resolution",
          "sourceKey",
          "lines",
          "retainedAt"
        ],
        "examples": [
          {
            "id": "hld_01M83PPH000000000000000001",
            "status": "released",
            "resolution": {
              "at": "2026-11-23T10:05:00.000Z"
            },
            "sourceKey": "checkout:109:hold",
            "lines": [],
            "retainedAt": "2026-11-26T10:05:00.000Z"
          }
        ]
      },
      "RescheduledLine": {
        "description": "One line a reschedule moved: its hold, and where it sat before and after.",
        "type": "object",
        "properties": {
          "claimId": {
            "type": "string",
            "description": "Claim ID, `clm_…`."
          },
          "holdId": {
            "type": "string",
            "description": "Hold ID, `hld_…`."
          },
          "before": {
            "$ref": "#/components/schemas/LinePosition"
          },
          "after": {
            "$ref": "#/components/schemas/LinePosition"
          }
        },
        "required": ["claimId", "holdId", "before", "after"],
        "examples": [
          {
            "claimId": "clm_01M83PPH000000000000000004",
            "holdId": "hld_01M83PPH000000000000000002",
            "before": {
              "resourceId": "res_01M83PPH000000000000000004",
              "scope": {
                "instanceId": "ins_01M83PPH000000000000000001"
              },
              "span": {
                "start": "2026-11-23T17:00:00.000Z",
                "end": "2026-11-23T18:00:00.000Z"
              }
            },
            "after": {
              "resourceId": "res_01M83PPH000000000000000004",
              "scope": {
                "instanceId": "ins_01M83PPH000000000000000001"
              },
              "span": {
                "start": "2026-11-23T18:00:00.000Z",
                "end": "2026-11-23T19:00:00.000Z"
              }
            }
          }
        ]
      },
      "AvailabilityLine": {
        "type": "object",
        "properties": {
          "resourceId": {
            "type": "string",
            "description": "Resource ID, `res_…`."
          },
          "scope": {
            "$ref": "#/components/schemas/Scope"
          },
          "quantity": {
            "type": "number",
            "description": "The quantity asked about."
          },
          "available": {
            "type": "number",
            "description": "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`."
          },
          "expected": {
            "type": "number",
            "description": "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": {
            "type": "number"
          },
          "asOf": {
            "type": "string",
            "format": "date-time"
          }
        },
        "required": [
          "resourceId",
          "scope",
          "quantity",
          "available",
          "expected",
          "version",
          "asOf"
        ],
        "examples": [
          {
            "resourceId": "res_01M83PPH000000000000000001",
            "scope": {
              "placeId": "plc_01M83PPH000000000000000001"
            },
            "quantity": 500,
            "available": 8500,
            "expected": 0,
            "version": 1,
            "asOf": "2026-11-23T09:55:00.000Z"
          }
        ]
      },
      "Balance": {
        "description": "The quantities and freshness of one scope's balance.",
        "type": "object",
        "properties": {
          "resourceId": {
            "type": "string",
            "description": "Resource ID, `res_…`."
          },
          "scope": {
            "$ref": "#/components/schemas/Scope",
            "description": "The scope read."
          },
          "onHand": {
            "type": "number",
            "description": "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`."
          },
          "held": {
            "type": "number",
            "description": "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`."
          },
          "expected": {
            "type": "number",
            "description": "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`."
          },
          "available": {
            "type": "number",
            "description": "On hand less held, plus expected for backorders. A shortage caused by holds reads as zero."
          },
          "version": {
            "type": "number",
            "description": "Moves with every change to the balance; 0 for a scope that has never had one."
          },
          "asOf": {
            "type": "string",
            "format": "date-time",
            "description": "When the answer was true."
          },
          "batches": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/BalanceBatch"
            },
            "description": "Each batch's share of the balance, included when asked for by batch."
          }
        },
        "required": [
          "resourceId",
          "scope",
          "onHand",
          "held",
          "expected",
          "available",
          "version",
          "asOf"
        ],
        "examples": [
          {
            "resourceId": "res_01M83PPH000000000000000001",
            "scope": {
              "placeId": "plc_01M83PPH000000000000000001"
            },
            "onHand": 6500,
            "held": 0,
            "expected": 0,
            "available": 6500,
            "version": 4,
            "asOf": "2026-11-23T10:30:00.000Z",
            "batches": [
              {
                "batchId": "bat_01M83PPH000000000000000001",
                "code": "ROAST-2026-11-23",
                "onHand": 6500,
                "held": 0,
                "available": 6500,
                "expiresAt": "2026-11-29T17:00:00.000Z"
              }
            ]
          }
        ]
      },
      "HolderBalance": {
        "description": "What one holder has on one resource.",
        "type": "object",
        "properties": {
          "resourceId": {
            "type": "string",
            "description": "Resource ID, `res_…`."
          },
          "holderRef": {
            "type": "string",
            "description": "Your app's name for the holder, such as `principal:external:u_maya`."
          },
          "onHand": {
            "type": "number",
            "description": "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`."
          },
          "held": {
            "type": "number",
            "description": "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`."
          },
          "available": {
            "type": "number",
            "description": "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": {
            "type": "number",
            "description": "Moves with every change to the balance; 0 for one that has never had one."
          },
          "supply": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SupplyEntry"
            },
            "description": "The holder's supply on hand, such as added entries and outputs, in the order a take draws from them."
          },
          "nextSupplyAt": {
            "type": "string",
            "format": "date-time",
            "description": "When the next of the holder's supply that starts later starts, when it has some."
          }
        },
        "required": [
          "resourceId",
          "holderRef",
          "onHand",
          "held",
          "available",
          "version",
          "supply"
        ],
        "examples": [
          {
            "resourceId": "res_01M83PPH000000000000000003",
            "holderRef": "principal:external:u_maya",
            "onHand": 8,
            "held": 0,
            "available": 8,
            "version": 4,
            "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"
              }
            ]
          }
        ]
      },
      "Schedule": {
        "description": "A resource's normal week. A bucket takes the pattern in effect on the local date it starts on, in the schedule's time zone. Inside that pattern's hours a bucket holds its window's `capacity`, else the resource's `capacity`, else as many of the resource's active instances as are not unavailable for any part of it, else 0; outside them it holds nothing. A pattern with no windows puts no limit on the hours. A step bucket is inside the hours when one window holds all of it. A day is inside them when a window falls on its weekday, and holds the largest capacity that day's windows give. A month is longer than any window, so patterns don't apply to it: it holds the resource's own capacity. An exception then replaces what the pattern gives (`ScheduleException`). A pattern that has taken effect, `from` today or earlier, stays as it is: a save changes, adds, or removes only patterns from tomorrow on.",
        "type": "object",
        "properties": {
          "resourceId": {
            "type": "string",
            "description": "Resource ID, `res_…`."
          },
          "timeZone": {
            "type": "string"
          },
          "patterns": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/WeeklyPattern"
            }
          },
          "version": {
            "type": "number",
            "description": "Moves with every save; send it in `If-Match` to save again."
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time"
          }
        },
        "required": [
          "resourceId",
          "timeZone",
          "patterns",
          "version",
          "updatedAt"
        ],
        "examples": [
          {
            "timeZone": "America/Los_Angeles",
            "patterns": [
              {
                "weekly": [
                  {
                    "day": 1,
                    "start": "09:00",
                    "end": "17:00"
                  }
                ]
              }
            ],
            "resourceId": "res_01M83PPH000000000000000004",
            "version": 1,
            "updatedAt": "2026-11-23T08:30:00.000Z"
          }
        ]
      },
      "ScheduleException": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "Exception ID, `exc_…`."
          },
          "resourceId": {
            "type": "string",
            "description": "Resource ID, `res_…`."
          },
          "span": {
            "$ref": "#/components/schemas/FiniteSpan"
          },
          "capacity": {
            "type": "number",
            "description": "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`."
          },
          "reason": {
            "type": "string"
          },
          "version": {
            "type": "number",
            "description": "Moves with every change; send it in `If-Match` to change it."
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time"
          }
        },
        "required": [
          "id",
          "resourceId",
          "span",
          "capacity",
          "version",
          "createdAt",
          "updatedAt"
        ],
        "examples": [
          {
            "id": "exc_01M83PPH000000000000000001",
            "resourceId": "res_01M83PPH000000000000000004",
            "span": {
              "start": "2026-11-23T18:00:00.000Z",
              "end": "2026-11-23T19:00:00.000Z"
            },
            "capacity": 0,
            "reason": "Court resurfacing",
            "version": 1,
            "createdAt": "2026-11-23T11:22:00.000Z",
            "updatedAt": "2026-11-23T11:22:00.000Z"
          }
        ]
      },
      "Slot": {
        "description": "One bucket a claim can take, or one over capacity, with what it holds and what is free. A bucket with no capacity is not a slot unless claims are still in it. Where a daylight-saving change repeats an hour, both of its buckets are slots with the same local time.",
        "type": "object",
        "properties": {
          "start": {
            "type": "string",
            "format": "date-time"
          },
          "end": {
            "type": "string",
            "format": "date-time"
          },
          "timeZone": {
            "type": "string",
            "description": "The resource's bucket time zone."
          },
          "local": {
            "type": "object",
            "properties": {
              "date": {
                "type": "string"
              },
              "time": {
                "type": "string"
              }
            },
            "required": ["date", "time"],
            "description": "Where the slot starts, on the local calendar and clock."
          },
          "capacity": {
            "type": "number",
            "description": "What the schedule gives the bucket."
          },
          "taken": {
            "type": "number",
            "description": "What bookings took."
          },
          "held": {
            "type": "number",
            "description": "What holds not past their expiry hold."
          },
          "available": {
            "type": "number",
            "description": "Capacity less what is held and taken, and never below 0: the bucket is over capacity when `taken` and `held` come to more than `capacity`."
          }
        },
        "required": [
          "start",
          "end",
          "timeZone",
          "local",
          "capacity",
          "taken",
          "held",
          "available"
        ],
        "examples": [
          {
            "start": "2026-11-23T17:00:00.000Z",
            "end": "2026-11-23T18:00:00.000Z",
            "timeZone": "America/Los_Angeles",
            "local": {
              "date": "2026-11-23",
              "time": "09:00"
            },
            "capacity": 1,
            "taken": 1,
            "held": 0,
            "available": 0
          }
        ]
      },
      "Transformation": {
        "description": "The record that links a conversion's inputs, outputs, and evidence.",
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "Transformation ID, `tfm_…`."
          },
          "takes": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "claimId": {
                  "type": "string",
                  "description": "Claim ID, `clm_…`."
                },
                "movementId": {
                  "type": "string",
                  "description": "Movement ID, `mov_…`."
                }
              },
              "required": ["claimId", "movementId"]
            }
          },
          "adds": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "supplyId": {
                  "type": "string",
                  "description": "Supply ID, `sup_…`."
                },
                "movementId": {
                  "type": "string",
                  "description": "Movement ID, `mov_…`."
                }
              },
              "required": ["supplyId", "movementId"]
            }
          },
          "evidence": {
            "$ref": "#/components/schemas/Evidence"
          },
          "sourceKey": {
            "type": "string"
          },
          "actor": {
            "$ref": "#/components/schemas/PrincipalRef"
          },
          "onBehalfOf": {
            "$ref": "#/components/schemas/PrincipalRef"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          }
        },
        "required": [
          "id",
          "takes",
          "adds",
          "evidence",
          "sourceKey",
          "actor",
          "createdAt"
        ],
        "examples": [
          {
            "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"
          }
        ]
      },
      "ResourceTotals": {
        "description": "One resource's totals.",
        "type": "object",
        "properties": {
          "resourceId": {
            "type": "string",
            "description": "Resource ID, `res_…`."
          },
          "key": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "unit": {
            "$ref": "#/components/schemas/Unit"
          },
          "balance": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/TotalsBalance"
              },
              {
                "type": "null"
              }
            ],
            "description": "The resource's balance over its scopes, or one holder's. Null on a resource counted in buckets: it has a balance for each bucket of time, and buckets of different times are never added together."
          },
          "movements": {
            "type": "object",
            "additionalProperties": {
              "type": "number",
              "description": "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`."
            },
            "description": "When a period was asked for: the resource's movements in it, by reason."
          },
          "groups": {
            "anyOf": [
              {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/TotalsGroup"
                }
              },
              {
                "type": "null"
              }
            ],
            "description": "When `groupBy` was asked for: the totals for each value of that attribute on the resource's supply entries, by value and the entries without it last. A unit counts in the group of the entry it sits on, and a movement in the groups of the entries it drew from or added to, so the groups add up to the resource's totals. What a balance owes, and what holds hold beyond its entries, sit on no entry and count in the null group, and so does what is available on a balance that has either. Null on a resource that keeps one running balance or counts in buckets: it keeps no supply entries apart, so there is nothing to group by."
          }
        },
        "required": ["resourceId", "key", "name", "unit", "balance"],
        "examples": [
          {
            "resourceId": "res_01M83PPH000000000000000003",
            "key": "tasting-credits",
            "name": "Prepaid tasting credits",
            "unit": {
              "code": "credit",
              "singular": "credit",
              "plural": "credits",
              "precision": 0
            },
            "balance": {
              "onHand": 8,
              "held": 0,
              "available": 8
            },
            "movements": {
              "add": 12,
              "use": -3,
              "settle": 1,
              "reversal": -2
            },
            "groups": [
              {
                "value": "tasting-club",
                "balance": {
                  "onHand": 8,
                  "held": 0,
                  "available": 8
                },
                "movements": {
                  "add": 12,
                  "use": -3,
                  "settle": 1,
                  "reversal": -2
                }
              }
            ]
          }
        ]
      },
      "ChangeEvent": {
        "description": "One change-feed record: CloudEvents 1.0, structured JSON. Written out in full, the kit's `ChangeEventBase` with this service's source, so the SDK's generated types need nothing from the kit.",
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "A plain ULID, unique to the event."
          },
          "seq": {
            "type": "number",
            "description": "The event's place in the project's feed, from 1. Pass it as `after` to read the events after it."
          },
          "specversion": {
            "const": "1.0"
          },
          "type": {
            "type": "string"
          },
          "source": {
            "const": "/resourceshark",
            "description": "`EVENT_SOURCE`, written out so the SDK's generated types need no value."
          },
          "subject": {
            "type": "string",
            "description": "The record the event is about."
          },
          "time": {
            "type": "string",
            "format": "date-time"
          },
          "datacontenttype": {
            "const": "application/json"
          },
          "data": {
            "type": "object",
            "properties": {
              "context": {
                "$ref": "#/components/schemas/ActingContext",
                "description": "Who made the change, and for whom."
              }
            },
            "required": ["context"],
            "additionalProperties": {}
          }
        },
        "required": [
          "id",
          "seq",
          "specversion",
          "type",
          "source",
          "time",
          "datacontenttype",
          "data"
        ],
        "examples": [
          {
            "id": "01M83PPH00000000000000000E",
            "seq": 37,
            "specversion": "1.0",
            "type": "tools.agentpost.resources.hold.placed",
            "source": "/resourceshark",
            "subject": "hld_01M83PPH000000000000000002",
            "time": "2026-11-23T11:00:00.000Z",
            "datacontenttype": "application/json",
            "data": {
              "context": {
                "actor": {
                  "id": "key:juniper-backend"
                }
              },
              "holdId": "hld_01M83PPH000000000000000002",
              "reason": "hold",
              "evidence": {
                "kind": "booking_request",
                "ref": "court_request_217"
              },
              "movementIds": ["mov_01M83PPH00000000000000000F"],
              "holderRef": "principal:external:u_maya",
              "label": "court-booking",
              "reference": {
                "kind": "booking_request",
                "ref": "court_request_217"
              },
              "expiresAt": "2026-11-23T11:15:00.000Z",
              "lines": [
                {
                  "claimId": "clm_01M83PPH000000000000000004",
                  "resourceId": "res_01M83PPH000000000000000004",
                  "scope": {
                    "instanceId": "ins_01M83PPH000000000000000001"
                  },
                  "quantity": 1,
                  "span": {
                    "start": "2026-11-23T17:00:00.000Z",
                    "end": "2026-11-23T18:00:00.000Z"
                  },
                  "status": "held"
                }
              ],
              "status": "open",
              "sourceKey": "court:217:hold",
              "actor": {
                "id": "key:juniper-backend"
              },
              "createdAt": "2026-11-23T11:00:00.000Z",
              "updatedAt": "2026-11-23T11:00:00.000Z"
            }
          }
        ]
      },
      "OverCapacityBucket": {
        "description": "A bucket where what is held and taken is more than its capacity.",
        "type": "object",
        "properties": {
          "span": {
            "$ref": "#/components/schemas/FiniteSpan"
          },
          "scope": {
            "$ref": "#/components/schemas/Scope"
          },
          "capacity": {
            "type": "number",
            "description": "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`."
          },
          "taken": {
            "type": "number",
            "description": "What bookings took."
          },
          "held": {
            "type": "number",
            "description": "What holds not past their expiry hold."
          },
          "claims": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/OverCapacityClaim"
            },
            "description": "Every claim in it, so your app can choose which to move, release, or cancel."
          }
        },
        "required": ["span", "scope", "capacity", "taken", "held", "claims"],
        "examples": [
          {
            "span": {
              "start": "2026-11-23T18:00:00.000Z",
              "end": "2026-11-23T19:00:00.000Z"
            },
            "scope": {
              "instanceId": "ins_01M83PPH000000000000000001"
            },
            "capacity": 0,
            "taken": 1,
            "held": 0,
            "claims": [
              {
                "id": "clm_01M83PPH000000000000000004",
                "kind": "booking",
                "status": "committed",
                "quantity": 1,
                "holdId": "hld_01M83PPH000000000000000002",
                "holderRef": "principal:external:u_maya"
              }
            ]
          }
        ]
      },
      "UnavailableSpan": {
        "description": "A period an instance is unavailable and counts toward no capacity. Half-open, with a finite end.",
        "type": "object",
        "properties": {
          "start": {
            "type": "string",
            "format": "date-time"
          },
          "end": {
            "type": "string",
            "format": "date-time"
          }
        },
        "required": ["start", "end"],
        "examples": [
          {
            "start": "2026-11-23T20:00:00.000Z",
            "end": "2026-11-23T21:00:00.000Z"
          }
        ]
      },
      "Scope": {
        "description": "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.",
        "type": "object",
        "properties": {
          "placeId": {
            "type": "string",
            "description": "Place ID, `plc_…`."
          },
          "condition": {
            "type": "string"
          },
          "holderRef": {
            "type": "string",
            "description": "Your app's name for the holder, such as `principal:external:u_maya`."
          },
          "instanceId": {
            "type": "string",
            "description": "Instance ID, `ins_…`."
          }
        },
        "required": [],
        "examples": [
          {
            "placeId": "plc_01M83PPH000000000000000001"
          }
        ]
      },
      "Evidence": {
        "description": "What a change was made for, such as `{ kind: \"order\", ref: \"ord_…\" }`.",
        "type": "object",
        "properties": {
          "kind": {
            "type": "string"
          },
          "ref": {
            "type": "string",
            "description": "An opaque reference to another system's record, such as `ord_01J…`. ResourceShark stores it and answers with it."
          }
        },
        "required": ["kind", "ref"],
        "examples": [
          {
            "kind": "checkout",
            "ref": "checkout_109"
          }
        ]
      },
      "PrincipalRef": {
        "description": "A principal that acted, with the kind it declared for itself.",
        "type": "object",
        "properties": {
          "kind": {
            "type": "string",
            "enum": ["human", "agent", "service"],
            "description": "The kind a principal may declare. A principal that declared none has no `kind`."
          },
          "id": {
            "type": "string"
          }
        },
        "required": ["id"],
        "examples": [
          {
            "id": "key:juniper-backend"
          }
        ]
      },
      "QuantityChange": {
        "description": "How one of a balance's quantities moved: signed, with the value before and after.",
        "type": "object",
        "properties": {
          "quantity": {
            "type": "number",
            "description": "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": {
            "type": "number",
            "description": "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": {
            "type": "number",
            "description": "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`."
          }
        },
        "required": ["quantity", "before", "after"],
        "examples": [
          {
            "quantity": -1,
            "before": 1,
            "after": 0
          }
        ]
      },
      "Peg": {
        "description": "How much a claim or movement drew from one supply entry.",
        "type": "object",
        "properties": {
          "supplyId": {
            "type": "string",
            "description": "Supply ID, `sup_…`."
          },
          "quantity": {
            "type": "number",
            "description": "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`."
          }
        },
        "required": ["supplyId", "quantity"],
        "examples": [
          {
            "supplyId": "sup_01M83PPH000000000000000002",
            "quantity": 500
          }
        ]
      },
      "Span": {
        "description": "Half-open, `[start, end)`, in UTC. A null `end` is open-ended.",
        "type": "object",
        "properties": {
          "start": {
            "type": "string",
            "format": "date-time"
          },
          "end": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ]
          }
        },
        "required": ["start", "end"],
        "examples": [
          {
            "start": "2026-11-23T09:30:00.000Z",
            "end": null
          }
        ]
      },
      "HoldLine": {
        "description": "One line of a hold, as its claim stands.",
        "type": "object",
        "properties": {
          "claimId": {
            "type": "string",
            "description": "Claim ID, `clm_…`."
          },
          "resourceId": {
            "type": "string",
            "description": "Resource ID, `res_…`."
          },
          "scope": {
            "$ref": "#/components/schemas/Scope",
            "description": "The scope it holds from."
          },
          "span": {
            "$ref": "#/components/schemas/FiniteSpan",
            "description": "On a resource counted in buckets: the time the line holds, `[start, end)`."
          },
          "quantity": {
            "type": "number",
            "description": "What the line holds, or held until the hold was resolved."
          },
          "status": {
            "type": "string",
            "enum": ["held", "committed", "released", "expired", "cancelled"],
            "description": "`cancelled` once a cancel gave back what its commit took."
          },
          "committed": {
            "type": "number",
            "description": "What the commit took for good; the rest of `quantity` was released."
          },
          "pegs": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Peg"
            },
            "description": "The supply entries the line holds from, or took from once committed, on a resource whose supply is told apart."
          }
        },
        "required": ["claimId", "resourceId", "scope", "quantity", "status"],
        "examples": [
          {
            "claimId": "clm_01M83PPH000000000000000003",
            "resourceId": "res_01M83PPH000000000000000001",
            "scope": {
              "placeId": "plc_01M83PPH000000000000000001"
            },
            "quantity": 500,
            "status": "held",
            "pegs": [
              {
                "supplyId": "sup_01M83PPH000000000000000002",
                "quantity": 500
              }
            ]
          }
        ]
      },
      "HoldResolution": {
        "description": "How a hold ended.",
        "type": "object",
        "properties": {
          "at": {
            "type": "string",
            "format": "date-time",
            "description": "When: the commit or the release, or, for an expiry, the `expiresAt` it ran out at."
          },
          "evidence": {
            "$ref": "#/components/schemas/Evidence",
            "description": "What a commit was made for, such as the order."
          },
          "sourceKey": {
            "type": "string",
            "description": "The commit's `sourceKey`."
          }
        },
        "required": ["at"],
        "examples": [
          {
            "at": "2026-11-23T11:15:00.000Z",
            "evidence": {
              "kind": "booking",
              "ref": "court_booking_217"
            },
            "sourceKey": "court:217:book"
          }
        ]
      },
      "HoldCancellation": {
        "description": "One cancel of a committed hold: the lines it gave back.",
        "type": "object",
        "properties": {
          "at": {
            "type": "string",
            "format": "date-time"
          },
          "claimIds": {
            "type": "array",
            "items": {
              "type": "string",
              "description": "Claim ID, `clm_…`."
            }
          },
          "evidence": {
            "$ref": "#/components/schemas/Evidence"
          },
          "sourceKey": {
            "type": "string"
          }
        },
        "required": ["at", "claimIds", "sourceKey"],
        "examples": [
          {
            "at": "2026-11-23T11:30:00.000Z",
            "claimIds": ["clm_01M83PPH000000000000000004"],
            "evidence": {
              "kind": "cancellation",
              "ref": "court_booking_217"
            },
            "sourceKey": "court:217:cancel"
          }
        ]
      },
      "LinePosition": {
        "description": "Where a hold line sits: its resource, its scope there, and its span.",
        "type": "object",
        "properties": {
          "resourceId": {
            "type": "string",
            "description": "Resource ID, `res_…`."
          },
          "scope": {
            "$ref": "#/components/schemas/Scope"
          },
          "span": {
            "$ref": "#/components/schemas/FiniteSpan"
          }
        },
        "required": ["resourceId", "scope", "span"],
        "examples": [
          {
            "resourceId": "res_01M83PPH000000000000000004",
            "scope": {
              "instanceId": "ins_01M83PPH000000000000000001"
            },
            "span": {
              "start": "2026-11-23T18:00:00.000Z",
              "end": "2026-11-23T19:00:00.000Z"
            }
          }
        ]
      },
      "BalanceBatch": {
        "description": "The portion of one scope's balance that belongs to a batch.",
        "type": "object",
        "properties": {
          "batchId": {
            "type": "string",
            "description": "Batch ID, `bat_…`."
          },
          "code": {
            "type": "string"
          },
          "onHand": {
            "type": "number",
            "description": "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`."
          },
          "held": {
            "type": "number",
            "description": "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`."
          },
          "available": {
            "type": "number",
            "description": "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`."
          },
          "expiresAt": {
            "type": "string",
            "format": "date-time"
          }
        },
        "required": ["batchId", "code", "onHand", "held", "available"],
        "examples": [
          {
            "batchId": "bat_01M83PPH000000000000000001",
            "code": "ROAST-2026-11-23",
            "onHand": 6500,
            "held": 0,
            "available": 6500,
            "expiresAt": "2026-11-29T17:00:00.000Z"
          }
        ]
      },
      "WeeklyPattern": {
        "description": "A normal week, in effect from `from` until the next pattern starts.",
        "type": "object",
        "properties": {
          "from": {
            "type": "string",
            "description": "`YYYY-MM-DD` in the schedule's time zone. Missing on the first pattern."
          },
          "weekly": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/WeeklyWindow"
            }
          }
        },
        "required": ["weekly"],
        "examples": [
          {
            "weekly": [
              {
                "day": 1,
                "start": "09:00",
                "end": "17:00"
              }
            ]
          }
        ]
      },
      "FiniteSpan": {
        "description": "Half-open, `[start, end)`, in UTC, with an end.",
        "type": "object",
        "properties": {
          "start": {
            "type": "string",
            "format": "date-time"
          },
          "end": {
            "type": "string",
            "format": "date-time"
          }
        },
        "required": ["start", "end"],
        "examples": [
          {
            "start": "2026-11-23T17:00:00.000Z",
            "end": "2026-11-23T18:00:00.000Z"
          }
        ]
      },
      "Unit": {
        "description": "A resource's base unit, with its labels and its precision: the number of decimal places one unit of `Quantity` stands for.",
        "type": "object",
        "properties": {
          "code": {
            "type": "string"
          },
          "singular": {
            "type": "string"
          },
          "plural": {
            "type": "string"
          },
          "precision": {
            "type": "number"
          }
        },
        "required": ["code", "singular", "plural", "precision"],
        "examples": [
          {
            "code": "g",
            "singular": "gram",
            "plural": "grams",
            "precision": 0
          }
        ]
      },
      "TotalsBalance": {
        "description": "A balance summed over scopes, each scope counted as a balance read counts it: an expired hold holds nothing, and supply past its expiry is not on hand.",
        "type": "object",
        "properties": {
          "onHand": {
            "type": "number",
            "description": "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`."
          },
          "held": {
            "type": "number",
            "description": "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`."
          },
          "available": {
            "type": "number",
            "description": "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`."
          }
        },
        "required": ["onHand", "held", "available"],
        "examples": [
          {
            "onHand": 8,
            "held": 0,
            "available": 8
          }
        ]
      },
      "TotalsGroup": {
        "description": "The totals of one value of the grouping attribute, or of the entries without it.",
        "type": "object",
        "properties": {
          "value": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "description": "The attribute's value on these entries, or null for the entries that don't carry it."
          },
          "balance": {
            "$ref": "#/components/schemas/TotalsBalance",
            "description": "What these entries have, as the resource's balance counts it."
          },
          "movements": {
            "type": "object",
            "additionalProperties": {
              "type": "number",
              "description": "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`."
            },
            "description": "When a period was asked for: what movements in it changed on these entries, by reason."
          }
        },
        "required": ["value", "balance"],
        "examples": [
          {
            "value": "tasting-club",
            "balance": {
              "onHand": 8,
              "held": 0,
              "available": 8
            },
            "movements": {
              "add": 12,
              "use": -3,
              "settle": 1,
              "reversal": -2
            }
          }
        ]
      },
      "ActingContext": {
        "description": "Who made a change and for whom, as a change-feed event carries it: the actor, and the delegator when the actor acted under a delegation. ResourceShark's own changes, such as a sweep's, name the `service` principal `resourceshark`.",
        "type": "object",
        "properties": {
          "actor": {
            "$ref": "#/components/schemas/PrincipalRef",
            "description": "The principal that made the request with its own credential. Your project's secret key is `key:` and the key's name, with no `kind`."
          },
          "onBehalfOf": {
            "$ref": "#/components/schemas/PrincipalRef",
            "description": "The delegator, when the actor acted under a delegation."
          }
        },
        "required": ["actor"],
        "examples": [
          {
            "actor": {
              "id": "key:juniper-backend"
            }
          }
        ]
      },
      "OverCapacityClaim": {
        "description": "One claim in a bucket over capacity.",
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "Claim ID, `clm_…`."
          },
          "kind": {
            "type": "string",
            "enum": ["hold", "consumption", "booking"]
          },
          "status": {
            "type": "string",
            "enum": ["held", "committed", "released", "expired", "cancelled"],
            "description": "`held` or `committed`."
          },
          "quantity": {
            "type": "number",
            "description": "What it holds, or what it took."
          },
          "holdId": {
            "type": "string",
            "description": "Hold ID, `hld_…`."
          },
          "holderRef": {
            "type": "string",
            "description": "Your app's name for the holder, such as `principal:external:u_maya`."
          }
        },
        "required": ["id", "kind", "status", "quantity"],
        "examples": [
          {
            "id": "clm_01M83PPH000000000000000004",
            "kind": "booking",
            "status": "committed",
            "quantity": 1,
            "holdId": "hld_01M83PPH000000000000000002",
            "holderRef": "principal:external:u_maya"
          }
        ]
      },
      "WeeklyWindow": {
        "description": "One weekly window, in the schedule's time zone.",
        "type": "object",
        "properties": {
          "day": {
            "type": "number",
            "enum": [0, 1, 2, 3, 4, 5, 6]
          },
          "start": {
            "type": "string",
            "description": "`HH:MM`."
          },
          "end": {
            "type": "string",
            "description": "`HH:MM`, or `24:00` for the end of the day."
          },
          "capacity": {
            "type": "number",
            "description": "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`."
          }
        },
        "required": ["day", "start", "end"],
        "examples": [
          {
            "day": 1,
            "start": "09:00",
            "end": "17:00"
          }
        ]
      },
      "Error": {
        "description": "The body of every error. Act on `error.code`: each code has an entry on [ResourceShark errors](https://agentpost.tools/docs/resourceshark/errors).",
        "type": "object",
        "properties": {
          "error": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string",
                "description": "What to act on. It never changes for a given error. Each error response lists the codes it can carry."
              },
              "message": {
                "type": "string",
                "description": "What went wrong, for humans. It may change."
              },
              "details": {
                "description": "What the code needs, when it needs more, such as `issues` for `invalid_request`."
              },
              "docs": {
                "type": "string",
                "format": "uri",
                "description": "The code’s entry on the errors page."
              },
              "class": {
                "type": "string",
                "enum": ["retry_later", "exhausted", "change_the_request"],
                "description": "What kind of action can succeed after this error."
              }
            },
            "required": ["code", "message", "docs", "class"]
          }
        },
        "required": ["error"],
        "examples": [
          {
            "error": {
              "code": "assignment_infeasible",
              "class": "change_the_request",
              "message": "line 0 names unit ins_01M83PPH000000000000000001 of resource res_01M83PPH000000000000000004, and it isn't free for that span: name another",
              "details": {
                "lines": [
                  {
                    "line": 0,
                    "resourceId": "res_01M83PPH000000000000000004",
                    "scope": {
                      "instanceId": "ins_01M83PPH000000000000000001"
                    },
                    "quantity": 1,
                    "available": 0
                  }
                ]
              },
              "docs": "https://agentpost.tools/docs/resourceshark/errors#assignment_infeasible"
            }
          }
        ]
      }
    },
    "securitySchemes": {
      "secretKey": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "sk_…",
        "description": "Your project’s secret key, sent from your server."
      },
      "userToken": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "ut_…",
        "description": "A signed-in principal’s user token. It can read the records of that principal’s `principal:<principal>` holder where the operation allows it."
      }
    }
  }
}
