Skip to content

REST API reference

github-actions[bot] edited this page Dec 6, 2026 · 1 revision

This document describes every HTTP endpoint exposed by the HomeVault backend. A machine-readable OpenAPI 3.1 description of the same API lives next to it in openapi.yaml. Import it into Postman, Insomnia, Bruno, or Swagger UI to explore and call the API interactively.

API version: v1 · Applies to: HomeVault 3.x


Contents


Overview

Base URLs

HomeVault ships as a single container. Inside it, the Go backend listens on 127.0.0.1:59234 and Next.js listens on :5959. Only Next.js is published, and it forwards API calls to the backend through a small proxy.

You are calling from… Base URL Example
A browser, script or tool on your network (normal case) http://<host>:<port>/api/proxy http://homevault.lan:5959/api/proxy/items
Inside the container, or a dev setup with the backend exposed http://<backend-host>:<BACKEND_PORT>/api/v1 http://localhost:59234/api/v1/items

The proxy maps paths one-to-one:

Proxy path Backend path
/api/proxy/<path> /api/v1/<path>
/api/proxy/images/items/..., /api/proxy/images/containers/... /images/items/..., /images/containers/... (static files)
/api/proxy/maps/floors/... /maps/floors/... (static files)

Query strings and the request body are forwarded unchanged. The proxy accepts GET, POST, PUT and DELETE.

All examples below use the proxy base URL:

export HV=http://localhost:5959/api/proxy

Authentication & security

Login is optional. While it is off, /api/proxy is open: anyone who can reach the HTTP port can read, change, back up, restore and delete all data through it, and can create API keys. Once it is on, /api/proxy requires a session cookie from POST /auth/login, and the user's role limits what it allows. /api/external always requires an API key instead.

HomeVault is meant to run on a trusted home network. If you expose it beyond that, put it behind one of these:

  • a VPN such as WireGuard or Tailscale, or
  • an authenticating reverse proxy, such as Authelia, Authentik, Cloudflare Access, or basic auth in Nginx Proxy Manager, Caddy or Traefik.

External apps (API keys)

Integrations should use http://<host>:<port>/api/external/<path>. Every request there needs a key, created in Settings → API Keys:

curl -H "Authorization: Bearer $HV_KEY" http://localhost:5959/api/external/items
curl -H "X-API-Key: $HV_KEY"            http://localhost:5959/api/external/stats
Key scope Allowed methods
read GET, HEAD
write everything below

Paths, parameters and responses are the same as in this document. Available: health and dashboard, items, categories, containers, segments, floors, tags, search, images, documents, alerts, offline sync, and backups (run, list, download, delete). Image and floor-plan files are served from /api/external/images/… and /api/external/maps/floors/….

Never available with a key (404): login and users, change history, API key management, backup settings and connection test, copy to NAS, restore, master data and test data.

Status Meaning
401 Key missing, unknown, revoked or expired.
403 A read-only key was used for a write.

To expose HomeVault to the internet, protect the whole site with an authenticating reverse proxy and exempt only /api/external/.

No CORS headers are sent: other websites cannot read the API from a browser.

External apps fetch photos and floor plans with their key from /api/external/files/images/{filename} and /api/external/files/maps/floors/{filename}.

Conventions

Topic Convention
Content type Requests and responses are application/json, except uploads, which use multipart/form-data.
IDs Positive 64-bit integers assigned by the server.
Timestamps created_at, updated_at and similar fields are RFC 3339 strings (2026-01-31T09:15:00.123456+05:30).
Calendar dates purchase_date, expiry_date and warranty_expiry are free-form strings. The UI writes and expects YYYY-MM-DD, and expiry calculations rely on that format.
Optional fields Fields that are null or unset are omitted from responses (omitempty). Treat a missing key as null.
Empty lists List endpoints return [], never null.
Deletes Items and containers are soft-deleted: archived is set to true and they disappear from listings. Tags, floors, segments, images and documents are removed, but can be restored. Backups are hard-deleted.
Success with no body 204 No Content.
Currency Stored per item as a free-form code. The default is INR.

Versioning

The version is part of the path (/api/v1, /api/external/v1).

  • Compatible changes stay in v1: new endpoints, new optional request fields, new response fields. Clients must ignore fields they don't know.
  • Breaking changes need v2: removing or renaming an endpoint or field, changing a type or meaning, or making an optional field required.
  • When v2 ships, v1 keeps working for at least one further major release of HomeVault, and the changelog names the removal.

Rate limits

Each client address may make 50 requests per second (burst 200) and 2 uploads per second (burst 60). Set RATE_LIMIT_RPS and UPLOAD_RATE_LIMIT_RPS to change this; 0 disables a limit. The address is the last entry of X-Forwarded-For, so put HomeVault behind a reverse proxy that sets it if you rely on the limit against untrusted clients: a direct caller can forge it.

Errors

Errors return a non-2xx status and a JSON body with a single message field:

{ "message": "name is required" }
Status Meaning in HomeVault
400 Bad Request Malformed JSON, invalid ID, missing required field, or an unsupported file.
401 Unauthorized No session while login is on, or on /api/external a missing, invalid or expired API key.
403 Forbidden Path traversal attempt, a table outside the master-data allow-list, a write with a read-only API key, something the user's role does not allow, or a changing request from another site.
404 Not Found The entity or file does not exist. Some endpoints don't check; see their notes.
409 Conflict Duplicate tag, container that still has children, floor still in use, test data already present, or a sync conflict.
429 Too Many Requests Rate limit reached; retry after a moment.
500 Internal Server Error Database error. Constraint violations show up here, for example a duplicate container code or segment name.
502 Bad Gateway The proxy could not reach the backend, or from-url could not fetch the remote image.

Segment scoping

Segments keep parts of a home, such as a garage or an outhouse, out of the main ("General") inventory. A container belongs to the segment set on itself or, if it has none, the segment of its nearest ancestor. Items belong to the segment of their container. Items with no container are General.

These endpoints accept two optional query parameters that select which part of the inventory they look at:

GET /items, GET /containers, GET /stats, GET /search, GET /search/suggest

Query Scope
(neither) General only: everything that is not in any segment.
segment_id=<id> Only things whose effective segment is <id>.
include_all=true Everything: General plus every segment. Takes precedence over segment_id.

GET /recent, GET /expiring and GET /low-stock are not scoped. They always cover the whole inventory.


Health & dashboard

GET /health

Checks the database and reports free space on the data volume and backend memory.

{
  "status": "ok",
  "service": "homevault",
  "database": { "status": "ok" },
  "disk": { "status": "ok", "free_bytes": 52613349376, "total_bytes": 125830000640 },
  "memory": { "heap_bytes": 3145728, "reserved_bytes": 16777216 }
}

status is ok, degraded (less than 200 MB free, still 200) or error (the database does not answer, 503). Health checks are never rate limited.

GET /stats

Dashboard counters. Segment-scoped (see Segment scoping). total_floors and total_images always count everything.

{
  "total_items": 412,
  "total_containers": 57,
  "total_value": 183450.5,
  "expiring_soon": 3,
  "low_stock": 5,
  "total_images": 260,
  "total_floors": 2
}
Field How it is computed
total_value Sum of price × quantity over non-archived items. A missing price counts as 0.
expiring_soon Items whose expiry_date is on or before today + 30 days, including already expired ones.
low_stock Items with quantity_min set and quantity < quantity_min.

GET /recent

The 10 most recently created non-archived items, newest first. Each is an Item with container_name. Not segment-scoped.

GET /expiring

Up to 20 items with an expiry_date on or before today + 30 days, soonest first. Not segment-scoped.

GET /low-stock

Up to 20 items where quantity < quantity_min, sorted by name. Not segment-scoped.


Items

GET /items

Paginated list of non-archived items.

Query Type Default Notes
page int 1 1-based.
per_page int 20 1–100. Values outside the range fall back to 20.
q string Full-text prefix search over name, description, notes, barcode, SKU, serial number, category and sub-category. Passed to SQLite FTS5 with a trailing *, so FTS operators work. A stray " can produce a 500; use GET /search for untrusted input.
container_id int Items in this container and all of its descendants.
category string Exact match.
sub_category string Exact match.
sort enum created_at name, created_at, updated_at, quantity, price, category, location (container name).
order enum desc asc or desc.
segment_id, include_all See Segment scoping.

Response:

{
  "data": [ { "id": 42, "name": "HDMI Cable", "...": "..." } ],
  "total": 133,
  "page": 1,
  "per_page": 20,
  "total_pages": 7
}

Each item in data includes tags (always an array), container_name, container_breadcrumb, and images. images holds only the primary image.

GET /items/{id}

One item, including archived ones, with all tags, all images, and container_breadcrumb (the path from the top-level container down to the one holding the item).

404 if the ID does not exist.

POST /items

Creates an item. Returns 201 with the created Item.

Field Required Default Notes
name ✔
quantity 1 0 is treated as "unset" and becomes 1.
quantity_unit pcs Free text: pcs, kg, packs, …
currency INR
container_id null
quantity_min Enables low-stock tracking.
price Unit price.
description, notes, category, sub_category, purchase_date, expiry_date, warranty_expiry, product_url, barcode, sku, serial_number, icon
tags [{ "name": "Fragile", "color": "#ef4444" }]. Tags are matched by name and created if missing.
curl -X POST "$HV/items" -H 'Content-Type: application/json' -d '{
  "name": "AA Batteries",
  "category": "Electronics",
  "sub_category": "Batteries",
  "container_id": 12,
  "quantity": 8,
  "quantity_unit": "pcs",
  "quantity_min": 4,
  "price": 25,
  "expiry_date": "2029-06-30",
  "tags": [{ "name": "Consumable", "color": "#f59e0b" }]
}'

PUT /items/{id}

Partial update. Only keys present in the body change. To clear a nullable field, send it as null or "".

  • tags: when present, replaces the item's tag set. null or [] removes all tags.
  • container_id: null takes the item out of any container. Prefer POST /items/{id}/move if you want the move recorded in history.
  • quantity must be a number. Anything else is ignored.

Returns 200 with the merged item, without tags, images or breadcrumb. Call GET /items/{id} for the full view. 404 if the item does not exist.

curl -X PUT "$HV/items/42" -H 'Content-Type: application/json' \
  -d '{ "quantity": 3, "notes": null }'

DELETE /items/{id}

Archives (soft-deletes) the item and returns 204. The row, images and history stay in the database and are still visible through master data. An unknown ID also returns 204.

POST /items/bulk

Applies one action to up to 500 items in a single transaction: either all of them change or none does.

action Extra fields
move container_id (target, or null for no location). Recorded in movement history.
delete Archives the items.
restore Brings archived items back.
add_tags, remove_tags tags: array of names. Missing tags are created when adding.
set_category category, sub_category. An empty category clears both.
{ "ids": [4, 7, 9], "action": "move", "container_id": 12 }

Returns { "updated": 3 }. 400 for a bad request or unknown destination, 404 if any ID does not exist.

GET /items/trash

Lists up to 500 archived items, most recently archived first.

POST /items/{id}/move

Moves an item to another container and records an entry in its movement history.

Field Required Notes
to_container_id ✔ Target container ID.
quantity Recorded in history only. The whole item moves; quantities are not split.
notes Free text, shown in history.
{ "status": "moved" }

GET /items/{id}/history

Movement history, newest first.

[
  {
    "id": 7,
    "item_id": 42,
    "from_container_id": 3,
    "to_container_id": 12,
    "from_container_name": "Kitchen Drawer",
    "to_container_name": "Garage Shelf A",
    "quantity_moved": 1,
    "moved_at": "2026-03-02T18:21:44Z",
    "notes": "Moved for the camping trip"
  }
]

Categories

Categories and sub-categories are plain strings on items. There is no separate category table. categories_meta only adds an optional icon, description and sort order for display.

GET /categories

Distinct non-empty category values, sorted. Includes values used only by archived items.

["Books", "Electronics", "Kitchen"]

GET /sub-categories

Distinct non-empty sub_category values. Pass ?category=Electronics to limit the list to one category.

PUT /categories/rename

Renames a category or sub-category on every item that uses it.

{ "old_name": "Electronic", "new_name": "Electronics", "is_sub": false }

For a sub-category, set "is_sub": true and, optionally, "category": "<parent>" to restrict the rename to one parent category. Returns { "status": "renamed" }, or { "status": "no change" } when the names are equal.

POST /categories/merge

Moves every item from one category or sub-category into another.

{ "from": "Cables", "to": "Cables & Adapters", "is_sub": true, "category": "Electronics" }

Returns { "status": "merged" }.

rename and merge run the same update; the two endpoints differ only in what the UI intends. Neither touches categories_meta, so if you rename a category that has an icon or description, update its meta row yourself.

GET /categories/meta

[
  { "name": "Electronics", "icon": "Cpu", "description": "Gadgets & cables", "sort_order": 0,
    "created_at": "2026-01-02T10:00:00Z", "updated_at": "2026-01-02T10:00:00Z" }
]

PUT /categories/meta

Creates or replaces (upserts) the meta row for a category. { "name": "Electronics", "icon": "Cpu", "description": "…", "sort_order": 1 }. Every field except name is overwritten: omitting one sets it to null (or 0 for sort_order). Returns { "status": "ok" }.

DELETE /categories/meta/{name}

Deletes the meta row only; items are not touched. URL-encode the name. Returns 204.


Containers

Containers form a tree: rooms hold shelves, shelves hold boxes, and so on. The UI uses the types room, shelf and box. The API accepts any string as type, but only these three get special validation.

GET /containers

Query Default Notes
flat false true returns a flat, name-sorted list. Otherwise you get a tree of top-level containers with nested children.
parent_id Flat mode only: direct children of this container.
segment_id, include_all See Segment scoping.

Fields that differ between modes:

Field Tree mode Flat mode
children Nested array (always present) —
item_count Items directly inside Items in the container and all descendants
parent_name — ✔
floor_name, segment_name, child_count ✔ ✔

GET /containers/{id}

One container with:

  • children: direct children, each with a recursive item_count
  • items: items directly inside, without tags or images
  • breadcrumb: [{id, name, type}] from the top-level container down to this one
  • floor_name, parent_name, segment_name, item_count (recursive), child_count

404 if not found.

GET /containers/{id}/items

Items directly in the container. Add ?recursive=true to include every descendant container. The response is a plain array of Item objects, without tags or images.

POST /containers

Returns 201 with the created container.

Field Notes
type Default room.
name Required for most types. box: optional, defaults to code. shelf: name or code is required.
code Required for box. Must be unique across all containers; a duplicate returns 500. Print it on a label and scan it later.
parent_id Parent container.
floor_id Floor the container is on.
segment_id Segment. 0 or omitted means General. Children inherit it.
map_x, map_y Position of the pin on the floor plan, as a percentage (0–100) of the image width and height.
color Default #6366f1.
description, notes, icon
curl -X POST "$HV/containers" -H 'Content-Type: application/json' \
  -d '{ "type": "box", "code": "GR-BOX-07", "parent_id": 5, "notes": "Christmas lights" }'

PUT /containers/{id}

Partial update: omitted fields keep their value. Send null or "" to clear a field (0 also works for parent_id, floor_id and segment_id).

  • Clearable: description, notes, code, icon, parent_id (makes it top-level), floor_id, segment_id (back to General), map_x, map_y.
  • name, type and color cannot be empty; empty values are ignored.
  • 400 if you clear the code of a box, or set a parent_id that doesn't exist, is the container itself or is one of its descendants.
curl -X PUT "$HV/containers/9" -H 'Content-Type: application/json' \
  -d '{ "description": null, "parent_id": null }'

Returns 200 with the updated container.

DELETE /containers/{id}

Archives the container and returns 204.

  • 409 if it still has non-archived child containers. Move or delete them first.
  • Items inside are not moved. They keep pointing at the archived container and no longer show up under it in container views.

Segments

GET /segments

[
  { "id": 2, "name": "Garage", "icon": "Wrench", "color": "#f97316",
    "description": "Tools and car stuff", "created_at": "…",
    "container_count": 14, "item_count": 120 }
]

The counts include containers that inherit the segment from an ancestor.

GET /segments/{id}

Same shape as one element of the list. 404 if not found.

POST /segments

{ "name": "Garage", "icon": "Wrench", "color": "#f97316", "description": "…" }

name is required and must be unique; a duplicate returns 500. icon defaults to Warehouse and color to #6366f1. Icons are Lucide icon names. Returns 201.

PUT /segments/{id}

Partial update of name, icon, color and description. Send description: null to clear it.

DELETE /segments/{id}

Deletes the segment and moves every container assigned to it back to General. Returns 204.


Floors

GET /floors

All floors sorted by level.

[{ "id": 1, "name": "Ground Floor", "level": 0, "map_image": "maps/floors/floor_1_1771698564.png", "created_at": "…" }]

GET /floors/{id}

404 if not found.

POST /floors

{ "name": "First Floor", "level": 1 }. name is required. Returns 201.

PUT /floors/{id}

Full replace of name and level. Always send both; an omitted level is saved as 0. A blank name is rejected with 400, an unknown floor with 404.

DELETE /floors/{id}

Hard delete. Returns 204. Returns 409 with an explanatory message while any non-archived container is on the floor; move or delete those first. Archived containers are detached from the floor automatically.

{ "message": "floor is still used by 2 container(s); move them to another floor or delete them first" }

POST /floors/{id}/map

Uploads a floor-plan image. multipart/form-data with field image, at most 10 MB. The file is stored as-is, without conversion.

curl -X POST "$HV/floors/1/map" -F image=@ground-floor.png
{ "map_image": "maps/floors/floor_1_1771698564.png" }

Fetch it from /api/proxy/maps/floors/floor_1_1771698564.png.

DELETE /floors/{id}/map

Removes the floor plan and clears the pins of every container on that floor. Returns 204, or 404 for an unknown floor.

curl -X DELETE "$HV/floors/1/map"

GET /floors/{id}/containers

Non-archived containers on that floor, with item_count (direct items only).


Tags

GET /tags

[{ "id": 1, "name": "Fragile", "color": "#ef4444" }], sorted by name.

POST /tags

{ "name": "Fragile", "color": "#ef4444" }. color defaults to #6366f1. Returns 201, or 409 if the name already exists.

DELETE /tags/{id}

Deletes the tag and removes it from every item. Returns 204.

To attach tags to an item, use the tags array on POST /items or PUT /items/{id}.


Search

GET /search

Searches items and containers together. Up to 30 of each are returned.

Query Notes
q Required. An empty q returns empty arrays.
segment_id, include_all See Segment scoping. Default: General only.

How matching works:

  • Each word is prefix-matched with FTS5 ("usb"*), or substring-matched with LIKE.
  • Items: name, description, notes, barcode, SKU, serial number, category, sub-category, and the container's name.
  • Containers: name, description, code, notes, floor name, and parent name.
  • Ranking: exact name match first, then names starting with q, then everything else alphabetically.
{
  "items": [ { "id": 42, "name": "USB-C Cable", "container_name": "Desk Drawer", "...": "..." } ],
  "containers": [ { "id": 9, "name": "USB Box", "type": "box", "code": "OF-BOX-02",
                    "floor_name": "First Floor", "parent_name": "Office Shelf",
                    "item_count": 6, "child_count": 0, "...": "..." } ]
}

Barcode and QR lookups. The app's scanner calls this endpoint with the decoded text, so a container code printed as a QR code or barcode jumps straight to the container.

GET /search/suggest

Lightweight typeahead. Uses FTS prefix matching only, returns at most 6 of each kind, and returns empty arrays when q is shorter than 2 characters.

{
  "items": [ { "id": 42, "name": "USB-C Cable", "subtitle": "Desk Drawer" } ],
  "containers": [ { "id": 9, "name": "USB Box", "subtitle": "box" } ]
}

For items, subtitle is the container name. For containers, it is the container type.


Images

Images belong to an item or a container. The entity_type in API paths is singular (item or container). The storage folder on disk is plural (items/, containers/).

POST /images/{entity_type}/{entity_id}

multipart/form-data with field image.

Rule Value
Max size 20 MB
Accepted formats JPEG, PNG, WebP, GIF (by Content-Type) and HEIC/HEIF (recognised by content, so any Content-Type works)
HEIC Converted on the server with libheif (included in the Docker image). Without it, HEIC uploads return 400.
Processing EXIF auto-rotation; resized so the long side is at most 800 px; encoded as WebP q80 (or JPEG when IMAGE_FORMAT=jpeg)
Thumbnails 150, 300 and 600 px versions are generated in the background at q70
Primary The first image of an entity becomes its primary image
curl -X POST "$HV/images/item/42" -F "image=@photo.jpg;type=image/jpeg"

Returns 201:

{ "id": 77, "entity_type": "item", "entity_id": 42,
  "filename": "items/42/5b1c…e3.webp", "original_name": "photo.jpg",
  "is_primary": true, "created_at": "0001-01-01T00:00:00Z" }

created_at in this response is a placeholder. The stored value is correct and shows up in later reads.

POST /images/{entity_type}/{entity_id}/from-url

Downloads an image from the web and processes it the same way as an upload.

{ "url": "https://example.com/product.jpg" }
  • Only http and https URLs are accepted.
  • SSRF protection: hosts that resolve to private, loopback, link-local or multicast addresses are refused, so LAN URLs won't work.
  • 15 s timeout, 20 MB limit. Network failures and remote errors return 502; data that isn't an image returns 400.
  • The source URL is stored in source_url.

GET /images/{entity_type}/{entity_id}

All images of an entity, primary first, then oldest first.

DELETE /images/{id}

Removes the image, setting its files aside so it can be restored, and returns 204. If the deleted image was primary, the oldest remaining image becomes primary.

Displaying images

Use the filename from any image object:

GET /api/proxy/images/{filename}              → full image (800 px)
GET /api/proxy/images/{filename}?size=300     → thumbnail (150 | 300 | 600)

If a thumbnail is missing, for example because generation hasn't finished, the full image is served instead. Responses carry long-lived Cache-Control headers.


Backups

A backup produces two kinds of ZIP files:

Kind File name Contents
data homevault-data-YYYYMMDD-HHMMSS.zip homevault.db (a consistent VACUUM INTO snapshot) and data.json (a readable export of items, containers, floors, tags, item_tags, images and item_movements)
images homevault-images-YYYYMMDD-HHMMSS.zip images/…, the full image tree
full homevault-backup-YYYYMMDD-HHMMSS.zip Legacy single-file backup from older versions. It can still be listed and restored.

Each kind is only written when its contents changed since the last backup of that kind. This keeps disk wear low on Raspberry Pi and SSD setups; see SSD_OPTIMIZATION.md. Retention keeps the newest max_backups files per kind.

Backups are written to BACKUP_PATH (default /homevault/backups). If that directory isn't writable, the backend falls back to /data/backups inside the container, which is not persisted across container re-creation.

POST /backups/run

Creates a backup now. An artifact whose contents haven't changed is skipped. Add ?force=true to write both regardless.

{ "data_file": "homevault-data-20260304-020000.zip",
  "images_file": "homevault-images-20260304-020000.zip" }
{ "skipped": ["data", "images"] }

After the backup, the new files are copied to the network target in the background when network_path is set, and retention is applied.

GET /backups

[
  { "filename": "homevault-data-20260304-020000.zip", "size": 48213,
    "created_at": "2026-03-04T02:00:01+05:30", "kind": "data" }
]

Newest first. Covers both the configured directory and the in-container fallback directory.

GET /backups/download/{filename}

Streams the ZIP. Names that are not HomeVault backup files are rejected with 400.

DELETE /backups/{filename}

{ "status": "deleted" }, or 404.

POST /backups/{filename}/copy-to-nas

Copies one backup to the configured network target and waits for the copy to finish. { "status": "copied", "destination": "<network_path>" }. Returns 400 if no network_path is configured.

POST /backups/restore

multipart/form-data with one or more files in field backup, up to 512 MB in total. Send a data ZIP, an images ZIP, both, or a legacy full ZIP.

curl -X POST "$HV/backups/restore" \
  -F backup=@homevault-data-20260304-020000.zip \
  -F backup=@homevault-images-20260304-020000.zip
{ "status": "restored", "database_restored": true, "images_restored": 212,
  "message": "Backup restored. Please restart the server." }

Restart the container after restoring a database (docker restart homevault). The database file is replaced on disk, but the running process keeps its open connection until restart.

Image archives larger than 512 MB are better restored by unzipping them into the host's data/images/ directory directly.

GET /backups/settings

{
  "schedule_enabled": true,
  "backup_mode": "onchange",
  "schedule_interval": "daily",
  "schedule_time": "02:00",
  "network_path": "/backups/homevault",
  "nfs_username": "homevault",
  "nfs_password_set": true,
  "external_ip": "192.168.1.20",
  "mount_type": "smb",
  "max_backups": 10,
  "copy_to_nas_on_schedule": true,
  "last_backup_at": "2026-03-04T02:00:01+05:30",
  "last_images_backup_at": "2026-02-28T02:00:03+05:30",
  "last_schedule_check_at": "2026-03-04T02:00:00+05:30",
  "last_data_hash": "…",
  "last_images_hash": "…"
}

The NAS password is write-only: it is never returned. nfs_password_set tells you whether one is saved. It is encrypted in the database and removed from the database copy inside backups; a restore keeps the one saved on this server.

PUT /backups/settings

Partial update: omitted keys keep their value.

Field Values Notes
schedule_enabled bool Master switch for automatic backups.
backup_mode scheduled | onchange scheduled writes on every due run. onchange checks once per due run and writes only if something changed. Invalid values become scheduled.
schedule_interval hourly | daily | weekly | monthly Invalid values become daily.
schedule_time HH:MM Server local time. For hourly, only the minutes are used. Invalid values behave as 02:00.
mount_type local | nfs | smb local means network_path is a directory the container can already see.
network_path string local: an absolute path inside an allowed directory (see Security). nfs: the export path on the server. smb: the share name or path.
external_ip string NAS IP or hostname. Required for nfs and smb.
nfs_username string SMB user. Leave empty for guest access. (Named this way for compatibility.)
nfs_password string Write-only. Omitted or empty keeps the saved one, unless external_ip changes, which discards it.
clear_nfs_password bool true erases the saved password.
max_backups 1–100 Retention per kind. Values below 1 become 5; values above 100 become 100.
copy_to_nas_on_schedule bool Also copy scheduled backups to the network target.

The scheduler checks every 60 seconds whether a run is due.

S3 destination

Web app only; API keys cannot reach these.

Endpoint Purpose
GET /backups/s3 Settings and sync status: last_attempt_at, last_success_at, last_error, syncing. The secret is reported only as secret_key_set.
PUT /backups/s3 Saves enabled, endpoint, region, bucket, prefix, access_key, secret_key. Send all fields. An empty secret_key keeps the saved one if the endpoint is unchanged; clear_secret_key: true removes it. Starts a sync when enabled.
POST /backups/s3/test Takes the same body and checks listing, writing and deleting without saving. 502 with the reason on failure.
POST /backups/s3/sync Starts an upload in the background and returns 202.
{ "enabled": true, "endpoint": "http://nas:9000", "region": "", "bucket": "backups",
  "prefix": "homevault", "access_key": "…", "secret_key": "…" }

POST /backups/test-connection

Runs the network target through the same steps a real copy uses, without saving anything:

{ "external_ip": "192.168.1.20", "network_path": "backups/homevault",
  "mount_type": "smb", "nfs_username": "homevault", "nfs_password": "secret" }
{
  "ip_status": "success",       "ip_message": "192.168.1.20 is reachable.",
  "path_status": "success",     "path_message": "SMB share mounted successfully: //192.168.1.20/backups/homevault",
  "transfer_status": "success", "transfer_message": "Write & read-back verified (49 bytes). Backups can be stored here."
}

If nfs_password is empty and external_ip and nfs_username match the saved settings, the saved password is used.

Each *_status is success, warning, error or none. The endpoint always returns 200; check the statuses. Mounting NFS or SMB requires the container privileges described in the README.


Offline sync

These endpoints back the installed PWA's offline mode. The browser keeps a local SQLite copy of the inventory and queues changes made while offline. Most integrations should use the regular endpoints instead.

GET /sync/bootstrap

A full snapshot of non-archived items and containers, plus all floors, segments and tags, with sync metadata:

{ "items": [ … ], "containers": [ … ], "floors": [ … ], "segments": [ … ], "tags": [ … ],
  "synced_at": 1772611200000 }

POST /sync

Applies a batch of offline operations using last-writer-wins on client_updated_at.

{
  "client_id": "c7a4e1b2-phone",
  "operations": [
    {
      "op_id": "0f6c1d2e-…",
      "entity_type": "item",
      "entity_id": 0,
      "operation": "CREATE",
      "payload": { "name": "Torch", "container_id": 12, "quantity": 1 },
      "client_updated_at": 1772611200000
    }
  ]
}
Rule Detail
client_id 1–64 characters, [A-Za-z0-9_-].
Batch size At most 500 operations.
op_id 1–128 characters, unique per operation. Replaying an already-applied op_id is acknowledged without being re-applied.
entity_type item, container, floor, segment, tag.
operation CREATE (entity_id = 0), UPDATE, DELETE.
payload The full entity (same field names as the REST API). UPDATE replaces every column.
UPDATE Applied only if client_updated_at is strictly newer than the stored value.
DELETE A hard delete, applied only if the stored value is not newer.
{
  "applied": ["0f6c1d2e-…"],
  "rejected": [{ "op_id": "…", "reason": "conflict: server has a newer or equal version" }],
  "created": [{ "op_id": "0f6c1d2e-…", "entity_id": 913 }],
  "server_updates": null
}

Changes made through the regular REST endpoints don't update client_updated_at, so a later offline edit of the same row always wins.


Audits and missing records

Items and containers carry missing_since while they cannot be found. They keep their recorded location, and moving one by any route clears the flag. This is separate from the change history under /audit.

Endpoint Purpose
GET /stocktake/lookup?code= Items whose barcode, SKU or serial number equals the code (case ignored).
GET /stocktake/missing {items, containers} currently marked missing.
POST /stocktake/mark {status, item_ids, container_ids, move_to}. status is missing or found. With found, move_to is the container they turned up in. Up to 500 of each list in total, changed together or not at all. Rooms cannot be moved.

Documents and alerts

Method and path Purpose
GET /items/{id}/attachments The item's documents: id, item_id, kind, original_name, mime_type, size, created_at.
POST /items/{id}/attachments multipart/form-data with file and optional kind (warranty, receipt, manual, other). PDF or picture, checked by content; up to 20 MB, 20 per item. 201, or 415 for other content.
GET /attachments/{id}/file Downloads the document (Content-Disposition: attachment).
DELETE /attachments/{id} Removes it; it can be restored. 204.
GET /alerts?days=30 Warranties and expiry dates ending within days (1–365), or ended in the last 30 days, soonest first: item_id, name, type (warranty or expiry), date, days_left, container_name.

Login and users

Web app only. Passwords are 8 to 72 bytes. A session is the hv_session cookie, valid for 30 days.

Method and path Who Body and result
GET /auth/status anyone {enabled, authenticated, user_id, username, role}. With login off, authenticated is true and role is admin.
POST /auth/setup anyone, while login is off {username, password}. Creates the first admin and signs in.
POST /auth/login anyone {username, password}. 401 if wrong, 429 after repeated failures.
POST /auth/logout signed in Ends the session.
PUT /auth/credentials signed in {username, password, current_password} for your own account; your other sessions end.
POST /auth/disable admin {password}. Removes every account and turns login off.
GET /users admin [{id, username, role, created_at}].
POST /users admin {username, password, role} with role admin, editor or viewer.
PUT /users/{id} admin Any of {username, role, password}. A new password signs that user out; your own is changed through /auth/credentials.
DELETE /users/{id} admin Not yourself. 204.

There is always at least one admin (409 otherwise). What each role may do is listed in the security model.


History and recovery

Web app only.

Method and path Purpose
GET /audit?table=&row_id=&page=&per_page= Changes, newest first: at, actor, table, row_id, name, action (insert, update, delete, archive, unarchive) and changes (field, from, to). With table=items or containers and a row_id, includes its photos (and an item's tags and documents). Only admins see users and api_keys.
GET /trash Deleted containers, floors, segments, tags, photos, documents and category details: kind, id, name, deleted_at, deleted_by.
POST /trash/restore {kind, id} as listed. 409 if it can no longer be put back.

Deleted items are listed by GET /items/trash and restored with POST /items/bulk.


Master data (raw table access)

Power-user endpoints behind Settings → Master Data. They read and write database rows directly, without validation, so use them with care.

Allowed tables: floors, containers, items, tags, item_tags, images, item_movements, segments. Any other table returns 403.

GET /db/tables

["containers", "floors", "images", "item_movements", "item_tags", "items", "segments", "tags"]

GET /db/tables/{name}

The column schema (from PRAGMA table_info) and up to the first 1000 rows:

{
  "columns": [ { "cid": 0, "name": "id", "type": "INTEGER", "notnull": false, "dflt_value": null, "pk": 1 } ],
  "rows": [ { "id": 1, "name": "Ground Floor", "level": 0 } ]
}

Archived items and containers are included, which makes this the way to find and un-archive them.

PUT /db/tables/{name}/{id}

Sets the given columns on the row with that id:

# Un-archive item 42
curl -X PUT "$HV/db/tables/items/42" -H 'Content-Type: application/json' -d '{ "archived": 0 }'

Column names must match ^[A-Za-z_][A-Za-z0-9_]*$. id can't be changed. item_tags has no id column, so it can't be edited here. Returns { "status": "success" }.


API keys

Management endpoints, used by Settings → API Keys. They are only on /api/proxy, never on /api/external.

GET /api-keys

[ { "id": 1, "name": "Home Assistant", "prefix": "hv_3fQ9kLm", "scope": "read",
    "created_at": "2026-12-05T08:00:00Z", "expires_at": "2027-03-05T08:00:00Z",
    "last_used_at": "2026-12-05T09:12:00Z" } ]

POST /api-keys

Field Notes
name Required, up to 100 characters.
scope read (default) or write.
expires_in_days 0 (default) never expires; up to 3650.

Returns 201 with the same fields plus key. The key is shown only once; HomeVault stores just a SHA-256 hash.

DELETE /api-keys/{id}

Revokes the key immediately. 204, or 404.

Keys are part of the database. Restoring an older backup brings back the keys that existed then, including ones revoked since.


Test data

POST /seed-data

Adds a demo dataset: 2 floors, up to 3 segments, 5 rooms, shelves, boxes and 100 items. Every record is marked with __SEED__ so it can be removed cleanly. Returns 409 if demo data already exists.

{ "status": "seeded", "floors": 2, "segments": 3, "rooms": 5, "shelves": 10, "boxes": 20, "items": 100 }

DELETE /seed-data

Removes all marked demo records: items, boxes, shelves, rooms, segments and floors. Your own data is not touched, but containers of yours that sit in a demo segment move back to General. { "status": "wiped" }.

GET /seed-data/status

{ "seeded": true, "items": 100, "containers": 35 }


Static files

Served by the backend outside /api/v1, and reachable through the proxy:

Proxy URL Backend URL Content
/api/proxy/images/items/{id}/{file} /images/items/{id}/{file} Item images (?size=150|300|600 for thumbnails)
/api/proxy/images/containers/{id}/{file} /images/containers/{id}/{file} Container images
/api/proxy/maps/floors/{file} /maps/floors/{file} Floor-plan images

Paths that escape the data directory are rejected with 403, as are deleted files and attached documents. With login on, these URLs need a session.


Data model reference

Item

Field Type Notes
id int
name string Required.
description string?
container_id int?
quantity number Default 1. Fractions are allowed (e.g. 1.5 kg).
quantity_unit string Default pcs.
quantity_min number? Low-stock threshold.
price number? Unit price.
currency string Default INR.
purchase_date, expiry_date, warranty_expiry string? YYYY-MM-DD.
product_url string?
barcode, sku, serial_number string? All searchable.
category, sub_category string?
notes string?
icon string? Icon name (Lucide or Iconify) shown when there is no photo.
archived bool
created_at, updated_at timestamp
container_name string? Read-only.
container_breadcrumb Breadcrumb[]? Read-only.
tags Tag[]?
images Image[]? Read-only; managed through the image endpoints.

Container

Field Type Notes
id int
name string
type string room | shelf | box (any string is accepted).
description, notes, icon string?
parent_id int?
floor_id int?
segment_id int? The segment set on this container. It may also inherit one from an ancestor.
code string? Unique. Used for labels, QR codes and scanning.
map_x, map_y number? Floor-plan pin position, percent (0–100) of image width / height.
color string Hex color.
archived bool
created_at, updated_at timestamp
item_count, child_count int Computed. See each endpoint for whether the count is recursive.
floor_name, parent_name, segment_name string? Computed.
children Container[]? Tree view and detail view.
items Item[]? Detail view.
breadcrumb Breadcrumb[]? Detail view.

Other types

Type Fields
Breadcrumb id, name, type
Tag id, name (unique), color
Floor id, name, level, map_image?, created_at
Segment id, name (unique), icon, color, description?, created_at, container_count, item_count
Image id, entity_type (item|container), entity_id, filename, original_name?, source_url?, is_primary, created_at
ItemMovement id, item_id, from_container_id?, to_container_id?, from_container_name?, to_container_name?, quantity_moved?, moved_at, notes?
CategoryMeta name, icon?, description?, sort_order, created_at, updated_at

Updates

Admins only, and not available to API keys.

GET /updates

The result of the last check for a newer release. It makes no request.

{
  "enabled": true,
  "locked": false,
  "supported": true,
  "current_version": "1.0.0",
  "latest_version": "1.1.0",
  "update_available": true,
  "release_url": "https://github.com/jnanadarshan/homevault/releases/tag/v1.1.0",
  "published_at": "2026-12-01T10:00:00Z",
  "checked_at": "2026-12-05T10:00:00Z"
}

locked is true when UPDATE_CHECK=false. supported is false for builds without a release version. error is present when the last check failed.

POST /updates/check

Checks now and returns the same object. Within a minute of the previous check it returns that result. 409 while checks are off.

PUT /updates

{"enabled": false} turns checks off; true turns them on and checks at once. 409 when UPDATE_CHECK=false.


Recipes

Export every item as JSON (jq required):

page=1; : > items.jsonl
while :; do
  r=$(curl -s "$HV/items?include_all=true&per_page=100&page=$page")
  echo "$r" | jq -c '.data[]' >> items.jsonl
  [ "$page" -ge "$(echo "$r" | jq .total_pages)" ] && break
  page=$((page+1))
done

Where is it? Look up an item and print its location path:

curl -s "$HV/search?q=drill&include_all=true" \
  | jq -r '.items[] | "\(.name) → \(.container_name // "unassigned")"'

Nightly off-box copy (cron on another machine):

curl -s -X POST "$HV/backups/run"
f=$(curl -s "$HV/backups" | jq -r '[.[] | select(.kind=="data")][0].filename')
curl -s -o "/srv/backups/$f" "$HV/backups/download/$f"

Home Assistant / uptime monitoring: poll GET /api/proxy/health and expect 200 with "status": "ok".

Clone this wiki locally