Update
An update endpoint is a write that changes an existing record of one collection, found by its id. It names which columns the caller may change, under any public names, and can set fixed values as well. It is the datahoster-endpoint-update.json file in an endpoint folder; its presence makes that endpoint answer a PUT that changes a record.
{
"datahoster-endpoint-update-collection": "messages",
"datahoster-endpoint-update-fields": [
{
"datahoster-endpoint-update-field-of": "handled"
}
],
"datahoster-endpoint-update-public": false,
"datahoster-endpoint-update-users": ["you"]
}
you may set handled on a message by id.Contents
The file is one JSON object; its keys are fixed names starting with datahoster-endpoint-update-. The example above, in a resolve/ endpoint, lets you set a message's handled column.
| Name | Type | Description |
|---|---|---|
datahoster-endpoint-update-collection | text | The collection whose record is changed. Required. |
datahoster-endpoint-update-fields | array | The columns the caller may change, each optionally renamed or required. Same shape as an insert field. |
datahoster-endpoint-update-values | array | Fixed values the endpoint sets on every update. Same shape as an insert value. Optional. |
datahoster-endpoint-update-public | boolean | Whether anyone may call it, with no token. Defaults to false. |
datahoster-endpoint-update-users | array | The users who may call it, each proving a token. Defaults to []. |
HTTP request
PUT the endpoint's path, at <domain>/<endpoint>, with the record's id and the changed fields, as a form or a JSON body. Only the listed fields may be sent; any others are refused. If the endpoint is not public, send the user's token as a bearer token. A request that is not allowed — no token where one is needed, a wrong token, or a user this endpoint does not list — gets the same 404 as a path with no endpoint.
PUT https://api.example.com/resolve
Content-Type: application/x-www-form-urlencoded
Authorization: Bearer k7Qw2f9xJ4mB6pR8tZ1nD3sV5hL0aYc
id=9f86d081884c7d659a2feaa0c55ad015&handled=true
id.| Status | Meaning |
|---|---|
200 | The record was changed. |
400 | The id is missing, a value fails its type or is too large for its column, or a field is not one this endpoint allows. |
404 | No update endpoint answers on this path, no record has that id, or the caller is not allowed it — a missing token, an invalid one, or a user the endpoint does not list. These are indistinguishable, so a probe cannot tell the endpoint is there. |