Give an item its picture
inventory.item.set_photo
POST/api/v1/households/{household_id}/commands/inventory.item.set_photo
- Command
- Rigel runs it
- Applies offline
Sets the item's picture to an uploaded image, or to just a crop of it (the part of a shelf photo that shows this item). Without a crop the whole image is used. A null file_id removes the picture. Errors: item_not_found, file_not_found.
Parameters#
| Field | Description |
|---|---|
household_idpathstringrequired | The household's ID. |
Idempotency-Keyheaderstringoptional | The command's ID. Reuse it when retrying the same command. |
Request body#
JSON, as application/json.
| Field | Description |
|---|---|
item_idstringrequired | The item to give a picture. |
file_idstring or nullrequired | The uploaded image. Null removes the picture and its crop. |
cropobjectoptional | Where the item is in the photo, as fractions of the image; the picture shows just that part. Leave out for the whole image. |
crop.xnumberrequired | Left edge of the item in the photo, as a fraction of the image width (0 to 1). |
crop.ynumberrequired | Top edge of the item in the photo, as a fraction of the image height (0 to 1). |
crop.widthnumberrequired | Width of the item in the photo, as a fraction of the image width (more than 0). |
crop.heightnumberrequired | Height of the item in the photo, as a fraction of the image height (more than 0). |
Response#
200 The command was applied.
| Field | Description |
|---|---|
resultobjectrequired | What the command returned, such as the IDs it created. |
versionintegerrequired | The household version after the command. |
Errors#
Every error has the same envelope: error.code, error.message, error.details, error.recovery and error.request_id.
| Status | Code | When |
|---|---|---|
400 | validation_failed | A field is missing, misspelled or out of range. details.fields lists each problem. |
401 | unauthenticated | The request has no valid session. |
404 | item_not_found |
|
404 | file_not_found |
|
404 | not_found | The household doesn't exist, or you aren't a member of it. |
409 | idempotency_key_reused | The Idempotency-Key was already used for a different command. |
Examples#
These are real. Each scenario is one of the command's test cases, run on a household when this site was built, and the response is what the API returned.
A photo with a crop
curl -X POST 'https://rigel.house/api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/inventory.item.set_photo' \
-H "Cookie: rigel_session=$RIGEL_SESSION" \
-H 'Content-Type: application/json' \
-H 'Idempotency-Key: cmd_01JC4N0000AAAAAAAAAAAAAAAA' \
-d '{
"item_id": "inv_01JC000000000000000000000A",
"file_id": "fil_01JC000000000000000000000A",
"crop": {
"x": 0.1,
"y": 0.2,
"width": 0.3,
"height": 0.4
}
}'const response = await fetch("https://rigel.house/api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/inventory.item.set_photo", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Idempotency-Key": "cmd_01JC4N0000AAAAAAAAAAAAAAAA",
Cookie: `rigel_session=${process.env.RIGEL_SESSION}`,
},
body: JSON.stringify({
item_id: "inv_01JC000000000000000000000A",
file_id: "fil_01JC000000000000000000000A",
crop: {
x: 0.1,
y: 0.2,
width: 0.3,
height: 0.4,
},
}),
});
const data = await response.json();POST /api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/inventory.item.set_photo HTTP/1.1
Host: rigel.house
Cookie: rigel_session=<your session>
Content-Type: application/json
Idempotency-Key: cmd_01JC4N0000AAAAAAAAAAAAAAAA
{
"item_id": "inv_01JC000000000000000000000A",
"file_id": "fil_01JC000000000000000000000A",
"crop": {
"x": 0.1,
"y": 0.2,
"width": 0.3,
"height": 0.4
}
}HTTP/1.1 200 OK
Content-Type: application/json
X-Request-Id: req_01K9D9S2R00VDBP2JP3SVRPHS5
{
"result": {},
"version": 1
}A photo without a crop clears an earlier crop
curl -X POST 'https://rigel.house/api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/inventory.item.set_photo' \
-H "Cookie: rigel_session=$RIGEL_SESSION" \
-H 'Content-Type: application/json' \
-H 'Idempotency-Key: cmd_01JC4N0000AAAAAAAAAAAAAAAA' \
-d '{
"item_id": "inv_01JC000000000000000000000A",
"file_id": "fil_01JC000000000000000000000A"
}'const response = await fetch("https://rigel.house/api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/inventory.item.set_photo", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Idempotency-Key": "cmd_01JC4N0000AAAAAAAAAAAAAAAA",
Cookie: `rigel_session=${process.env.RIGEL_SESSION}`,
},
body: JSON.stringify({
item_id: "inv_01JC000000000000000000000A",
file_id: "fil_01JC000000000000000000000A",
}),
});
const data = await response.json();POST /api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/inventory.item.set_photo HTTP/1.1
Host: rigel.house
Cookie: rigel_session=<your session>
Content-Type: application/json
Idempotency-Key: cmd_01JC4N0000AAAAAAAAAAAAAAAA
{
"item_id": "inv_01JC000000000000000000000A",
"file_id": "fil_01JC000000000000000000000A"
}HTTP/1.1 200 OK
Content-Type: application/json
X-Request-Id: req_01K9D9S2R0NX1B06DXRD1GGMJR
{
"result": {},
"version": 1
}A crop that fills the image to the edge
curl -X POST 'https://rigel.house/api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/inventory.item.set_photo' \
-H "Cookie: rigel_session=$RIGEL_SESSION" \
-H 'Content-Type: application/json' \
-H 'Idempotency-Key: cmd_01JC4N0000AAAAAAAAAAAAAAAA' \
-d '{
"item_id": "inv_01JC000000000000000000000A",
"file_id": "fil_01JC000000000000000000000A",
"crop": {
"x": 0.5,
"y": 0.5,
"width": 0.5,
"height": 0.5
}
}'const response = await fetch("https://rigel.house/api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/inventory.item.set_photo", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Idempotency-Key": "cmd_01JC4N0000AAAAAAAAAAAAAAAA",
Cookie: `rigel_session=${process.env.RIGEL_SESSION}`,
},
body: JSON.stringify({
item_id: "inv_01JC000000000000000000000A",
file_id: "fil_01JC000000000000000000000A",
crop: {
x: 0.5,
y: 0.5,
width: 0.5,
height: 0.5,
},
}),
});
const data = await response.json();POST /api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/inventory.item.set_photo HTTP/1.1
Host: rigel.house
Cookie: rigel_session=<your session>
Content-Type: application/json
Idempotency-Key: cmd_01JC4N0000AAAAAAAAAAAAAAAA
{
"item_id": "inv_01JC000000000000000000000A",
"file_id": "fil_01JC000000000000000000000A",
"crop": {
"x": 0.5,
"y": 0.5,
"width": 0.5,
"height": 0.5
}
}HTTP/1.1 200 OK
Content-Type: application/json
X-Request-Id: req_01K9D9S2R0DS3TYSNQY242R5SM
{
"result": {},
"version": 1
}Null clears the photo and its crop
curl -X POST 'https://rigel.house/api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/inventory.item.set_photo' \
-H "Cookie: rigel_session=$RIGEL_SESSION" \
-H 'Content-Type: application/json' \
-H 'Idempotency-Key: cmd_01JC4N0000AAAAAAAAAAAAAAAA' \
-d '{
"item_id": "inv_01JC000000000000000000000A",
"file_id": null
}'const response = await fetch("https://rigel.house/api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/inventory.item.set_photo", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Idempotency-Key": "cmd_01JC4N0000AAAAAAAAAAAAAAAA",
Cookie: `rigel_session=${process.env.RIGEL_SESSION}`,
},
body: JSON.stringify({
item_id: "inv_01JC000000000000000000000A",
file_id: null,
}),
});
const data = await response.json();POST /api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/inventory.item.set_photo HTTP/1.1
Host: rigel.house
Cookie: rigel_session=<your session>
Content-Type: application/json
Idempotency-Key: cmd_01JC4N0000AAAAAAAAAAAAAAAA
{
"item_id": "inv_01JC000000000000000000000A",
"file_id": null
}HTTP/1.1 200 OK
Content-Type: application/json
X-Request-Id: req_01K9D9S2R0PY05EV1HXE5HVXG2
{
"result": {},
"version": 1
}An unknown file
curl -X POST 'https://rigel.house/api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/inventory.item.set_photo' \
-H "Cookie: rigel_session=$RIGEL_SESSION" \
-H 'Content-Type: application/json' \
-H 'Idempotency-Key: cmd_01JC4N0000AAAAAAAAAAAAAAAA' \
-d '{
"item_id": "inv_01JC000000000000000000000A",
"file_id": "fil_01JC000000000000000000000Z"
}'const response = await fetch("https://rigel.house/api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/inventory.item.set_photo", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Idempotency-Key": "cmd_01JC4N0000AAAAAAAAAAAAAAAA",
Cookie: `rigel_session=${process.env.RIGEL_SESSION}`,
},
body: JSON.stringify({
item_id: "inv_01JC000000000000000000000A",
file_id: "fil_01JC000000000000000000000Z",
}),
});
const data = await response.json();POST /api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/inventory.item.set_photo HTTP/1.1
Host: rigel.house
Cookie: rigel_session=<your session>
Content-Type: application/json
Idempotency-Key: cmd_01JC4N0000AAAAAAAAAAAAAAAA
{
"item_id": "inv_01JC000000000000000000000A",
"file_id": "fil_01JC000000000000000000000Z"
}HTTP/1.1 404 Not Found
Content-Type: application/json
X-Request-Id: req_01K9D9S2R0W8DJAQK2CPSG44X4
{
"error": {
"code": "file_not_found",
"message": "That file isn't there any more. No changes were applied.",
"details": {
"file_id": "fil_01JC000000000000000000000Z"
},
"recovery": "Read the current state, then send a command that fits it.",
"request_id": "req_01K9D9S2R0W8DJAQK2CPSG44X4"
}
}An unknown item
curl -X POST 'https://rigel.house/api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/inventory.item.set_photo' \
-H "Cookie: rigel_session=$RIGEL_SESSION" \
-H 'Content-Type: application/json' \
-H 'Idempotency-Key: cmd_01JC4N0000AAAAAAAAAAAAAAAA' \
-d '{
"item_id": "inv_01JC000000000000000000000Z",
"file_id": "fil_01JC000000000000000000000A"
}'const response = await fetch("https://rigel.house/api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/inventory.item.set_photo", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Idempotency-Key": "cmd_01JC4N0000AAAAAAAAAAAAAAAA",
Cookie: `rigel_session=${process.env.RIGEL_SESSION}`,
},
body: JSON.stringify({
item_id: "inv_01JC000000000000000000000Z",
file_id: "fil_01JC000000000000000000000A",
}),
});
const data = await response.json();POST /api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/inventory.item.set_photo HTTP/1.1
Host: rigel.house
Cookie: rigel_session=<your session>
Content-Type: application/json
Idempotency-Key: cmd_01JC4N0000AAAAAAAAAAAAAAAA
{
"item_id": "inv_01JC000000000000000000000Z",
"file_id": "fil_01JC000000000000000000000A"
}HTTP/1.1 404 Not Found
Content-Type: application/json
X-Request-Id: req_01K9D9S2R0SBQ0EM3XVYM15AEQ
{
"error": {
"code": "item_not_found",
"message": "That item isn't in the inventory any more. No changes were applied.",
"details": {
"item_id": "inv_01JC000000000000000000000Z"
},
"recovery": "Read the current state, then send a command that fits it.",
"request_id": "req_01K9D9S2R0SBQ0EM3XVYM15AEQ"
}
}Clearing the photo of an unknown item
curl -X POST 'https://rigel.house/api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/inventory.item.set_photo' \
-H "Cookie: rigel_session=$RIGEL_SESSION" \
-H 'Content-Type: application/json' \
-H 'Idempotency-Key: cmd_01JC4N0000AAAAAAAAAAAAAAAA' \
-d '{
"item_id": "inv_01JC000000000000000000000Z",
"file_id": null
}'const response = await fetch("https://rigel.house/api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/inventory.item.set_photo", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Idempotency-Key": "cmd_01JC4N0000AAAAAAAAAAAAAAAA",
Cookie: `rigel_session=${process.env.RIGEL_SESSION}`,
},
body: JSON.stringify({
item_id: "inv_01JC000000000000000000000Z",
file_id: null,
}),
});
const data = await response.json();POST /api/v1/households/hh_01K9BKKP003AHRZ6DMV29GQY5C/commands/inventory.item.set_photo HTTP/1.1
Host: rigel.house
Cookie: rigel_session=<your session>
Content-Type: application/json
Idempotency-Key: cmd_01JC4N0000AAAAAAAAAAAAAAAA
{
"item_id": "inv_01JC000000000000000000000Z",
"file_id": null
}HTTP/1.1 404 Not Found
Content-Type: application/json
X-Request-Id: req_01K9D9S2R0WY32322G66KY87MD
{
"error": {
"code": "item_not_found",
"message": "That item isn't in the inventory any more. No changes were applied.",
"details": {
"item_id": "inv_01JC000000000000000000000Z"
},
"recovery": "Read the current state, then send a command that fits it.",
"request_id": "req_01K9D9S2R0WY32322G66KY87MD"
}
}Give an item a photo
crop picks the part of the picture that shows this item, as fractions of its width and height.
curl -X POST 'https://rigel.house/api/v1/households/hh_01M6V9CS6GGVFCY7NAS8ZTQV95/commands/inventory.item.set_photo' \
-H "Cookie: rigel_session=$RIGEL_SESSION" \
-H 'Content-Type: application/json' \
-H 'Idempotency-Key: cmd_01M6V9CSCPN1CZB6KKGZSKTZ67' \
-d '{
"item_id": "inv_01M6V9CSAPM8JH7W1W1YEBHPRS",
"file_id": "fil_01M6V9CS96RRJQEBVXVCKMMR0T",
"crop": {
"x": 0.04,
"y": 0.08,
"width": 0.2,
"height": 0.35
}
}'const response = await fetch("https://rigel.house/api/v1/households/hh_01M6V9CS6GGVFCY7NAS8ZTQV95/commands/inventory.item.set_photo", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Idempotency-Key": "cmd_01M6V9CSCPN1CZB6KKGZSKTZ67",
Cookie: `rigel_session=${process.env.RIGEL_SESSION}`,
},
body: JSON.stringify({
item_id: "inv_01M6V9CSAPM8JH7W1W1YEBHPRS",
file_id: "fil_01M6V9CS96RRJQEBVXVCKMMR0T",
crop: {
x: 0.04,
y: 0.08,
width: 0.2,
height: 0.35,
},
}),
});
const data = await response.json();POST /api/v1/households/hh_01M6V9CS6GGVFCY7NAS8ZTQV95/commands/inventory.item.set_photo HTTP/1.1
Host: rigel.house
Cookie: rigel_session=<your session>
Content-Type: application/json
Idempotency-Key: cmd_01M6V9CSCPN1CZB6KKGZSKTZ67
{
"item_id": "inv_01M6V9CSAPM8JH7W1W1YEBHPRS",
"file_id": "fil_01M6V9CS96RRJQEBVXVCKMMR0T",
"crop": {
"x": 0.04,
"y": 0.08,
"width": 0.2,
"height": 0.35
}
}HTTP/1.1 200 OK
Content-Type: application/json
X-Request-Id: req_01M6V9CSCPQY98T1EKBECNV79H
{
"result": {},
"version": 46
}For Rigel#
Rigel's tool for this command is inventory_item_set_photo. Rigel runs this on its own, then says what it did. The agent guide has the rest.