Schedules
Read or set a resource’s recurring capacity, and manage dated exceptions to it.
Paths are relative to https://api.agentpost.tools/v1/resources. Who may call explains each credential.
Save a schedule
PUT /resources/:id/schedule
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.
- 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.schedules.put(resourceId, body) - Idempotency-Key: optional. Retrying a write has the rule.
- If-Match: Send the version you read when replacing an existing schedule.
Path parameters
| Name | Type | Required | Description |
|---|---|---|---|
id |
string |
Yes | Resource ID, res_…. The id of a Resource. |
Body
| Name | Type | Required | Description |
|---|---|---|---|
timeZone |
string |
No | |
patterns |
object[] |
Yes | 1–100 items. |
patterns[]. |
string |
No | |
patterns[]. |
object[] |
Yes | Up to 100 items. |
patterns[]. |
integer |
Yes | 0–6. |
patterns[]. |
string |
Yes | |
patterns[]. |
string |
Yes | |
patterns[]. |
number |
No |
Response
200 OK, with ScheduleSaveResponse.
Errors
invalid_request(400)payload_too_large(413)invalid_quantity(422)not_found(404)stale_version(409)
Any operation can also answer with the codes Conventions lists.
Get a schedule
GET /resources/:id/schedule
Reads a resource’s schedule and its version.
- 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.schedules.get(resourceId)
Path parameters
| Name | Type | Required | Description |
|---|---|---|---|
id |
string |
Yes | Resource ID, res_…. The id of a Resource. |
Response
200 OK, with ScheduleResponse.
Errors
not_found(404)
Any operation can also answer with the codes Conventions lists.
Create a schedule exception
POST /resources/:id/exceptions
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.
- 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.exceptions.create(resourceId, body, { idempotencyKey }) - Idempotency-Key: required. Retrying a write has the rule.
Path parameters
| Name | Type | Required | Description |
|---|---|---|---|
id |
string |
Yes | Resource ID, res_…. The id of a Resource. |
Body
| Name | Type | Required | Description |
|---|---|---|---|
span |
object |
Yes | |
span. |
string |
Yes | An ISO 8601 date and time. |
span. |
string |
Yes | An ISO 8601 date and time. |
capacity |
number |
Yes | |
reason |
string |
No | 1–200 characters. |
sourceKey |
string |
Yes | 1–200 characters. |
Response
201 Created, with ExceptionCreateResponse.
Errors
invalid_request(400)payload_too_large(413)invalid_quantity(422)not_found(404)duplicate_source(409)
Any operation can also answer with the codes Conventions lists.
List schedule exceptions
GET /resources/:id/exceptions
Lists a resource’s exceptions that overlap [from, to), or all of them, by start.
- 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.exceptions.list(resourceId, query)
Path parameters
| Name | Type | Required | Description |
|---|---|---|---|
id |
string |
Yes | Resource ID, res_…. The id of a Resource. |
Query parameters
| Name | Type | Required | Description |
|---|---|---|---|
from |
string |
No | An ISO 8601 date and time. |
to |
string |
No | An ISO 8601 date and time. |
Response
200 OK, with ExceptionsList.
Errors
invalid_request(400)not_found(404)
Any operation can also answer with the codes Conventions lists.
Update a schedule exception
PATCH /resources/:id/exceptions/:eid
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.
- 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.exceptions.patch(resourceId, eid, 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. |
eid |
string |
Yes | Exception ID, exc_…. The id of a ScheduleException. |
Body
| Name | Type | Required | Description |
|---|---|---|---|
span |
object |
No | |
span. |
string |
Yes | An ISO 8601 date and time. |
span. |
string |
Yes | An ISO 8601 date and time. |
capacity |
number |
No | |
reason |
string or null |
No |
Response
200 OK, with ExceptionResponse.
Errors
invalid_request(400)payload_too_large(413)invalid_quantity(422)not_found(404)stale_version(409)
Any operation can also answer with the codes Conventions lists.
Delete a schedule exception
DELETE /resources/:id/exceptions/:eid
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.
- 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.exceptions.delete(resourceId, eid) - 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. |
eid |
string |
Yes | Exception ID, exc_…. The id of a ScheduleException. |
Response
200 OK, with ExceptionDeleteResponse.
Errors
invalid_request(400)not_found(404)
Any operation can also answer with the codes Conventions lists.
The ScheduleSaveResponse object
| Name | Type | Present | Description |
|---|---|---|---|
schedule |
Schedule |
Always | |
overCapacity |
OverCapacity |
Always |
The ScheduleResponse object
| Name | Type | Present | Description |
|---|---|---|---|
schedule |
Schedule |
Always |
The ExceptionCreateResponse object
| Name | Type | Present | Description |
|---|---|---|---|
exception |
ScheduleException |
Always | |
overCapacity |
OverCapacity |
Always | |
duplicate |
true |
When set | Set when the source key already named this request. |
The ExceptionsList object
At most MAX_EXCEPTIONS, so one answer holds them all, by start.
| Name | Type | Present | Description |
|---|---|---|---|
exceptions |
ScheduleException array |
Always |
The ExceptionResponse object
| Name | Type | Present | Description |
|---|---|---|---|
exception |
ScheduleException |
Always | |
overCapacity |
OverCapacity |
Always |
The ExceptionDeleteResponse object
| Name | Type | Present | Description |
|---|---|---|---|
overCapacity |
OverCapacity |
Always |
The Schedule object
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.
| Name | Type | Present | Description |
|---|---|---|---|
resourceId |
string |
Always | Resource ID, res_…. |
timeZone |
string |
Always | |
patterns |
WeeklyPattern array |
Always | |
version |
number |
Always | Moves with every save; send it in If-Match to save again. |
updatedAt |
string |
Always | An ISO 8601 date and time. |
The ScheduleException object
| Name | Type | Present | Description |
|---|---|---|---|
id |
string |
Always | Exception ID, exc_…. |
resourceId |
string |
Always | Resource ID, res_…. |
span |
FiniteSpan |
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. |
reason |
string |
When set | |
version |
number |
Always | Moves with every change; send it in If-Match to change it. |
createdAt |
string |
Always | An ISO 8601 date and time. |
updatedAt |
string |
Always | An ISO 8601 date and time. |
The WeeklyPattern object
A normal week, in effect from from until the next pattern starts.
| Name | Type | Present | Description |
|---|---|---|---|
from |
string |
When set | YYYY-MM-DD in the schedule’s time zone. Missing on the first pattern. |
weekly |
WeeklyWindow array |
Always |
The FiniteSpan object
Half-open, [start, end), in UTC, with an end.
| Name | Type | Present | Description |
|---|---|---|---|
start |
string |
Always | An ISO 8601 date and time. |
end |
string |
Always | An ISO 8601 date and time. |
The WeeklyWindow object
One weekly window, in the schedule’s time zone.
| Name | Type | Present | Description |
|---|---|---|---|
day |
0, 1, 2, 3, 4, 5, or 6 |
Always | |
start |
string |
Always | HH:MM. |
end |
string |
Always | HH:MM, or 24:00 for the end of the day. |
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. |