Resources
Define what you count, how it is measured, and which scopes hold it. Read, edit, or archive a resource.
Paths are relative to https://api.agentpost.tools/v1/resources. Who may call explains each credential.
Create a resource
POST /resources
Creates a resource under a key unique in the project. Send both scope flags, places and holders.
- Who may call: Your server, with your project’s secret key.
- Credential: the examples send your project’s
devsecret key,sk_test_…, asAuthorization: Bearer <token>. - SDK:
client.resources.create(body) - Idempotency-Key: optional. Retrying a write has the rule.
Body
| Name | Type | Required | Description |
|---|---|---|---|
key |
string |
Yes | 1–200 characters. |
name |
string |
Yes | 1–200 characters. |
unit |
object |
Yes | |
unit. |
string |
Yes | 1–40 characters. |
unit. |
string |
Yes | 1–80 characters. |
unit. |
string |
Yes | 1–80 characters. |
unit. |
integer |
Yes | 0–6. |
settings |
object |
Yes | |
settings. |
"none" or "buckets" |
Yes | |
settings. |
object |
No | |
settings. |
string |
Yes | One of "step", "day", or "month". |
settings. |
integer |
No | 1–1440. |
settings. |
string |
Yes | |
settings. |
"count" or "instance" |
Yes | |
settings. |
"none" or "expiring" |
Yes | |
scope |
object |
Yes | |
scope. |
boolean |
Yes | |
scope. |
boolean |
Yes | |
tracking |
"none" or "batch" |
Yes | |
shortage |
string |
Yes | One of "deny", "backorder", or "negative". |
capacity |
number |
No | |
tags |
string[] |
No | |
attributes |
object |
No | Each value is a string. |
contentRef |
string |
No | 1–256 characters. |
externalRef |
string |
No | 1–256 characters. |
Response
201 Created, with ResourceResponse.
Errors
invalid_request(400)payload_too_large(413)invalid_quantity(422)key_in_use(409)
Any operation can also answer with the codes Conventions lists.
List resources
GET /resources
Lists active resources, optionally filtered by tag, key, or both.
- Who may call: Your server, with your project’s secret key.
- Credential: the examples send your project’s
devsecret key,sk_test_…, asAuthorization: Bearer <token>. - SDK:
client.resources.list(query) - Pages:
limit, 1 to 500, default 100, withnextandafter. Lists has the rule.
Query parameters
| Name | Type | Required | Description |
|---|---|---|---|
after |
string |
No | 1–200 characters. |
limit |
integer |
No | 1–500; default 100. |
key |
string |
No | 1–200 characters. |
tag |
string |
No | 1–200 characters. |
Response
200 OK, with ResourcesPage.
Errors
invalid_request(400)
Any operation can also answer with the codes Conventions lists.
Get a resource
GET /resources/:id
Reads a resource by ID, including an archived resource.
- Who may call: Your server, with your project’s secret key.
- Credential: the examples send your project’s
devsecret key,sk_test_…, asAuthorization: Bearer <token>. - SDK:
client.resources.get(id)
Path parameters
| Name | Type | Required | Description |
|---|---|---|---|
id |
string |
Yes | Resource ID, res_…. The id of a Resource. |
Response
200 OK, with ResourceResponse.
Errors
not_found(404)
Any operation can also answer with the codes Conventions lists.
Update a resource
PATCH /resources/:id
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.
- Who may call: Your server, with your project’s secret key.
- Credential: the examples send your project’s
devsecret key,sk_test_…, asAuthorization: Bearer <token>. - SDK:
client.resources.patch(id, body, { ifMatch }) - Idempotency-Key: optional. Retrying a write has the rule.
- If-Match: Required. Send the version you read.
Path parameters
| Name | Type | Required | Description |
|---|---|---|---|
id |
string |
Yes | Resource ID, res_…. The id of a Resource. |
Body
| Name | Type | Required | Description |
|---|---|---|---|
key |
string |
No | 1–200 characters. |
name |
string |
No | 1–200 characters. |
unit |
object |
No | |
unit. |
string |
No | 1–40 characters. |
unit. |
string |
No | 1–80 characters. |
unit. |
string |
No | 1–80 characters. |
unit. |
integer |
No | 0–6. |
settings |
object |
No | |
settings. |
"none" or "buckets" |
No | |
settings. |
object or null |
No | |
settings. |
"count" or "instance" |
No | |
settings. |
"none" or "expiring" |
No | |
scope |
object |
No | |
scope. |
boolean |
No | |
scope. |
boolean |
No | |
tracking |
"none" or "batch" |
No | |
shortage |
string |
No | One of "deny", "backorder", or "negative". |
capacity |
number or null |
No | |
tags |
string[] |
No | |
attributes |
object or null |
No | Each value is a string. |
contentRef |
string or null |
No | |
externalRef |
string or null |
No |
Response
200 OK, with ResourceResponse.
Errors
invalid_request(400)payload_too_large(413)invalid_quantity(422)key_in_use(409)not_found(404)stale_version(409)settings_locked(409)
Any operation can also answer with the codes Conventions lists.
Archive a resource
POST /resources/:id/archive
Archives a resource, keeping its key and making it read-only.
- Who may call: Your server, with your project’s secret key.
- Credential: the examples send your project’s
devsecret key,sk_test_…, asAuthorization: Bearer <token>. - SDK:
client.resources.archive(id) - Idempotency-Key: optional. Retrying a write has the rule.
Path parameters
| Name | Type | Required | Description |
|---|---|---|---|
id |
string |
Yes | Resource ID, res_…. The id of a Resource. |
Response
200 OK, with ResourceResponse.
Errors
not_found(404)
Any operation can also answer with the codes Conventions lists.
The ResourceResponse object
| Name | Type | Present | Description |
|---|---|---|---|
resource |
Resource |
Always | |
overCapacity |
OverCapacity |
When set | With a change to a bucketed resource’s capacity: the buckets now over it. |
The ResourcesPage object
| Name | Type | Present | Description |
|---|---|---|---|
resources |
Resource array |
Always | |
next |
string |
When set |
The Resource object
| Name | Type | Present | Description |
|---|---|---|---|
key |
string |
Always | 1–200 characters. |
name |
string |
Always | 1–200 characters. |
unit |
object |
Always | |
unit. |
string |
Always | 1–40 characters. |
unit. |
string |
Always | 1–80 characters. |
unit. |
string |
Always | 1–80 characters. |
unit. |
integer |
Always | 0–6. |
settings |
object |
Always | |
settings. |
"none" or "buckets" |
Always | |
settings. |
object |
When set | |
settings. |
string |
Always | One of "step", "day", or "month". |
settings. |
integer |
When set | 1–1440. |
settings. |
string |
Always | |
settings. |
"count" or "instance" |
Always | |
settings. |
"none" or "expiring" |
Always | |
scope |
object |
Always | |
scope. |
boolean |
Always | |
scope. |
boolean |
Always | |
tracking |
"none" or "batch" |
Always | |
shortage |
string |
Always | One of "deny", "backorder", or "negative". |
tags |
string[] |
Always | |
attributes |
object |
When set | Each value is a string. |
contentRef |
string |
When set | 1–256 characters. |
externalRef |
string |
When set | 1–256 characters. |
id |
string |
Always | Resource ID, res_…. |
capacity |
number |
When set | An integer in the resource’s base unit at its precision, as money is in cents: grams at precision 0, meters at precision 2, so 1 is 1 cm. A quantity with a fraction is refused with invalid_quantity. |
version |
number |
Always | |
archivedAt |
string |
When set | An ISO 8601 date and time. |
The OverCapacity object
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.
| Name | Type | Present | Description |
|---|---|---|---|
buckets |
OverCapacityBucket array |
Always | |
more |
boolean |
Always |
The OverCapacityBucket object
A bucket where what is held and taken is more than its capacity.
| Name | Type | Present | Description |
|---|---|---|---|
span |
FiniteSpan |
Always | |
scope |
Scope |
Always | |
capacity |
number |
Always | An integer in the resource’s base unit at its precision, as money is in cents: grams at precision 0, meters at precision 2, so 1 is 1 cm. A quantity with a fraction is refused with invalid_quantity. |
taken |
number |
Always | What bookings took. |
held |
number |
Always | What holds not past their expiry hold. |
claims |
OverCapacityClaim array |
Always | Every claim in it, so your app can choose which to move, release, or cancel. |
The OverCapacityClaim object
One claim in a bucket over capacity.
| Name | Type | Present | Description |
|---|---|---|---|
id |
string |
Always | Claim ID, clm_…. |
kind |
string |
Always | One of "hold", "consumption", or "booking". |
status |
string |
Always | held or committed. One of "held", "committed", "released", "expired", or "cancelled". |
quantity |
number |
Always | What it holds, or what it took. |
holdId |
string |
When set | Hold ID, hld_…. |
holderRef |
string |
When set | Your app’s name for the holder, such as principal:external:u_maya. |