Set Item Image
POST /items/{id}/image
Upload an image and make it the item's image
Scope items:write; role permission inventory.edit. Replaces any previous image. Thumbnails are generated.
Request
POST https://example.com/api/index.php/v1/nextinventory/items/{id}/image
Parameters
| Name | Type | In | Required | Description |
|---|---|---|---|---|
id |
integer |
path |
Yes | (min 1) |
Idempotency-Key |
string |
header |
No | Optional. Any unique string (1 to 191 printable ASCII characters, no spaces; a UUID is ideal). The request runs once: a retry with the same key gets the first response back, with the header Idempotent-Replayed: true, instead of running again. Keys are kept for 24 hours per token. 409 IDEMPOTENCY_IN_PROGRESS while the first request is still running; 422 IDEMPOTENCY_KEY_REUSED if the key comes with a different request. A 5xx answer is not kept, so it can be retried with the same key. (min length 1, max length 191, pattern ^[\x21-\x7E]+$) |
Request body
Content type: multipart/form-data
| Field | Type | Required | Description |
|---|---|---|---|
image |
string |
Yes | jpg, png, gif or webp, as allowed in Settings. (binary) |
{
"image": "string"
}
Responses
200 — The stored image.
{
"data": {
"image": "string",
"thumb_small": "string",
"thumb_medium": "string"
}
}
| Field | Type | Meaning |
|---|---|---|
data.image |
string |
Site-relative path of the original. |
data.thumb_small |
string|null |
|
data.thumb_medium |
string|null |
Errors
| Status | Code | When |
|---|---|---|
4 |
A refusal. Common codes: MISSING_TOKEN / INVALID_TOKEN (401); API_DISABLED, ACCOUNT_UNUSABLE, ACCESS_DENIED, TASK_NOT_ALLOWED, MISSING_SCOPE, APP_DISABLED, DEMO_LOCKED, FORBIDDEN (403); NOT_FOUND (404); BAD_REQUEST / INVALID_JSON / INVALID_IDEMPOTENCY_KEY (400, validation and stock rules, with the reason in title); IDEMPOTENCY_IN_PROGRESS (409); PRECONDITION_FAILED (412, the record changed since the If-Match ETag was read); IDEMPOTENCY_KEY_REUSED (422); RATE_LIMITED / TOO_MANY_FAILED_LOGINS (429, with a Retry-After header in seconds); SERVER_ERROR (500). |
Examples
curl
curl -s -X POST "https://example.com/api/index.php/v1/nextinventory/items/1/image" \
-H "Authorization: Bearer $API_TOKEN" \
-H "Content-Type: multipart/form-data" \
-d '{"image":"string"}'