API pentru widget-uri
Înregistrează, actualizează, listează și șterge widget-uri prin REST. Widget-urile sunt alimentate prin push: fiecare PATCH trimite un push mic care reîmprospătează widgetul pe dispozitivele iPhone sau Android ale utilizatorului.
Widget endpoints require an integration key (hlk_) with a widgets level: read to list and get widgets, write to also create, update and delete them. It is none on new keys by default — set it per key in the iOS app's integration-keys screen (see Authentication). Each user can have a maximum of 50 widgets; attempting to create more returns 429 with code: "widget.limit_exceeded".
Create Widget
/widgetsRegister a widget by slug. Idempotent — re-POSTing the same slug refreshes name / content / push_throttle in place and still returns 201.
Request Body
| Field | Type | Required | Description | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
slug | string | Yes | URL-safe identifier (alphanumeric, hyphens, underscores; first char alphanumeric; max 128 chars). Unique per user. The widget slug namespace is independent of activity slugs. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
name | string | Yes | Human-readable name shown in the iOS widget picker. Max 256 chars. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
content | object | Yes | Initial content snapshot. Must include content.template. Other fields depend on the template (see Content). | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
push_throttle | integer | No | Minimum seconds between APNs pushes for this widget (1 – 3600). Overrides the server's default coalesce window when you know updates will be bursty. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Vine în versiunea 1.17.0 a aplicației | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
target | object | No | Organization keys only: narrows which members get the widget. See Organization widgets. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
curl -X POST https://api.pushward.app/widgets \
-H "Authorization: Bearer hlk_YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"slug": "cpu-load",
"name": "CPU Load",
"content": {
"template": "progress",
"value": 0.42,
"label": "load avg",
"icon": "cpu",
"accent_color": "cyan"
}
}'Response (always 201 Created):
{
"slug": "cpu-load",
"name": "CPU Load",
"content": {
"template": "progress",
"value": 0.42,
"label": "load avg",
"icon": "cpu",
"accent_color": "cyan"
},
"created_at": "2026-05-10T12:00:00Z",
"updated_at": "2026-05-10T12:00:00Z"
}The X-Resource-Action response header (created / updated) says which happened — the same convention as POST /activities.
List Widgets
/widgetsList every widget owned by the calling user.
curl https://api.pushward.app/widgets \
-H "Authorization: Bearer hlk_YOUR_TOKEN"Response (200):
{
"items": [
{
"slug": "cpu-load",
"name": "CPU Load",
"content": { "template": "progress", "value": 0.42, "label": "load avg", "icon": "cpu", "accent_color": "cyan" },
"created_at": "2026-05-10T12:00:00Z",
"updated_at": "2026-05-10T12:00:00Z"
}
]
}Get Widget
/widgets/{slug}Fetch a widget by slug. The iOS extension calls this from TimelineProvider.getTimeline whenever it needs a freshness pull.
curl https://api.pushward.app/widgets/cpu-load \
-H "Authorization: Bearer hlk_YOUR_TOKEN"Update Widget
/widgets/{slug}RFC 7396 JSON merge patch. Absent fields preserve, explicit null clears, present values overwrite. Triggers a thin push so the iOS extension reloads.
Semantics — Content-Type rules included — follow the activities merge-patch contract. Widget-specific: the template lives inside content, so change it via content.template and include any newly-required fields for the new template in the same patch (invalid combinations return 422).
curl -X PATCH https://api.pushward.app/widgets/cpu-load \
-H "Authorization: Bearer hlk_YOUR_TOKEN" \
-H "Content-Type: application/merge-patch+json" \
-d '{
"content": {
"value": 0.78,
"accent_color": "orange"
}
}'curl -X PATCH https://api.pushward.app/widgets/cpu-load \
-H "Authorization: Bearer hlk_YOUR_TOKEN" \
-H "Content-Type: application/merge-patch+json" \
-d '{"content": {"subtitle": null}}'Delete Widget
/widgets/{slug}Remove a widget. iOS instances configured to this slug become inert at the next timeline refresh.
curl -X DELETE https://api.pushward.app/widgets/cpu-load \
-H "Authorization: Bearer hlk_YOUR_TOKEN"Response: 204 No Content
Content
Per-template required fields are listed in the overview; everything else on content is optional:
| Field | Type | Description | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
template | string | Required. One of value, progress, status, gauge, stat_list, trend, countdown, battery, schedule, flow, each documented on its own page under Widgets. Determines which other fields are required for this widget. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
template | string | Required. One of value, progress, status, gauge, stat_list, trend, countdown, battery, schedule, flow, heatmap, each documented on its own page under Widgets. Determines which other fields are required for this widget. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
cells | array | Required for heatmap. 7 to 154 daily values, oldest first, each a finite number or null for a day without data. Only the heatmap draws it, but the server bounds it on every template, so a cells array shorter than 7 or longer than 154 is a 422 on any widget. Shading, layout, and a full example: Heatmap. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
value | float | Primary value. Required for progress (0.0–1.0) and gauge (must fall within min_value/max_value). Must be finite. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
min_value | float | Required for gauge. Must be strictly less than max_value. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
max_value | float | Required for gauge. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
unit | string | Unit label rendered next to the value (e.g. %, °C, rpm). Max 32 chars. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
label | string | Short label rendered above or beside the value. Max 256 chars. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
subtitle | string | Secondary text shown when the widget family has room (medium / large). Max 256 chars. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
icon | string | SF Symbol name, or an MDI icon prefixed with mdi:. Max 128 chars. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
severity | string | One of info, warning, critical, success. Drives the chip colour on the status template and tints the accent on other templates when accent_color is unset. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
accent_color | string | Named colour (see Colors) or hex string. Falls back to a per-template default. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
background_color | string | Optional override for the widget background. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
text_color | string | Optional override for primary text colour. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
stat_rows | array | Required for stat_list. 1 – 6 rows. Each row is { label (≤32), value (≤32), unit? (≤16) }. value and progress render the first 3 as supporting rows on the large family; the remaining templates ignore them. Row shape, string formatting, and a full example: Stat list. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
trend | string | Optional up / down / flat annotation. Renders as an inline arrow on the rectangular (medium) value family. The server also accepts it on gauge, but the current iOS widget doesn't render the arrow there; progress, status, and stat_list ignore it. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
device_sort | object[] | Up to 2 { field, direction } keys applied to devices before they are stored, so the prefix each family renders holds the devices that matter. field is level or name, direction is asc (the default) or desc. Omit to keep the order you sent. Applies to battery; the other templates ignore it. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
tap_action | object | Whole-widget tap target — mapped to SwiftUI's widgetURL, and therefore the only slot that applies to the accessory families (accessoryCircular, accessoryInline), which have no room for inline controls. When set, overrides the default "open the PushWard app to the widget detail" behaviour. See Tap actions. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
url_action | object | Primary inline button rendered on system widget families (small/medium/large). Same shape as tap_action; the optional title and icon become the button label. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
secondary_url_action | object | Secondary button shown next to url_action on medium and large families. Ignored on small. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Vine în versiunea 1.6 a aplicației | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
subtitle_timer | object | Any template. { date (RFC 3339), style? } — renders the subtitle as a self-updating timer (style: "timer", the default, ticks like 01:23:45; "relative" renders coarse units like 2 min). A past date counts up, a future date counts down. subtitle stays the static fallback for clients that don't render timers. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
stat_rows[].timer | object | Same shape, applied to one stat_list row: the row's trailing text becomes a ticking timer. The row's value is still required and remains the static fallback. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Vine în versiunea 1.30.0 a aplicației | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
style | string | The look the widget is drawn in on every size: standard, bold, classic, on any template. Omit it to let the person who placed the widget pick. See Styles. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
style_by_size | object | The look per size, ahead of style on the sizes it names: keys from small, medium, large, lock_screen (Sizes), values as style. Any template. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
density | string | stat_list only. The Row Density on every size: auto, compact, comfortable. Omit it to let the app user pick. See Styles. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
density_by_size | object | stat_list only. The Row Density per size, ahead of density: the same keys as style_by_size, values as density. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Tap actions
Widget tap actions use the same Action object,
dispatch modes, and limits — and the same iOS dispatcher — as Live Activity tap actions and notification actions, including the best-effort
caveat on silent webhooks. The three slots — tap_action, url_action, secondary_url_action — are described in the Content table above.
Differences from the Live Activity contract on the widget surface:
- An
http(s)action fires silently by default —foregrounddefaults tofalseand no HTTP shape (method/headers/body) is needed for silent dispatch. Setforeground: trueto open the URL in Safari instead. method,headers, andbodyare rejected on custom-scheme URLs, not silently ignored.Content-Type: application/jsonis set automatically when abodyis present and noContent-Typeheader was supplied.- The widget extension's URLSession budget is ~30 seconds — design webhooks to return promptly.
- Besides third-party schemes (
homeassistant://,shortcuts://), PushWard's ownpushward://deep links work as custom-scheme targets.
curl -X PATCH https://api.pushward.app/widgets/blinds \
-H "Authorization: Bearer hlk_YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"content": {
"label": "Living Room",
"icon": "blinds.horizontal.closed",
"url_action": {
"title": "Open",
"icon": "arrow.up.to.line",
"url": "https://homeassistant.example.com/api/services/cover/open_cover",
"method": "POST",
"headers": { "Authorization": "Bearer HA_LONG_LIVED_TOKEN" },
"body": "{\"entity_id\":\"cover.blinds_living_room\"}"
},
"secondary_url_action": {
"title": "Close",
"icon": "arrow.down.to.line",
"url": "https://homeassistant.example.com/api/services/cover/close_cover",
"method": "POST",
"headers": { "Authorization": "Bearer HA_LONG_LIVED_TOKEN" },
"body": "{\"entity_id\":\"cover.blinds_living_room\"}"
},
"tap_action": {
"url": "homeassistant://navigate/lovelace/blinds"
}
}
}'Această secțiune descrie o funcție dintr-o actualizare a aplicației aflată în așteptarea verificării App Store. Se deblochează automat aici imediat ce actualizarea devine disponibilă.
Styles (style, style_by_size, density)
Every template draws in Standard (the default), Bold or Classic, the design widgets had before the styles
without the colored strip along the top. What they look like: Styles in the overview, or pick
one per size on the playground. A stat_list also takes a Row Density.
| Field | Values |
|---|---|
style | standard, bold, classic |
style_by_size | An object from size to a style value |
density (stat_list) | auto, compact, comfortable |
density_by_size (stat_list) | An object from size to a density value |
Sizes
| Key | iPhone and iPad | Android |
|---|---|---|
small | The small Home Screen widget (systemSmall) | The 2x2 widget |
medium | The medium Home Screen widget (systemMedium) | The 4x2 widget |
large | The large Home Screen widget (systemLarge) | The 4x4 widget |
lock_screen | Every Lock Screen widget: rectangular, circular and inline | Not used: the app has no Lock Screen widgets |
Which value a size draws
For each size it draws, the app takes style_by_size for that size, else style, else the look
the person who placed the widget picked in the app for that size, else their pick for every size, else Standard.
Row Density resolves the same way through density_by_size and density, else Auto.
- A value you send for a size always wins over the in-app pick for that size. The app still lets them preview the other looks, shows that size as set by the API, and keeps drawing yours. Sizes you leave out stay theirs to pick.
- Leaving
styleout is not the same as sendingstandard: a widget created without it reads back without the key, and the choice stays with the app's user. Send these fields only when the look should not change. - On
PATCH, a field you leave out keeps its stored value, andnullremoves it and hands the choice back to the app ("style": ""does too). A map you send replaces the whole stored map, never merges into it: send every size you want to keep. An empty object is stored as no map. A re-POSTreplaces the whole content, so it clears all four fields unless you send them again. - An unknown key or value is a
422withcode: "widget.content_invalid"naming the allowed ones. Case is ignored.densityanddensity_by_sizeon a template other thanstat_listare refused the same way, and so is aPATCHthat moves a widget with a stored density to another template, unless the same request clears both fields. - Standard and Bold also draw
stat_rowsonstatusandgauge, and onvalueandprogressfrom the medium size up, as many whole rows as fit. - App builds from before the styles ignore these fields: they keep drawing the earlier design, and Row Density stays the app user's setting. On the Home Screen every look draws every size. On the Lock Screen, a look with no design for that size draws the earlier Lock Screen design there, even where Standard has one.
curl -X PATCH https://api.pushward.app/widgets/cpu-load \
-H "Authorization: Bearer hlk_YOUR_TOKEN" \
-H "Content-Type: application/merge-patch+json" \
-d '{"content": {"style": "bold"}}'curl -X PATCH https://api.pushward.app/widgets/cpu-load \
-H "Authorization: Bearer hlk_YOUR_TOKEN" \
-H "Content-Type: application/merge-patch+json" \
-d '{"content": {"style_by_size": {"large": "bold", "lock_screen": "classic"}}}'curl -X PATCH https://api.pushward.app/widgets/on-call \
-H "Authorization: Bearer hlk_YOUR_TOKEN" \
-H "Content-Type: application/merge-patch+json" \
-d '{"content": {"density": "comfortable", "density_by_size": {"small": "compact", "lock_screen": "compact"}}}'curl -X PATCH https://api.pushward.app/widgets/cpu-load \
-H "Authorization: Bearer hlk_YOUR_TOKEN" \
-H "Content-Type: application/merge-patch+json" \
-d '{"content": {"style": null}}'Această secțiune descrie o funcție dintr-o actualizare a aplicației aflată în așteptarea verificării App Store. Se deblochează automat aici imediat ce actualizarea devine disponibilă.
Staleness (stale_after)
stale_after is a widget-level field — a sibling of slug and name, not part of content — accepted on both POST /widgets and PATCH /widgets/{slug}.
| Field | Type | Description |
|---|---|---|
stale_after | integer | Seconds after the widget's updated_at before clients render it as stale: Home Screen widgets dim and show a locale-formatted "as of" timestamp; Lock Screen (accessory) widgets keep their normal appearance. 60 – 604800 (one minute to seven days). Absent means never demoted; send null in a PATCH to clear it. |
curl -X PATCH https://api.pushward.app/widgets/cpu-load \
-H "Authorization: Bearer hlk_YOUR_TOKEN" \
-H "Content-Type: application/merge-patch+json" \
-d '{
"stale_after": 900,
"content": { "value": 0.42 }
}'A PATCH that changes nothing still re-stamps updated_at and resets the staleness clock — stale_after is a liveness signal, not a change signal. A poller that finds the value unchanged should PATCH anyway, so a widget whose producer died shows as stale instead of a confident, wrong number.
Această secțiune descrie o funcție dintr-o actualizare a aplicației aflată în așteptarea verificării App Store. Se deblochează automat aici imediat ce actualizarea devine disponibilă.
Organization widgets
A widget created with a key from an organization belongs to the organization and reaches its members' iPhone and iPad Home Screens, filtered by the routing rules that apply to widgets. Members add it like any other PushWard widget. On Apple Watch, PushWard 1.18.0 or later lists organization widgets in the watch app and in the complication picker.
POST /widgets and PATCH /widgets/{slug} take an optional target with groups, tags and members, the same object as on activities and notifications. It narrows who reads the widget and has it
reloaded, and never reaches anyone a rule keeps out. A re-POST of an existing slug without target keeps the stored one. On PATCH a new target replaces it and "target": null clears it, so everyone the rules allow gets the widget again. A personal key gets 422 org.target_unavailable.
curl -X POST https://api.pushward.app/widgets \
-H "Authorization: Bearer hlk_YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"slug": "queue-depth",
"name": "Queue depth",
"content": { "template": "value", "value": 42, "label": "jobs" },
"target": { "groups": ["oncall"] }
}'All of an organization's widgets share one push window of at least 60 seconds, and push_throttle is
ignored. A change inside the window is saved at once and reaches members' devices when the window closes, so
updating more than once a minute does not make the widget any fresher. A key limited to groups and tags only sees
widgets inside them (see Keys limited to groups and tags).
Errors
Widget errors use the same RFC 9457 Problem Details body shape and stable code matching guidance as the rest of the API.
| Status | Meaning |
|---|---|
400 | Malformed JSON or empty PATCH body. |
401 | Missing or invalid token. |
403 | Integration key's widgets level is below what the call needs (integration_key.permission_denied), or the slug is outside its widget_slugs (integration_key.slug_invalid). |
404 | Widget slug not found. |
422 | Validation failure: missing required content field for the template, value out of range, non-finite number, etc. A bad organization target uses the org.target_* codes listed under Teams. |
429 | Per-user widget cap reached (code: widget.limit_exceeded) or rate limit hit. |