Material capacity¶
Current version: 1.0.0
A material has a default quantity (aantal), see Materials (Materialen). On top of that
default you can define capacity entries: time-bounded overrides that change how
much of a material is available during a specific period. This is used, for
example, when you have fewer (or more) items available on certain days or during
certain hours.
Concepts¶
Every entry belongs to a single material and has a
begin, anendand anamount(the quantity available during that period).Entries for one material never overlap. When you create or update an entry that overlaps existing entries, the new entry always wins: existing entries are trimmed, split in two, or removed so that the new period is applied exactly. Because of this, writing an entry can change the
begin/endof neighbouring entries.An entry may not cross the daily daybreak at
04:00. In Recras a day runs from04:00until04:00the next day, so a single entry has to stay within one such day (e.g.08:00–17:00is fine,02:00–06:00is not).Entries that are part of a recurring series share the same
internal_reference. The series endpoints let you read or delete a whole series (or the tail of it) at once. Recurrence is expanded on the client: each occurrence is sent as an individual entry, and the shared reference ties them together.
Permissions¶
Reading capacity entries only requires a valid API key. Creating, updating and
deleting entries requires the editMateriaal permission.
The capacity entry object¶
{
"id": 42,
"material_id": 1,
"begin": "2027-01-01T08:00:00+01:00",
"end": "2027-01-01T12:00:00+01:00",
"amount": 2,
"internal_reference": null
}
- json int id:
ID number, may not be changed
- json int material_id:
The material this entry belongs to. Taken from the URL, not from the body.
- json string begin:
Start of the period, ISO 8601 datetime
- json string end:
End of the period, ISO 8601 datetime
- json int amount:
Quantity of the material available during this period, at least
0- json string internal_reference:
Optional label (max 50 characters) used to group the entries of a recurring series.
nullwhen the entry is not part of a series.
Read¶
- GET /api2/materialen/(int: material_id)/capacity¶
The capacity entries of a material, ordered by
beginascending.Example request:
GET /api2/materialen/1/capacity?beginAfter=2027-01-01T00:00:00&endBefore=2027-01-01T23:59:59 HTTP/1.1 Host: demo.recras.nl Accept: application/json
Example response:
HTTP/1.1 200 OK Content-Type: application/json [ { "id": 42, "material_id": 1, "begin": "2027-01-01T08:00:00+01:00", "end": "2027-01-01T12:00:00+01:00", "amount": 2, "internal_reference": null }, { "id": 43, "material_id": 1, "begin": "2027-01-01T14:00:00+01:00", "end": "2027-01-01T17:00:00+01:00", "amount": 5, "internal_reference": null } ]
- Query Parameters:
beginAfter (datetime) – Only return entries whose
beginis on or after this datetimebeginBefore (datetime) – Only return entries whose
beginis on or before this datetimeendAfter (datetime) – Only return entries whose
endis strictly after this datetimeendBefore (datetime) – Only return entries whose
endis on or before this datetime
- Status Codes:
200 OK – no error
- GET /api2/materialen/(int: material_id)/capacity/(int: id)¶
A specific capacity entry.
Example request:
GET /api2/materialen/1/capacity/42 HTTP/1.1 Host: demo.recras.nl Accept: application/json
Example response:
HTTP/1.1 200 OK Content-Type: application/json { "id": 42, "material_id": 1, "begin": "2027-01-01T08:00:00+01:00", "end": "2027-01-01T12:00:00+01:00", "amount": 2, "internal_reference": null }
- Status Codes:
200 OK – OK
404 Not Found – No capacity entry with this
idfor this material
Create¶
- POST /api2/materialen/(int: material_id)/capacity¶
Create a single capacity entry. If the new period overlaps existing entries, those entries are trimmed, split or removed so that the new entry is applied exactly (see Concepts).
Example request:
POST /api2/materialen/1/capacity HTTP/1.1 Host: demo.recras.nl Accept: application/json { "begin": "2027-01-01T08:00:00", "end": "2027-01-01T12:00:00", "amount": 2 }
Example response:
HTTP/1.1 201 Created Content-Type: application/json { "id": 42, "material_id": 1, "begin": "2027-01-01T08:00:00+01:00", "end": "2027-01-01T12:00:00+01:00", "amount": 2, "internal_reference": null }
- JSON Parameters:
begin (string) – Start of the period, ISO 8601 datetime. Required.
end (string) – End of the period, ISO 8601 datetime. Required, must be after
begin.amount (int) – Quantity available during this period. Required, at least
0.internal_reference (string) – Optional series label, max 50 characters.
- Status Codes:
201 Created – Capacity entry created
406 Not Acceptable – Error in the input, see Validation errors
403 Forbidden – User does not have the
editMateriaalpermission
Update¶
- PUT /api2/materialen/(int: material_id)/capacity/(int: id)¶
Replace the
begin,endandamountof an existing entry. As with Create, overlapping neighbouring entries are adjusted to make room.Example request:
PUT /api2/materialen/1/capacity/42 HTTP/1.1 Host: demo.recras.nl Accept: application/json { "begin": "2027-01-01T08:00:00", "end": "2027-01-01T13:00:00", "amount": 4 }
Example response:
HTTP/1.1 200 OK Content-Type: application/json { "id": 42, "material_id": 1, "begin": "2027-01-01T08:00:00+01:00", "end": "2027-01-01T13:00:00+01:00", "amount": 4, "internal_reference": null }
- JSON Parameters:
begin (string) – Start of the period, ISO 8601 datetime. Required.
end (string) – End of the period, ISO 8601 datetime. Required, must be after
begin.amount (int) – Quantity available during this period. Required, at least
0.internal_reference (string) – Optional series label, max 50 characters.
- Status Codes:
200 OK – Capacity entry updated
404 Not Found – No capacity entry with this
idfor this material406 Not Acceptable – Error in the input, see Validation errors
403 Forbidden – User does not have the
editMateriaalpermission
Delete¶
- DELETE /api2/materialen/(int: material_id)/capacity/(int: id)¶
Delete a single capacity entry. Deleting an entry does not restore any neighbouring entries that were trimmed earlier.
Example request:
DELETE /api2/materialen/1/capacity/42 HTTP/1.1 Host: demo.recras.nl
Example response:
HTTP/1.1 200 OK
- Status Codes:
200 OK – Capacity entry deleted
404 Not Found – No capacity entry with this
idfor this material403 Forbidden – User does not have the
editMateriaalpermission
Batch update¶
- POST /api2/materialen/(int: material_id)/capacity/batchupdate¶
Apply many capacity entries in one request. This is the recommended way to store a recurring series: expand the recurrence on the client and send one entry per occurrence, all sharing the same
internal_reference.The entries in the payload must not overlap each other. They may overlap existing entries of the material; those existing entries are trimmed, split or removed to make room, exactly like Create does for a single entry. At most
1000entries can be sent in a single request.Example request:
POST /api2/materialen/1/capacity/batchupdate HTTP/1.1 Host: demo.recras.nl Accept: application/json [ { "begin": "2027-01-01T08:00:00", "end": "2027-01-01T12:00:00", "amount": 2, "internal_reference": "winter-2027" }, { "begin": "2027-01-02T08:00:00", "end": "2027-01-02T12:00:00", "amount": 2, "internal_reference": "winter-2027" } ]
Example response:
HTTP/1.1 200 OK Content-Type: application/json {}
The response body is empty. Read the entries back with the Read or Series endpoints to see the resulting state.
- JSON Parameters:
begin (string) – Start of the period, ISO 8601 datetime. Required.
end (string) – End of the period, ISO 8601 datetime. Required, must be after
begin.amount (int) – Quantity available during this period. Required, at least
0.internal_reference (string) – Optional series label, max 50 characters.
- Status Codes:
200 OK – Entries applied
406 Not Acceptable – Error in the input, see Validation errors
403 Forbidden – User does not have the
editMateriaalpermission
Series¶
- GET /api2/materialen/(int: material_id)/capacity/series/(string: internal_reference)¶
All entries of a material that share the given
internal_reference, ordered bybeginascending.Example request:
GET /api2/materialen/1/capacity/series/winter-2027 HTTP/1.1 Host: demo.recras.nl Accept: application/json
Example response:
HTTP/1.1 200 OK Content-Type: application/json [ { "id": 42, "material_id": 1, "begin": "2027-01-01T08:00:00+01:00", "end": "2027-01-01T12:00:00+01:00", "amount": 2, "internal_reference": "winter-2027" }, { "id": 43, "material_id": 1, "begin": "2027-01-02T08:00:00+01:00", "end": "2027-01-02T12:00:00+01:00", "amount": 2, "internal_reference": "winter-2027" } ]
- Status Codes:
200 OK – no error
- DELETE /api2/materialen/(int: material_id)/capacity/series/(string: internal_reference)¶
Delete every entry of the series (all entries sharing this
internal_reference).Example request:
DELETE /api2/materialen/1/capacity/series/winter-2027 HTTP/1.1 Host: demo.recras.nl
Example response:
HTTP/1.1 200 OK Content-Type: application/json {}
- Status Codes:
200 OK – Series deleted
403 Forbidden – User does not have the
editMateriaalpermission
- DELETE /api2/materialen/(int: material_id)/capacity/series/(string: internal_reference)/from¶
Delete this and all following occurrences of a series, i.e. every entry of the series whose
beginis on or after the givenbeginquery parameter. Occurrences before that moment are kept. This is the “this and following events” delete of a recurring series.Example request:
DELETE /api2/materialen/1/capacity/series/winter-2027/from?begin=2027-01-02T00:00:00 HTTP/1.1 Host: demo.recras.nl
Example response:
HTTP/1.1 200 OK Content-Type: application/json {}
- Query Parameters:
begin (datetime) – Required. Only entries of the series whose
beginis on or after this datetime are deleted.
- Status Codes:
200 OK – Occurrences deleted
406 Not Acceptable – The
beginquery parameter is missing403 Forbidden – User does not have the
editMateriaalpermission
Upcoming¶
- GET /api2/materialen/capacity/upcoming¶
The ids of all materials that have at least one capacity entry ending in the future. Useful to know which materials currently use variable capacity without fetching every material’s entries.
Example request:
GET /api2/materialen/capacity/upcoming HTTP/1.1 Host: demo.recras.nl Accept: application/json
Example response:
HTTP/1.1 200 OK Content-Type: application/json { "material_ids": [1, 7, 13] }
- Status Codes:
200 OK – no error
Validation errors¶
When the input is invalid, the API responds with status 406 and a JSON array
of message objects:
[
{ "message": "\"begin\" must be before \"end\"" }
]
The following messages can occur:
Message |
Meaning |
|---|---|
|
|
|
A negative |
|
|
|
Two entries in the same Batch update payload overlap. |
|
An entry crosses the |
|
More than 1000 entries were sent in one Batch update request. |
|
The |
Malformed or missing begin/end/amount fields (wrong type, not a valid
datetime) also result in a 406 response with a mapping error message.