Get the current state of a machine instance.
Retrieve the state of the machine instance that was previously created by
calling POST /machines/{machineSlug}
and may have had events sent to it
by calling POST /machines/{machineSlug}/i/{instanceSlug}/events
.
The allowRead
function for the machine definition version will be called
to authorize the read and, if it fails, a 403 with code
rejected-by-machine-authorizer
will be returned.
Otherwise, the current state of the machine instance will be returned.
Obviously, the state returned may be out of date by the time it is returned because reads are non-blocking but a the returned state will always be self-consistent.
GET
/machines/{machineSlug}/i/{instanceSlug}
curl \
-X GET https://api.statebacked.dev/machines/my-machine/i/user-1234 \
-H "Authorization: Bearer $ACCESS_TOKEN"
Response examples (200)
Simple state without public context
{
"state": "idle",
"done": false,
"tags": [
"some-tag"
]
}
{
"state": {
"parent": {
"nested1": "idle"
}
},
"publicContext": {
"user": "u_1234"
},
"done": false,
"tags": [
"some-tag"
]
}
{
"values": {
"state": {
"parent": {
"nested1": "idle",
"nested2": "idle"
}
},
"publicContext": {
"connectedDocuments": [
"doc_1234",
"doc_5678"
]
},
"done": false,
"tags": [
"some-tag"
]
}
}
Response examples (200)
{
"done": false,
"tags": [
"some-tag"
],
"state": "idle"
}
Response examples (403)
{
"error": "string",
"code": "missing-scope"
}
Response examples (403)
{
"error": "string",
"code": "missing-scope"
}