Source: https://activitysmith.com/docs # Quickstart Send your first Push Notification to your iPhone or iPad. ## Pair Your Device [Download ActivitySmith for iOS](https://apps.apple.com/us/app/activitysmith/id6752254835) and sign in with the same account you use on the web. Your device pairs during setup. Allow notifications when prompted. If you haven't created an account yet, [start setup](https://activitysmith.com/app/onboarding?entry=quickstart). ## Create an API Key [Create an API key in the web app](https://activitysmith.com/app/keys) and copy it. ## Send a Push Notification Replace `your-api-key` below with your API key, then run the command: ```bash cURL YOUR_API_KEY="your-api-key" curl -X POST https://activitysmith.com/api/push-notification \ -H "Authorization: Bearer $YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "title": "New subscription 💸", "message": "Customer upgraded to Pro plan" }' ``` The notification will appear on your paired device. On Windows, some tools change accented characters and emoji, including `curl` in Git Bash. Follow the steps in [Character encoding](/docs/api-reference/introduction#character-encoding). ![Push Notification for a new subscription](https://cdn.activitysmith.com/features/new-subscription-push-notification.png) ## Choose Your SDK Find installation instructions and examples in the [SDK documentation](/docs/sdks/overview). --- Source: https://activitysmith.com/docs/api-keys # API Keys Create and manage API keys API Keys are secret tokens used to authenticate your requests. They are unique to your account and should be kept confidential. ## Create an API Key To create an API key, go to the [API Keys](https://activitysmith.com/app/keys) page and click the **Create API Key** button. 1. Click **Create API Key**. 2. Give your API Key a name (maximum 100 characters). 3. Select **All Recipients** or **Channel Scoped** as the Scope. 4. If you select **Channel Scoped**, you can choose the channels you want to restrict access to. ![Create API Key](https://cdn.activitysmith.com/features/create-api-key.png) > For security reasons, you can only view the API Key once. AI agents connected through the [ActivitySmith MCP server](/docs/mcp-server) can also create API keys, but only if you tick **Manage API keys** when you approve them. Keys an agent creates show which agent created them on the [API Keys](https://activitysmith.com/app/keys) page. ## API Key Scopes There are two different API Key Scopes you can choose from: - **All Recipients**: The API key can target all recipients in the account. - **Channel Scoped**: The API key is restricted to channels assigned to that key. ![API Key Scopes](https://cdn.activitysmith.com/features/channel-scoped-api-key.png) You can configure scope when creating or editing a key on the [API Keys](https://activitysmith.com/app/keys) page. ## Edit API Key details After creating an API Key, you can edit the following details: - Name - Scope - Scope Channels (only available if Scope is **Channel Scoped**) To edit an API Key, click the **Edit API Key** button. ## View all API Keys To manage your API keys, go to the [API Keys](https://activitysmith.com/app/keys) page. The page shows you all the API Keys you have created along with their details ![View API Keys](https://cdn.activitysmith.com/features/api-keys.png) ## Scope behavior with `target.channels` - Scope `all` + no `target.channels`: sends to all recipients in your account. - Scope `all` + `target.channels`: sends only to the provided channel slugs. - Scope `channels` + no `target.channels`: sends to channels assigned to that API key. - Scope `channels` + `target.channels`: requested channel slugs must be a subset of channels assigned to that API key. Channels in request payloads use channel slugs, for example, `["marketing", "test-devices"]`. ## Scope enforcement and errors If a channel-scoped key (`channels`) tries to target channel slugs outside its assignment, the request fails with `403 Forbidden` and a clear scope-violation error message. Use the [channels guide](/docs/channels) for channel setup and targeting examples. --- Source: https://activitysmith.com/docs/live-activity-stream # Live Activity Stream Start, update, and dismiss Live Activities with a stable stream key. Live Activity streams use a stable `stream_key` for the thing you want to keep visible. Send the latest state to that key whenever the data changes. - The first `PUT` starts the Live Activity. - The next `PUT` request with the same `stream_key` updates it. - `DELETE` ends the Live Activity when the work is done. ## What is a `stream_key`? A `stream_key` is a stable name for one ongoing process. Examples: - `prod-web-1` - `deployment-main` - `nightly-backup` - `ev-charging` Use one `stream_key` for one system, workflow, or process. The same stream mechanism works with all Live Activity types. See the [API reference](/docs/api-reference/endpoint/live-activity-stream) for available fields. ## Start Live Activity Send the initial state to `prod-web-1`. The first `PUT` starts a Metrics Live Activity. ```bash curl -X PUT https://activitysmith.com/api/live-activity/stream/prod-web-1 \ -H "Authorization: Bearer $YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "content_state": { "title": "Server Health", "subtitle": "prod-web-1", "type": "metrics", "metrics": [ { "label": "CPU", "value": 24, "unit": "%" }, { "label": "MEM", "value": 61, "unit": "%" } ] } }' ``` ## Update Live Activity Send the latest state to the same `stream_key`. This updates the existing Live Activity with new CPU and memory values. ```bash curl -X PUT https://activitysmith.com/api/live-activity/stream/prod-web-1 \ -H "Authorization: Bearer $YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "content_state": { "title": "Server Health", "subtitle": "prod-web-1", "type": "metrics", "metrics": [ { "label": "CPU", "value": 42, "unit": "%" }, { "label": "MEM", "value": 68, "unit": "%" } ] } }' ``` ## End Live Activity Use `DELETE /live-activity/stream/:stream_key` when the tracked process is finished and you want to dismiss the Live Activity. You can include final values before it is removed. By default, iOS removes the Live Activity after two minutes. Set `auto_dismiss_minutes` to choose a different dismissal time, including `0` for immediate dismissal. ```bash curl -X DELETE https://activitysmith.com/api/live-activity/stream/prod-web-1 \ -H "Authorization: Bearer $YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "content_state": { "title": "Server Health", "subtitle": "prod-web-1", "type": "metrics", "metrics": [ { "label": "CPU", "value": 7, "unit": "%" }, { "label": "MEM", "value": 38, "unit": "%" } ], "auto_dismiss_minutes": 2 } }' ``` `content_state` is optional here. Include it if you want one last update before the Live Activity is dismissed. The response includes `delivered`. When it is `false`, no device received the end and a `warning` explains why. The Live Activity can then stay on the Lock Screen until iOS removes it or someone dismisses it. If you later send another `PUT` request with the same `stream_key`, ActivitySmith starts a new Live Activity. ## Stream responses Stream responses include an `operation` field: - `started`: ActivitySmith started a new Live Activity for this `stream_key` - `updated`: ActivitySmith updated the current Live Activity - `rotated`: ActivitySmith ended the current Live Activity and started a new one, for example because `content_state.type` or the target channels changed - `noop`: the incoming state matched the current state, so no update was sent - `ended`: returned by `DELETE /live-activity/stream/:stream_key` `updated` responses also include a `warning` when this Live Activity is updating often enough that iOS may throttle it. ## Update frequency and iOS limits > [!WARNING] > iOS gives each device an update budget for Live Activities, which refills > roughly every hour. If a Live Activity updates faster than the budget allows, > iOS throttles it and it stops changing until the budget refills, even though > the API still returns `200`. > > Short bursts that end are fine, like the steps of a deployment. Avoid updating > the same Live Activity more often than every couple of minutes for long > periods, such as from a polling loop. When that happens, the response includes > a `warning`. For countdowns, use the `timer` type, which counts on the device > without updates. ### 8-hour limit iOS ends every Live Activity 8 hours after it starts and keeps it on the Lock Screen for up to 4 more hours. Once iOS ends it, no update or end can reach it. To keep long-running streams reachable, ActivitySmith replaces a stream's Live Activity with a new one shortly before the 8-hour mark. The new Live Activity keeps the latest content, actions, Tags, and Metadata, and the `stream_key` stays the same, so later updates and the end work as usual. The stream's `activity_id` changes to the new Live Activity. Replacement only applies to streams that received a request in the last 24 hours, and it is not billed. --- Source: https://activitysmith.com/docs/inbound-webhooks # Inbound Webhooks Forward events from external services into Push Notifications and Live Activities. Inbound webhooks let an external service POST events to ActivitySmith. Each event is turned into a Push Notification or a Live Activity on the paired iOS devices you target, with no backend code on your side. Use inbound webhooks when you want lock-screen visibility into a service that already has its own webhook system, like CI runs, deploys, error alerts, or issue updates. ![Inbound webhook presets in the ActivitySmith dashboard](https://cdn.activitysmith.com/features/vercel-webhooks-push-notifications-live-activities-presets.png) ## How It Works 1. Generate an inbound webhook URL in the [Webhooks section](https://activitysmith.com/app/webhooks). 2. Paste it into the source service (GitHub, Vercel, Sentry, and so on) and pick the events you care about. 3. Choose how the event is delivered: Push Notification or Live Activity. 4. Map payload fields to the title, message, and metadata you want shown. 5. Optionally route the event to specific [channels](/docs/channels). Each integration ships with ready-to-use presets that cover the most common events, so you can connect a source in a few clicks. Tweak any field on a preset, or start from scratch when you want full control over the title, body, action buttons, etc. The same source service can drive multiple webhooks. For example, you can send production deploy events to a `#prod` channel as a Live Activity, and preview deploys to a `#previews` channel as a Push Notification. ## Delivery Options Each webhook delivers events as one of: - **Push Notification**: best for short, conclusive events like a check that failed, a PR that merged, or an alert that fired. - **Live Activity**: best for long-running work like CI workflows or production deploys. The Live Activity stays on the lock screen while the job runs and dismisses when it finishes. You can also attach action buttons to the resulting notification or activity that open the source service (the GitHub run, the Sentry issue, the Vercel deployment, and so on) or trigger a backend webhook. See the SDK examples for [Push Notification actions](/docs/sdks/node#actionable-push-notifications) and [Live Activity actions](/docs/sdks/node#actions). ## Channel Routing Inbound webhooks use the same [channels](/docs/channels) as the rest of the API. Route events from a webhook to one or more channel slugs so they reach the right people or devices. ## Secret Verification ActivitySmith verifies inbound requests with a per-webhook secret. The source service must include the secret on every request as an HTTP header: ``` X-ActivitySmith-Webhook-Secret: YOUR_SECRET ``` Requests with a missing or wrong secret are rejected and logged in the delivery log so you can spot misconfigured sources. Some integrations (like GitHub and Linear) sign their payloads with their own scheme. ActivitySmith verifies those signatures natively when you use the integration, so you do not need a separate secret. ## Delivery Log ![Webhook delivery log in the ActivitySmith dashboard](https://cdn.activitysmith.com/features/webhook-delivery-log.png) Every webhook keeps a rolling log of recent requests. For each entry you can see: - The raw incoming payload - The mapped Push Notification or Live Activity that was sent - Verification or mapping errors, if any Use the log to debug new integrations, confirm a noisy source has been quieted down, or replay a payload while you tweak the field mapping. ## Available Integrations Pre-built integrations handle event subscription, signature verification, and a default field mapping for you. You can override the mapping at any time. | Integration | Supported events | | ---------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------- | | [GitHub](https://activitysmith.com/integrations/github-webhooks) | [GitHub webhook events](https://docs.github.com/en/webhooks/webhook-events-and-payloads) | | [GitLab](https://activitysmith.com/integrations/gitlab) | [GitLab webhook events](https://docs.gitlab.com/user/project/integrations/webhook_events/) | | [Linear](https://activitysmith.com/integrations/linear) | [Linear webhook events](https://linear.app/developers/webhooks) | | [Sentry](https://activitysmith.com/integrations/sentry) | [Sentry webhook events](https://docs.sentry.io/organization/integrations/integration-platform/webhooks/) | | [Vercel](https://activitysmith.com/integrations/vercel) | [Vercel webhook events](https://vercel.com/docs/webhooks/webhooks-api) | | [Netlify](https://activitysmith.com/integrations/netlify) | [Netlify deploy notifications](https://docs.netlify.com/deploy/deploy-notifications/) | | [Railway](https://activitysmith.com/integrations/railway) | [Railway webhook events](https://docs.railway.com/guides/webhooks) | The full integration list with setup guides lives at [activitysmith.com/integrations](https://activitysmith.com/integrations). ## Generic JSON If the service you want to track is not on the list, use a generic JSON webhook. Send any JSON payload to your inbound URL, paste a sample into the dashboard, and map fields like `title`, `subtitle`, `body`, and `url` onto the resulting Push Notification or Live Activity. This works for internal services, cron jobs, or third-party tools that expose webhooks but do not have a dedicated ActivitySmith integration yet. Need an integration that is not listed? Email [adam@activitysmith.com](mailto:adam@activitysmith.com). --- Source: https://activitysmith.com/docs/widgets # Widgets ActivitySmith lets you display any value on your Lock Screen with widgets - SaaS metrics, revenue, signups, uptime, habits, or anything else you want to track. ![ActivitySmith Lock Screen widgets](https://cdn.activitysmith.com/features/lock-screen-widgets.png) ## How It Works 1. Send a value to a metric key with the API. 2. Add the widget to your iPhone Lock Screen and pick the metric. 3. The widget fetches the latest value about every 15 minutes. iOS manages the refresh schedule. The first value sent to a new key creates the metric. ActivitySmith makes the label from the key, so `deploy.success_rate` becomes "Deploy success rate". Numeric values get the number format, and text values get the string format. ## Creating a Metric A metric has one of these formats: number, currency, percent, unit, or string. To use currency, percent, or unit, create the metric before you send the first value. You can create a metric in three ways: - In the [web app](https://activitysmith.com/app/widgets). - With the API, using `PUT /metrics/{key}`. - With an AI agent, using the `create_widget_metric` tool of the [MCP server](/docs/mcp-server). ![Create a widget metric in ActivitySmith](https://cdn.activitysmith.com/features/create-widget-metric.png) ```bash cURL curl -X PUT "https://activitysmith.com/api/metrics/mrr" \ -H "Authorization: Bearer $YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "label": "MRR", "format": "currency", "currency_code": "USD" }' ``` `PUT /metrics/{key}` creates the metric if the key is new. For an existing metric, it changes only the fields you send. You can send the same request each time your script starts. For the full API reference, see [Create or Update Metric](/docs/api-reference/endpoint/metric-upsert). ## Updating Metric Value Use the metric key when sending updates. Values can be numbers or strings. ```js Node import ActivitySmith from "activitysmith"; const activitysmith = new ActivitySmith({ apiKey: process.env.ACTIVITYSMITH_API_KEY, }); await activitysmith.metrics.update("deploy.success_rate", 99.9); ``` ```python Python import os from activitysmith import ActivitySmith activitysmith = ActivitySmith(api_key=os.environ["ACTIVITYSMITH_API_KEY"]) activitysmith.metrics.update("deploy.success_rate", 99.9) ``` ```go Go package main import ( "log" activitysmithsdk "github.com/ActivitySmithHQ/activitysmith-go" ) func main() { activitysmith, err := activitysmithsdk.New("YOUR-API-KEY") if err != nil { log.Fatal(err) } _, err = activitysmith.Metrics.Update("deploy.success_rate", 99.9) if err != nil { log.Fatal(err) } } ``` ```php PHP metrics->update('deploy.success_rate', 99.9); ``` ```ruby Ruby require "activitysmith" activitysmith = ActivitySmith::Client.new(api_key: ENV.fetch("ACTIVITYSMITH_API_KEY")) activitysmith.metrics.update("deploy.success_rate", 99.9) ``` ```bash cURL curl -X POST "https://activitysmith.com/api/metrics/deploy.success_rate/value" \ -H "Authorization: Bearer $YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "value": 99.9 }' ``` For the full API reference, see [Update Metric Value](/docs/api-reference/endpoint/metric-value-update). ## Deleted Metrics Values sent to the key of a deleted metric do not create the metric again. The API returns `404` with the code `metric_deleted`. To use the key again, create the metric again in the web app or with `PUT /metrics/{key}`. ## Limits Each account can have up to 100 metrics created through the API. When the account reaches the limit, requests that would create a metric return `409` with the code `metric_limit_reached`. Delete metrics you do not use to add more. --- Source: https://activitysmith.com/docs/app-icon-badge-count # App Icon Badge Set any number you care about on your ActivitySmith app icon through the ActivitySmith API. Track MRR, user count, stock price, or any other value you want to keep in view. ![ActivitySmith app icon with an App Icon Badge](https://cdn.activitysmith.com/features/badge-count.png) ## How It Works - Send a badge value through the API, an SDK, or the CLI. - Send `0` to clear the badge. - Use channels to target specific team members or devices. ## Set the Badge Value ```bash cURL curl -X POST "https://activitysmith.com/api/badge" \ -H "Authorization: Bearer $YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "badge": 8333 }' ``` ```js Node await activitysmith.badgeCount(8333); ``` ```python Python activitysmith.badge_count(8333) ``` ```go Go activitysmith.BadgeCount(8333) ``` ```php PHP $activitysmith->badgeCount(8333); ``` ```ruby Ruby activitysmith.badge_count(8333) ``` ```bash CLI activitysmith badge 8333 ``` ## Clear the Badge Set the value to `0` to hide the badge ```bash cURL curl -X POST "https://activitysmith.com/api/badge" \ -H "Authorization: Bearer $YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "badge": 0 }' ``` ```js Node await activitysmith.badgeCount(0); ``` ```python Python activitysmith.badge_count(0) ``` ```go Go activitysmith.BadgeCount(0) ``` ```php PHP $activitysmith->badgeCount(0); ``` ```ruby Ruby activitysmith.badge_count(0) ``` ```bash CLI activitysmith badge 0 ``` ## Target Specific Devices Use `target.channels` in API requests to target specific team members or devices ```bash cURL curl -X POST "https://activitysmith.com/api/badge" \ -H "Authorization: Bearer $YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "badge": 3, "target": { "channels": ["sales", "customer-success"] } }' ``` ## Requirements App Icon Badge requires Push Notifications enabled. On your iPhone, open Settings > ActivitySmith > Notifications and turn on Allow Notifications. --- Source: https://activitysmith.com/docs/mcp-server # MCP Server Let AI agents send Push Notifications, show real-time progress with Live Activities, update Lock Screen Widgets, and request approval on your iPhone or iPad. ## Server URL ```bash https://mcp.activitysmith.com/mcp ``` ## What Agents Can Do ### Push Notifications Send Push Notifications to your paired devices. ### Live Activities Show real-time business metrics, operational state, or ongoing work on your Lock Screen. ### Lock Screen Widgets Update values shown in Lock Screen widgets. ### Remote Approvals Your agents ask for your approval, and you approve or reject from your iPhone. ### App Icon Badge Set or clear the App Icon Badge on paired devices with Push Notifications turned on. ### History Review Push Notification and Live Activity history. ![Push Notifications from Claude, Cursor, and ChatGPT agents on an iPhone Lock Screen, sent over MCP](https://cdn.activitysmith.com/features/agent-notifications-lock-screen.png) ![AI agent progress Live Activity on the iPhone Lock Screen, updated over MCP](https://cdn.activitysmith.com/features/ai-agent-progress-live-activity-phone.png) ## Setup Instructions Send the setup prompt to your agent, or follow the steps for your client below. The server URL is the same in every client. ### Send This Prompt to Your Agent Paste it into Claude Code, Codex, Cursor, Hermes, or a chat app like Claude or ChatGPT. Your agent adds the server, walks you through the sign-in, and checks that your iPhone is paired. ```text Set up ActivitySmith so you can notify me on my iPhone. Follow https://activitysmith.com/agent-setup.md ``` Or add it in one click: [Add to Cursor](cursor://anysphere.cursor-deeplink/mcp/install?name=activitysmith&config=eyJ1cmwiOiJodHRwczovL21jcC5hY3Rpdml0eXNtaXRoLmNvbS9tY3AifQ==) or [Add to Claude](https://claude.ai/customize/connectors?modal=add-custom-connector&connectorName=ActivitySmith&connectorUrl=https%3A%2F%2Fmcp.activitysmith.com%2Fmcp). ### Claude Open [Add to Claude](https://claude.ai/customize/connectors?modal=add-custom-connector&connectorName=ActivitySmith&connectorUrl=https%3A%2F%2Fmcp.activitysmith.com%2Fmcp). It fills in the name and server URL. Select **Add**, then **Connect**, and approve the sign-in. To add it yourself, open **Customize**, then **Connectors**. Add a custom connector named `ActivitySmith` with the server URL: ```text https://mcp.activitysmith.com/mcp ``` ### Claude Code ```bash claude mcp add --transport http --scope user activitysmith https://mcp.activitysmith.com/mcp ``` User scope makes ActivitySmith available in every project. Start a new Claude Code session, run `/mcp`, select `activitysmith`, and approve the sign-in. ### ChatGPT Open **Settings**, then **Apps**. Under **Advanced settings**, turn on **Developer mode**. Select **Create app**, enter `ActivitySmith` as the name, and paste the server URL: ```text https://mcp.activitysmith.com/mcp ``` Approve the sign-in. Custom apps need a ChatGPT plan that supports Developer mode. ### Codex ```bash codex mcp add activitysmith --url https://mcp.activitysmith.com/mcp ``` Then authenticate: ```bash codex mcp login activitysmith ``` ### Cursor [Install in Cursor](cursor://anysphere.cursor-deeplink/mcp/install?name=activitysmith&config=eyJ1cmwiOiJodHRwczovL21jcC5hY3Rpdml0eXNtaXRoLmNvbS9tY3AifQ==) with one click. If you prefer manual setup, add the server to `~/.cursor/mcp.json`: ```json { "mcpServers": { "activitysmith": { "url": "https://mcp.activitysmith.com/mcp" } } } ``` Cursor prompts you to log in the first time the server is used. ### Grok In Grok, open [Connectors](https://grok.com/connectors), select **New Connector**, then select **Custom** and enter the server URL: ```text https://mcp.activitysmith.com/mcp ``` Complete the OAuth flow in the pop-up window. For Grok Build, add the server from a terminal: ```bash grok mcp add --transport http activitysmith https://mcp.activitysmith.com/mcp ``` ### Hermes ```bash hermes mcp add --url https://mcp.activitysmith.com/mcp --auth oauth activitysmith ``` Hermes opens the sign-in page in your browser. Approve it, then run `/reload-mcp` in your Hermes session to load the tools. ### Other MCP Clients For any client that asks for a remote MCP server URL, use: ```text https://mcp.activitysmith.com/mcp ``` The authorization flow happens in ActivitySmith. After approval, tools run against the account you authorized. ## OAuth ActivitySmith MCP uses OAuth. You do not need to create or paste an ActivitySmith API key into an agent prompt. During authorization, ActivitySmith shows the access requested by the client. Most clients request read and write access so the agent can inspect current state and then take action when you ask it to. ### Manage API keys The approval screen also has an optional **Manage API keys** checkbox. It is unchecked by default. Tick it when you want the agent to set up code that calls the ActivitySmith API on its own, for example by creating a key for a CI job and saving it as a secret. With this permission the agent can list, create, rename, and delete API keys. It never sees existing key secrets, only the secret of a key it creates. Keys an agent creates keep working after you disconnect the agent, so delete them on the [API Keys](https://activitysmith.com/app/keys) page when you no longer need them. Each one is labeled with the agent that created it. If you skipped the checkbox, the API key tools return an error that asks you to reconnect ActivitySmith and tick it. The OAuth scope is `api_keys:write`. ActivitySmith grants it only when you tick the checkbox, even if the client requests it. ## Example Prompts ```txt Notify me on my iPhone when this is done. ``` ```txt Show me the progress visible on my Lock Screen with a Live Activity. ``` ```txt Send me a Push Notification if this task gets blocked. ``` ```txt Ask me for approval on my iPhone before sending any email to customers. ``` ## Tools The server exposes the following MCP tools, grouped by resource. Keep tool confirmation enabled in your client when possible, especially when you connect multiple MCP servers to the same agent session. The API key tools only work if you ticked the optional **Manage API keys** checkbox when you approved the agent in ActivitySmith. See [Manage API keys](#manage-api-keys). | Resource | Tool | Description | | ------------------- | ----------------------------- | ------------------------------------------------------------------------------ | | Approvals | `request_approval` | Send a remote approval and wait for the decision. | | Approvals | `wait_for_approval` | Continue waiting for a pending approval. | | Approvals | `get_approval` | Get the current state of an approval without waiting. | | Approvals | `cancel_approval` | Cancel a pending approval that is no longer needed. | | Push Notifications | `send_push_notification` | Send a Push Notification, with optional icon, interruption level, actions, media, and channel targeting. | | Push Notifications | `replace_push_notification` | Silently replace a sent Push Notification on the Lock Screen and in history, using its `notification_id`. | | Push Notifications | `dismiss_push_notification` | Clear a sent Push Notification from the Lock Screen and Notification Center, using its `notification_id`. History keeps it. | | Push Notifications | `list_push_notifications` | List Push Notification history for the account. | | Push Notifications | `get_push_notification` | Get one Push Notification by public ID. | | App Icon Badge | `update_app_icon_badge_count` | Set or clear the App Icon Badge, with optional channel targeting. | | Live Activities | `set_live_activity_stream` | Start or update a managed Live Activity stream. | | Live Activities | `pause_live_activity_stream` | Pause a stream and end its current Live Activity. | | Live Activities | `resume_live_activity_stream` | Resume a paused stream so updates apply again. | | Live Activities | `end_live_activity_stream` | End the current Live Activity and remove the stream key. | | Live Activities | `list_live_activities` | List Live Activities for the account. | | Live Activities | `get_live_activity` | Get one Live Activity with its metadata, tags, channels, and actions. | | Lock Screen Widgets | `create_widget_metric` | Create a widget metric definition. | | Lock Screen Widgets | `set_widget_metric_value` | Set the latest value for a widget metric. A new key creates the metric. | | Lock Screen Widgets | `update_widget_metric` | Update a widget metric definition. | | Lock Screen Widgets | `list_widget_metrics` | List widget metrics for the account. | | Lock Screen Widgets | `delete_widget_metric` | Delete a widget metric. | | Tags | `list_tags` | List tags and their usage across Push Notifications and Live Activities. | | Channels | `create_channel` | Create a channel for targeting Push Notifications and Live Activities. | | Channels | `get_channel` | Get one channel with its assigned users and devices. | | Channels | `list_channels` | List channels for the account. | | Channels | `update_channel` | Update a channel slug. | | Channels | `set_channel_users` | Replace the user membership for a channel. | | Channels | `set_channel_devices` | Replace explicit device assignments for a channel. | | Channels | `delete_channel` | Delete a channel. | | Users and Devices | `list_account_users` | List users in the account for channel assignment. | | Users and Devices | `list_account_devices` | List active devices for explicit channel assignment. | | API Keys | `list_api_keys` | List API keys without their secrets. | | API Keys | `create_api_key` | Create an API key and return its secret once. | | API Keys | `rename_api_key` | Rename an API key. | | API Keys | `delete_api_key` | Delete an API key. | ## Pagination `list_push_notifications`, `list_live_activities`, `list_tags`, and `list_account_devices` support offset pagination. Other list tools currently return their complete result without pagination. | Tool | Default limit | Maximum limit | Ordering | | --- | --- | --- | --- | | `list_push_notifications` | 50 | 100 | Newest first; equal creation times use descending ID order | | `list_live_activities` | 50 | 100 | Newest first; equal creation times use descending ID order | | `list_tags` | 50 | 100 | Alphabetical by slug, then ID | | `list_account_devices` | 100 | 100 | Active devices first, then most recently updated and created; ties use device and owner identifiers | For all four tools, `limit` must be an integer from 1 to 100. `offset` defaults to 0 and must be a nonnegative integer. For example, call `list_push_notifications` with: ```json { "limit": 50, "offset": 0 } ``` A page containing the first 50 of 120 matching records includes this metadata: ```json { "meta": { "total": 120, "limit": 50, "offset": 0, "has_more": true, "next_offset": 50 } } ``` Records appear in `data`, except `list_account_devices`, which returns `devices`. - `total`: matching records when counted; this can change between requests. - `limit`: the requested maximum page size. - `offset`: how many records were skipped. - `has_more`: whether another page is available. - `next_offset`: the offset for the next request, or `null` when finished. Use `next_offset` as the next request's `offset`, keeping the same tool, filters, and limit. Stop when `next_offset` is `null`. An empty page also ends pagination, including when the offset is beyond the available results. New or removed records, or changes to sort values, can move results between pages. When processing multiple pages, deduplicate by record identifier. Offset pagination does not guarantee a complete snapshot while results are changing. --- Source: https://activitysmith.com/docs/rate-limits # Rate Limits Rate limits for API requests ## Concurrent Live Activities Limits iOS supports up to 5 concurrent Live Activities per app on a device. The exact capacity is dynamic: iOS may allow fewer depending on device conditions and other active or scheduled Live Activities. ActivitySmith mirrors this iOS limit server-side. This gives API clients a clear, actionable response instead of allowing APNs to accept a start that iOS may not create on the device. Paid accounts receive a `429` response when a targeted device has reached the enforced concurrency threshold. During a trial, starting a sixth Live Activity ends the oldest active Live Activity before starting the new one. Limit responses always include the highest active count among targeted devices. When multiple targeted devices have mixed capacity, the response also includes `blocked_devices` and `targeted_devices` to explain which targets prevented the start. End Live Activities as soon as they are no longer useful so iOS can release their capacity. iOS also limits how often a Live Activity can update. See [Update frequency and iOS limits](/docs/live-activity-stream#update-frequency-and-ios-limits). ## API Rate Limits Each feature has its own request allowance per account. Requests to one feature do not reduce the allowance for another. | Feature | Requests per minute | Endpoints | | --- | --- | --- | | Push Notifications | 60 | `POST /push-notification` | | App Icon Badge | 60 | `POST /badge` | | Live Activities | 300 | `PUT` and `DELETE /live-activity/stream/{stream_key}`, `POST /live-activity/start`, `POST /live-activity/update`, `POST /live-activity/end` | | Lock Screen Widget metrics | 300 | `PUT /metrics/{metric_key}`, `POST /metrics/{metric_key}/value` | API keys belonging to the same account share each feature's allowance. For example, reaching the metric update limit does not block Push Notifications. The Live Activity endpoints share one Live Activities allowance. **IP address limits**: 600 requests per minute per feature. These allowances are also independent, so metric requests do not consume the Push Notification IP allowance. Requests with missing or invalid credentials count toward the relevant IP limit. Browser preflight (`OPTIONS`) requests do not count. These rate limits are enforced to ensure fair usage and availability of the API for all users. If you require higher limits, please contact us at [adam@activitysmith.com](mailto:adam@activitysmith.com). ## Response Headers Use the `RateLimit` and `RateLimit-Policy` response headers to track your remaining allowance and when it resets. The headers use the IETF draft-8 format. When both IP and account limits apply, they appear as comma-separated entries: ```http RateLimit-Policy: "public-api-ip:notifications"; q=600; w=60, "account:notifications"; q=60; w=60 RateLimit: "public-api-ip:notifications"; r=599; t=60, "account:notifications"; r=59; t=60 ``` - `q`: request allowance for the named policy. - `w`: policy window in seconds. - `r`: requests remaining after this request, never below zero. - `t`: seconds until the policy resets, not a Unix timestamp. Policies may also include an opaque `pk` partition identifier. Clients should ignore parameters they do not recognize. Browser clients can read these headers through `Access-Control-Expose-Headers`. Unauthenticated requests receive the relevant feature's IP policy only. Authenticated requests also receive that feature's account policy. A request is blocked when either applicable allowance is exhausted. ## Handling 429 Responses A request-rate `429 Too Many Requests` response also includes `Retry-After`, expressed as seconds until the blocking policy resets: ```http HTTP/1.1 429 Too Many Requests RateLimit-Policy: "account:notifications"; q=60; w=60 RateLimit: "account:notifications"; r=0; t=30 Retry-After: 30 ``` Wait at least `Retry-After` seconds before retrying. If several policies show zero remaining requests, wait until all have reset. Add a small random delay to avoid sending a burst when the window opens. Other requests for the same feature may consume its allowance during the wait, so the next attempt can still be rate limited. Live Activity capacity errors also use HTTP 429, but they are separate from request-rate limits. Their body contains `limit` and `active`; free device capacity by ending an existing Live Activity before starting another. A clock-based retry alone does not resolve a capacity error. --- Source: https://activitysmith.com/docs/team # Team Members Manage your team from one place: invite members, track pending invites, and remove access. ![Team Members](https://cdn.activitysmith.com/docs/members.png) ## Managing Team Members The **Members** page is where team owners manage access for the whole workspace. You can: - Invite one or many people at once - See active users and their role - Track pending invitations and expiration dates - Remove members when they no longer need access ## Roles ActivitySmith currently supports two team roles: | Role | Access | | -------- | ------------------------------------------------------------- | | `owner` | Full access, including inviting and removing members | | `member` | Standard workspace access without team management permissions | ## Invite Team Members Only team owners can invite new members. 1. Open your ActivitySmith dashboard. 2. Go to **Members** in the left sidebar. 3. Click **Invite members**. 4. Enter one or more email addresses in the invite modal. 5. Separate multiple emails with commas or new lines. 6. Click **Send Invites**. ![Invite Team Members](https://cdn.activitysmith.com/docs/members-invite.png) Newly invited users appear in the **Invited users** table with: - `pending` status until accepted - Invite date (`Invited`) - Expiration date (`Expires`) Members are added to **Active users** only after they accept the invite. ## Remove a Member Only team owners can remove members. 1. Open **Members**. 2. Find the user in **Active users**. 3. Click **Remove** in the **Actions** column. 4. Confirm the removal. The removed member loses team access immediately. --- Source: https://activitysmith.com/docs/metadata # Metadata Add extra information to your Push Notifications and Live Activities. Attach details such as a customer ID or job result as metadata. You can view them in ActivitySmith on iOS or the web by opening a Push Notification or Live Activity detail. Metadata does not appear in the Push Notification or Live Activity shown on your Lock Screen. ![Push Notification detail showing metadata in ActivitySmith for iOS](https://cdn.activitysmith.com/features/metadata-ios.png) ## Add metadata Include a top-level `metadata` object when sending a Push Notification or Live Activity. ```js Node await activitysmith.notifications.send({ title: "New subscription", message: "Customer upgraded to Pro plan", metadata: { customer_id: "382", plan: "Pro", amount: 29, trial: false, }, }); ``` ```python Python activitysmith.notifications.send( title="New subscription", message="Customer upgraded to Pro plan", metadata={ "customer_id": "382", "plan": "Pro", "amount": 29, "trial": False, }, ) ``` ```go Go activitysmith.Notifications.Send(activitysmithsdk.PushNotificationInput{ Title: "New subscription", Message: "Customer upgraded to Pro plan", Metadata: map[string]any{ "customer_id": "382", "plan": "Pro", "amount": 29, "trial": false, }, }) ``` ```php PHP $activitysmith->notifications->send( title: 'New subscription', message: 'Customer upgraded to Pro plan', metadata: [ 'customer_id' => '382', 'plan' => 'Pro', 'amount' => 29, 'trial' => false, ], ); ``` ```ruby Ruby activitysmith.notifications.send( title: "New subscription", message: "Customer upgraded to Pro plan", metadata: { customer_id: "382", plan: "Pro", amount: 29, trial: false, } ) ``` ```bash CLI activitysmith push \ --title "New subscription" \ --message "Customer upgraded to Pro plan" \ --metadata '{ "customer_id": "382", "plan": "Pro", "amount": 29, "trial": false }' ``` ```bash cURL curl -X POST https://activitysmith.com/api/push-notification \ -H "Authorization: Bearer $YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "title": "New subscription", "message": "Customer upgraded to Pro plan", "metadata": { "customer_id": "382", "plan": "Pro", "amount": 29, "trial": false } }' ``` ## Update or clear metadata When updating or ending a Live Activity: - Omit `metadata` to keep the existing fields. - Send a `metadata` object to replace all existing fields. Include every field you want to keep. - Send `"metadata": {}` to clear all fields. These rules apply to managed streams and the legacy start, update, and end endpoints when they update an existing activity. ## Supported values and limits | Property | Limit | | --- | --- | | Fields | Up to 50 entries | | Field names | 1 to 100 characters, cannot be blank or `__proto__` | | String values | Up to 4,000 characters | | Number values | Finite numbers | | Boolean values | `true` or `false` | | Total size | Up to 16 KB of serialized UTF-8 JSON | Nested objects, arrays, and `null` values are not supported. --- Source: https://activitysmith.com/docs/channels # Channels Use channels to target specific users and devices. Channels let you target specific groups of recipients instead of sending to everyone in an account. Common use case: - Different teams should receive different notifications (for example, `marketing`, `developers`, `devops`, `sre`). Channels are flexible: - You can assign users, devices, or both to a channel. - You can choose channels per request using `target.channels`. - You can keep some [API key](/docs/api-keys) broad and scope other [API key](/docs/api-keys) to specific channels. ## How Targeting Works Use channel slugs in `target.channels`: ```json { "target": { "channels": ["ios-beta", "ops"] } } ``` - If `target` is omitted and API key scope is `all`, delivery goes to all recipients in the account. - If `target` is omitted and API key scope is `channels`, delivery goes to channels assigned to that [API key](/docs/api-keys). - If `target.channels` is provided, only those channel slugs are targeted. ## Push Notifications ```json { "title": "New subscription 💸", "message": "Customer upgraded to Pro plan", "target": { "channels": ["ios-beta", "ops"] } } ``` ## Live Activities ```json { "content_state": { "title": "Nightly database backup", "number_of_steps": 3, "current_step": 1, "type": "segmented_progress" }, "target": { "channels": ["ios-beta", "ops"] } } ``` See endpoint docs for full request and response fields: - [/api-reference/endpoint/push-notification](/docs/api-reference/endpoint/push-notification) - [/api-reference/endpoint/live-activity-start](/docs/api-reference/endpoint/live-activity-start) --- Source: https://activitysmith.com/docs/tags # Tags Organize and filter Push Notification and Live Activity history. Tags help you organize Push Notification and Live Activity history around the people, customers, environments, or workflows that matter to you. For example: - `user:382` - `billing` - `environment:production` - `order_9381` ## Add Tags Add an optional top-level `tags` array when sending a Push Notification or starting a Live Activity. New tags are created automatically when you first use them. ### Push Notifications ```json { "title": "New subscription 💸", "message": "Customer upgraded to Pro plan", "tags": ["user:382", "billing"] } ``` ### Live Activities ```json { "content_state": { "title": "Search reindex", "subtitle": "catalog-v2", "type": "progress", "percentage": 42 }, "tags": ["user:382", "search-reindex"] } ``` ## Filter History Use one or more tags to filter Push Notification and Live Activity history. - Click a tag in Push Notification history to see Push Notifications with that tag. - Click a tag in Live Activity history to see Live Activities with that tag. - Open **Tags** in the ActivitySmith web app and click a tag to see its combined Push Notification and Live Activity history. - When filtering by multiple tags, choose whether results must match all tags or any tag. ## Manage Tags The **Tags** page in the ActivitySmith web app shows every tag and its usage across Push Notifications and Live Activities. From there, you can: - Search and sort tags. - Rename a tag. The new name appears throughout notification history. - Delete individual tags or select multiple tags for deletion. - Delete all tags. Deleting a tag removes it from associated history records. It does not delete the Push Notifications or Live Activities themselves. ## Tag Format - Up to 20 unique tags per request. - Between 1 and 64 characters per tag. - Supported characters: lowercase letters, numbers, dashes (`-`), underscores (`_`), periods (`.`), and colons (`:`). - Tags are trimmed, converted to lowercase, and deduplicated. See the endpoint documentation for complete request fields: - [Send a Push Notification](/docs/api-reference/endpoint/push-notification) - [Start or update a Live Activity](/docs/api-reference/endpoint/live-activity-start) --- Source: https://activitysmith.com/docs/colors # Live Activity Colors Colors can be used to customize the appearance of your Live Activities. You can choose from the following colors(default is `blue`): ### `lime` ![Lime Live Activity](https://cdn.activitysmith.com/printkit/live-activity-lime.png) ### `green` ![Green Live Activity](https://cdn.activitysmith.com/printkit/live-activity-green.png) ### `cyan` ![Cyan Live Activity](https://cdn.activitysmith.com/printkit/live-activity-cyan.png) ### `blue` ![Blue Live Activity](https://cdn.activitysmith.com/printkit/live-activity-blue.png) ### `purple` ![Purple Live Activity](https://cdn.activitysmith.com/printkit/live-activity-purple.png) ### `magenta` ![Magenta Live Activity](https://cdn.activitysmith.com/printkit/live-activity-magenta.png) ### `red` ![Red Live Activity](https://cdn.activitysmith.com/printkit/live-activity-red.png) ### `orange` ![Orange Live Activity](https://cdn.activitysmith.com/printkit/live-activity-orange.png) ### `yellow` ![Yellow Live Activity](https://cdn.activitysmith.com/printkit/live-activity-start.png) --- Source: https://activitysmith.com/docs/sdks/overview # Overview Use an official SDK or the CLI to send Push Notifications, manage Live Activities, update Lock Screen Widgets, and set the App Icon Badge. ## Official SDKs ### [Node SDK](/docs/sdks/node) Explore the Node SDK for ActivitySmith. ### [Python SDK](/docs/sdks/python) Explore the Python SDK for ActivitySmith. ### [Go SDK](/docs/sdks/go) Explore the Go SDK for ActivitySmith. ### [PHP SDK](/docs/sdks/php) Explore the PHP SDK for ActivitySmith. ### [Ruby SDK](/docs/sdks/ruby) Explore the Ruby SDK for ActivitySmith. ### [CLI](/docs/sdks/cli) Use ActivitySmith directly from the command line. --- Source: https://activitysmith.com/docs/sdks/node # Node.js Use the ActivitySmith Node.js SDK to send Push Notifications and Live Activity progress updates from Node services, jobs, and CI workflows. ## Installation Install the ActivitySmith Node.js SDK with npm: ```bash npm install activitysmith ``` ## Quickstart 1. [Create an API key](https://activitysmith.com/app/keys) 2. Set `ACTIVITYSMITH_API_KEY` or pass `apiKey` when creating the client. ```js Node import ActivitySmith from "activitysmith"; const activitysmith = new ActivitySmith({ apiKey: process.env.ACTIVITYSMITH_API_KEY, }); ``` ## Push Notifications ### Send a Push Notification Send an immediate notification for a completed task or event. ![Push Notification example for a new subscription event](https://cdn.activitysmith.com/features/new-subscription-push-notification.png) ```js Node await activitysmith.notifications.send({ title: "New subscription 💸", message: "Customer upgraded to Pro plan", }); ``` ### Custom Push Notification Icons ![Push Notifications with custom icons](https://cdn.activitysmith.com/features/push-notifications-with-custom-icons.png) Set `icon` to a publicly accessible HTTPS image URL to show a logo or avatar alongside a smaller ActivitySmith app icon. Host the image anywhere, such as on your own website or CDN. With a custom icon, iOS may omit `subtitle` from the notification. ```js Node await activitysmith.notifications.send({ title: "MRR just crossed $10,000 🎉", message: "Up 18% this month from 31 new subscriptions.", icon: "https://example.com/icons/stripe.png", }); ``` ### Rich Push Notifications with Media ![Rich Push Notification with image](https://cdn.activitysmith.com/features/rich-push-notification-with-image.png) ```js Node await activitysmith.notifications.send({ title: "Homepage ready", message: "Your agent finished the redesign.", media: "https://cdn.example.com/output/homepage-v2.png", }); ``` Attach images, videos, or audio to your Push Notifications. Press and hold the notification to preview the media. ![Rich Push Notification with audio](https://cdn.activitysmith.com/features/rich-push-notification-with-audio.png) What will work: - direct image URL: `.jpg`, `.png`, `.gif`, etc. - direct audio file URL: `.mp3`, `.m4a`, etc. - direct video file URL: `.mp4`, `.mov`, etc. - URL that responds with a proper media `Content-Type`, even if the path has no extension `media` cannot be combined with `actions`. ### Push Notifications with Redirection Open a web page, run an iOS Shortcut, or open an app when someone taps the notification. `redirection` supports: - **HTTP/HTTPS:** Web pages, e.g. `https://example.com` - **Shortcuts:** Run Jarvis with `shortcuts://run-shortcut?name=Jarvis` - **App deep links:** Installed apps or specific content within them - **Spotify:** A track, e.g. `spotify:track:6rqhFgbbKwnb9MLmUQDhG6` - **Termius:** `termius://` to open the app - **Claude:** `claude://code` to open the Code tab - **ChatGPT:** `chatgpt://` to open the app ```js Node await activitysmith.notifications.send({ title: "Homepage ready", message: "Your agent finished the redesign.", redirection: "https://github.com/acme/web/pull/482", }); ``` ### Actionable Push Notifications ![Actionable Push Notification with redirection and actions](https://cdn.activitysmith.com/features/actionable-push-notifications-2.png) `open_url` actions open a web page, run an iOS Shortcut, or open an app when someone taps the button. Supported links: - **HTTP/HTTPS:** Web pages, e.g. `https://example.com` - **Shortcuts:** Run Jarvis with `shortcuts://run-shortcut?name=Jarvis` - **App deep links:** Installed apps or specific content within them - **Spotify:** A track, e.g. `spotify:track:6rqhFgbbKwnb9MLmUQDhG6` - **Termius:** `termius://` to open the app - **Claude:** `claude://code` to open the Code tab - **ChatGPT:** `chatgpt://` to open the app Webhooks are executed by the ActivitySmith backend and must use HTTPS. ```js Node await activitysmith.notifications.send({ title: "New subscription 💸", message: "Customer upgraded to Pro plan", actions: [ { title: "Open CRM", type: "open_url", url: "https://crm.example.com/customers/cus_9f3a1d", }, { title: "Chat with Jarvis", type: "open_url", url: "shortcuts://run-shortcut?name=Jarvis", }, { title: "Start Onboarding Workflow", type: "webhook", url: "https://hooks.example.com/activitysmith/onboarding/start", method: "POST", body: { customer_id: "cus_9f3a1d", plan: "pro", }, }, ], }); ``` ### Interruption Levels ![Time Sensitive Push Notification](https://cdn.activitysmith.com/features/time-sensitive-push-notifications.png) Use `interruption_level` to choose how urgently iOS presents a Push Notification. Omit it for normal delivery. Explicit `active` has the same behavior as the default. | Value | Behavior | | --- | --- | | `passive` | Appears quietly in the notification list, without sound or waking the screen. | | `active` | Normal delivery, subject to the device's notification settings and Focus. This is the default. | | `time-sensitive` | Can bypass Scheduled Summary and Focus when the user allows Time Sensitive Notifications for ActivitySmith. | See Apple's [interruption levels](https://developer.apple.com/documentation/usernotifications/unnotificationinterruptionlevel) for the system behavior. The SDK also exports these values as `ActivitySmith.pushInterruptionLevels.passive`, `.active`, and `.timeSensitive`. #### Passive ```js Node await activitysmith.notifications.send({ title: "Daily summary", message: "All scheduled jobs completed successfully.", interruption_level: "passive", }); ``` #### Active (default) ```js Node await activitysmith.notifications.send({ title: "Deployment complete", message: "Your latest changes are live.", interruption_level: "active", }); ``` Removing `interruption_level` from this example produces the same delivery behavior. #### Time Sensitive ```js Node await activitysmith.notifications.send({ title: "🚨 checkout-api is down", message: "500 errors on 62% of requests. Customers can't complete payments.", interruption_level: "time-sensitive", }); ``` ### Replace a Push Notification Every send returns a `notification_id`. Pass it to `replace` to update a Push Notification you already sent, for example when an incident you alerted on is resolved. The replacement takes the old notification's place on the Lock Screen and in history instead of stacking a second one. It arrives silently, without sound or waking the screen, and goes to the same recipients as the original. Omit `metadata` or `tags` to keep their stored values. ```js Node const sent = await activitysmith.notifications.send({ title: "🚨 checkout-api is down", message: "500 errors on 62% of requests.", }); await activitysmith.notifications.replace(sent.notification_id, { title: "✅ checkout-api recovered", message: "Error rate is back to normal. Incident resolved.", }); ``` ### Dismiss a Push Notification Pass the `notification_id` to `dismiss` when a Push Notification no longer needs attention, for example after you answered an agent's question somewhere else. Dismissing clears it from the Lock Screen and Notification Center on every device it was sent to. History keeps it. Devices clear the notification in the background, so it can take a moment. ```js Node const sent = await activitysmith.notifications.send({ title: "🙋 Agent needs your input", message: "Approve the database migration?", }); await activitysmith.notifications.dismiss(sent.notification_id); ``` ## Live Activities Choose the Live Activity type that matches what you want to show: - ![Value Live Activity showing revenue with a growth badge](https://cdn.activitysmith.com/features/value-live-activity.png) **Value**: Show a single value on your Lock Screen, such as revenue, a queue count, or a temperature. - ![Stats Live Activity with six labeled sales metrics](https://cdn.activitysmith.com/features/stats-live-activity.png) **Stats**: Show up to 8 labeled values on your Lock Screen, from revenue and orders to uptime and conversion. - ![Alert Live Activity showing a customer reactivation update](https://cdn.activitysmith.com/features/alert-live-activity.png) **Alert**: Show status updates with a clear message, badge, and icon. When you add an action button, `color` controls the button tint. - ![Metrics Live Activity with CPU and memory values](https://cdn.activitysmith.com/features/metrics-live-activity-start.png) **Metrics**: Track two related values with segmented bars, such as CPU and memory. - ![Segmented Progress Live Activity showing a workflow step](https://cdn.activitysmith.com/features/update-live-activity.png) **Segmented Progress**: Show progress through a known set of steps, like build, test, deploy, and verify. - ![Progress Live Activity showing percentage completion](https://cdn.activitysmith.com/features/progress-live-activity.png) **Progress**: Show percentage progress for jobs that move continuously toward completion. - ![Timer Live Activity showing a benchmark run countdown](https://cdn.activitysmith.com/features/timer-live-activity.png) **Timer**: Count down from a duration, or count up from 00:00 while a job runs. ### Start & Update Live Activity Use a stable `streamKey` to identify the metric, job, deployment, or system you want to keep visible. The first `stream(...)` call starts the Live Activity. Later calls with the same `streamKey` update it. > [!WARNING] > iOS limits how often a Live Activity can update. Short bursts that end, like deployment steps, are fine. If one Live Activity keeps updating more often than every couple of minutes, iOS throttles it until the budget refills, roughly an hour, even though the API still returns `200`. [Learn more](/docs/live-activity-stream#update-frequency-and-ios-limits) #### Value ![Value Live Activity stream example](https://cdn.activitysmith.com/features/value-live-activity.png) ```ts await activitysmith.liveActivities.stream("revenue-today", { content_state: ActivitySmith.contentState({ title: "Revenue", type: "value", value: "$1,240", color: "green", icon: ActivitySmith.alertIcon("dollarsign.circle", { color: "green" }), badge: ActivitySmith.alertBadge("↑ 18%", { color: "purple" }), }), }); ``` Send a string or number in `value`. Strings keep their formatting, including currency symbols, units, and decimal places. #### Stats ![Stats Live Activity stream example](https://cdn.activitysmith.com/features/stats-live-activity.png) ```ts await activitysmith.liveActivities.stream("sales-hourly", { content_state: { title: "Sales", subtitle: "last hour", type: "stats", metrics: [ { label: "Revenue", value: "$2430", color: "blue" }, { label: "Orders", value: "37", color: "green" }, { label: "Conversion", value: "4.8%", color: "magenta" }, { label: "Avg Order", value: "$65.68", color: "yellow" }, { label: "Refunds", value: "$84", color: "red" }, { label: "New Buyers", value: "18", color: "cyan" }, ], }, }); ``` #### Alert ![Alert Live Activity stream example](https://cdn.activitysmith.com/features/alert-live-activity.png) ```ts await activitysmith.liveActivities.stream("customer-ops", { content_state: ActivitySmith.contentState({ title: "Reactivation", message: "Lumen came back after 2 weeks", type: "alert", icon: ActivitySmith.alertIcon("cloud.sun", { color: "yellow" }), badge: ActivitySmith.alertBadge("Customer", { color: "magenta" }), }), }); ``` #### Metrics ![Metrics Live Activity stream example](https://cdn.activitysmith.com/features/metrics-live-activity-start.png) ```ts await activitysmith.liveActivities.stream("prod-web-1", { content_state: { title: "Server Health", subtitle: "prod-web-1", type: "metrics", metrics: [ { label: "CPU", value: 9, unit: "%" }, { label: "MEM", value: 45, unit: "%" }, ], }, }); ``` #### Segmented Progress ![Segmented Progress Live Activity stream example](https://cdn.activitysmith.com/features/update-live-activity.png) ```ts await activitysmith.liveActivities.stream("nightly-backup", { content_state: { title: "Nightly Backup", subtitle: "upload archive", type: "segmented_progress", number_of_steps: 3, current_step: 2, }, }); ``` #### Progress ![Progress Live Activity stream example](https://cdn.activitysmith.com/features/progress-live-activity.png) ```ts await activitysmith.liveActivities.stream("search-reindex", { content_state: { title: "Search Reindex", subtitle: "catalog-v2", type: "progress", percentage: 42, }, }); ``` #### Timer ![Timer Live Activity stream example](https://cdn.activitysmith.com/features/timer-live-activity.png) ```ts await activitysmith.liveActivities.stream("benchmark-run", { content_state: { title: "Benchmark Run", subtitle: "sampling", type: "timer", duration_seconds: 300, color: "cyan", }, }); ``` For a countdown, send `duration_seconds`. You can update `title`, `subtitle`, `color`, or any other visible field as the work changes. Leave `duration_seconds` out unless you want to change the timer. To start at 00:00 and count up, set `counts_down: false` and leave out `duration_seconds`. ### End Live Activity Call `endStream(...)` with the same `streamKey` to dismiss the Live Activity. You can include final values before it is removed. Set `auto_dismiss_seconds` to dismiss it after a delay in seconds, or `auto_dismiss_minutes` for minutes. Use `0` for immediate dismissal. Seconds take precedence if both are set. ```ts await activitysmith.liveActivities.endStream("prod-web-1", { content_state: { title: "Server Health", subtitle: "prod-web-1", type: "metrics", metrics: [ { label: "CPU", value: 7, unit: "%" }, { label: "MEM", value: 38, unit: "%" }, ], auto_dismiss_seconds: 30, }, }); ``` ### Icons and Badges Add more context to Live Activities with icons and badges. #### Icon Supported Live Activity types: `value`, `stats`, `alert`, `metrics`, `segmented_progress`, `progress`, and `timer`. ![Metrics Live Activity with an SF Symbol icon on the iPhone Lock Screen](https://cdn.activitysmith.com/features/metrics-live-activity-with-icon.png) ```ts await activitysmith.liveActivities.stream("prod-web-1", { content_state: ActivitySmith.contentState({ title: "Server Health", subtitle: "prod-web-1", type: "metrics", icon: ActivitySmith.alertIcon("server.rack", { color: "blue" }), metrics: [ { label: "CPU", value: 18, unit: "%" }, { label: "MEM", value: 42, unit: "%" }, ], }), }); ``` The `icon.symbol` value is an Apple SF Symbol name. Browse the catalog with one of these tools: - [ActivitySmith app](https://apps.apple.com/us/app/activitysmith/id6752254835) - Open Settings -> SF Symbols to browse 45 hand-picked icons ready to use - [SF Symbols](https://developer.apple.com/sf-symbols/) - Apple's official macOS app - [Interactful](https://apps.apple.com/app/interactful/id1528095640) - free third-party iOS app listing all SF Symbols under Foundations -> Iconography #### Badge Badges are supported by `value`, `alert`, `segmented_progress`, and `progress` Live Activities. ![Progress Live Activity with a badge on the iPhone Lock Screen](https://cdn.activitysmith.com/features/progress-live-activity-with-badge.png) ```ts await activitysmith.liveActivities.stream("nightly-database-backup", { content_state: ActivitySmith.contentState({ title: "Nightly Database Backup", subtitle: "verify restore", type: "progress", badge: ActivitySmith.alertBadge("S3", { color: "cyan" }), percentage: 62, }), }); ``` ### Colors Choose from these colors for the Live Activity accent, including progress bars and action buttons, or apply them to an individual icon or badge: `lime`, `green`, `cyan`, `blue`, `purple`, `magenta`, `red`, `orange`, `yellow`, `gray` ### Actions ![Metrics Live Activity with action](https://cdn.activitysmith.com/features/metrics-live-activity-action.png) Live Activities can include an action button. - `open_url`: Open a web page or run an iOS Shortcut - `webhook`: Trigger a backend GET/POST workflow #### Open URL action Open a web page or run an iOS Shortcut when someone taps the button. Supported links: - **HTTP/HTTPS:** Web pages, e.g. `https://example.com` - **Shortcuts:** Run Jarvis with `shortcuts://run-shortcut?name=Jarvis` ```ts await activitysmith.liveActivities.stream("prod-web-1", { content_state: { title: "Server Health", subtitle: "prod-web-1", type: "metrics", metrics: [ { label: "CPU", value: 76, unit: "%" }, { label: "MEM", value: 52, unit: "%" }, ], }, action: { title: "Dashboard", type: "open_url", url: "https://status.example.com/servers/prod-web-1", }, }); ``` #### Apple Shortcut action ```ts await activitysmith.liveActivities.stream("prod-web-1", { content_state: { title: "Server Health", subtitle: "prod-web-1", type: "metrics", metrics: [ { label: "CPU", value: 76, unit: "%" }, { label: "MEM", value: 52, unit: "%" }, ], }, action: { title: "Chat with Jarvis", type: "open_url", url: "shortcuts://run-shortcut?name=Jarvis", }, }); ``` #### Webhook action ```ts await activitysmith.liveActivities.stream("search-reindex", { content_state: { title: "Reindexing product search", subtitle: "Shard 7 of 12", type: "segmented_progress", number_of_steps: 12, current_step: 7, }, action: { title: "Pause Reindex", type: "webhook", url: "https://ops.example.com/hooks/search/reindex/pause", method: "POST", body: { job_id: "reindex-2026-03-19", requested_by: "activitysmith-node", }, }, }); ``` #### Secondary action ![Alert Live Activity with primary and secondary action buttons](https://cdn.activitysmith.com/features/live-activity-secondary-action.png) Use `secondary_action` when you want a second button beside the primary `action`. The secondary action button is supported for `value`, `alert`, `segmented_progress`, and `progress` Live Activities. Both buttons use the same `open_url`, `webhook`, and Apple Shortcut payload shapes. ```ts await activitysmith.liveActivities.stream("agent-approval", { content_state: { title: "Approval Needed", message: "Should I send the follow-up email to Brightlane?", type: "alert", color: "green", icon: { symbol: "sparkles", color: "green", }, badge: { title: "Agent", color: "green", }, }, action: { title: "Send", type: "webhook", url: "https://agent.example.com/live-activity/approve", method: "POST", body: { approval_id: "approval_01JY3J7Q9S0P8M1V5PZK7DR4M2", decision: "send", }, }, secondary_action: { title: "Deny", type: "webhook", url: "https://agent.example.com/live-activity/deny", method: "POST", body: { approval_id: "approval_01JY3J7Q9S0P8M1V5PZK7DR4M2", decision: "deny", }, }, }); ``` ## Lock Screen Widgets ![Lock screen widgets](https://cdn.activitysmith.com/features/lock-screen-widgets.png) ActivitySmith lets you display any value on your Lock Screen with widgets - SaaS metrics, revenue, signups, uptime, habits, or anything else you want to track. Send a value to a metric key, add a widget to your Lock Screen, and it fetches the latest value automatically. Use the metric key to update its value. The first value creates the metric. ```ts await activitysmith.metrics.update("deploy.success_rate", 99.9); ``` String metric values work too. ```ts await activitysmith.metrics.update("prod.status", "healthy"); ``` ### Create a metric Use `create` to set the label and how widgets show the value, such as currency, percent, or a unit. Omitted fields keep their current values, so you can call it every time your app starts. ```ts await activitysmith.metrics.create("mrr", { label: "MRR", format: "currency", currency_code: "USD", }); await activitysmith.metrics.update("mrr", 12450); ``` You can also create and edit metrics in the [web app](https://activitysmith.com/app/widgets). ![Create widget metric](https://cdn.activitysmith.com/features/create-widget-metric.png) ## App Icon Badge ![ActivitySmith app icon with an App Icon Badge](https://cdn.activitysmith.com/features/badge-count.png) Show the number you care about on your ActivitySmith app icon. Track MRR, a customer count, a stock price, or any other value you want to keep in view. App Icon Badge requires Push Notifications enabled. On your iPhone, open Settings > ActivitySmith > Notifications and turn on Allow Notifications. ### Set or update the badge value ```js Node await activitysmith.badgeCount(8333); ``` ### Clear the badge Pass `0` to clear the badge. ```js Node await activitysmith.badgeCount(0); ``` ## Metadata Metadata adds extra information to Push Notification and Live Activity details in ActivitySmith. It does not appear in the notification or Live Activity on your device. ```js Node await activitysmith.notifications.send({ title: "New subscription 💸", message: "Customer upgraded to Pro plan", metadata: { customer_id: "382", plan: "Pro", amount: 29, trial: false, }, }); await activitysmith.liveActivities.stream("customer-import", { content_state: { title: "Customer Import", type: "progress", percentage: 60, }, metadata: { job_id: "import-382", records: 1200, }, }); ``` Values can be strings, numbers, or booleans. Metadata supports up to 50 entries and 16 KB of JSON, with keys up to 100 characters and strings up to 4,000 characters. Nested objects, arrays, and null values are not supported. ## Tags Use `tags` to organize and filter your Push Notification and Live Activity history. Tags are created automatically when you first use them. ```js Node await activitysmith.notifications.send({ title: "New subscription 💸", message: "Customer upgraded to Pro plan", tags: ["user:382", "billing"], }); ``` On Live Activity stream updates and legacy `update` or `end` calls, omit `tags` to keep existing Tags, supply a list to replace them, or pass `tags: []` to clear them. ```js Node await activitysmith.liveActivities.update({ activity_id: "YOUR_ACTIVITY_ID", content_state: { title: "Customer Import", percentage: 60 }, tags: [], }); ``` ## Channels Use `channels` to target specific team members or devices when sending Push Notifications, Live Activities, or App Icon Badge updates. Omit it for account-wide delivery. ```js Node await activitysmith.notifications.send({ title: "New subscription 💸", message: "Customer upgraded to Pro plan", channels: ["sales", "customer-success"], }); await activitysmith.liveActivities.stream("nightly-backup", { content_state: { title: "Nightly database backup", number_of_steps: 3, current_step: 1, type: "segmented_progress", }, channels: ["ios-builds"], }); await activitysmith.badgeCount(3, { channels: ["sales", "customer-success"], }); ``` ## Paired Devices List the iPhones and iPads paired to your account, for example to check that a device is paired before you send. Active devices come first: ```js Node const { devices } = await activitysmith.devices.list(); for (const device of devices) { console.log(device.device_name, device.system_name, device.is_active); } ``` An empty list means no device is paired. Install ActivitySmith on your iPhone, sign in with the same account, and allow notifications. Channel-scoped API keys cannot list devices. Pass `includeInactive` to also list devices that can no longer receive deliveries: ```js Node await activitysmith.devices.list({ includeInactive: true }); ``` ## Error Handling SDK calls return promises, so you can wrap API calls with `try/catch`: ```js Node try { await activitysmith.notifications.send({ title: "Hello" }); } catch (error) { console.error(error); } ``` ## Additional Resources ### [NPM Package](https://www.npmjs.com/package/activitysmith) Install the ActivitySmith Node.js SDK from npm ### [Source Code](https://github.com/ActivitySmithHQ/activitysmith-node) View the Node.js SDK source on GitHub --- Source: https://activitysmith.com/docs/sdks/python # Python Use the ActivitySmith Python SDK to send Push Notifications and Live Activity progress updates from Python scripts, jobs, and backend services. ## Installation Install the ActivitySmith Python SDK with pip: ```bash pip install activitysmith ``` ## Quickstart 1. [Create an API key](https://activitysmith.com/app/keys) 2. Set `ACTIVITYSMITH_API_KEY` or pass it directly to `ActivitySmith`. ```python Python import os from activitysmith import ( ActivitySmith, action, alert_badge, alert_icon, content_state, metric, ) activitysmith = ActivitySmith(api_key=os.environ["ACTIVITYSMITH_API_KEY"]) ``` ## Push Notifications ### Send a Push Notification Send an immediate notification for a completed task or event. ![Push Notification example for a new subscription event](https://cdn.activitysmith.com/features/new-subscription-push-notification.png) ```python Python activitysmith.notifications.send( title="New subscription 💸", message="Customer upgraded to Pro plan", ) ``` ### Custom Push Notification Icons ![Push Notifications with custom icons](https://cdn.activitysmith.com/features/push-notifications-with-custom-icons.png) Set `icon` to a publicly accessible HTTPS image URL to show a logo or avatar alongside a smaller ActivitySmith app icon. Host the image anywhere, such as on your own website or CDN. With a custom icon, iOS may omit the subtitle from the notification. ```python Python activitysmith.notifications.send( title="MRR just crossed $10,000 🎉", message="Up 18% this month from 31 new subscriptions.", icon="https://example.com/icons/stripe.png", ) ``` ### Rich Push Notifications with Media ![Rich Push Notification with image](https://cdn.activitysmith.com/features/rich-push-notification-with-image.png) ```python Python activitysmith.notifications.send( title="Homepage ready", message="Your agent finished the redesign.", media="https://cdn.example.com/output/homepage-v2.png", ) ``` Attach images, videos, or audio to your Push Notifications. Press and hold the notification to preview the media. ![Rich Push Notification with audio](https://cdn.activitysmith.com/features/rich-push-notification-with-audio.png) What will work: - direct image URL: `.jpg`, `.png`, `.gif`, etc. - direct audio file URL: `.mp3`, `.m4a`, etc. - direct video file URL: `.mp4`, `.mov`, etc. - URL that responds with a proper media `Content-Type`, even if the path has no extension `media` cannot be combined with `actions`. ### Push Notifications with Redirection Open a web page, run an iOS Shortcut, or open an app when someone taps the notification. `redirection` supports: - **HTTP/HTTPS:** Web pages, e.g. `https://example.com` - **Shortcuts:** Run Jarvis with `shortcuts://run-shortcut?name=Jarvis` - **App deep links:** Installed apps or specific content within them - **Spotify:** A track, e.g. `spotify:track:6rqhFgbbKwnb9MLmUQDhG6` - **Termius:** `termius://` to open the app - **Claude:** `claude://code` to open the Code tab - **ChatGPT:** `chatgpt://` to open the app ```python Python activitysmith.notifications.send( title="Homepage ready", message="Your agent finished the redesign.", redirection="https://github.com/acme/web/pull/482", ) ``` ### Actionable Push Notifications ![Actionable Push Notification with redirection and actions](https://cdn.activitysmith.com/features/actionable-push-notifications-2.png) `open_url` actions open a web page, run an iOS Shortcut, or open an app when someone taps the button. Supported links: - **HTTP/HTTPS:** Web pages, e.g. `https://example.com` - **Shortcuts:** Run Jarvis with `shortcuts://run-shortcut?name=Jarvis` - **App deep links:** Installed apps or specific content within them - **Spotify:** A track, e.g. `spotify:track:6rqhFgbbKwnb9MLmUQDhG6` - **Termius:** `termius://` to open the app - **Claude:** `claude://code` to open the Code tab - **ChatGPT:** `chatgpt://` to open the app Webhooks are executed by the ActivitySmith backend and must use HTTPS. ```python Python activitysmith.notifications.send( title="New subscription 💸", message="Customer upgraded to Pro plan", actions=[ action( title="Open CRM", type="open_url", url="https://crm.example.com/customers/cus_9f3a1d", ), action( title="Chat with Jarvis", type="open_url", url="shortcuts://run-shortcut?name=Jarvis", ), action( title="Start Onboarding Workflow", type="webhook", url="https://hooks.example.com/activitysmith/onboarding/start", method="POST", body={ "customer_id": "cus_9f3a1d", "plan": "pro", }, ), ], ) ``` ### Interruption Levels ![Time Sensitive Push Notification](https://cdn.activitysmith.com/features/time-sensitive-push-notifications.png) Use `interruption_level` to choose how urgently iOS presents a Push Notification. Omit it for normal delivery. Explicit `active` has the same behavior as the default. | Value | Behavior | | --- | --- | | `passive` | Appears quietly in the notification list, without sound or waking the screen. | | `active` | Normal delivery, subject to the device's notification settings and Focus. This is the default. | | `time-sensitive` | Can bypass Scheduled Summary and Focus when the user allows Time Sensitive Notifications for ActivitySmith. | See Apple's [interruption levels](https://developer.apple.com/documentation/usernotifications/unnotificationinterruptionlevel) for the system behavior. The SDK also exports these values as `PushInterruptionLevel.PASSIVE`, `PushInterruptionLevel.ACTIVE`, and `PushInterruptionLevel.TIME_SENSITIVE`. #### Passive ```python Python activitysmith.notifications.send( title="Daily summary", message="All scheduled jobs completed successfully.", interruption_level="passive", ) ``` #### Active (default) ```python Python activitysmith.notifications.send( title="Deployment complete", message="Your latest changes are live.", interruption_level="active", ) ``` Removing the interruption level from this example produces the same delivery behavior. #### Time Sensitive ```python Python activitysmith.notifications.send( title="🚨 checkout-api is down", message="500 errors on 62% of requests. Customers can't complete payments.", interruption_level="time-sensitive", ) ``` ### Replace a Push Notification Every send returns a `notification_id`. Pass it to `replace` to update a Push Notification you already sent, for example when an incident you alerted on is resolved. The replacement takes the old notification's place on the Lock Screen and in history instead of stacking a second one. It arrives silently, without sound or waking the screen, and goes to the same recipients as the original. Omit `metadata` or `tags` to keep their stored values. ```python Python sent = activitysmith.notifications.send( title="🚨 checkout-api is down", message="500 errors on 62% of requests.", ) activitysmith.notifications.replace( sent.notification_id, title="✅ checkout-api recovered", message="Error rate is back to normal. Incident resolved.", ) ``` ### Dismiss a Push Notification Pass the `notification_id` to `dismiss` when a Push Notification no longer needs attention, for example after you answered an agent's question somewhere else. Dismissing clears it from the Lock Screen and Notification Center on every device it was sent to. History keeps it. Devices clear the notification in the background, so it can take a moment. ```python Python sent = activitysmith.notifications.send( title="🙋 Agent needs your input", message="Approve the database migration?", ) activitysmith.notifications.dismiss(sent.notification_id) ``` ## Live Activities Choose the Live Activity type that matches what you want to show: - ![Value Live Activity showing revenue with a growth badge](https://cdn.activitysmith.com/features/value-live-activity.png) **Value**: Show a single value on your Lock Screen, such as revenue, a queue count, or a temperature. - ![Stats Live Activity with six labeled sales metrics](https://cdn.activitysmith.com/features/stats-live-activity.png) **Stats**: Show up to 8 labeled values on your Lock Screen, from revenue and orders to uptime and conversion. - ![Alert Live Activity showing a customer reactivation update](https://cdn.activitysmith.com/features/alert-live-activity.png) **Alert**: Show status updates with a clear message, badge, and icon. When you add an action button, `color` controls the button tint. - ![Metrics Live Activity with CPU and memory values](https://cdn.activitysmith.com/features/metrics-live-activity-start.png) **Metrics**: Track two related values with segmented bars, such as CPU and memory. - ![Segmented Progress Live Activity showing a workflow step](https://cdn.activitysmith.com/features/update-live-activity.png) **Segmented Progress**: Show progress through a known set of steps, like build, test, deploy, and verify. - ![Progress Live Activity showing percentage completion](https://cdn.activitysmith.com/features/progress-live-activity.png) **Progress**: Show percentage progress for jobs that move continuously toward completion. - ![Timer Live Activity showing a benchmark run countdown](https://cdn.activitysmith.com/features/timer-live-activity.png) **Timer**: Count down from a duration, or count up from 00:00 while a job runs. ### Start & Update Live Activity Use a stable `stream_key` to identify the metric, job, deployment, or system you want to keep visible. The first `stream(...)` call starts the Live Activity. Later calls with the same `stream_key` update it. > [!WARNING] > iOS limits how often a Live Activity can update. Short bursts that end, like deployment steps, are fine. If one Live Activity keeps updating more often than every couple of minutes, iOS throttles it until the budget refills, roughly an hour, even though the API still returns `200`. [Learn more](/docs/live-activity-stream#update-frequency-and-ios-limits) #### Value ![Value Live Activity stream example](https://cdn.activitysmith.com/features/value-live-activity.png) ```python activitysmith.live_activities.stream( "revenue-today", content_state=content_state( title="Revenue", type="value", value="$1,240", color="green", icon=alert_icon("dollarsign.circle", color="green"), badge=alert_badge("↑ 18%", color="purple"), ), ) ``` Send a string or number in `value`. Strings keep their formatting, including currency symbols, units, and decimal places. #### Stats ![Stats Live Activity stream example](https://cdn.activitysmith.com/features/stats-live-activity.png) ```python activitysmith.live_activities.stream( "sales-hourly", content_state=content_state( title="Sales", subtitle="last hour", type="stats", metrics=[ metric(label="Revenue", value="$2430", color="blue"), metric(label="Orders", value="37", color="green"), metric(label="Conversion", value="4.8%", color="magenta"), metric(label="Avg Order", value="$65.68", color="yellow"), metric(label="Refunds", value="$84", color="red"), metric(label="New Buyers", value="18", color="cyan"), ], ), ) ``` #### Alert ![Alert Live Activity stream example](https://cdn.activitysmith.com/features/alert-live-activity.png) ```python activitysmith.live_activities.stream( "customer-ops", content_state=content_state( title="Reactivation", message="Lumen came back after 2 weeks", type="alert", icon=alert_icon("cloud.sun", color="yellow"), badge=alert_badge("Customer", color="magenta"), ), ) ``` #### Metrics ![Metrics Live Activity stream example](https://cdn.activitysmith.com/features/metrics-live-activity-start.png) ```python activitysmith.live_activities.stream( "prod-web-1", content_state=content_state( title="Server Health", subtitle="prod-web-1", type="metrics", metrics=[ metric(label="CPU", value=9, unit="%"), metric(label="MEM", value=45, unit="%"), ], ), ) ``` #### Segmented Progress ![Segmented Progress Live Activity stream example](https://cdn.activitysmith.com/features/update-live-activity.png) ```python activitysmith.live_activities.stream( "nightly-backup", content_state=content_state( title="Nightly Backup", subtitle="upload archive", type="segmented_progress", number_of_steps=3, current_step=2, ), ) ``` #### Progress ![Progress Live Activity stream example](https://cdn.activitysmith.com/features/progress-live-activity.png) ```python activitysmith.live_activities.stream( "search-reindex", content_state=content_state( title="Search Reindex", subtitle="catalog-v2", type="progress", percentage=42, ), ) ``` #### Timer ![Timer Live Activity stream example](https://cdn.activitysmith.com/features/timer-live-activity.png) ```python activitysmith.live_activities.stream( "benchmark-run", content_state=content_state( title="Benchmark Run", subtitle="sampling", type="timer", duration_seconds=300, color="cyan", ), ) ``` For a countdown, send `duration_seconds`. You can update `title`, `subtitle`, `color`, or any other visible field as the work changes. Leave `duration_seconds` out unless you want to change the timer. To start at 00:00 and count up, set `counts_down=False` and leave out `duration_seconds`. ### End Live Activity Call `end_stream(...)` with the same `stream_key` to dismiss the Live Activity. You can include final values before it is removed. Set `auto_dismiss_seconds` to dismiss it after a delay in seconds, or `auto_dismiss_minutes` for minutes. Use `0` for immediate dismissal. Seconds take precedence if both are set. ```python activitysmith.live_activities.end_stream( "prod-web-1", content_state=content_state( title="Server Health", subtitle="prod-web-1", type="metrics", metrics=[ metric(label="CPU", value=7, unit="%"), metric(label="MEM", value=38, unit="%"), ], auto_dismiss_seconds=30, ), ) ``` ### Icons and Badges Add more context to Live Activities with icons and badges. #### Icon Supported Live Activity types: `value`, `stats`, `alert`, `metrics`, `segmented_progress`, `progress`, and `timer`. ![Metrics Live Activity with an SF Symbol icon on the iPhone Lock Screen](https://cdn.activitysmith.com/features/metrics-live-activity-with-icon.png) ```python activitysmith.live_activities.stream( "prod-web-1", content_state=content_state( title="Server Health", subtitle="prod-web-1", type=activitysmith.live_activities.TYPE_METRICS, icon=alert_icon("server.rack", color="blue"), metrics=[ metric(label="CPU", value=18, unit="%"), metric(label="MEM", value=42, unit="%"), ], ), ) ``` The `icon.symbol` value is an Apple SF Symbol name. Browse the catalog with one of these tools: - [ActivitySmith app](https://apps.apple.com/us/app/activitysmith/id6752254835) - Open Settings -> SF Symbols to browse 45 hand-picked icons ready to use - [SF Symbols](https://developer.apple.com/sf-symbols/) - Apple's official macOS app - [Interactful](https://apps.apple.com/app/interactful/id1528095640) - free third-party iOS app listing all SF Symbols under Foundations -> Iconography #### Badge Badges are supported by `value`, `alert`, `segmented_progress`, and `progress` Live Activities. ![Progress Live Activity with a badge on the iPhone Lock Screen](https://cdn.activitysmith.com/features/progress-live-activity-with-badge.png) ```python activitysmith.live_activities.stream( "nightly-database-backup", content_state=content_state( title="Nightly Database Backup", subtitle="verify restore", type=activitysmith.live_activities.TYPE_PROGRESS, badge=alert_badge("S3", color="cyan"), percentage=62, ), ) ``` ### Colors Choose from these colors for the Live Activity accent, including progress bars and action buttons, or apply them to an individual icon or badge: `lime`, `green`, `cyan`, `blue`, `purple`, `magenta`, `red`, `orange`, `yellow`, `gray` ### Actions ![Metrics Live Activity with action](https://cdn.activitysmith.com/features/metrics-live-activity-action.png) Live Activities can include an action button. - `open_url`: Open a web page or run an iOS Shortcut - `webhook`: Trigger a backend GET/POST workflow #### Open URL action Open a web page or run an iOS Shortcut when someone taps the button. Supported links: - **HTTP/HTTPS:** Web pages, e.g. `https://example.com` - **Shortcuts:** Run Jarvis with `shortcuts://run-shortcut?name=Jarvis` ```python activitysmith.live_activities.stream( "prod-web-1", content_state=content_state( title="Server Health", subtitle="prod-web-1", type="metrics", metrics=[ metric(label="CPU", value=76, unit="%"), metric(label="MEM", value=52, unit="%"), ], ), action=action( title="Dashboard", type="open_url", url="https://status.example.com/servers/prod-web-1", ), ) ``` #### Apple Shortcut action ```python activitysmith.live_activities.stream( "prod-web-1", content_state=content_state( title="Server Health", subtitle="prod-web-1", type="metrics", metrics=[ metric(label="CPU", value=76, unit="%"), metric(label="MEM", value=52, unit="%"), ], ), action=action( title="Chat with Jarvis", type="open_url", url="shortcuts://run-shortcut?name=Jarvis", ), ) ``` #### Webhook action ```python activitysmith.live_activities.stream( "search-reindex", content_state=content_state( title="Reindexing product search", subtitle="Shard 7 of 12", type="segmented_progress", number_of_steps=12, current_step=7, ), action=action( title="Pause Reindex", type="webhook", url="https://ops.example.com/hooks/search/reindex/pause", method="POST", body={ "job_id": "reindex-2026-03-19", "requested_by": "activitysmith-python", }, ), ) ``` #### Secondary action ![Alert Live Activity with primary and secondary action buttons](https://cdn.activitysmith.com/features/live-activity-secondary-action.png) Use `secondary_action` when you want a second button beside the primary `action`. The secondary action button is supported for `value`, `alert`, `segmented_progress`, and `progress` Live Activities. Both buttons use the same `open_url`, `webhook`, and Apple Shortcut payload shapes. ```python activitysmith.live_activities.stream( "agent-approval", content_state=content_state( title="Approval Needed", message="Should I send the follow-up email to Brightlane?", type="alert", color="green", icon=alert_icon("sparkles", color="green"), badge=alert_badge("Agent", color="green"), ), action=action( title="Send", type="webhook", url="https://agent.example.com/live-activity/approve", method="POST", body={ "approval_id": "approval_01JY3J7Q9S0P8M1V5PZK7DR4M2", "decision": "send", }, ), secondary_action=action( title="Deny", type="webhook", url="https://agent.example.com/live-activity/deny", method="POST", body={ "approval_id": "approval_01JY3J7Q9S0P8M1V5PZK7DR4M2", "decision": "deny", }, ), ) ``` ## Lock Screen Widgets ![Lock screen widgets](https://cdn.activitysmith.com/features/lock-screen-widgets.png) ActivitySmith lets you display any value on your Lock Screen with widgets - SaaS metrics, revenue, signups, uptime, habits, or anything else you want to track. Send a value to a metric key, add a widget to your Lock Screen, and it fetches the latest value automatically. Use the metric key to update its value. The first value creates the metric. ```python activitysmith.metrics.update("deploy.success_rate", 99.9) ``` String metric values work too. ```python activitysmith.metrics.update("prod.status", "healthy") ``` ### Create a metric Use `create` to set the label and how widgets show the value, such as currency, percent, or a unit. Omitted fields keep their current values, so you can call it every time your app starts. ```python activitysmith.metrics.create( "mrr", label="MRR", format="currency", currency_code="USD", ) activitysmith.metrics.update("mrr", 12450) ``` You can also create and edit metrics in the [web app](https://activitysmith.com/app/widgets). ![Create widget metric](https://cdn.activitysmith.com/features/create-widget-metric.png) ## App Icon Badge ![ActivitySmith app icon with an App Icon Badge](https://cdn.activitysmith.com/features/badge-count.png) Show the number you care about on your ActivitySmith app icon. Track MRR, a customer count, a stock price, or any other value you want to keep in view. App Icon Badge requires Push Notifications enabled. On your iPhone, open Settings > ActivitySmith > Notifications and turn on Allow Notifications. ### Set or update the badge value ```python Python activitysmith.badge_count(8333) ``` ### Clear the badge Pass `0` to clear the badge. ```python Python activitysmith.badge_count(0) ``` ## Metadata Metadata adds extra information to Push Notification and Live Activity details in ActivitySmith. It does not appear in the notification or Live Activity on your device. ```python Python activitysmith.notifications.send( title="New subscription 💸", message="Customer upgraded to Pro plan", metadata={ "customer_id": "382", "plan": "Pro", "amount": 29, "trial": False, }, ) activitysmith.live_activities.stream( "customer-import", title="Customer Import", type="progress", percentage=60, metadata={ "job_id": "import-382", "records": 1200, }, ) ``` Values can be strings, numbers, or booleans. Metadata supports up to 50 entries and 16 KB of JSON, with keys up to 100 characters and strings up to 4,000 characters. Nested objects, arrays, and null values are not supported. ## Tags Use Tags to organize and filter Push Notification and Live Activity history. Tags are created automatically when you first use them. Sending Tags requires SDK version 1.10.0 or later. ```python activitysmith.notifications.send( title="New subscription 💸", message="Customer upgraded to Pro plan", tags=["user:382", "billing"], ) ``` On Live Activity stream updates and legacy `update` or `end` calls, omit `tags` to keep existing Tags, supply a list to replace them, or pass `tags=[]` to clear them. ```python Python activitysmith.live_activities.update( activity_id="YOUR_ACTIVITY_ID", title="Customer Import", percentage=60, tags=[], ) ``` ## Channels Use `channels` to target specific team members or devices when sending Push Notifications, Live Activities, or App Icon Badge updates. Omit it for account-wide delivery. ```python Python activitysmith.notifications.send( title="New subscription 💸", message="Customer upgraded to Pro plan", channels=["sales", "customer-success"], ) activitysmith.live_activities.stream( "nightly-backup", content_state=content_state( title="Nightly database backup", type="segmented_progress", number_of_steps=3, current_step=1, ), channels=["ios-builds"], ) activitysmith.badge_count(3, channels=["sales", "customer-success"]) ``` ## Paired Devices List the iPhones and iPads paired to your account, for example to check that a device is paired before you send. Active devices come first: ```python Python result = activitysmith.devices.list() for device in result.devices: print(device.device_name, device.system_name, device.is_active) ``` An empty list means no device is paired. Install ActivitySmith on your iPhone, sign in with the same account, and allow notifications. Channel-scoped API keys cannot list devices. Pass `include_inactive` to also list devices that can no longer receive deliveries: ```python Python activitysmith.devices.list(include_inactive=True) ``` ## Error Handling Wrap API calls with `try/except`. The SDK raises exceptions for non-2xx responses. Rate limit errors use the `error` and `message` fields, and Live Activity limit errors include `limit` and `active`. See [Rate Limits](/docs/rate-limits) for details. ## Additional Resources ### [PyPI Package](https://pypi.org/project/activitysmith/) Install the ActivitySmith Python SDK from PyPI ### [Source Code](https://github.com/ActivitySmithHQ/activitysmith-python) View the Python SDK source on GitHub --- Source: https://activitysmith.com/docs/sdks/go # Go Use the ActivitySmith Go SDK to send Push Notifications and Live Activity progress updates from Go services, workers, and automation jobs. ## Installation Install the ActivitySmith Go SDK with `go get`: ```bash go get github.com/ActivitySmithHQ/activitysmith-go ``` ## Quickstart 1. [Create an API key](https://activitysmith.com/app/keys) 2. Pass the API key into `activitysmithsdk.New`. ```go Go package main import ( "os" activitysmithsdk "github.com/ActivitySmithHQ/activitysmith-go" ) func main() { activitysmith, _ := activitysmithsdk.New(os.Getenv("ACTIVITYSMITH_API_KEY")) } ``` ## Push Notifications ### Send a Push Notification Send an immediate notification for a completed task or event. ![Push Notification example for a new subscription event](https://cdn.activitysmith.com/features/new-subscription-push-notification.png) ```go Go input := activitysmithsdk.PushNotificationInput{ Title: "New subscription 💸", Message: "Customer upgraded to Pro plan", } activitysmith.Notifications.Send(input) ``` ### Custom Push Notification Icons ![Push Notifications with custom icons](https://cdn.activitysmith.com/features/push-notifications-with-custom-icons.png) Set `Icon` to a publicly accessible HTTPS image URL to show a logo or avatar alongside a smaller ActivitySmith app icon. Host the image anywhere, such as on your own website or CDN. With a custom icon, iOS may omit the subtitle from the notification. ```go Go input := activitysmithsdk.PushNotificationInput{ Title: "MRR just crossed $10,000 🎉", Message: "Up 18% this month from 31 new subscriptions.", Icon: "https://example.com/icons/stripe.png", } activitysmith.Notifications.Send(input) ``` ### Rich Push Notifications with Media ![Rich Push Notification with image](https://cdn.activitysmith.com/features/rich-push-notification-with-image.png) ```go Go input := activitysmithsdk.PushNotificationInput{ Title: "Homepage ready", Message: "Your agent finished the redesign.", Media: "https://cdn.example.com/output/homepage-v2.png", } activitysmith.Notifications.Send(input) ``` Attach images, videos, or audio to your Push Notifications. Press and hold the notification to preview the media. ![Rich Push Notification with audio](https://cdn.activitysmith.com/features/rich-push-notification-with-audio.png) What will work: - direct image URL: `.jpg`, `.png`, `.gif`, etc. - direct audio file URL: `.mp3`, `.m4a`, etc. - direct video file URL: `.mp4`, `.mov`, etc. - URL that responds with a proper media `Content-Type`, even if the path has no extension `Media` cannot be combined with `Actions`. ### Push Notifications with Redirection Open a web page, run an iOS Shortcut, or open an app when someone taps the notification. `Redirection` supports: - **HTTP/HTTPS:** Web pages, e.g. `https://example.com` - **Shortcuts:** Run Jarvis with `shortcuts://run-shortcut?name=Jarvis` - **App deep links:** Installed apps or specific content within them - **Spotify:** A track, e.g. `spotify:track:6rqhFgbbKwnb9MLmUQDhG6` - **Termius:** `termius://` to open the app - **Claude:** `claude://code` to open the Code tab - **ChatGPT:** `chatgpt://` to open the app ```go Go input := activitysmithsdk.PushNotificationInput{ Title: "Homepage ready", Message: "Your agent finished the redesign.", Redirection: "https://github.com/acme/web/pull/482", } activitysmith.Notifications.Send(input) ``` ### Actionable Push Notifications ![Actionable Push Notification with redirection and actions](https://cdn.activitysmith.com/features/actionable-push-notifications-2.png) `open_url` actions open a web page, run an iOS Shortcut, or open an app when someone taps the button. Supported links: - **HTTP/HTTPS:** Web pages, e.g. `https://example.com` - **Shortcuts:** Run Jarvis with `shortcuts://run-shortcut?name=Jarvis` - **App deep links:** Installed apps or specific content within them - **Spotify:** A track, e.g. `spotify:track:6rqhFgbbKwnb9MLmUQDhG6` - **Termius:** `termius://` to open the app - **Claude:** `claude://code` to open the Code tab - **ChatGPT:** `chatgpt://` to open the app Webhooks are executed by the ActivitySmith backend and must use HTTPS. ```go Go input := activitysmithsdk.PushNotificationInput{ Title: "New subscription 💸", Message: "Customer upgraded to Pro plan", Actions: []activitysmithsdk.PushNotificationAction{ activitysmithsdk.PushAction( "Open CRM", "open_url", "https://crm.example.com/customers/cus_9f3a1d", ), activitysmithsdk.PushAction( "Chat with Jarvis", "open_url", "shortcuts://run-shortcut?name=Jarvis", ), activitysmithsdk.PushAction( "Start Onboarding Workflow", "webhook", "https://hooks.example.com/activitysmith/onboarding/start", activitysmithsdk.PushActionMethod("POST"), activitysmithsdk.PushActionBody(map[string]interface{}{ "customer_id": "cus_9f3a1d", "plan": "pro", }), ), }, } activitysmith.Notifications.Send(input) ``` ### Interruption Levels ![Time Sensitive Push Notification](https://cdn.activitysmith.com/features/time-sensitive-push-notifications.png) Use `InterruptionLevel` to choose how urgently iOS presents a Push Notification. Omit it for normal delivery. Explicit `active` has the same behavior as the default. | Value | Behavior | | --- | --- | | `passive` | Appears quietly in the notification list, without sound or waking the screen. | | `active` | Normal delivery, subject to the device's notification settings and Focus. This is the default. | | `time-sensitive` | Can bypass Scheduled Summary and Focus when the user allows Time Sensitive Notifications for ActivitySmith. | See Apple's [interruption levels](https://developer.apple.com/documentation/usernotifications/unnotificationinterruptionlevel) for the system behavior. The SDK also exports these values as `activitysmithsdk.PushInterruptionLevelPassive`, `activitysmithsdk.PushInterruptionLevelActive`, and `activitysmithsdk.PushInterruptionLevelTimeSensitive`. #### Passive ```go Go input := activitysmithsdk.PushNotificationInput{ Title: "Daily summary", Message: "All scheduled jobs completed successfully.", InterruptionLevel: "passive", } activitysmith.Notifications.Send(input) ``` #### Active (default) ```go Go input := activitysmithsdk.PushNotificationInput{ Title: "Deployment complete", Message: "Your latest changes are live.", InterruptionLevel: "active", } activitysmith.Notifications.Send(input) ``` Removing the interruption level from this example produces the same delivery behavior. #### Time Sensitive ```go Go input := activitysmithsdk.PushNotificationInput{ Title: "🚨 checkout-api is down", Message: "500 errors on 62% of requests. Customers can't complete payments.", InterruptionLevel: "time-sensitive", } activitysmith.Notifications.Send(input) ``` ### Replace a Push Notification Every send returns a `notification_id`. Pass it to `replace` to update a Push Notification you already sent, for example when an incident you alerted on is resolved. The replacement takes the old notification's place on the Lock Screen and in history instead of stacking a second one. It arrives silently, without sound or waking the screen, and goes to the same recipients as the original. Omit `metadata` or `tags` to keep their stored values. ```go Go sent, err := activitysmith.Notifications.Send(activitysmithsdk.PushNotificationInput{ Title: "🚨 checkout-api is down", Message: "500 errors on 62% of requests.", }) if err != nil { log.Fatal(err) } _, err = activitysmith.Notifications.Replace(sent.GetNotificationId(), activitysmithsdk.PushNotificationReplaceInput{ Title: "✅ checkout-api recovered", Message: "Error rate is back to normal. Incident resolved.", }) ``` ### Dismiss a Push Notification Pass the `notification_id` to `dismiss` when a Push Notification no longer needs attention, for example after you answered an agent's question somewhere else. Dismissing clears it from the Lock Screen and Notification Center on every device it was sent to. History keeps it. Devices clear the notification in the background, so it can take a moment. ```go Go sent, err := activitysmith.Notifications.Send(activitysmithsdk.PushNotificationInput{ Title: "🙋 Agent needs your input", Message: "Approve the database migration?", }) if err != nil { log.Fatal(err) } _, err = activitysmith.Notifications.Dismiss(sent.GetNotificationId()) ``` ## Live Activities Choose the Live Activity type that matches what you want to show: - ![Value Live Activity showing revenue with a growth badge](https://cdn.activitysmith.com/features/value-live-activity.png) **Value**: Show a single value on your Lock Screen, such as revenue, a queue count, or a temperature. - ![Stats Live Activity with six labeled sales metrics](https://cdn.activitysmith.com/features/stats-live-activity.png) **Stats**: Show up to 8 labeled values on your Lock Screen, from revenue and orders to uptime and conversion. - ![Alert Live Activity showing a customer reactivation update](https://cdn.activitysmith.com/features/alert-live-activity.png) **Alert**: Show status updates with a clear message, badge, and icon. When you add an action button, `color` controls the button tint. - ![Metrics Live Activity with CPU and memory values](https://cdn.activitysmith.com/features/metrics-live-activity-start.png) **Metrics**: Track two related values with segmented bars, such as CPU and memory. - ![Segmented Progress Live Activity showing a workflow step](https://cdn.activitysmith.com/features/update-live-activity.png) **Segmented Progress**: Show progress through a known set of steps, like build, test, deploy, and verify. - ![Progress Live Activity showing percentage completion](https://cdn.activitysmith.com/features/progress-live-activity.png) **Progress**: Show percentage progress for jobs that move continuously toward completion. - ![Timer Live Activity showing a benchmark run countdown](https://cdn.activitysmith.com/features/timer-live-activity.png) **Timer**: Count down from a duration, or count up from 00:00 while a job runs. ### Start & Update Live Activity Use a stable `streamKey` to identify the metric, job, deployment, or system you want to keep visible. The first `Stream(...)` call starts the Live Activity. Later calls with the same `streamKey` update it. > [!WARNING] > iOS limits how often a Live Activity can update. Short bursts that end, like deployment steps, are fine. If one Live Activity keeps updating more often than every couple of minutes, iOS throttles it until the budget refills, roughly an hour, even though the API still returns `200`. [Learn more](/docs/live-activity-stream#update-frequency-and-ios-limits) #### Value ![Value Live Activity stream example](https://cdn.activitysmith.com/features/value-live-activity.png) ```go activitysmith.LiveActivities.Stream( "revenue-today", activitysmithsdk.LiveActivityStreamInput{ Title: "Revenue", Type: "value", Value: "$1,240", Color: "green", Icon: activitysmithsdk.AlertIcon("dollarsign.circle", "green"), Badge: activitysmithsdk.AlertBadge("↑ 18%", "purple"), }, ) ``` Send a string or number in `value`. Strings keep their formatting, including currency symbols, units, and decimal places. #### Stats ![Stats Live Activity stream example](https://cdn.activitysmith.com/features/stats-live-activity.png) ```go activitysmith.LiveActivities.Stream( "sales-hourly", activitysmithsdk.LiveActivityStreamInput{ Title: "Sales", Subtitle: "last hour", Type: "stats", Metrics: []activitysmithsdk.ActivityMetric{ activitysmithsdk.Metric("Revenue", "$2430", activitysmithsdk.MetricColor("blue")), activitysmithsdk.Metric("Orders", "37", activitysmithsdk.MetricColor("green")), activitysmithsdk.Metric("Conversion", "4.8%", activitysmithsdk.MetricColor("magenta")), activitysmithsdk.Metric("Avg Order", "$65.68", activitysmithsdk.MetricColor("yellow")), activitysmithsdk.Metric("Refunds", "$84", activitysmithsdk.MetricColor("red")), activitysmithsdk.Metric("New Buyers", "18", activitysmithsdk.MetricColor("cyan")), }, }, ) ``` #### Alert ![Alert Live Activity stream example](https://cdn.activitysmith.com/features/alert-live-activity.png) ```go activitysmith.LiveActivities.Stream( "customer-ops", activitysmithsdk.LiveActivityStreamInput{ Title: "Reactivation", Message: "Lumen came back after 2 weeks", Type: activitysmithsdk.LiveActivityTypeAlert, Icon: activitysmithsdk.AlertIcon("cloud.sun", "yellow"), Badge: activitysmithsdk.AlertBadge("Customer", "magenta"), }, ) ``` #### Metrics ![Metrics Live Activity stream example](https://cdn.activitysmith.com/features/metrics-live-activity-start.png) ```go activitysmith.LiveActivities.Stream( "prod-web-1", activitysmithsdk.LiveActivityStreamInput{ Title: "Server Health", Subtitle: "prod-web-1", Type: "metrics", Metrics: []activitysmithsdk.ActivityMetric{ activitysmithsdk.Metric("CPU", 9, activitysmithsdk.MetricUnit("%")), activitysmithsdk.Metric("MEM", 45, activitysmithsdk.MetricUnit("%")), }, }, ) ``` #### Segmented Progress ![Segmented Progress Live Activity stream example](https://cdn.activitysmith.com/features/update-live-activity.png) ```go activitysmith.LiveActivities.Stream( "nightly-backup", activitysmithsdk.LiveActivityStreamInput{ Title: "Nightly Backup", Subtitle: "upload archive", Type: "segmented_progress", NumberOfSteps: 3, CurrentStep: 2, }, ) ``` #### Progress ![Progress Live Activity stream example](https://cdn.activitysmith.com/features/progress-live-activity.png) ```go activitysmith.LiveActivities.Stream( "search-reindex", activitysmithsdk.LiveActivityStreamInput{ Title: "Search Reindex", Subtitle: "catalog-v2", Type: "progress", Percentage: 42, }, ) ``` #### Timer ![Timer Live Activity stream example](https://cdn.activitysmith.com/features/timer-live-activity.png) ```go activitysmith.LiveActivities.Stream( "benchmark-run", activitysmithsdk.LiveActivityStreamInput{ Title: "Benchmark Run", Subtitle: "sampling", Type: "timer", DurationSeconds: 300, Color: "cyan", }, ) ``` For a countdown, send `DurationSeconds`. You can update `Title`, `Subtitle`, `Color`, or any other visible field as the work changes. Leave `DurationSeconds` out unless you want to change the timer. To start at 00:00 and count up, set `CountsDown` to `false` and leave out `DurationSeconds`. ### End Live Activity Call `EndStream(...)` with the same `streamKey` to dismiss the Live Activity. You can include final values before it is removed. Set `AutoDismissSeconds` or `AutoDismissMinutes` on `ContentState` to delay dismissal. Seconds take precedence when both are supplied. Use `WithAutoDismissSeconds(0)` or `WithAutoDismissMinutes(0)` for immediate dismissal. ```go activitysmith.LiveActivities.EndStream( "prod-web-1", activitysmithsdk.LiveActivityStreamEndInput{ ContentState: activitysmithsdk.LiveActivityContentStateInput{ Title: "Server Health", Subtitle: "prod-web-1", Type: "metrics", Metrics: []activitysmithsdk.ActivityMetric{ activitysmithsdk.Metric("CPU", 7, activitysmithsdk.MetricUnit("%")), activitysmithsdk.Metric("MEM", 38, activitysmithsdk.MetricUnit("%")), }, AutoDismissSeconds: 30, }, }, ) ``` ### Icons and Badges Add more context to Live Activities with icons and badges. #### Icon Supported Live Activity types: `value`, `stats`, `alert`, `metrics`, `segmented_progress`, `progress`, and `timer`. ![Metrics Live Activity with an SF Symbol icon on the iPhone Lock Screen](https://cdn.activitysmith.com/features/metrics-live-activity-with-icon.png) ```go activitysmith.LiveActivities.Stream( "prod-web-1", activitysmithsdk.LiveActivityStreamInput{ Title: "Server Health", Subtitle: "prod-web-1", Type: "metrics", Icon: activitysmithsdk.AlertIcon("server.rack", "blue"), Metrics: []activitysmithsdk.ActivityMetric{ activitysmithsdk.Metric("CPU", 18, activitysmithsdk.MetricUnit("%")), activitysmithsdk.Metric("MEM", 42, activitysmithsdk.MetricUnit("%")), }, }, ) ``` The `Icon` symbol value is an Apple SF Symbol name. Browse the catalog with one of these tools: - [ActivitySmith app](https://apps.apple.com/us/app/activitysmith/id6752254835) - Open Settings -> SF Symbols to browse 45 hand-picked icons ready to use - [SF Symbols](https://developer.apple.com/sf-symbols/) - Apple's official macOS app - [Interactful](https://apps.apple.com/app/interactful/id1528095640) - free third-party iOS app listing all SF Symbols under Foundations -> Iconography #### Badge Badges are supported by `value`, `alert`, `segmented_progress`, and `progress` Live Activities. ![Progress Live Activity with a badge on the iPhone Lock Screen](https://cdn.activitysmith.com/features/progress-live-activity-with-badge.png) ```go activitysmith.LiveActivities.Stream( "nightly-database-backup", activitysmithsdk.LiveActivityStreamInput{ Title: "Nightly Database Backup", Subtitle: "verify restore", Type: "progress", Badge: activitysmithsdk.AlertBadge("S3", "cyan"), Percentage: 62, }, ) ``` ### Colors Choose from these colors for the Live Activity accent, including progress bars and action buttons, or apply them to an individual icon or badge: `lime`, `green`, `cyan`, `blue`, `purple`, `magenta`, `red`, `orange`, `yellow`, `gray` ### Actions ![Metrics Live Activity with action](https://cdn.activitysmith.com/features/metrics-live-activity-action.png) Live Activities can include an action button. - `open_url`: Open a web page or run an iOS Shortcut - `webhook`: Trigger a backend GET/POST workflow #### Open URL action Open a web page or run an iOS Shortcut when someone taps the button. Supported links: - **HTTP/HTTPS:** Web pages, e.g. `https://example.com` - **Shortcuts:** Run Jarvis with `shortcuts://run-shortcut?name=Jarvis` ```go activitysmith.LiveActivities.Stream( "prod-web-1", activitysmithsdk.LiveActivityStreamInput{ Title: "Server Health", Subtitle: "prod-web-1", Type: "metrics", Metrics: []activitysmithsdk.ActivityMetric{ activitysmithsdk.Metric("CPU", 76, activitysmithsdk.MetricUnit("%")), activitysmithsdk.Metric("MEM", 52, activitysmithsdk.MetricUnit("%")), }, Action: &activitysmithsdk.LiveActivityActionInput{ Title: "Dashboard", Type: "open_url", URL: "https://status.example.com/servers/prod-web-1", }, }, ) ``` #### Apple Shortcut action ```go activitysmith.LiveActivities.Stream( "prod-web-1", activitysmithsdk.LiveActivityStreamInput{ Title: "Server Health", Subtitle: "prod-web-1", Type: "metrics", Metrics: []activitysmithsdk.ActivityMetric{ activitysmithsdk.Metric("CPU", 76, activitysmithsdk.MetricUnit("%")), activitysmithsdk.Metric("MEM", 52, activitysmithsdk.MetricUnit("%")), }, Action: &activitysmithsdk.LiveActivityActionInput{ Title: "Chat with Jarvis", Type: "open_url", URL: "shortcuts://run-shortcut?name=Jarvis", }, }, ) ``` #### Webhook action ```go activitysmith.LiveActivities.Stream( "search-reindex", activitysmithsdk.LiveActivityStreamInput{ Title: "Reindexing product search", Subtitle: "Shard 7 of 12", Type: "segmented_progress", NumberOfSteps: 12, CurrentStep: 7, Action: &activitysmithsdk.LiveActivityActionInput{ Title: "Pause Reindex", Type: "webhook", URL: "https://ops.example.com/hooks/search/reindex/pause", Method: "POST", Body: map[string]interface{}{ "job_id": "reindex-2026-03-19", "requested_by": "activitysmith-go", }, }, }, ) ``` #### Secondary action ![Alert Live Activity with primary and secondary action buttons](https://cdn.activitysmith.com/features/live-activity-secondary-action.png) Use `secondary_action` when you want a second button beside the primary `action`. The secondary action button is supported for `value`, `alert`, `segmented_progress`, and `progress` Live Activities. Both buttons use the same `open_url`, `webhook`, and Apple Shortcut payload shapes. ```go activitysmith.LiveActivities.Stream( "agent-approval", activitysmithsdk.LiveActivityStreamInput{ Title: "Approval Needed", Message: "Should I send the follow-up email to Brightlane?", Type: "alert", Color: "green", Icon: activitysmithsdk.AlertIcon("sparkles", "green"), Badge: activitysmithsdk.AlertBadge("Agent", "green"), Action: &activitysmithsdk.LiveActivityActionInput{ Title: "Send", Type: "webhook", URL: "https://agent.example.com/live-activity/approve", Method: "POST", Body: map[string]interface{}{ "approval_id": "approval_01JY3J7Q9S0P8M1V5PZK7DR4M2", "decision": "send", }, }, SecondaryAction: &activitysmithsdk.LiveActivityActionInput{ Title: "Deny", Type: "webhook", URL: "https://agent.example.com/live-activity/deny", Method: "POST", Body: map[string]interface{}{ "approval_id": "approval_01JY3J7Q9S0P8M1V5PZK7DR4M2", "decision": "deny", }, }, }, ) ``` ## Lock Screen Widgets ![Lock screen widgets](https://cdn.activitysmith.com/features/lock-screen-widgets.png) ActivitySmith lets you display any value on your Lock Screen with widgets - SaaS metrics, revenue, signups, uptime, habits, or anything else you want to track. Send a value to a metric key, add a widget to your Lock Screen, and it fetches the latest value automatically. Use the metric key to update its value. The first value creates the metric. ```go activitysmith.Metrics.Update("deploy.success_rate", 99.9) ``` String metric values work too. ```go activitysmith.Metrics.Update("prod.status", "healthy") ``` ### Create a metric Use `create` to set the label and how widgets show the value, such as currency, percent, or a unit. Omitted fields keep their current values, so you can call it every time your app starts. ```go activitysmith.Metrics.Create("mrr", activitysmithsdk.MetricInput{ Label: "MRR", Format: "currency", CurrencyCode: "USD", }) activitysmith.Metrics.Update("mrr", 12450) ``` You can also create and edit metrics in the [web app](https://activitysmith.com/app/widgets). ![Create widget metric](https://cdn.activitysmith.com/features/create-widget-metric.png) ## App Icon Badge ![ActivitySmith app icon with an App Icon Badge](https://cdn.activitysmith.com/features/badge-count.png) Show the number you care about on your ActivitySmith app icon. Track MRR, a customer count, a stock price, or any other value you want to keep in view. App Icon Badge requires Push Notifications enabled. On your iPhone, open Settings > ActivitySmith > Notifications and turn on Allow Notifications. ### Set or update the badge value ```go Go activitysmith.BadgeCount(8333) ``` ### Clear the badge Pass `0` to clear the badge. ```go Go activitysmith.BadgeCount(0) ``` ## Metadata Metadata adds extra information to Push Notification and Live Activity details in ActivitySmith. It does not appear in the notification or Live Activity on your device. ```go Go activitysmith.Notifications.Send(activitysmithsdk.PushNotificationInput{ Title: "New subscription 💸", Message: "Customer upgraded to Pro plan", Metadata: map[string]any{ "customer_id": "382", "plan": "Pro", "amount": 29, "trial": false, }, }) activitysmith.LiveActivities.Stream("customer-import", activitysmithsdk.LiveActivityStreamInput{ ContentState: activitysmithsdk.LiveActivityContentStateInput{ Title: "Customer Import", Type: "progress", Percentage: 60, }, Metadata: map[string]any{ "job_id": "import-382", "records": 1200, }, }) ``` Values can be strings, numbers, or booleans. Metadata supports up to 50 entries and 16 KB of JSON, with keys up to 100 characters and strings up to 4,000 characters. Nested objects, arrays, and null values are not supported. ## Tags Use Tags to organize and filter Push Notification and Live Activity history. Tags are created automatically when you first use them. Sending Tags requires SDK version 1.10.0 or later. ```go activitysmith.Notifications.Send(activitysmithsdk.PushNotificationInput{ Title: "New subscription 💸", Message: "Customer upgraded to Pro plan", Tags: []string{"user:382", "billing"}, }) ``` On Live Activity stream updates and legacy `Update` or `End` calls, leave `Tags` nil to keep existing Tags, supply a slice to replace them, or pass `Tags: []string{}` to clear them. ```go Go activitysmith.LiveActivities.Update(activitysmithsdk.LiveActivityUpdateInput{ ActivityID: "YOUR_ACTIVITY_ID", ContentState: activitysmithsdk.LiveActivityContentStateInput{ Title: "Customer Import", Percentage: 60, }, Tags: []string{}, }) ``` ## Channels Use `Channels` to target specific team members or devices when sending Push Notifications, Live Activities, or App Icon Badge updates. Omit it for account-wide delivery. ```go Go activitysmith.Notifications.Send(activitysmithsdk.PushNotificationInput{ Title: "New subscription 💸", Message: "Customer upgraded to Pro plan", Channels: []string{"sales", "customer-success"}, }) activitysmith.LiveActivities.Stream( "nightly-backup", activitysmithsdk.LiveActivityStreamInput{ Title: "Nightly database backup", NumberOfSteps: 3, CurrentStep: 1, Type: "segmented_progress", Channels: []string{"ios-builds"}, }, ) activitysmith.BadgeCount(3, "sales", "customer-success") ``` ## Paired Devices List the iPhones and iPads paired to your account, for example to check that a device is paired before you send. Active devices come first: ```go Go result, err := activitysmith.Devices.List(activitysmithsdk.DeviceListInput{}) if err != nil { log.Fatal(err) } for _, device := range result.GetDevices() { fmt.Println(device.GetDeviceName(), device.GetSystemName(), device.GetIsActive()) } ``` An empty list means no device is paired. Install ActivitySmith on your iPhone, sign in with the same account, and allow notifications. Channel-scoped API keys cannot list devices. Pass `IncludeInactive` to also list devices that can no longer receive deliveries: ```go Go result, err := activitysmith.Devices.List(activitysmithsdk.DeviceListInput{ IncludeInactive: true, }) ``` ## Error Handling SDK calls return `response, err`, so check `err` after every call. ## Additional Resources ### [Source Code](https://github.com/ActivitySmithHQ/activitysmith-go) View the Go SDK source on GitHub --- Source: https://activitysmith.com/docs/sdks/php # PHP Use the ActivitySmith PHP SDK to send Push Notifications and Live Activity progress updates from PHP apps, queues, and scheduled jobs. ## Installation Install the ActivitySmith PHP SDK with Composer: ```bash composer require activitysmith/activitysmith ``` ## Quickstart 1. [Create an API key](https://activitysmith.com/app/keys) 2. Set `ACTIVITYSMITH_API_KEY` or pass it directly to `ActivitySmith`. ```php PHP notifications->send( title: 'New subscription 💸', message: 'Customer upgraded to Pro plan', ); ``` ### Custom Push Notification Icons ![Push Notifications with custom icons](https://cdn.activitysmith.com/features/push-notifications-with-custom-icons.png) Set `icon` to a publicly accessible HTTPS image URL to show a logo or avatar alongside a smaller ActivitySmith app icon. Host the image anywhere, such as on your own website or CDN. With a custom icon, iOS may omit the subtitle from the notification. ```php PHP $activitysmith->notifications->send( title: 'MRR just crossed $10,000 🎉', message: 'Up 18% this month from 31 new subscriptions.', icon: 'https://example.com/icons/stripe.png', ); ``` ### Rich Push Notifications with Media ![Rich Push Notification with image](https://cdn.activitysmith.com/features/rich-push-notification-with-image.png) ```php PHP $activitysmith->notifications->send( title: 'Homepage ready', message: 'Your agent finished the redesign.', media: 'https://cdn.example.com/output/homepage-v2.png', ); ``` Attach images, videos, or audio to your Push Notifications. Press and hold the notification to preview the media. ![Rich Push Notification with audio](https://cdn.activitysmith.com/features/rich-push-notification-with-audio.png) What will work: - direct image URL: `.jpg`, `.png`, `.gif`, etc. - direct audio file URL: `.mp3`, `.m4a`, etc. - direct video file URL: `.mp4`, `.mov`, etc. - URL that responds with a proper media `Content-Type`, even if the path has no extension `media` cannot be combined with `actions`. ### Push Notifications with Redirection Open a web page, run an iOS Shortcut, or open an app when someone taps the notification. `redirection` supports: - **HTTP/HTTPS:** Web pages, e.g. `https://example.com` - **Shortcuts:** Run Jarvis with `shortcuts://run-shortcut?name=Jarvis` - **App deep links:** Installed apps or specific content within them - **Spotify:** A track, e.g. `spotify:track:6rqhFgbbKwnb9MLmUQDhG6` - **Termius:** `termius://` to open the app - **Claude:** `claude://code` to open the Code tab - **ChatGPT:** `chatgpt://` to open the app ```php PHP $activitysmith->notifications->send( title: 'Homepage ready', message: 'Your agent finished the redesign.', redirection: 'https://github.com/acme/web/pull/482', ); ``` ### Actionable Push Notifications ![Actionable Push Notification with redirection and actions](https://cdn.activitysmith.com/features/actionable-push-notifications-2.png) `open_url` actions open a web page, run an iOS Shortcut, or open an app when someone taps the button. Supported links: - **HTTP/HTTPS:** Web pages, e.g. `https://example.com` - **Shortcuts:** Run Jarvis with `shortcuts://run-shortcut?name=Jarvis` - **App deep links:** Installed apps or specific content within them - **Spotify:** A track, e.g. `spotify:track:6rqhFgbbKwnb9MLmUQDhG6` - **Termius:** `termius://` to open the app - **Claude:** `claude://code` to open the Code tab - **ChatGPT:** `chatgpt://` to open the app Webhooks are executed by the ActivitySmith backend and must use HTTPS. ```php PHP $activitysmith->notifications->send( title: 'New subscription 💸', message: 'Customer upgraded to Pro plan', actions: [ PushAction::make( title: 'Open CRM', type: 'open_url', url: 'https://crm.example.com/customers/cus_9f3a1d', ), PushAction::make( title: 'Chat with Jarvis', type: 'open_url', url: 'shortcuts://run-shortcut?name=Jarvis', ), PushAction::make( title: 'Start Onboarding Workflow', type: 'webhook', url: 'https://hooks.example.com/activitysmith/onboarding/start', method: 'POST', body: [ 'customer_id' => 'cus_9f3a1d', 'plan' => 'pro', ], ), ], ); ``` ### Interruption Levels ![Time Sensitive Push Notification](https://cdn.activitysmith.com/features/time-sensitive-push-notifications.png) Use `interruptionLevel` to choose how urgently iOS presents a Push Notification. Omit it for normal delivery. Explicit `active` has the same behavior as the default. | Value | Behavior | | --- | --- | | `passive` | Appears quietly in the notification list, without sound or waking the screen. | | `active` | Normal delivery, subject to the device's notification settings and Focus. This is the default. | | `time-sensitive` | Can bypass Scheduled Summary and Focus when the user allows Time Sensitive Notifications for ActivitySmith. | See Apple's [interruption levels](https://developer.apple.com/documentation/usernotifications/unnotificationinterruptionlevel) for the system behavior. The SDK also exports these values as `PushInterruptionLevel::PASSIVE`, `PushInterruptionLevel::ACTIVE`, and `PushInterruptionLevel::TIME_SENSITIVE`. #### Passive ```php PHP $activitysmith->notifications->send( title: 'Daily summary', message: 'All scheduled jobs completed successfully.', interruptionLevel: 'passive', ); ``` #### Active (default) ```php PHP $activitysmith->notifications->send( title: 'Deployment complete', message: 'Your latest changes are live.', interruptionLevel: 'active', ); ``` Removing the interruption level from this example produces the same delivery behavior. #### Time Sensitive ```php PHP $activitysmith->notifications->send( title: '🚨 checkout-api is down', message: '500 errors on 62% of requests. Customers can\'t complete payments.', interruptionLevel: 'time-sensitive', ); ``` ### Replace a Push Notification Every send returns a `notification_id`. Pass it to `replace` to update a Push Notification you already sent, for example when an incident you alerted on is resolved. The replacement takes the old notification's place on the Lock Screen and in history instead of stacking a second one. It arrives silently, without sound or waking the screen, and goes to the same recipients as the original. Omit `metadata` or `tags` to keep their stored values. ```php PHP $sent = $activitysmith->notifications->send( title: '🚨 checkout-api is down', message: '500 errors on 62% of requests.', ); $activitysmith->notifications->replace( $sent->getNotificationId(), title: '✅ checkout-api recovered', message: 'Error rate is back to normal. Incident resolved.', ); ``` ### Dismiss a Push Notification Pass the `notification_id` to `dismiss` when a Push Notification no longer needs attention, for example after you answered an agent's question somewhere else. Dismissing clears it from the Lock Screen and Notification Center on every device it was sent to. History keeps it. Devices clear the notification in the background, so it can take a moment. ```php PHP $sent = $activitysmith->notifications->send( title: '🙋 Agent needs your input', message: 'Approve the database migration?', ); $activitysmith->notifications->dismiss($sent->getNotificationId()); ``` ## Live Activities Choose the Live Activity type that matches what you want to show: - ![Value Live Activity showing revenue with a growth badge](https://cdn.activitysmith.com/features/value-live-activity.png) **Value**: Show a single value on your Lock Screen, such as revenue, a queue count, or a temperature. - ![Stats Live Activity with six labeled sales metrics](https://cdn.activitysmith.com/features/stats-live-activity.png) **Stats**: Show up to 8 labeled values on your Lock Screen, from revenue and orders to uptime and conversion. - ![Alert Live Activity showing a customer reactivation update](https://cdn.activitysmith.com/features/alert-live-activity.png) **Alert**: Show status updates with a clear message, badge, and icon. When you add an action button, `color` controls the button tint. - ![Metrics Live Activity with CPU and memory values](https://cdn.activitysmith.com/features/metrics-live-activity-start.png) **Metrics**: Track two related values with segmented bars, such as CPU and memory. - ![Segmented Progress Live Activity showing a workflow step](https://cdn.activitysmith.com/features/update-live-activity.png) **Segmented Progress**: Show progress through a known set of steps, like build, test, deploy, and verify. - ![Progress Live Activity showing percentage completion](https://cdn.activitysmith.com/features/progress-live-activity.png) **Progress**: Show percentage progress for jobs that move continuously toward completion. - ![Timer Live Activity showing a benchmark run countdown](https://cdn.activitysmith.com/features/timer-live-activity.png) **Timer**: Count down from a duration, or count up from 00:00 while a job runs. ### Start & Update Live Activity Use a stable `streamKey` to identify the metric, job, deployment, or system you want to keep visible. The first `stream(...)` call starts the Live Activity. Later calls with the same `streamKey` update it. > [!WARNING] > iOS limits how often a Live Activity can update. Short bursts that end, like deployment steps, are fine. If one Live Activity keeps updating more often than every couple of minutes, iOS throttles it until the budget refills, roughly an hour, even though the API still returns `200`. [Learn more](/docs/live-activity-stream#update-frequency-and-ios-limits) #### Value ![Value Live Activity stream example](https://cdn.activitysmith.com/features/value-live-activity.png) ```php $activitysmith->liveActivities->stream( 'revenue-today', contentState: LiveActivityContentState::make( title: 'Revenue', type: 'value', value: '$1,240', color: 'green', icon: LiveActivityAlertIcon::make(symbol: 'dollarsign.circle', color: 'green'), badge: LiveActivityAlertBadge::make(title: '↑ 18%', color: 'purple'), ), ); ``` Send a string or number in `value`. Strings keep their formatting, including currency symbols, units, and decimal places. #### Stats ![Stats Live Activity stream example](https://cdn.activitysmith.com/features/stats-live-activity.png) ```php $activitysmith->liveActivities->stream( 'sales-hourly', contentState: LiveActivityContentState::make( title: 'Sales', subtitle: 'last hour', type: 'stats', metrics: [ LiveActivityMetric::make(label: 'Revenue', value: '$2430', color: 'blue'), LiveActivityMetric::make(label: 'Orders', value: '37', color: 'green'), LiveActivityMetric::make(label: 'Conversion', value: '4.8%', color: 'magenta'), LiveActivityMetric::make(label: 'Avg Order', value: '$65.68', color: 'yellow'), LiveActivityMetric::make(label: 'Refunds', value: '$84', color: 'red'), LiveActivityMetric::make(label: 'New Buyers', value: '18', color: 'cyan'), ], ), ); ``` #### Alert ![Alert Live Activity stream example](https://cdn.activitysmith.com/features/alert-live-activity.png) ```php $activitysmith->liveActivities->stream( 'customer-ops', contentState: LiveActivityContentState::make( title: 'Reactivation', message: 'Lumen came back after 2 weeks', type: 'alert', icon: LiveActivityAlertIcon::make(symbol: 'cloud.sun', color: 'yellow'), badge: LiveActivityAlertBadge::make(title: 'Customer', color: 'magenta'), ), ); ``` #### Metrics ![Metrics Live Activity stream example](https://cdn.activitysmith.com/features/metrics-live-activity-start.png) ```php $activitysmith->liveActivities->stream( 'prod-web-1', contentState: LiveActivityContentState::make( title: 'Server Health', subtitle: 'prod-web-1', type: 'metrics', metrics: [ LiveActivityMetric::make(label: 'CPU', value: 9, unit: '%'), LiveActivityMetric::make(label: 'MEM', value: 45, unit: '%'), ], ), ); ``` #### Segmented Progress ![Segmented Progress Live Activity stream example](https://cdn.activitysmith.com/features/update-live-activity.png) ```php $activitysmith->liveActivities->stream( 'nightly-backup', contentState: LiveActivityContentState::make( title: 'Nightly Backup', subtitle: 'upload archive', type: 'segmented_progress', numberOfSteps: 3, currentStep: 2, ), ); ``` #### Progress ![Progress Live Activity stream example](https://cdn.activitysmith.com/features/progress-live-activity.png) ```php $activitysmith->liveActivities->stream( 'search-reindex', contentState: LiveActivityContentState::make( title: 'Search Reindex', subtitle: 'catalog-v2', type: 'progress', percentage: 42, ), ); ``` #### Timer ![Timer Live Activity stream example](https://cdn.activitysmith.com/features/timer-live-activity.png) ```php $activitysmith->liveActivities->stream( 'benchmark-run', contentState: LiveActivityContentState::make( title: 'Benchmark Run', subtitle: 'sampling', type: 'timer', durationSeconds: 300, color: 'cyan', ), ); ``` For a countdown, send `durationSeconds`. You can update `title`, `subtitle`, `color`, or any other visible field as the work changes. Leave `durationSeconds` out unless you want to change the timer. To start at 00:00 and count up, set `countsDown` to `false` and leave out `durationSeconds`. ### End Live Activity Call `endStream(...)` with the same `streamKey` to dismiss the Live Activity. You can include final values before it is removed. Set `autoDismissSeconds` to dismiss it after a delay in seconds, or `autoDismissMinutes` for minutes. Use `0` for immediate dismissal. Seconds take precedence if both are set. ```php $activitysmith->liveActivities->endStream( 'prod-web-1', contentState: LiveActivityContentState::make( title: 'Server Health', subtitle: 'prod-web-1', type: 'metrics', metrics: [ LiveActivityMetric::make(label: 'CPU', value: 7, unit: '%'), LiveActivityMetric::make(label: 'MEM', value: 38, unit: '%'), ], autoDismissSeconds: 30, ), ); ``` ### Icons and Badges Add more context to Live Activities with icons and badges. #### Icon Supported Live Activity types: `value`, `stats`, `alert`, `metrics`, `segmented_progress`, `progress`, and `timer`. ![Metrics Live Activity with an SF Symbol icon on the iPhone Lock Screen](https://cdn.activitysmith.com/features/metrics-live-activity-with-icon.png) ```php $activitysmith->liveActivities->stream( 'prod-web-1', contentState: LiveActivityContentState::make( title: 'Server Health', subtitle: 'prod-web-1', type: LiveActivities::TYPE_METRICS, icon: LiveActivityAlertIcon::make(symbol: 'server.rack', color: 'blue'), metrics: [ LiveActivityMetric::make(label: 'CPU', value: 18, unit: '%'), LiveActivityMetric::make(label: 'MEM', value: 42, unit: '%'), ], ), ); ``` The `icon` symbol value is an Apple SF Symbol name. Browse the catalog with one of these tools: - [ActivitySmith app](https://apps.apple.com/us/app/activitysmith/id6752254835) - Open Settings -> SF Symbols to browse 45 hand-picked icons ready to use - [SF Symbols](https://developer.apple.com/sf-symbols/) - Apple's official macOS app - [Interactful](https://apps.apple.com/app/interactful/id1528095640) - free third-party iOS app listing all SF Symbols under Foundations -> Iconography #### Badge Badges are supported by `value`, `alert`, `segmented_progress`, and `progress` Live Activities. ![Progress Live Activity with a badge on the iPhone Lock Screen](https://cdn.activitysmith.com/features/progress-live-activity-with-badge.png) ```php $activitysmith->liveActivities->stream( 'nightly-database-backup', contentState: LiveActivityContentState::make( title: 'Nightly Database Backup', subtitle: 'verify restore', type: LiveActivities::TYPE_PROGRESS, badge: LiveActivityAlertBadge::make(title: 'S3', color: 'cyan'), percentage: 62, ), ); ``` ### Colors Choose from these colors for the Live Activity accent, including progress bars and action buttons, or apply them to an individual icon or badge: `lime`, `green`, `cyan`, `blue`, `purple`, `magenta`, `red`, `orange`, `yellow`, `gray` ### Actions ![Metrics Live Activity with action](https://cdn.activitysmith.com/features/metrics-live-activity-action.png) Live Activities can include an action button. - `open_url`: Open a web page or run an iOS Shortcut - `webhook`: Trigger a backend GET/POST workflow #### Open URL action Open a web page or run an iOS Shortcut when someone taps the button. Supported links: - **HTTP/HTTPS:** Web pages, e.g. `https://example.com` - **Shortcuts:** Run Jarvis with `shortcuts://run-shortcut?name=Jarvis` ```php $activitysmith->liveActivities->stream( 'prod-web-1', contentState: LiveActivityContentState::make( title: 'Server Health', subtitle: 'prod-web-1', type: 'metrics', metrics: [ LiveActivityMetric::make(label: 'CPU', value: 76, unit: '%'), LiveActivityMetric::make(label: 'MEM', value: 52, unit: '%'), ], ), action: LiveActivityAction::make( title: 'Dashboard', type: 'open_url', url: 'https://status.example.com/servers/prod-web-1', ), ); ``` #### Apple Shortcut action ```php $activitysmith->liveActivities->stream( 'prod-web-1', contentState: LiveActivityContentState::make( title: 'Server Health', subtitle: 'prod-web-1', type: 'metrics', metrics: [ LiveActivityMetric::make(label: 'CPU', value: 76, unit: '%'), LiveActivityMetric::make(label: 'MEM', value: 52, unit: '%'), ], ), action: LiveActivityAction::make( title: 'Chat with Jarvis', type: 'open_url', url: 'shortcuts://run-shortcut?name=Jarvis', ), ); ``` #### Webhook action ```php $activitysmith->liveActivities->stream( 'search-reindex', contentState: LiveActivityContentState::make( title: 'Reindexing product search', subtitle: 'Shard 7 of 12', type: 'segmented_progress', numberOfSteps: 12, currentStep: 7, ), action: LiveActivityAction::make( title: 'Pause Reindex', type: 'webhook', url: 'https://ops.example.com/hooks/search/reindex/pause', method: 'POST', body: [ 'job_id' => 'reindex-2026-03-19', 'requested_by' => 'activitysmith-php', ], ), ); ``` #### Secondary action ![Alert Live Activity with primary and secondary action buttons](https://cdn.activitysmith.com/features/live-activity-secondary-action.png) Use `secondary_action` when you want a second button beside the primary `action`. The secondary action button is supported for `value`, `alert`, `segmented_progress`, and `progress` Live Activities. Both buttons use the same `open_url`, `webhook`, and Apple Shortcut payload shapes. ```php $activitysmith->liveActivities->stream( 'agent-approval', contentState: LiveActivityContentState::make( title: 'Approval Needed', message: 'Should I send the follow-up email to Brightlane?', type: 'alert', color: 'green', icon: LiveActivityAlertIcon::make(symbol: 'sparkles', color: 'green'), badge: LiveActivityAlertBadge::make(title: 'Agent', color: 'green'), ), action: LiveActivityAction::make( title: 'Send', type: 'webhook', url: 'https://agent.example.com/live-activity/approve', method: 'POST', body: [ 'approval_id' => 'approval_01JY3J7Q9S0P8M1V5PZK7DR4M2', 'decision' => 'send', ], ), secondaryAction: LiveActivityAction::make( title: 'Deny', type: 'webhook', url: 'https://agent.example.com/live-activity/deny', method: 'POST', body: [ 'approval_id' => 'approval_01JY3J7Q9S0P8M1V5PZK7DR4M2', 'decision' => 'deny', ], ), ); ``` ## Lock Screen Widgets ![Lock screen widgets](https://cdn.activitysmith.com/features/lock-screen-widgets.png) ActivitySmith lets you display any value on your Lock Screen with widgets - SaaS metrics, revenue, signups, uptime, habits, or anything else you want to track. Send a value to a metric key, add a widget to your Lock Screen, and it fetches the latest value automatically. Use the metric key to update its value. The first value creates the metric. ```php $activitysmith->metrics->update('deploy.success_rate', 99.9); ``` String metric values work too. ```php $activitysmith->metrics->update('prod.status', 'healthy'); ``` ### Create a metric Use `create` to set the label and how widgets show the value, such as currency, percent, or a unit. Omitted fields keep their current values, so you can call it every time your app starts. ```php $activitysmith->metrics->create( 'mrr', label: 'MRR', format: 'currency', currencyCode: 'USD', ); $activitysmith->metrics->update('mrr', 12450); ``` You can also create and edit metrics in the [web app](https://activitysmith.com/app/widgets). ![Create widget metric](https://cdn.activitysmith.com/features/create-widget-metric.png) ## App Icon Badge ![ActivitySmith app icon with an App Icon Badge](https://cdn.activitysmith.com/features/badge-count.png) Show the number you care about on your ActivitySmith app icon. Track MRR, a customer count, a stock price, or any other value you want to keep in view. App Icon Badge requires Push Notifications enabled. On your iPhone, open Settings > ActivitySmith > Notifications and turn on Allow Notifications. ### Set or update the badge value ```php PHP $activitysmith->badgeCount(8333); ``` ### Clear the badge Pass `0` to clear the badge. ```php PHP $activitysmith->badgeCount(0); ``` ## Metadata Metadata adds extra information to Push Notification and Live Activity details in ActivitySmith. It does not appear in the notification or Live Activity on your device. ```php PHP $activitysmith->notifications->send( title: 'New subscription 💸', message: 'Customer upgraded to Pro plan', metadata: [ 'customer_id' => '382', 'plan' => 'Pro', 'amount' => 29, 'trial' => false, ], ); $activitysmith->liveActivities->stream( 'customer-import', title: 'Customer Import', type: 'progress', percentage: 60, metadata: [ 'job_id' => 'import-382', 'records' => 1200, ], ); ``` Values can be strings, numbers, or booleans. Metadata supports up to 50 entries and 16 KB of JSON, with keys up to 100 characters and strings up to 4,000 characters. Nested objects, arrays, and null values are not supported. ## Tags Use `tags` to organize and filter your Push Notification and Live Activity history. Tags are created automatically when you first use them. ```php PHP $activitysmith->notifications->send([ 'title' => 'New subscription 💸', 'message' => 'Customer upgraded to Pro plan', 'tags' => ['user:382', 'billing'], ]); ``` On Live Activity stream updates and legacy `update` or `end` calls, omit `tags` to keep existing Tags, supply a list to replace them, or pass `tags: []` to clear them. ```php PHP $activitysmith->liveActivities->update( activityId: 'YOUR_ACTIVITY_ID', title: 'Customer Import', percentage: 60, tags: [], ); ``` ## Channels Use `channels` to target specific team members or devices when sending Push Notifications, Live Activities, or App Icon Badge updates. Omit it for account-wide delivery. ```php PHP $activitysmith->notifications->send( title: 'New subscription 💸', message: 'Customer upgraded to Pro plan', channels: ['sales', 'customer-success'], ); $activitysmith->liveActivities->stream( 'nightly-backup', contentState: LiveActivityContentState::make( title: 'Nightly database backup', type: 'segmented_progress', numberOfSteps: 3, currentStep: 1, ), channels: ['ios-builds'], ); $activitysmith->badgeCount(3, channels: ['sales', 'customer-success']); ``` ## Paired Devices List the iPhones and iPads paired to your account, for example to check that a device is paired before you send. Active devices come first: ```php PHP $result = $activitysmith->devices->list(); foreach ($result->getDevices() as $device) { echo $device->getDeviceName() . ' ' . $device->getSystemName() . PHP_EOL; } ``` An empty list means no device is paired. Install ActivitySmith on your iPhone, sign in with the same account, and allow notifications. Channel-scoped API keys cannot list devices. Pass `includeInactive` to also list devices that can no longer receive deliveries: ```php PHP $activitysmith->devices->list(includeInactive: true); ``` ## Error Handling Wrap SDK calls with `try/catch`: ```php PHP try { $activitysmith->notifications->send(title: 'Hello'); } catch (\Throwable $error) { echo $error->getMessage(); } ``` ## Additional Resources ### [Packagist](https://packagist.org/packages/activitysmith/activitysmith) Install the ActivitySmith PHP SDK from Packagist ### [Source Code](https://github.com/ActivitySmithHQ/activitysmith-php) View the PHP SDK source on GitHub --- Source: https://activitysmith.com/docs/sdks/ruby # Ruby Use the ActivitySmith Ruby SDK to send Push Notifications and Live Activity progress updates from Ruby apps, workers, and scheduled jobs. ## Installation Install the ActivitySmith Ruby SDK with RubyGems: ```bash gem install activitysmith ``` ## Quickstart 1. [Create an API key](https://activitysmith.com/app/keys) 2. Set `ACTIVITYSMITH_API_KEY` or pass it directly to `ActivitySmith::Client`. ```ruby Ruby require "activitysmith" activitysmith = ActivitySmith::Client.new( api_key: ENV["ACTIVITYSMITH_API_KEY"] ) ``` ## Push Notifications ### Send a Push Notification Send an immediate notification for a completed task or event. ![Push Notification example for a new subscription event](https://cdn.activitysmith.com/features/new-subscription-push-notification.png) ```ruby Ruby activitysmith.notifications.send( { title: "New subscription 💸", message: "Customer upgraded to Pro plan" } ) ``` ### Custom Push Notification Icons ![Push Notifications with custom icons](https://cdn.activitysmith.com/features/push-notifications-with-custom-icons.png) Set `icon` to a publicly accessible HTTPS image URL to show a logo or avatar alongside a smaller ActivitySmith app icon. Host the image anywhere, such as on your own website or CDN. With a custom icon, iOS may omit the subtitle from the notification. ```ruby Ruby activitysmith.notifications.send( { title: "MRR just crossed $10,000 🎉", message: "Up 18% this month from 31 new subscriptions.", icon: "https://example.com/icons/stripe.png" } ) ``` ### Rich Push Notifications with Media ![Rich Push Notification with image](https://cdn.activitysmith.com/features/rich-push-notification-with-image.png) ```ruby Ruby activitysmith.notifications.send( { title: "Homepage ready", message: "Your agent finished the redesign.", media: "https://cdn.example.com/output/homepage-v2.png" } ) ``` Attach images, videos, or audio to your Push Notifications. Press and hold the notification to preview the media. ![Rich Push Notification with audio](https://cdn.activitysmith.com/features/rich-push-notification-with-audio.png) What will work: - direct image URL: `.jpg`, `.png`, `.gif`, etc. - direct audio file URL: `.mp3`, `.m4a`, etc. - direct video file URL: `.mp4`, `.mov`, etc. - URL that responds with a proper media `Content-Type`, even if the path has no extension `media` cannot be combined with `actions`. ### Push Notifications with Redirection Open a web page, run an iOS Shortcut, or open an app when someone taps the notification. `redirection` supports: - **HTTP/HTTPS:** Web pages, e.g. `https://example.com` - **Shortcuts:** Run Jarvis with `shortcuts://run-shortcut?name=Jarvis` - **App deep links:** Installed apps or specific content within them - **Spotify:** A track, e.g. `spotify:track:6rqhFgbbKwnb9MLmUQDhG6` - **Termius:** `termius://` to open the app - **Claude:** `claude://code` to open the Code tab - **ChatGPT:** `chatgpt://` to open the app ```ruby Ruby activitysmith.notifications.send( { title: "Homepage ready", message: "Your agent finished the redesign.", redirection: "https://github.com/acme/web/pull/482" } ) ``` ### Actionable Push Notifications ![Actionable Push Notification with redirection and actions](https://cdn.activitysmith.com/features/actionable-push-notifications-2.png) `open_url` actions open a web page, run an iOS Shortcut, or open an app when someone taps the button. Supported links: - **HTTP/HTTPS:** Web pages, e.g. `https://example.com` - **Shortcuts:** Run Jarvis with `shortcuts://run-shortcut?name=Jarvis` - **App deep links:** Installed apps or specific content within them - **Spotify:** A track, e.g. `spotify:track:6rqhFgbbKwnb9MLmUQDhG6` - **Termius:** `termius://` to open the app - **Claude:** `claude://code` to open the Code tab - **ChatGPT:** `chatgpt://` to open the app Webhooks are executed by the ActivitySmith backend and must use HTTPS. ```ruby Ruby activitysmith.notifications.send( { title: "New subscription 💸", message: "Customer upgraded to Pro plan", actions: [ { title: "Open CRM", type: "open_url", url: "https://crm.example.com/customers/cus_9f3a1d" }, { title: "Chat with Jarvis", type: "open_url", url: "shortcuts://run-shortcut?name=Jarvis" }, { title: "Start Onboarding Workflow", type: "webhook", url: "https://hooks.example.com/activitysmith/onboarding/start", method: "POST", body: { customer_id: "cus_9f3a1d", plan: "pro" } } ] } ) ``` ### Interruption Levels ![Time Sensitive Push Notification](https://cdn.activitysmith.com/features/time-sensitive-push-notifications.png) Use `interruption_level` to choose how urgently iOS presents a Push Notification. Omit it for normal delivery. Explicit `active` has the same behavior as the default. | Value | Behavior | | --- | --- | | `passive` | Appears quietly in the notification list, without sound or waking the screen. | | `active` | Normal delivery, subject to the device's notification settings and Focus. This is the default. | | `time-sensitive` | Can bypass Scheduled Summary and Focus when the user allows Time Sensitive Notifications for ActivitySmith. | See Apple's [interruption levels](https://developer.apple.com/documentation/usernotifications/unnotificationinterruptionlevel) for the system behavior. The SDK also exports these values as `ActivitySmith::PushInterruptionLevel::PASSIVE`, `ACTIVE`, and `TIME_SENSITIVE`. #### Passive ```ruby Ruby activitysmith.notifications.send( { title: "Daily summary", message: "All scheduled jobs completed successfully.", interruption_level: "passive" } ) ``` #### Active (default) ```ruby Ruby activitysmith.notifications.send( { title: "Deployment complete", message: "Your latest changes are live.", interruption_level: "active" } ) ``` Removing the interruption level from this example produces the same delivery behavior. #### Time Sensitive ```ruby Ruby activitysmith.notifications.send( { title: "🚨 checkout-api is down", message: "500 errors on 62% of requests. Customers can't complete payments.", interruption_level: "time-sensitive" } ) ``` ### Replace a Push Notification Every send returns a `notification_id`. Pass it to `replace` to update a Push Notification you already sent, for example when an incident you alerted on is resolved. The replacement takes the old notification's place on the Lock Screen and in history instead of stacking a second one. It arrives silently, without sound or waking the screen, and goes to the same recipients as the original. Omit `metadata` or `tags` to keep their stored values. ```ruby Ruby sent = activitysmith.notifications.send( { title: "🚨 checkout-api is down", message: "500 errors on 62% of requests." } ) activitysmith.notifications.replace( sent.notification_id, { title: "✅ checkout-api recovered", message: "Error rate is back to normal. Incident resolved." } ) ``` ### Dismiss a Push Notification Pass the `notification_id` to `dismiss` when a Push Notification no longer needs attention, for example after you answered an agent's question somewhere else. Dismissing clears it from the Lock Screen and Notification Center on every device it was sent to. History keeps it. Devices clear the notification in the background, so it can take a moment. ```ruby Ruby sent = activitysmith.notifications.send( { title: "🙋 Agent needs your input", message: "Approve the database migration?" } ) activitysmith.notifications.dismiss(sent.notification_id) ``` ## Live Activities Choose the Live Activity type that matches what you want to show: - ![Value Live Activity showing revenue with a growth badge](https://cdn.activitysmith.com/features/value-live-activity.png) **Value**: Show a single value on your Lock Screen, such as revenue, a queue count, or a temperature. - ![Stats Live Activity with six labeled sales metrics](https://cdn.activitysmith.com/features/stats-live-activity.png) **Stats**: Show up to 8 labeled values on your Lock Screen, from revenue and orders to uptime and conversion. - ![Alert Live Activity showing a customer reactivation update](https://cdn.activitysmith.com/features/alert-live-activity.png) **Alert**: Show status updates with a clear message, badge, and icon. When you add an action button, `color` controls the button tint. - ![Metrics Live Activity with CPU and memory values](https://cdn.activitysmith.com/features/metrics-live-activity-start.png) **Metrics**: Track two related values with segmented bars, such as CPU and memory. - ![Segmented Progress Live Activity showing a workflow step](https://cdn.activitysmith.com/features/update-live-activity.png) **Segmented Progress**: Show progress through a known set of steps, like build, test, deploy, and verify. - ![Progress Live Activity showing percentage completion](https://cdn.activitysmith.com/features/progress-live-activity.png) **Progress**: Show percentage progress for jobs that move continuously toward completion. - ![Timer Live Activity showing a benchmark run countdown](https://cdn.activitysmith.com/features/timer-live-activity.png) **Timer**: Count down from a duration, or count up from 00:00 while a job runs. ### Start & Update Live Activity Use a stable `stream_key` to identify the metric, job, deployment, or system you want to keep visible. The first `stream(...)` call starts the Live Activity. Later calls with the same `stream_key` update it. > [!WARNING] > iOS limits how often a Live Activity can update. Short bursts that end, like deployment steps, are fine. If one Live Activity keeps updating more often than every couple of minutes, iOS throttles it until the budget refills, roughly an hour, even though the API still returns `200`. [Learn more](/docs/live-activity-stream#update-frequency-and-ios-limits) #### Value ![Value Live Activity stream example](https://cdn.activitysmith.com/features/value-live-activity.png) ```ruby activitysmith.live_activities.stream( "revenue-today", { content_state: { title: "Revenue", type: "value", value: "$1,240", color: "green", icon: { symbol: "dollarsign.circle", color: "green" }, badge: { title: "↑ 18%", color: "purple" } } } ) ``` Send a string or number in `value`. Strings keep their formatting, including currency symbols, units, and decimal places. #### Stats ![Stats Live Activity stream example](https://cdn.activitysmith.com/features/stats-live-activity.png) ```ruby activitysmith.live_activities.stream( "sales-hourly", { content_state: { title: "Sales", subtitle: "last hour", type: "stats", metrics: [ { label: "Revenue", value: "$2430", color: "blue" }, { label: "Orders", value: "37", color: "green" }, { label: "Conversion", value: "4.8%", color: "magenta" }, { label: "Avg Order", value: "$65.68", color: "yellow" }, { label: "Refunds", value: "$84", color: "red" }, { label: "New Buyers", value: "18", color: "cyan" } ] } } ) ``` #### Alert ![Alert Live Activity stream example](https://cdn.activitysmith.com/features/alert-live-activity.png) ```ruby activitysmith.live_activities.stream( "customer-ops", { content_state: ActivitySmith::LiveActivities.content_state( title: "Reactivation", message: "Lumen came back after 2 weeks", type: ActivitySmith::LiveActivities::TYPE_ALERT, icon: ActivitySmith::LiveActivities.alert_icon("cloud.sun", color: "yellow"), badge: ActivitySmith::LiveActivities.alert_badge("Customer", color: "magenta") ) } ) ``` #### Metrics ![Metrics Live Activity stream example](https://cdn.activitysmith.com/features/metrics-live-activity-start.png) ```ruby activitysmith.live_activities.stream( "prod-web-1", { content_state: { title: "Server Health", subtitle: "prod-web-1", type: "metrics", metrics: [ { label: "CPU", value: 9, unit: "%" }, { label: "MEM", value: 45, unit: "%" } ] } } ) ``` #### Segmented Progress ![Segmented Progress Live Activity stream example](https://cdn.activitysmith.com/features/update-live-activity.png) ```ruby activitysmith.live_activities.stream( "nightly-backup", { content_state: { title: "Nightly Backup", subtitle: "upload archive", type: "segmented_progress", number_of_steps: 3, current_step: 2 } } ) ``` #### Progress ![Progress Live Activity stream example](https://cdn.activitysmith.com/features/progress-live-activity.png) ```ruby activitysmith.live_activities.stream( "search-reindex", { content_state: { title: "Search Reindex", subtitle: "catalog-v2", type: "progress", percentage: 42 } } ) ``` #### Timer ![Timer Live Activity stream example](https://cdn.activitysmith.com/features/timer-live-activity.png) ```ruby activitysmith.live_activities.stream( "benchmark-run", { content_state: { title: "Benchmark Run", subtitle: "sampling", type: "timer", duration_seconds: 300, color: "cyan" } } ) ``` For a countdown, send `duration_seconds`. You can update `title`, `subtitle`, `color`, or any other visible field as the work changes. Leave `duration_seconds` out unless you want to change the timer. To start at 00:00 and count up, set `counts_down: false` and leave out `duration_seconds`. ### End Live Activity Call `end_stream(...)` with the same `stream_key` to dismiss the Live Activity. You can include final values before it is removed. Set `auto_dismiss_seconds` to dismiss it after a delay in seconds, or `auto_dismiss_minutes` for minutes. Use `0` for immediate dismissal. Seconds take precedence if both are set. ```ruby activitysmith.live_activities.end_stream( "prod-web-1", { content_state: { title: "Server Health", subtitle: "prod-web-1", type: "metrics", metrics: [ { label: "CPU", value: 7, unit: "%" }, { label: "MEM", value: 38, unit: "%" } ], auto_dismiss_seconds: 30 } } ) ``` ### Icons and Badges Add more context to Live Activities with icons and badges. #### Icon Supported Live Activity types: `value`, `stats`, `alert`, `metrics`, `segmented_progress`, `progress`, and `timer`. ![Metrics Live Activity with an SF Symbol icon on the iPhone Lock Screen](https://cdn.activitysmith.com/features/metrics-live-activity-with-icon.png) ```ruby activitysmith.live_activities.stream( "prod-web-1", { content_state: ActivitySmith::LiveActivities.content_state( title: "Server Health", subtitle: "prod-web-1", type: "metrics", icon: ActivitySmith::LiveActivities.alert_icon("server.rack", color: "blue"), metrics: [ { label: "CPU", value: 18, unit: "%" }, { label: "MEM", value: 42, unit: "%" } ] ) } ) ``` The `icon` symbol value is an Apple SF Symbol name. Browse the catalog with one of these tools: - [ActivitySmith app](https://apps.apple.com/us/app/activitysmith/id6752254835) - Open Settings -> SF Symbols to browse 45 hand-picked icons ready to use - [SF Symbols](https://developer.apple.com/sf-symbols/) - Apple's official macOS app - [Interactful](https://apps.apple.com/app/interactful/id1528095640) - free third-party iOS app listing all SF Symbols under Foundations -> Iconography #### Badge Badges are supported by `value`, `alert`, `segmented_progress`, and `progress` Live Activities. ![Progress Live Activity with a badge on the iPhone Lock Screen](https://cdn.activitysmith.com/features/progress-live-activity-with-badge.png) ```ruby activitysmith.live_activities.stream( "nightly-database-backup", { content_state: ActivitySmith::LiveActivities.content_state( title: "Nightly Database Backup", subtitle: "verify restore", type: "progress", badge: ActivitySmith::LiveActivities.alert_badge("S3", color: "cyan"), percentage: 62 ) } ) ``` ### Colors Choose from these colors for the Live Activity accent, including progress bars and action buttons, or apply them to an individual icon or badge: `lime`, `green`, `cyan`, `blue`, `purple`, `magenta`, `red`, `orange`, `yellow`, `gray` ### Actions ![Metrics Live Activity with action](https://cdn.activitysmith.com/features/metrics-live-activity-action.png) Live Activities can include an action button. - `open_url`: Open a web page or run an iOS Shortcut - `webhook`: Trigger a backend GET/POST workflow #### Open URL action Open a web page or run an iOS Shortcut when someone taps the button. Supported links: - **HTTP/HTTPS:** Web pages, e.g. `https://example.com` - **Shortcuts:** Run Jarvis with `shortcuts://run-shortcut?name=Jarvis` ```ruby activitysmith.live_activities.stream( "prod-web-1", { content_state: { title: "Server Health", subtitle: "prod-web-1", type: "metrics", metrics: [ { label: "CPU", value: 76, unit: "%" }, { label: "MEM", value: 52, unit: "%" } ] }, action: { title: "Dashboard", type: "open_url", url: "https://status.example.com/servers/prod-web-1" } } ) ``` #### Apple Shortcut action ```ruby activitysmith.live_activities.stream( "prod-web-1", { content_state: { title: "Server Health", subtitle: "prod-web-1", type: "metrics", metrics: [ { label: "CPU", value: 76, unit: "%" }, { label: "MEM", value: 52, unit: "%" } ] }, action: { title: "Chat with Jarvis", type: "open_url", url: "shortcuts://run-shortcut?name=Jarvis" } } ) ``` #### Webhook action ```ruby activitysmith.live_activities.stream( "search-reindex", { content_state: { title: "Reindexing product search", subtitle: "Shard 7 of 12", type: "segmented_progress", number_of_steps: 12, current_step: 7 }, action: { title: "Pause Reindex", type: "webhook", url: "https://ops.example.com/hooks/search/reindex/pause", method: "POST", body: { job_id: "reindex-2026-03-19", requested_by: "activitysmith-ruby" } } } ) ``` #### Secondary action ![Alert Live Activity with primary and secondary action buttons](https://cdn.activitysmith.com/features/live-activity-secondary-action.png) Use `secondary_action` when you want a second button beside the primary `action`. The secondary action button is supported for `value`, `alert`, `segmented_progress`, and `progress` Live Activities. Both buttons use the same `open_url`, `webhook`, and Apple Shortcut payload shapes. ```ruby activitysmith.live_activities.stream( "agent-approval", { content_state: ActivitySmith::LiveActivities.content_state( title: "Approval Needed", message: "Should I send the follow-up email to Brightlane?", type: "alert", color: "green", icon: ActivitySmith::LiveActivities.alert_icon("sparkles", color: "green"), badge: ActivitySmith::LiveActivities.alert_badge("Agent", color: "green") ), action: { title: "Send", type: "webhook", url: "https://agent.example.com/live-activity/approve", method: "POST", body: { approval_id: "approval_01JY3J7Q9S0P8M1V5PZK7DR4M2", decision: "send" } }, secondary_action: { title: "Deny", type: "webhook", url: "https://agent.example.com/live-activity/deny", method: "POST", body: { approval_id: "approval_01JY3J7Q9S0P8M1V5PZK7DR4M2", decision: "deny" } } } ) ``` ## Lock Screen Widgets ![Lock screen widgets](https://cdn.activitysmith.com/features/lock-screen-widgets.png) ActivitySmith lets you display any value on your Lock Screen with widgets - SaaS metrics, revenue, signups, uptime, habits, or anything else you want to track. Send a value to a metric key, add a widget to your Lock Screen, and it fetches the latest value automatically. Use the metric key to update its value. The first value creates the metric. ```ruby activitysmith.metrics.update("deploy.success_rate", 99.9) ``` String metric values work too. ```ruby activitysmith.metrics.update("prod.status", "healthy") ``` ### Create a metric Use `create` to set the label and how widgets show the value, such as currency, percent, or a unit. Omitted fields keep their current values, so you can call it every time your app starts. ```ruby activitysmith.metrics.create( "mrr", label: "MRR", format: "currency", currency_code: "USD" ) activitysmith.metrics.update("mrr", 12450) ``` You can also create and edit metrics in the [web app](https://activitysmith.com/app/widgets). ![Create widget metric](https://cdn.activitysmith.com/features/create-widget-metric.png) ## App Icon Badge ![ActivitySmith app icon with an App Icon Badge](https://cdn.activitysmith.com/features/badge-count.png) Show the number you care about on your ActivitySmith app icon. Track MRR, a customer count, a stock price, or any other value you want to keep in view. App Icon Badge requires Push Notifications enabled. On your iPhone, open Settings > ActivitySmith > Notifications and turn on Allow Notifications. ### Set or update the badge value ```ruby Ruby activitysmith.badge_count(8333) ``` ### Clear the badge Pass `0` to clear the badge. ```ruby Ruby activitysmith.badge_count(0) ``` ## Metadata Metadata adds extra information to Push Notification and Live Activity details in ActivitySmith. It does not appear in the notification or Live Activity on your device. ```ruby Ruby activitysmith.notifications.send( title: "New subscription 💸", message: "Customer upgraded to Pro plan", metadata: { customer_id: "382", plan: "Pro", amount: 29, trial: false, } ) activitysmith.live_activities.stream( "customer-import", content_state: { title: "Customer Import", type: "progress", percentage: 60, }, metadata: { job_id: "import-382", records: 1200, } ) ``` Values can be strings, numbers, or booleans. Metadata supports up to 50 entries and 16 KB of JSON, with keys up to 100 characters and strings up to 4,000 characters. Nested objects, arrays, and null values are not supported. ## Tags Use `tags` to organize and filter your Push Notification and Live Activity history. Tags are created automatically when you first use them. ```ruby Ruby activitysmith.notifications.send( { title: "New subscription 💸", message: "Customer upgraded to Pro plan", tags: ["user:382", "billing"] } ) ``` On Live Activity stream updates and legacy `update` or `end` calls, omit `tags` to keep existing Tags, supply a list to replace them, or pass `tags: []` to clear them. ```ruby Ruby activitysmith.live_activities.update( activity_id: "YOUR_ACTIVITY_ID", content_state: { title: "Customer Import", percentage: 60 }, tags: [] ) ``` ## Channels Use `channels` to target specific team members or devices when sending Push Notifications, Live Activities, or App Icon Badge updates. Omit it for account-wide delivery. ```ruby Ruby activitysmith.notifications.send( { title: "New subscription 💸", message: "Customer upgraded to Pro plan", channels: ["sales", "customer-success"] } ) activitysmith.live_activities.stream( "nightly-backup", { channels: ["ios-builds"], content_state: { title: "Nightly database backup", number_of_steps: 3, current_step: 1, type: "segmented_progress" } } ) activitysmith.badge_count(3, channels: ["sales", "customer-success"]) ``` ## Paired Devices List the iPhones and iPads paired to your account, for example to check that a device is paired before you send. Active devices come first: ```ruby Ruby result = activitysmith.devices.list result.devices.each do |device| puts [device.device_name, device.system_name, device.is_active].join(" ") end ``` An empty list means no device is paired. Install ActivitySmith on your iPhone, sign in with the same account, and allow notifications. Channel-scoped API keys cannot list devices. Pass `include_inactive` to also list devices that can no longer receive deliveries: ```ruby Ruby activitysmith.devices.list(include_inactive: true) ``` ## Error Handling Handle API errors with `begin/rescue` around SDK calls: ```ruby Ruby begin activitysmith.notifications.send( { title: "Hello" } ) rescue OpenapiClient::ApiError => err puts "Request failed: #{err.code} #{err.message}" end ``` ## Additional Resources ### [RubyGems Package](https://rubygems.org/gems/activitysmith) Install the ActivitySmith Ruby SDK from RubyGems ### [Source Code](https://github.com/ActivitySmithHQ/activitysmith-ruby) View the Ruby SDK source on GitHub --- Source: https://activitysmith.com/docs/sdks/cli # CLI Use the ActivitySmith CLI to send Push Notifications, start, update, and end Live Activities, run iOS Shortcuts from notification actions, update Lock Screen widgets, and set the App Icon Badge from shell scripts, CI pipelines, coding agents, and terminal workflows. ## Installation Install the ActivitySmith CLI globally with npm: ```bash CLI npm install -g activitysmith-cli ``` ## Agent Skill Install the ActivitySmith skill when you want Codex, Claude, Cursor, or another skills-compatible agent to decide which ActivitySmith CLI command to run. ```bash CLI npx -y skills@latest add ActivitySmithHQ/activitysmith-cli --skill activitysmith ``` Use the skill when an agent should notify you with Push Notifications, include a notification tap or action that can open a URL or run a specific iOS Shortcut, or keep task progress visible with Live Activities. For example, a Codex agent can work on your computer, send a Push Notification when it needs your attention, and include a Shortcut action that runs an `OpenChatGPT` Shortcut on your iPhone so you can continue the conversation in the ChatGPT app. ## Quickstart 1. Run `activitysmith auth login` and approve access in your browser. 2. Run `activitysmith devices list` to check that your iPhone is paired. 3. Run `activitysmith --help` to inspect available commands. ```bash CLI activitysmith auth login activitysmith devices list activitysmith push --title "Hello" ``` ## Authentication ### Sign in with your browser `activitysmith auth login` opens your browser to the ActivitySmith approval screen. Select **Approve**. The CLI saves the sign-in to `~/.config/activitysmith/credentials.json` with owner-only file permissions, and every command then uses it. No API key is created. ```bash CLI activitysmith auth login ``` If no browser can open, for example over SSH, the CLI prints the sign-in URL. Open it in any browser. After you approve, paste the address the browser lands on back into the terminal. ```bash CLI activitysmith auth login --no-browser ``` The CLI appears under AI Agents in the ActivitySmith web app. Select **Disconnect** there to stop it immediately on every machine. Check how the CLI authenticates. Secrets are never printed: ```bash CLI activitysmith auth status ``` Sign out to disconnect the CLI and remove the saved sign-in from this machine: ```bash CLI activitysmith auth logout ``` Set `ACTIVITYSMITH_CONFIG_DIR` to save the sign-in in a different directory. ### Use an API key 1. [Create an API key](https://activitysmith.com/app/keys) 2. Set `ACTIVITYSMITH_API_KEY` or pass `--api-key` per command. Use an API key for CI pipelines, servers, and other machines where nobody can approve a browser sign-in. The CLI uses `--api-key` first, then `ACTIVITYSMITH_API_KEY`, then the sign-in from `activitysmith auth login`. Use the environment variable when you want the cleanest shell scripts: ```bash CLI export ACTIVITYSMITH_API_KEY="YOUR-API-KEY" activitysmith --help ``` Or pass the key directly: ```bash CLI activitysmith --api-key "YOUR-API-KEY" push --title "Hello" ``` ### Create an API key from the CLI Create an API key for CI, servers, and scripts without opening the web app. The command uses the browser sign-in. The first time, it opens your browser so you can approve API key access. ```bash CLI activitysmith keys create --name "GitHub Actions" ``` The key is shown only once. Add `--raw` to print only the key, then pipe it straight into a secret store. The key never appears in your terminal: ```bash CLI activitysmith keys create --name "GitHub Actions" --raw | gh secret set ACTIVITYSMITH_API_KEY ``` Add `--channels` to limit the key to some Channels: ```bash CLI activitysmith keys create --name "Ops alerts" --channels ops,alerts ``` An API key cannot create another key. This command always uses the browser sign-in, even when `ACTIVITYSMITH_API_KEY` is set. ## Push Notifications ### Send a Push Notification Send an immediate notification for a completed task or event. ![Push Notification example](https://cdn.activitysmith.com/printkit/notification.png) ```bash CLI activitysmith push \ --title "Build Failed 🚨" \ --message "CI pipeline failed on main branch" \ --subtitle "main" ``` ### Custom Push Notification Icons ![Push Notifications with custom icons](https://cdn.activitysmith.com/features/push-notifications-with-custom-icons.png) Set `--icon` to a publicly accessible HTTPS image URL to show a logo or avatar alongside a smaller ActivitySmith app icon. Host the image anywhere, such as on your own website or CDN. With a custom icon, iOS may omit the subtitle from the notification. ```bash CLI activitysmith push \ --title 'MRR just crossed $10,000 🎉' \ --message "Up 18% this month from 31 new subscriptions." \ --icon "https://example.com/icons/stripe.png" ``` ### Rich Push Notifications with Media ![Rich Push Notification with image](https://cdn.activitysmith.com/features/rich-push-notification-with-image.png) ```bash CLI activitysmith push \ --title "Homepage ready" \ --message "Your agent finished the redesign." \ --media "https://cdn.example.com/output/homepage-v2.png" ``` Attach images, videos, or audio to your Push Notifications. Press and hold the notification to preview the media. ![Rich Push Notification with audio](https://cdn.activitysmith.com/features/rich-push-notification-with-audio.png) What will work: - direct image URL: `.jpg`, `.png`, `.gif`, etc. - direct audio file URL: `.mp3`, `.m4a`, etc. - direct video file URL: `.mp4`, `.mov`, etc. - URL that responds with a proper media `Content-Type`, even if the path has no extension `--media` cannot be combined with `--actions`. ### Push Notifications with Redirection Open a web page, run an iOS Shortcut, or open an app when someone taps the notification. `--redirection` supports: - **HTTP/HTTPS:** Web pages, e.g. `https://example.com` - **Shortcuts:** Run Jarvis with `shortcuts://run-shortcut?name=Jarvis` - **App deep links:** Installed apps or specific content within them - **Spotify:** A track, e.g. `spotify:track:6rqhFgbbKwnb9MLmUQDhG6` - **Termius:** `termius://` to open the app - **Claude:** `claude://code` to open the Code tab - **ChatGPT:** `chatgpt://` to open the app ```bash CLI activitysmith push \ --title "Homepage ready" \ --message "Your agent finished the redesign." \ --redirection "https://github.com/acme/web/pull/482" ``` ### Actionable Push Notifications ![Actionable Push Notification with redirection and actions](https://cdn.activitysmith.com/features/actionable-push-notifications-2.png) `open_url` actions open a web page, run an iOS Shortcut, or open an app when someone taps the button. Supported links: - **HTTP/HTTPS:** Web pages, e.g. `https://example.com` - **Shortcuts:** Run Jarvis with `shortcuts://run-shortcut?name=Jarvis` - **App deep links:** Installed apps or specific content within them - **Spotify:** A track, e.g. `spotify:track:6rqhFgbbKwnb9MLmUQDhG6` - **Termius:** `termius://` to open the app - **Claude:** `claude://code` to open the Code tab - **ChatGPT:** `chatgpt://` to open the app Webhooks are executed by the ActivitySmith backend and must use HTTPS. ```bash CLI activitysmith push \ --title "Build Failed 🚨" \ --message "CI pipeline failed on main branch" \ --actions '[ { "title": "Open Build", "type": "open_url", "url": "https://github.com/org/repo/actions/runs/123456789" }, { "title": "Chat with Jarvis", "type": "open_url", "url": "shortcuts://run-shortcut?name=Jarvis" }, { "title": "Create Incident", "type": "webhook", "url": "https://hooks.example.com/incidents/create", "method": "POST", "body": { "service": "payments-api", "severity": "high", "source": "activitysmith-cli" } } ]' ``` You can also save the JSON array above as `actions.json` and load it from a file: ```bash CLI activitysmith push \ --title "Build Failed 🚨" \ --message "CI pipeline failed on main branch" \ --actions-file "./actions.json" ``` ### Interruption Levels ![Time Sensitive Push Notification](https://cdn.activitysmith.com/features/time-sensitive-push-notifications.png) Use `--interruption-level` to choose how urgently iOS presents a Push Notification. Omit it for normal delivery. Explicit `active` has the same behavior as the default. | Value | Behavior | | --- | --- | | `passive` | Appears quietly in the notification list, without sound or waking the screen. | | `active` | Normal delivery, subject to the device's notification settings and Focus. This is the default. | | `time-sensitive` | Can bypass Scheduled Summary and Focus when the user allows Time Sensitive Notifications for ActivitySmith. | See Apple's [interruption levels](https://developer.apple.com/documentation/usernotifications/unnotificationinterruptionlevel) for the system behavior. #### Passive ```bash CLI activitysmith push \ --title "Daily summary" \ --message "All scheduled jobs completed successfully." \ --interruption-level "passive" ``` #### Active (default) ```bash CLI activitysmith push \ --title "Deployment complete" \ --message "Your latest changes are live." \ --interruption-level "active" ``` Removing the interruption level from this example produces the same delivery behavior. #### Time Sensitive ```bash CLI activitysmith push \ --title "🚨 checkout-api is down" \ --message "500 errors on 62% of requests. Customers can't complete payments." \ --interruption-level "time-sensitive" ``` ### Replace a Push Notification Every `push` prints a `Notification ID`. Pass it to `--replace` to update a Push Notification you already sent, for example when an incident you alerted on is resolved. The replacement takes the old notification's place on the Lock Screen and in history instead of stacking a second one. It arrives silently, without sound or waking the screen, and goes to the same recipients as the original, so `--channels` and `--interruption-level` don't apply. ```bash CLI activitysmith push \ --title "🚨 checkout-api is down" \ --message "500 errors on 62% of requests." # Notification ID: Xk3pQ8mV2nR7tL9wB4yZ activitysmith push \ --replace "Xk3pQ8mV2nR7tL9wB4yZ" \ --title "✅ checkout-api recovered" \ --message "Error rate is back to normal. Incident resolved." ``` ### Dismiss a Push Notification Pass the `Notification ID` to `push dismiss` when a Push Notification no longer needs attention, for example after you answered an agent's question somewhere else. Dismissing clears it from the Lock Screen and Notification Center on every device it was sent to. History keeps it. Devices clear the notification in the background, so it can take a moment. ```bash CLI activitysmith push \ --title "🙋 Agent needs your input" \ --message "Approve the database migration?" # Notification ID: Xk3pQ8mV2nR7tL9wB4yZ activitysmith push dismiss "Xk3pQ8mV2nR7tL9wB4yZ" ``` ## Live Activities Choose the Live Activity type that matches what you want to show: - ![Value Live Activity showing revenue with a growth badge](https://cdn.activitysmith.com/features/value-live-activity.png) **Value**: Show a single value on your Lock Screen, such as revenue, a queue count, or a temperature. - ![Stats Live Activity with six labeled sales metrics](https://cdn.activitysmith.com/features/stats-live-activity.png) **Stats**: Show up to 8 labeled values on your Lock Screen, from revenue and orders to uptime and conversion. - ![Alert Live Activity showing a customer reactivation update](https://cdn.activitysmith.com/features/alert-live-activity.png) **Alert**: Show status updates with a clear message, badge, and icon. When you add an action button, `color` controls the button tint. - ![Metrics Live Activity with CPU and memory values](https://cdn.activitysmith.com/features/metrics-live-activity-start.png) **Metrics**: Track two related values with segmented bars, such as CPU and memory. - ![Segmented Progress Live Activity showing a workflow step](https://cdn.activitysmith.com/features/update-live-activity.png) **Segmented Progress**: Show progress through a known set of steps, like build, test, deploy, and verify. - ![Progress Live Activity showing percentage completion](https://cdn.activitysmith.com/features/progress-live-activity.png) **Progress**: Show percentage progress for jobs that move continuously toward completion. - ![Timer Live Activity showing a benchmark run countdown](https://cdn.activitysmith.com/features/timer-live-activity.png) **Timer**: Count down from a duration, or count up from 00:00 while a job runs. ### Start & Update Live Activity Use a stable `stream_key` to identify the metric, job, deployment, or system you want to keep visible. The first `activity stream` command starts the Live Activity. Later commands with the same `stream_key` update it. > [!WARNING] > iOS limits how often a Live Activity can update. Short bursts that end, like deployment steps, are fine. If one Live Activity keeps updating more often than every couple of minutes, iOS throttles it until the budget refills, roughly an hour, even though the API still returns `200`. [Learn more](/docs/live-activity-stream#update-frequency-and-ios-limits) #### Value ![Value Live Activity stream example](https://cdn.activitysmith.com/features/value-live-activity.png) ```bash CLI activitysmith activity stream revenue-today \ --content-state '{ "title": "Revenue", "type": "value", "value": "$1,240", "color": "green", "icon": { "symbol": "dollarsign.circle", "color": "green" }, "badge": { "title": "↑ 18%", "color": "purple" } }' ``` Send a string or number in `value`. Strings keep their formatting, including currency symbols, units, and decimal places. #### Stats ![Stats Live Activity stream example](https://cdn.activitysmith.com/features/stats-live-activity.png) ```bash CLI activitysmith activity stream sales-hourly \ --content-state '{ "title": "Sales", "subtitle": "last hour", "type": "stats", "metrics": [ { "label": "Revenue", "value": "$2430", "color": "blue" }, { "label": "Orders", "value": "37", "color": "green" }, { "label": "Conversion", "value": "4.8%", "color": "magenta" }, { "label": "Avg Order", "value": "$65.68", "color": "yellow" }, { "label": "Refunds", "value": "$84", "color": "red" }, { "label": "New Buyers", "value": "18", "color": "cyan" } ] }' ``` #### Alert ![Alert Live Activity stream example](https://cdn.activitysmith.com/features/alert-live-activity.png) ```bash CLI activitysmith activity stream customer-ops \ --content-state '{ "title": "Reactivation", "message": "Lumen came back after 2 weeks", "type": "alert", "icon": { "symbol": "cloud.sun", "color": "yellow" }, "badge": { "title": "Customer", "color": "magenta" } }' ``` #### Metrics ![Metrics Live Activity stream example](https://cdn.activitysmith.com/features/metrics-live-activity-start.png) ```bash CLI activitysmith activity stream prod-web-1 \ --content-state '{ "title": "Server Health", "subtitle": "prod-web-1", "type": "metrics", "metrics": [ { "label": "CPU", "value": 9, "unit": "%" }, { "label": "MEM", "value": 45, "unit": "%" } ] }' ``` #### Segmented Progress ![Segmented Progress Live Activity stream example](https://cdn.activitysmith.com/features/update-live-activity.png) ```bash CLI activitysmith activity stream nightly-backup \ --content-state '{ "title": "Nightly Backup", "subtitle": "upload archive", "type": "segmented_progress", "numberOfSteps": 3, "currentStep": 2 }' ``` #### Progress ![Progress Live Activity stream example](https://cdn.activitysmith.com/features/progress-live-activity.png) ```bash CLI activitysmith activity stream search-reindex \ --content-state '{ "title": "Search Reindex", "subtitle": "catalog-v2", "type": "progress", "percentage": 42 }' ``` #### Timer ![Timer Live Activity stream example](https://cdn.activitysmith.com/features/timer-live-activity.png) ```bash CLI activitysmith activity stream benchmark-run \ --content-state '{ "title": "Benchmark Run", "subtitle": "sampling", "type": "timer", "durationSeconds": 300, "color": "cyan" }' ``` For a countdown, send `durationSeconds`. Leave it out on later stream updates to preserve the running timer. Supplying a new duration restarts the countdown. To start at 00:00 and count up, set `countsDown` to `false` and leave out `durationSeconds`. ### End Live Activity Call `activity end-stream` with the same `stream_key` to dismiss the Live Activity. You can include final values before it is removed. Use `--auto-dismiss-seconds` or `--auto-dismiss-minutes` to delay dismissal. Use `0` for immediate dismissal. Seconds take precedence if both are set. JSON content state also accepts `autoDismissSeconds` or `auto_dismiss_seconds`. ```bash CLI activitysmith activity end-stream prod-web-1 \ --auto-dismiss-seconds 30 \ --content-state '{ "title": "Server Health", "subtitle": "prod-web-1", "type": "metrics", "metrics": [ { "label": "CPU", "value": 7, "unit": "%" }, { "label": "MEM", "value": 38, "unit": "%" } ] }' ``` ### Icons and Badges Add more context to Live Activities with icons and badges. #### Icon ```bash activitysmith activity stream prod-web-1 \ --content-state '{ "title": "Server Health", "type": "metrics", "metrics": [ { "label": "CPU", "value": 18, "unit": "%" }, { "label": "MEM", "value": 42, "unit": "%" } ], "icon": { "symbol": "server.rack", "color": "blue" } }' ``` The `icon.symbol` value is an Apple SF Symbol name. Browse the catalog in the ActivitySmith iOS app under Settings > SF Symbols. #### Badge ```bash activitysmith activity stream nightly-backup \ --content-state '{ "title": "Nightly Database Backup", "type": "segmented_progress", "numberOfSteps": 3, "currentStep": 2, "badge": { "title": "S3", "color": "cyan" } }' ``` ### Colors Choose from these colors for the Live Activity accent, including progress bars and action buttons, or apply them to an individual icon or badge: `lime`, `green`, `cyan`, `blue`, `purple`, `magenta`, `red`, `orange`, `yellow`, `gray` ### Actions ![Metrics Live Activity with action](https://cdn.activitysmith.com/features/metrics-live-activity-action.png) Live Activities can include an action button. - `open_url`: Open a web page or run an iOS Shortcut - `webhook`: Trigger a backend GET/POST workflow #### Open URL action Open a web page or run an iOS Shortcut when someone taps the button. Supported links: - **HTTP/HTTPS:** Web pages, e.g. `https://example.com` - **Shortcuts:** Run Jarvis with `shortcuts://run-shortcut?name=Jarvis` ```bash CLI activitysmith activity stream prod-web-1 \ --content-state '{ "title": "Server Health", "subtitle": "prod-web-1", "type": "metrics", "metrics": [ { "label": "CPU", "value": 76, "unit": "%" }, { "label": "MEM", "value": 52, "unit": "%" } ] }' \ --action '{ "title": "Dashboard", "type": "open_url", "url": "https://status.example.com/servers/prod-web-1" }' ``` #### Apple Shortcut action ```bash CLI activitysmith activity stream prod-web-1 \ --content-state '{ "title": "Server Health", "subtitle": "prod-web-1", "type": "metrics", "metrics": [ { "label": "CPU", "value": 76, "unit": "%" }, { "label": "MEM", "value": 52, "unit": "%" } ] }' \ --action '{ "title": "Chat with Jarvis", "type": "open_url", "url": "shortcuts://run-shortcut?name=Jarvis" }' ``` #### Webhook action ```bash CLI activitysmith activity stream search-reindex \ --content-state '{ "title": "Reindexing product search", "subtitle": "Shard 7 of 12", "type": "segmented_progress", "numberOfSteps": 12, "currentStep": 7 }' \ --action '{ "title": "Pause Reindex", "type": "webhook", "url": "https://ops.example.com/hooks/search/reindex/pause", "method": "POST", "body": { "job_id": "reindex-2026-03-19", "requested_by": "activitysmith-cli" } }' ``` #### Secondary action ![Alert Live Activity with primary and secondary action buttons](https://cdn.activitysmith.com/features/live-activity-secondary-action.png) Use `--secondary-action` when you want a second button beside the primary `--action`. The secondary action button is supported for `value`, `alert`, `segmented_progress`, and `progress` Live Activities. Both buttons use the same `open_url`, `webhook`, and Apple Shortcut payload shapes. ```bash CLI activitysmith activity stream agent-approval \ --content-state '{ "title": "Approval Needed", "message": "Should I send the follow-up email to Brightlane?", "type": "alert", "color": "green", "icon": { "symbol": "sparkles", "color": "green" }, "badge": { "title": "Agent", "color": "green" } }' \ --action '{ "title": "Send", "type": "webhook", "url": "https://agent.example.com/live-activity/approve", "method": "POST", "body": { "approval_id": "approval_01JY3J7Q9S0P8M1V5PZK7DR4M2", "decision": "send" } }' \ --secondary-action '{ "title": "Deny", "type": "webhook", "url": "https://agent.example.com/live-activity/deny", "method": "POST", "body": { "approval_id": "approval_01JY3J7Q9S0P8M1V5PZK7DR4M2", "decision": "deny" } }' ``` ## Lock Screen Widgets ![Lock screen widgets](https://cdn.activitysmith.com/features/lock-screen-widgets.png) ActivitySmith lets you display any value on your Lock Screen with widgets - SaaS metrics, revenue, signups, uptime, habits, or anything else you want to track. Send a value to a metric key, add a widget to your Lock Screen, and it fetches the latest value automatically. Use the metric key to update its value. The first value creates the metric. ```bash activitysmith metrics update deploy.success_rate 99.9 ``` String metric values work too. ```bash activitysmith metrics update prod.status healthy ``` ### Create a metric Use `create` to set the label and how widgets show the value, such as currency, percent, or a unit. Omitted fields keep their current values, so you can call it every time your app starts. ```bash activitysmith metrics create mrr \ --label MRR \ --format currency \ --currency-code USD activitysmith metrics update mrr 12450 ``` You can also create and edit metrics in the [web app](https://activitysmith.com/app/widgets). ![Create widget metric](https://cdn.activitysmith.com/features/create-widget-metric.png) ## App Icon Badge ![ActivitySmith app icon with an App Icon Badge](https://cdn.activitysmith.com/features/badge-count.png) Show the number you care about on your ActivitySmith app icon. Track MRR, a customer count, a stock price, or any other value you want to keep in view. App Icon Badge requires Push Notifications enabled. On your iPhone, open Settings > ActivitySmith > Notifications and turn on Allow Notifications. ### Set or update the badge value ```bash CLI activitysmith badge 8333 ``` ### Clear the badge Pass `0` to clear the badge. ```bash CLI activitysmith badge 0 ``` ## Approvals ![Approval Live Activity on an iPhone Lock Screen with Send and Deny buttons](https://cdn.activitysmith.com/features/ai-agent-approval-live-activity-phone.png) Let your agents ask for your approval before they act, such as sending an email to customers or deploying to production. The request reaches your iPhone as a Live Activity or an actionable Push Notification, both with two buttons. The agent waits until you tap one and continues only when you approve. ```bash CLI activitysmith approval request "Send the pricing update email to 214 customers?" \ --approve-label "Send" \ --reject-label "Don't Send" ``` When you approve, the command prints `Approved.` and exits with code `0`. The agent, or a script, runs the action only after that: ```bash CLI activitysmith approval request "Deploy to production?" --approve-label "Deploy" && ./deploy.sh ``` Exit codes for `approval request` and `approval wait`: - `0`: Approved. Continue with the action. - `1`: Rejected, timed out after 30 minutes, or cancelled. Do not continue. - `2`: The request failed, for example because no device is paired. - `3`: Still pending after `--timeout`, or sent with `--no-wait`. ### Show the exact command Add `--command` with the exact command that waits for approval. The request shows the command and the current directory: ```bash CLI activitysmith approval request "Run the database migration?" \ --approve-label "Migrate" \ --command "npm run db:migrate -- --env production" ``` Add `--details` for short context. Add `--scope` to show where the action applies, such as `environment:production`. ### Wait in steps Some agents stop shell commands after a few minutes. Add `--timeout` to stop waiting early. The command then prints the approval ID and exits with code `3`. Run `approval wait` to keep waiting: ```bash CLI activitysmith approval request "Publish the release notes?" --timeout 100 activitysmith approval wait apr_Xk3pQ8mV2nR7tL9w --timeout 100 ``` ### Check or cancel a request ```bash CLI activitysmith approval get apr_Xk3pQ8mV2nR7tL9w activitysmith approval cancel apr_Xk3pQ8mV2nR7tL9w ``` Cancel a request when the action is no longer needed. Its buttons stop working, and a Live Activity updates to show the request was cancelled. ### Change how the request looks By default, the request is a Live Activity, with an actionable Push Notification as the fallback. Add `--delivery push_notification` to always send a Push Notification, or `--delivery live_activity` to always send a Live Activity. Use `--badge`, `--color`, and `--icon` to change the Live Activity: ```bash CLI activitysmith approval request "Refund order #4821 for $129?" \ --approve-label "Refund" \ --badge "Billing" \ --color orange \ --icon creditcard ``` ## Metadata Metadata adds extra information to Push Notification and Live Activity details in ActivitySmith. It does not appear in the notification or Live Activity on your device. ```bash CLI activitysmith push \ --title "New subscription 💸" \ --message "Customer upgraded to Pro plan" \ --metadata '{ "customer_id": "382", "plan": "Pro", "amount": 29, "trial": false }' activitysmith activity stream customer-import \ --title "Customer Import" \ --type progress \ --percentage 60 \ --metadata '{ "job_id": "import-382", "records": 1200 }' ``` Values can be strings, numbers, or booleans. Metadata supports up to 50 entries and 16 KB of JSON, with keys up to 100 characters and strings up to 4,000 characters. Nested objects, arrays, and null values are not supported. ## Tags Use `tags` to organize and filter your Push Notification and Live Activity history. Tags are created automatically when you first use them. ```bash CLI activitysmith push \ --title "New subscription 💸" \ --message "Customer upgraded to Pro plan" \ --tags "user:382,billing" ``` For `activity stream`, `activity update`, and `activity end`, omit `--tags` to keep existing Tags, pass `--tags` to replace them, or use `--clear-tags` to remove them. `--tags` and `--clear-tags` cannot be used together. ```bash activitysmith activity stream customer-import \ --title "Customer Import" \ --type progress \ --percentage 60 \ --clear-tags ``` `activity end-stream` also accepts `--tags` or `--clear-tags` to replace or clear Tags in the final history entry. Omit both flags to preserve them. ## Channels Use `--channels` to target specific team members or devices when sending Push Notifications, Live Activities, or App Icon Badge updates. Omit it for account-wide delivery. ```bash CLI activitysmith push \ --title "Build Failed 🚨" \ --message "CI pipeline failed on main branch" \ --channels "devs,ops" ``` ```bash CLI activitysmith activity stream nightly-backup \ --content-state '{ "title": "Nightly database backup", "type": "segmented_progress", "numberOfSteps": 4, "currentStep": 1 }' \ --channels "devs,ops" ``` ```bash CLI activitysmith badge 3 --channels "sales,customer-success" ``` ## Paired Devices List the iPhones and iPads paired to your account. Active devices come first: ```bash CLI activitysmith devices list ``` If no device is paired, the command prints the App Store link. Install ActivitySmith on your iPhone, sign in with the same account, and allow notifications. Add `--include-inactive` to also list devices that can no longer receive deliveries: ```bash CLI activitysmith devices list --include-inactive ``` ## Output Use `--json` for machine-readable output: ```bash CLI activitysmith push --title "Hello" --json ``` ## Error Handling The CLI exits non-zero on non-2xx responses and prints the API error body. That includes validation failures, rate limits, and Live Activity limit errors. ## Additional Resources ### [NPM Package](https://www.npmjs.com/package/activitysmith-cli) Install the ActivitySmith CLI from npm ### [Source Code](https://github.com/ActivitySmithHQ/activitysmith-cli) View the CLI source on GitHub --- Source: https://activitysmith.com/docs/api-reference/introduction # Introduction ActivitySmith API reference ## Features ### [Push Notifications](/docs/api-reference/endpoint/push-notification) Send a push notification to all of your paired devices. ### [Live Activities](/docs/api-reference/endpoint/live-activity-stream) Start, update, and dismiss a Live Activity stream. ### [Widgets](/docs/api-reference/endpoint/metric-value-update) Create metrics and update the values shown in ActivitySmith widgets. ### [App Icon Badge](/docs/api-reference/endpoint/app-icon-badge-count) Show the number you care about on your ActivitySmith app icon. ## Base URL All requests contain the following base URL: ```bash https://activitysmith.com/api/ ``` ## Authentication For authentication, it's required to include an Authorization header. The header should contain `Bearer ask_123456789`, where `ask_123456789` represents your [API Key](/docs/api-keys). ```bash Authorization: Bearer ask_123456789 ``` ## Response codes ActivitySmith employs conventional HTTP status codes to signify the outcome of your requests. Typically, 2xx HTTP status codes denote success, 4xx codes represent failures related to the user, and 5xx codes signal infrastructure problems. | Status | Description | | ------ | -------------------------------------------- | | 200 | Request was successful. | | 400 | Verify the correctness of the parameters. | | 401 | The API key is invalid or was not provided. | | 404 | The requested resource could not be located. | | 429 | The rate limit has been surpassed. | | 5xx | Signifies a server error with ActivitySmith. | Refer to the Error Codes section for a detailed explanation of all potential API errors. ## Character encoding Send JSON request bodies as UTF-8. If a body has bytes that are not valid UTF-8, the API returns `400` with the code `invalid_utf8` and sends nothing. You can send the request again with a UTF-8 body. ### Accented characters and emoji on Windows Some Windows tools send your text in a legacy code page instead of UTF-8: - `curl` in Git Bash, when the JSON is on the command line. - `Invoke-RestMethod`, `Invoke-WebRequest`, and the `curl` alias in Windows PowerShell 5.1, when the body is a string. This causes two problems: - Accented characters such as `é` become invalid bytes, and the API returns `invalid_utf8`. - Emoji become `??`. The API cannot detect this because `??` is valid text, so the Push Notification shows `??`. Plain ASCII text is not affected. To send other characters, use one of these options. **Use an SDK or the CLI.** This is the simplest option. Use an [SDK or the CLI](/docs/sdks/overview) instead of cURL. **Send the JSON through stdin in Git Bash.** `curl` sends stdin unchanged, so the text stays UTF-8: ```bash Git Bash YOUR_API_KEY="your-api-key" curl -X POST https://activitysmith.com/api/push-notification \ -H "Authorization: Bearer $YOUR_API_KEY" \ -H "Content-Type: application/json" \ --data-binary @- <<'JSON' {"title":"Commande reçue 🚀","message":"Paiement confirmé"} JSON ``` **Send UTF-8 bytes from PowerShell.** This example works in Windows PowerShell 5.1 and PowerShell 7: ```bash PowerShell $YOUR_API_KEY = "your-api-key" $body = @{ title = "Commande reçue 🚀" message = "Paiement confirmé" } | ConvertTo-Json -Compress Invoke-RestMethod -Method Post ` -Uri "https://activitysmith.com/api/push-notification" ` -Headers @{ Authorization = "Bearer $YOUR_API_KEY" } ` -ContentType "application/json; charset=utf-8" ` -Body ([System.Text.Encoding]::UTF8.GetBytes($body)) ``` Do not pass the JSON string directly to `-Body`. PowerShell versions before 7.4 do not encode it as UTF-8 by default. If you save this example as a `.ps1` file for Windows PowerShell 5.1, save the file as UTF-8 with a BOM. Without a BOM, Windows PowerShell 5.1 misreads the accented characters and emoji in the script, and the API cannot detect the wrong text. **Send a file with `curl.exe` from PowerShell.** Write each non-ASCII character as a JSON escape, such as `\u00e7` for `ç` and `\ud83d\ude80` for 🚀. The file is then plain ASCII, so no code page can change it: ```bash PowerShell $YOUR_API_KEY = "your-api-key" '{"title":"Commande re\u00e7ue \ud83d\ude80","message":"Paiement confirm\u00e9"}' | Set-Content -Encoding UTF8 body.json curl.exe -X POST https://activitysmith.com/api/push-notification ` -H "Authorization: Bearer $YOUR_API_KEY" ` -H "Content-Type: application/json" ` --data-binary "@body.json" ``` Follow these rules when you use `curl.exe`: - Type `curl.exe`. In Windows PowerShell 5.1, `curl` runs `Invoke-WebRequest`. - Send the JSON from a file. Windows PowerShell 5.1 removes the double quotes from JSON on the command line, and the API returns `invalid_json`. - Put quotes around `"@body.json"`. PowerShell gives `@` a special meaning. - In Command Prompt, save the same JSON as `body.json` with a text editor, then run the `curl.exe` command on one line. ## Channels Channels let you target specific subsets of recipients instead of broadcasting to everyone in an account. - Use channels when teams, environments, or workflows need separate delivery groups. - Keep [API keys](/docs/api-keys) broad or channel-scoped depending on how strict you want targeting to be. Read the full [channels guide](/docs/channels). ## Rate limit The ActivitySmith API has a [rate limit](/docs/rate-limits) to ensure the stability and reliability of the service. The rate limit is applied to all endpoints and is based on the number of requests made within a specific time frame. When you exceed the rate limit, you will receive a 429 response code. --- Source: https://activitysmith.com/docs/api-reference/endpoint/push-notification # Send Push Notification Sends a push notification to devices matched by API key scope and optional target channels. Supports optional redirection URL, optional media preview or playback when the notification is expanded, and up to 4 interactive actions. `media` cannot be combined with `actions`. Optional `icon` shows a custom image, such as a logo or avatar, next to a smaller app icon. Optional `interruption_level` sets how urgently iOS presents the notification. Optional tags to organize and filter notification history. ```http POST https://activitysmith.com/api/push-notification ``` ## Authentication Use your [API key](/docs/api-keys) in the request header. ```http Authorization: Bearer $YOUR_API_KEY ``` ## Request examples ```javascript Node import ActivitySmith from "activitysmith"; const activitysmith = new ActivitySmith({ apiKey: process.env.ACTIVITYSMITH_API_KEY, }); await activitysmith.notifications.send({ title: "New subscription 💸", message: "Customer upgraded to Pro plan", }); ``` ```python Python import os from activitysmith import ActivitySmith activitysmith = ActivitySmith(api_key=os.environ["ACTIVITYSMITH_API_KEY"]) activitysmith.notifications.send({ "title": "New subscription 💸", "message": "Customer upgraded to Pro plan", }) ``` ```go Go package main import ( "log" activitysmithsdk "github.com/ActivitySmithHQ/activitysmith-go" ) func main() { activitysmith, err := activitysmithsdk.New("YOUR-API-KEY") if err != nil { log.Fatal(err) } _, err = activitysmith.Notifications.Send(activitysmithsdk.PushNotificationInput{ Title: "New subscription 💸", Message: "Customer upgraded to Pro plan", }) if err != nil { log.Fatal(err) } } ``` ```php PHP notifications->send([ 'title' => 'New subscription 💸', 'message' => 'Customer upgraded to Pro plan', ]); ``` ```ruby Ruby require "activitysmith" activitysmith = ActivitySmith::Client.new(api_key: ENV.fetch("ACTIVITYSMITH_API_KEY")) activitysmith.notifications.send( title: "New subscription 💸", message: "Customer upgraded to Pro plan" ) ``` ```bash cURL curl -X POST "https://activitysmith.com/api/push-notification" \ -H "Authorization: Bearer $YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "title": "New subscription 💸", "message": "Customer upgraded to Pro plan" }' ``` ## Body Content type: `application/json` ### Schema: PushNotificationRequest | Field | Type | Presence | Description | Constraints | | --- | --- | --- | --- | --- | | `metadata` | `Metadata` | Optional | | | | `title` | string | Required | | | | `message` | string | Optional | | | | `subtitle` | string | Optional | | | | `icon` | `string` | Optional | Optional HTTPS image URL without credentials for a custom notification icon. If the image cannot be loaded, the app icon is used. iOS may omit subtitle when displaying a custom icon. | **Pattern**: `^https://` | | `interruption_level` | `PushInterruptionLevel` | Optional | Optional. How urgently iOS presents the notification: `passive` (quiet, no sound or screen wake), `active` (default), or `time-sensitive` (can break through Focus and Scheduled Summary when allowed). Omit for normal delivery. | | | `media` | `string` | Optional | Optional HTTPS URL for an image, audio file, or video that users can preview or play when they expand the notification. If `redirection` is omitted, tapping the notification opens this URL. Cannot be combined with `actions`. | **Pattern**: `^https://` | | `redirection` | `string` | Optional | Optional HTTP, HTTPS, Shortcuts, or installed app URL opened when the user taps the notification body. Custom schemes such as spotify:// and spotify:track:123 require iOS 1.13.4 build 2 or later and an installed handler; no web fallback is provided. Internal and executable schemes are blocked. Overrides the default tap target from media. | **Pattern**: `^[A-Za-z][A-Za-z0-9+.-]*:`; **Max Length**: `2048` | | `actions` | array of `PushNotificationAction` | Optional | Optional interactive actions shown when users expand the notification. Cannot be combined with `media`. | **Max Items**: `4` | | `payload` | object | Optional | | **Additional Properties**: `true` | | `badge` | integer | Optional | | | | `sound` | string | Optional | | | | `target` | `ChannelTarget` | Optional | | | | `tags` | `TagSlugs` | Optional | | | **Additional Properties**: `false` **default** ```json { "title": "New subscription 💸", "message": "Customer upgraded to Pro plan" } ``` **channel targeted** ```json { "title": "New subscription 💸", "message": "Customer upgraded to Pro plan", "target": { "channels": [ "devs", "ops" ] } } ``` **redirection** ```json { "title": "Incident Resolved ✅", "message": "All systems operational", "redirection": "https://status.example.com/incidents/abc-123" } ``` **media preview** ```json { "title": "Homepage ready", "message": "Your agent finished the redesign.", "media": "https://cdn.example.com/output/homepage.png" } ``` **media preview with redirection** ```json { "title": "Homepage ready", "message": "Your agent finished the redesign.", "media": "https://cdn.example.com/output/homepage.png", "redirection": "https://github.com/acme/web/pull/482" } ``` **actions open url** ```json { "title": "Release Candidate Ready 🚀", "message": "v2.14.0-rc.1 deployed to staging", "actions": [ { "title": "View CI Run", "type": "open_url", "url": "https://github.com/activitysmithhq/backend/actions/runs/1234567890" }, { "title": "Release Notes", "type": "open_url", "url": "https://github.com/activitysmithhq/backend/releases/tag/v2.14.0-rc.1" } ] } ``` **actions webhook** ```json { "title": "Build Failed 🚨", "message": "Tap and hold for remediation actions", "redirection": "https://ci.example.com/builds/8842", "actions": [ { "title": "Retry Build", "type": "webhook", "url": "https://hooks.example.com/activitysmith/build-retry", "method": "POST", "body": { "build_id": "8842", "source": "push_action" } } ] } ``` **Organize notification history with tags** ```json { "title": "New subscription 💸", "message": "Customer upgraded to Pro plan", "tags": [ "user:382", "billing" ] } ``` **Show a custom icon** ```json { "title": "MRR just crossed $10,000 🎉", "message": "Up 18% this month from 31 new subscriptions.", "icon": "https://example.com/icons/stripe.png" } ``` **Deliver as Time Sensitive** ```json { "title": "🚨 checkout-api is down", "message": "500 errors on 62% of requests. Customers can't complete payments.", "interruption_level": "time-sensitive" } ``` ## Responses ### 200 Push notification sent Content type: `application/json` ### Schema: PushNotificationResponse Apple APNs acceptance result. Acceptance does not confirm device delivery or presentation. Alerts remain eligible for APNs delivery retries for 24 hours; device settings and APNs storage policies still apply. | Field | Type | Presence | Description | Constraints | | --- | --- | --- | --- | --- | | `success` | boolean | Required | True when APNs accepts the notification for at least one targeted device. | | | `notification_id` | string | Optional | ID of this Push Notification. Pass it to `PUT /push-notification/{notification_id}` to replace the notification later. | | | `devices_notified` | integer | Optional | Number of device tokens for which APNs accepted the notification, without confirming on-device delivery. | | | `users_notified` | integer | Optional | | | | `effective_channel_slugs` | array of string or null | Optional | | | | `tags` | `TagSlugs` | Optional | | | | `timestamp` | `string` | Required | | | | `devices_targeted` | integer | Optional | Number of device tokens targeted. | | | `devices_deactivated` | integer | Optional | Number of device tokens deactivated because APNs reported them unregistered. | | | `devices_unregistered` | integer | Optional | Number of targeted device tokens APNs reported as unregistered. | | | `credential_test` | boolean | Optional | True when the request was an integration connection test and no paired devices were available. | | | `message` | string | Optional | | | **Additional Properties**: `false` **default** ```json { "success": true, "notification_id": "Xk3pQ8mV2nR7tL9wB4yZ", "devices_notified": 2, "users_notified": 1, "timestamp": "2025-08-12T12:00:00.000Z" } ``` **channel targeted** ```json { "success": true, "notification_id": "Xk3pQ8mV2nR7tL9wB4yZ", "devices_notified": 2, "users_notified": 1, "effective_channel_slugs": [ "devs", "ops" ], "timestamp": "2025-08-12T12:00:00.000Z" } ``` **tagged** ```json { "success": true, "notification_id": "Xk3pQ8mV2nR7tL9wB4yZ", "devices_notified": 2, "users_notified": 1, "effective_channel_slugs": null, "tags": [ "user:382", "billing" ], "timestamp": "2025-08-12T12:00:00.000Z" } ``` ### 400 Bad request (invalid payload or channel targeting input) Content type: `application/json` ### Schema: BadRequestError | Field | Type | Presence | Description | Constraints | | --- | --- | --- | --- | --- | | `error` | string | Required | | | | `message` | string | Required | | | **Additional Properties**: `true` **invalid target** ```json { "error": "Invalid channel targeting", "message": "target.channels must be an array of channel slugs" } ``` **invalid tags** ```json { "error": "Invalid tags", "code": "invalid_tags", "message": "tags must use 1-64 lowercase letters, numbers, dashes, underscores, periods, or colons" } ``` ### 402 Billing access required Content type: `application/json` ### Schema: BillingBlockedError | Field | Type | Presence | Description | Constraints | | --- | --- | --- | --- | --- | | `error` | string | Required | | **Enum**: `["trial_expired","trial_exhausted","billing_overage_cap_reached"]` | | `message` | string | Required | | | | `trial_period` | object | Optional | | | | `trial_period.started_at` | `string` | Required | | | | `trial_period.ends_at` | `string` | Required | | | | `upgrade_url` | `string` | Required | | | **Additional Properties**: `true` ### 403 Forbidden (API key scope or channel assignment violation) Content type: `application/json` ### Schema: ForbiddenError | Field | Type | Presence | Description | Constraints | | --- | --- | --- | --- | --- | | `error` | string | Required | | | | `message` | string | Required | | | **Additional Properties**: `true` **channel scope violation** ```json { "error": "Invalid channel targeting", "message": "This API key can only target assigned channels. Requested channels include channels outside this key scope." } ``` ### 422 No paired devices on the account, or no devices matched the effective channel target Content type: `application/json` ### Schema: NoRecipientsError | Field | Type | Presence | Description | Constraints | | --- | --- | --- | --- | --- | | `error` | string | Required | | | | `code` | string | Optional | Machine-readable reason. no_paired_devices: the account has no active paired iOS devices; pair an iPhone with the ActivitySmith app. no_recipients_found: devices are paired, but none matched the targeted channels. Treat unknown values as a generic no-delivery error. | | | `message` | string | Required | | | | `app_store_url` | `string` | Optional | ActivitySmith App Store link. Present when code is no_paired_devices. | | | `effective_channel_slugs` | array of string or null | Optional | | | **Additional Properties**: `true` **no paired devices** ```json { "error": "No paired devices", "code": "no_paired_devices", "message": "No active iOS devices are paired yet. Download ActivitySmith from the App Store and pair your device.", "effective_channel_slugs": null, "app_store_url": "https://apps.apple.com/us/app/activitysmith/id6752254835" } ``` **no channel recipients** ```json { "error": "No recipients found", "code": "no_recipients_found", "message": "No active iOS devices matched the targeted channels.", "effective_channel_slugs": [ "marketing" ] } ``` ### 429 Rate limit exceeded Content type: `application/json` **oneOf** Schema: `RateLimitError` Schema: `LiveActivityLimitError` **rate limited** ```json { "error": "Rate limit exceeded", "message": "Too many requests, please try again later." } ``` [Download the OpenAPI specification](/openapi.json) --- Source: https://activitysmith.com/docs/api-reference/endpoint/push-notification-replace # Replace Push Notification Replaces a Push Notification you already sent, using the `notification_id` from the send response. The replacement takes the original's place on the Lock Screen and in Notification Center instead of appearing as a second notification. It is delivered silently, with no sound or screen wake, to the same recipients as the original. Notification history is updated in place. ```http PUT https://activitysmith.com/api/push-notification/{notification_id} ``` ## Authentication Use your [API key](/docs/api-keys) in the request header. ```http Authorization: Bearer $YOUR_API_KEY ``` ## Parameters ### notification_id path parameter. Required. The `notification_id` returned when the Push Notification was sent. Type: string **Min Length**: `1` ## Request examples ```javascript Node import ActivitySmith from "activitysmith"; const activitysmith = new ActivitySmith({ apiKey: process.env.ACTIVITYSMITH_API_KEY, }); await activitysmith.notifications.replace("Xk3pQ8mV2nR7tL9wB4yZ", { title: "✅ checkout-api recovered", message: "Error rate is back to normal. Incident resolved.", }); ``` ```python Python import os from activitysmith import ActivitySmith activitysmith = ActivitySmith(api_key=os.environ["ACTIVITYSMITH_API_KEY"]) activitysmith.notifications.replace( "Xk3pQ8mV2nR7tL9wB4yZ", title="✅ checkout-api recovered", message="Error rate is back to normal. Incident resolved.", ) ``` ```go Go package main import ( "log" activitysmithsdk "github.com/ActivitySmithHQ/activitysmith-go" ) func main() { activitysmith, err := activitysmithsdk.New("YOUR-API-KEY") if err != nil { log.Fatal(err) } _, err = activitysmith.Notifications.Replace("Xk3pQ8mV2nR7tL9wB4yZ", activitysmithsdk.PushNotificationReplaceInput{ Title: "✅ checkout-api recovered", Message: "Error rate is back to normal. Incident resolved.", }) if err != nil { log.Fatal(err) } } ``` ```php PHP notifications->replace( 'Xk3pQ8mV2nR7tL9wB4yZ', title: '✅ checkout-api recovered', message: 'Error rate is back to normal. Incident resolved.', ); ``` ```ruby Ruby require "activitysmith" activitysmith = ActivitySmith::Client.new(api_key: ENV.fetch("ACTIVITYSMITH_API_KEY")) activitysmith.notifications.replace( "Xk3pQ8mV2nR7tL9wB4yZ", { title: "✅ checkout-api recovered", message: "Error rate is back to normal. Incident resolved." } ) ``` ```bash CLI activitysmith push \ --replace "Xk3pQ8mV2nR7tL9wB4yZ" \ --title "✅ checkout-api recovered" \ --message "Error rate is back to normal. Incident resolved." ``` ```bash cURL curl -X PUT "https://activitysmith.com/api/push-notification/Xk3pQ8mV2nR7tL9wB4yZ" \ -H "Authorization: Bearer $YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "title": "✅ checkout-api recovered", "message": "Error rate is back to normal. Incident resolved." }' ``` ## Body Content type: `application/json` ### Schema: PushNotificationReplaceRequest Replacement content. title, subtitle, message, redirection, media, icon, actions, and payload fully replace the original values. Omit metadata or tags to keep the stored values; send {} or [] to clear them. | Field | Type | Presence | Description | Constraints | | --- | --- | --- | --- | --- | | `metadata` | `Metadata` | Optional | Optional. Omit to keep the stored metadata; send {} to clear it. | | | `title` | string | Required | | | | `message` | string | Optional | | | | `subtitle` | string | Optional | | | | `icon` | `string` | Optional | Optional HTTPS image URL without credentials for a custom notification icon. If the image cannot be loaded, the app icon is used. iOS may omit subtitle when displaying a custom icon. | **Pattern**: `^https://` | | `media` | `string` | Optional | Optional HTTPS URL for an image, audio file, or video that users can preview or play when they expand the notification. If `redirection` is omitted, tapping the notification opens this URL. Cannot be combined with `actions`. | **Pattern**: `^https://` | | `redirection` | `string` | Optional | Optional HTTP, HTTPS, Shortcuts, or installed app URL opened when the user taps the notification body. Custom schemes such as spotify:// and spotify:track:123 require iOS 1.13.4 build 2 or later and an installed handler; no web fallback is provided. Internal and executable schemes are blocked. Overrides the default tap target from media. | **Pattern**: `^[A-Za-z][A-Za-z0-9+.-]*:`; **Max Length**: `2048` | | `actions` | array of `PushNotificationAction` | Optional | Optional interactive actions shown when users expand the notification. Cannot be combined with `media`. | **Max Items**: `4` | | `payload` | object | Optional | | **Additional Properties**: `true` | | `badge` | integer | Optional | | | | `tags` | `TagSlugs` | Optional | Optional. Omit to keep the stored tags; send [] to clear them. | | **Additional Properties**: `false` **default** ```json { "title": "✅ checkout-api recovered", "message": "Error rate is back to normal. Incident resolved." } ``` ## Responses ### 200 Push notification replaced Content type: `application/json` ### Schema: PushNotificationReplaceResponse Apple APNs acceptance result for the replacement. Acceptance does not confirm device delivery or presentation. | Field | Type | Presence | Description | Constraints | | --- | --- | --- | --- | --- | | `success` | boolean | Required | True when APNs accepts the replacement for at least one device. | | | `notification_id` | string | Required | ID of the replaced Push Notification. It stays the same, so you can replace it again. | | | `devices_notified` | integer | Optional | Number of device tokens for which APNs accepted the notification, without confirming on-device delivery. | | | `users_notified` | integer | Optional | | | | `effective_channel_slugs` | array of string or null | Optional | | | | `tags` | `TagSlugs` | Optional | | | | `timestamp` | `string` | Required | | | **Additional Properties**: `false` **default** ```json { "success": true, "notification_id": "Xk3pQ8mV2nR7tL9wB4yZ", "devices_notified": 2, "users_notified": 1, "effective_channel_slugs": null, "timestamp": "2025-08-12T12:05:00.000Z" } ``` ### 400 Bad request (invalid payload or channel targeting input) Content type: `application/json` ### Schema: BadRequestError | Field | Type | Presence | Description | Constraints | | --- | --- | --- | --- | --- | | `error` | string | Required | | | | `message` | string | Required | | | **Additional Properties**: `true` **missing title** ```json { "error": "Missing title", "code": "missing_title", "message": "title is required in the request body." } ``` **invalid tags** ```json { "error": "Invalid tags", "code": "invalid_tags", "message": "tags must use 1-64 lowercase letters, numbers, dashes, underscores, periods, or colons" } ``` ### 402 Billing access required Content type: `application/json` ### Schema: BillingBlockedError | Field | Type | Presence | Description | Constraints | | --- | --- | --- | --- | --- | | `error` | string | Required | | **Enum**: `["trial_expired","trial_exhausted","billing_overage_cap_reached"]` | | `message` | string | Required | | | | `trial_period` | object | Optional | | | | `trial_period.started_at` | `string` | Required | | | | `trial_period.ends_at` | `string` | Required | | | | `upgrade_url` | `string` | Required | | | **Additional Properties**: `true` ### 403 Forbidden (API key scope or channel assignment violation) Content type: `application/json` ### Schema: ForbiddenError | Field | Type | Presence | Description | Constraints | | --- | --- | --- | --- | --- | | `error` | string | Required | | | | `message` | string | Required | | | **Additional Properties**: `true` **channel scope violation** ```json { "error": "Invalid channel targeting", "message": "This API key can only target assigned channels. Requested channels include channels outside this key scope." } ``` ### 404 Push notification not found Content type: `application/json` ### Schema: NotFoundError | Field | Type | Presence | Description | Constraints | | --- | --- | --- | --- | --- | | `error` | string | Required | | | | `message` | string | Required | | | **Additional Properties**: `true` **not found** ```json { "error": "Push notification not found", "code": "push_notification_not_found", "message": "No push notification found with id: Xk3pQ8mV2nR7tL9wB4yZ" } ``` ### 409 Push notification cannot be replaced (sent before replacement support, or dismissed) Content type: `application/json` Schema: [NotFoundError](#schema-notfounderror) **not replaceable** ```json { "error": "Push notification cannot be replaced", "code": "push_notification_not_replaceable", "message": "This push notification was sent before replacement was supported and cannot be replaced. Send a new push notification instead." } ``` **dismissed** ```json { "error": "Push notification cannot be replaced", "code": "push_notification_dismissed", "message": "This push notification was dismissed and cannot be replaced. Send a new push notification instead." } ``` ### 422 No recipients of the original Push Notification are still available Content type: `application/json` ### Schema: NoRecipientsError | Field | Type | Presence | Description | Constraints | | --- | --- | --- | --- | --- | | `error` | string | Required | | | | `code` | string | Optional | Machine-readable reason. no_paired_devices: the account has no active paired iOS devices; pair an iPhone with the ActivitySmith app. no_recipients_found: devices are paired, but none matched the targeted channels. Treat unknown values as a generic no-delivery error. | | | `message` | string | Required | | | | `app_store_url` | `string` | Optional | ActivitySmith App Store link. Present when code is no_paired_devices. | | | `effective_channel_slugs` | array of string or null | Optional | | | **Additional Properties**: `true` **no paired devices** ```json { "error": "No paired devices", "code": "no_paired_devices", "message": "No active iOS devices are paired yet. Download ActivitySmith from the App Store and pair your device.", "effective_channel_slugs": null, "app_store_url": "https://apps.apple.com/us/app/activitysmith/id6752254835" } ``` **no channel recipients** ```json { "error": "No recipients found", "code": "no_recipients_found", "message": "No active iOS devices matched the targeted channels.", "effective_channel_slugs": [ "marketing" ] } ``` ### 429 Rate limit exceeded Content type: `application/json` **oneOf** Schema: `RateLimitError` Schema: `LiveActivityLimitError` **rate limited** ```json { "error": "Rate limit exceeded", "message": "Too many requests, please try again later." } ``` [Download the OpenAPI specification](/openapi.json) --- Source: https://activitysmith.com/docs/api-reference/endpoint/push-notification-dismiss # Dismiss Push Notification Clears a Push Notification you already sent from the Lock Screen and Notification Center on every device it was sent to, using the `notification_id` from the send response. Notification history keeps it. Devices clear the notification in the background, which can take a moment or wait until the ActivitySmith app next opens. A successful response means the dismissal was recorded, not that every device has cleared it yet. Devices running an ActivitySmith app version before 1.17.0 show a silent notification titled "Push Notification dismissed" in its place until the user clears it. Calling this again for the same notification returns the same response and sends nothing. A dismissed notification cannot be replaced. ```http POST https://activitysmith.com/api/push-notification/{notification_id}/dismiss ``` ## Authentication Use your [API key](/docs/api-keys) in the request header. ```http Authorization: Bearer $YOUR_API_KEY ``` ## Parameters ### notification_id path parameter. Required. The `notification_id` returned when the Push Notification was sent. Type: string **Min Length**: `1` ## Request examples ```javascript Node import ActivitySmith from "activitysmith"; const activitysmith = new ActivitySmith({ apiKey: process.env.ACTIVITYSMITH_API_KEY, }); await activitysmith.notifications.dismiss("Xk3pQ8mV2nR7tL9wB4yZ"); ``` ```python Python import os from activitysmith import ActivitySmith activitysmith = ActivitySmith(api_key=os.environ["ACTIVITYSMITH_API_KEY"]) activitysmith.notifications.dismiss("Xk3pQ8mV2nR7tL9wB4yZ") ``` ```go Go package main import ( "log" activitysmithsdk "github.com/ActivitySmithHQ/activitysmith-go" ) func main() { activitysmith, err := activitysmithsdk.New("YOUR-API-KEY") if err != nil { log.Fatal(err) } _, err = activitysmith.Notifications.Dismiss("Xk3pQ8mV2nR7tL9wB4yZ") if err != nil { log.Fatal(err) } } ``` ```php PHP notifications->dismiss('Xk3pQ8mV2nR7tL9wB4yZ'); ``` ```ruby Ruby require "activitysmith" activitysmith = ActivitySmith::Client.new(api_key: ENV.fetch("ACTIVITYSMITH_API_KEY")) activitysmith.notifications.dismiss("Xk3pQ8mV2nR7tL9wB4yZ") ``` ```bash CLI activitysmith push dismiss "Xk3pQ8mV2nR7tL9wB4yZ" ``` ```bash cURL curl -X POST "https://activitysmith.com/api/push-notification/Xk3pQ8mV2nR7tL9wB4yZ/dismiss" \ -H "Authorization: Bearer $YOUR_API_KEY" ``` ## Responses ### 200 Push notification dismissal recorded Content type: `application/json` ### Schema: PushNotificationDismissResponse Dismissal result. Devices clear the notification after this response, so it does not confirm that any device has cleared it. | Field | Type | Presence | Description | Constraints | | --- | --- | --- | --- | --- | | `success` | boolean | Required | True when the dismissal is recorded. | | | `notification_id` | string | Required | ID of the dismissed Push Notification. | | | `dismissed_at` | `string` | Required | When the notification was first dismissed. Repeat calls return the same time. | | **Additional Properties**: `false` **default** ```json { "success": true, "notification_id": "Xk3pQ8mV2nR7tL9wB4yZ", "dismissed_at": "2025-08-12T12:05:00.000Z" } ``` ### 402 Billing access required Content type: `application/json` ### Schema: BillingBlockedError | Field | Type | Presence | Description | Constraints | | --- | --- | --- | --- | --- | | `error` | string | Required | | **Enum**: `["trial_expired","trial_exhausted","billing_overage_cap_reached"]` | | `message` | string | Required | | | | `trial_period` | object | Optional | | | | `trial_period.started_at` | `string` | Required | | | | `trial_period.ends_at` | `string` | Required | | | | `upgrade_url` | `string` | Required | | | **Additional Properties**: `true` ### 403 Forbidden (API key scope or channel assignment violation) Content type: `application/json` ### Schema: ForbiddenError | Field | Type | Presence | Description | Constraints | | --- | --- | --- | --- | --- | | `error` | string | Required | | | | `message` | string | Required | | | **Additional Properties**: `true` **channel scope violation** ```json { "error": "Invalid channel targeting", "message": "This API key can only target assigned channels. Requested channels include channels outside this key scope." } ``` ### 404 Push notification not found Content type: `application/json` ### Schema: NotFoundError | Field | Type | Presence | Description | Constraints | | --- | --- | --- | --- | --- | | `error` | string | Required | | | | `message` | string | Required | | | **Additional Properties**: `true` **not found** ```json { "error": "Push notification not found", "code": "push_notification_not_found", "message": "No push notification found with id: Xk3pQ8mV2nR7tL9wB4yZ" } ``` ### 409 Push notification was sent before dismissal support Content type: `application/json` Schema: [NotFoundError](#schema-notfounderror) **not dismissible** ```json { "error": "Push notification cannot be dismissed", "code": "push_notification_not_dismissible", "message": "This push notification was sent before dismissal was supported and cannot be dismissed." } ``` ### 429 Rate limit exceeded Content type: `application/json` **oneOf** Schema: `RateLimitError` Schema: `LiveActivityLimitError` **rate limited** ```json { "error": "Rate limit exceeded", "message": "Too many requests, please try again later." } ``` [Download the OpenAPI specification](/openapi.json) --- Source: https://activitysmith.com/docs/api-reference/endpoint/live-activity-stream # Live Activity Stream Start a new Live Activity or update an existing one Use a stable stream_key for each ongoing thing you want to show as a Live Activity. Send the latest content_state whenever it changes, and ActivitySmith will keep the Live Activity in sync. For timer streams, send duration_seconds to start or reset the timer; omit duration_seconds on later updates to preserve the existing timer window. Use secondary_action for a second button on alert, progress, segmented_progress, and value Live Activities. Optional tags to organize and filter notification history. On later stream updates, omit tags to keep the current tags, send tags again to replace them, or send an empty array to clear them. ```http PUT https://activitysmith.com/api/live-activity/stream/{stream_key} ``` ## Authentication Use your [API key](/docs/api-keys) in the request header. ```http Authorization: Bearer $YOUR_API_KEY ``` ## Parameters ### stream_key path parameter. Required. Stable identifier for one ongoing thing. Allowed characters: letters, numbers, underscores, and hyphens. Type: string **Max Length**: `255`; **Pattern**: `^[A-Za-z0-9_-]+$` ## Request examples ```javascript Node import ActivitySmith from "activitysmith"; const activitysmith = new ActivitySmith({ apiKey: process.env.ACTIVITYSMITH_API_KEY, }); await activitysmith.liveActivities.stream("search-reindex", { content_state: { title: "Search Reindex", subtitle: "catalog-v2", type: "progress", percentage: 42, }, }); ``` ```python Python import os from activitysmith import ActivitySmith activitysmith = ActivitySmith(api_key=os.environ["ACTIVITYSMITH_API_KEY"]) activitysmith.live_activities.stream( "search-reindex", { "content_state": { "title": "Search Reindex", "subtitle": "catalog-v2", "type": "progress", "percentage": 42, }, }, ) ``` ```go Go package main import ( "log" activitysmithsdk "github.com/ActivitySmithHQ/activitysmith-go" ) func main() { activitysmith, err := activitysmithsdk.New("YOUR-API-KEY") if err != nil { log.Fatal(err) } _, err = activitysmith.LiveActivities.Stream("search-reindex", activitysmithsdk.LiveActivityStreamInput{ Title: "Search Reindex", Subtitle: "catalog-v2", Type: "progress", Percentage: 42, }) if err != nil { log.Fatal(err) } } ``` ```php PHP liveActivities->stream('search-reindex', [ 'content_state' => [ 'title' => 'Search Reindex', 'subtitle' => 'catalog-v2', 'type' => 'progress', 'percentage' => 42, ], ]); ``` ```ruby Ruby require "activitysmith" activitysmith = ActivitySmith::Client.new(api_key: ENV.fetch("ACTIVITYSMITH_API_KEY")) activitysmith.live_activities.stream( "search-reindex", content_state: { title: "Search Reindex", subtitle: "catalog-v2", type: "progress", percentage: 42 } ) ``` ```bash cURL curl -X PUT "https://activitysmith.com/api/live-activity/stream/search-reindex" \ -H "Authorization: Bearer $YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "content_state": { "title": "Search Reindex", "subtitle": "catalog-v2", "type": "progress", "percentage": 42 } }' ``` ## Body Content type: `application/json` ### Schema: LiveActivityStreamRequest Send the latest state for a managed Live Activity stream. channels is the streamlined form for stream targeting. target.channels is also accepted for compatibility. If both are provided, they must match. | Field | Type | Presence | Description | Constraints | | --- | --- | --- | --- | --- | | `metadata` | `Metadata` | Optional | | | | `content_state` | `StreamContentState` | Required | | | | `action` | `LiveActivityAction` | Optional | | | | `secondary_action` | `LiveActivityAction` | Optional | Optional secondary action button. Supported for alert, progress, segmented_progress, and value Live Activities. Uses the same open_url, shortcuts://, and webhook shapes as action. | | | `alert` | `AlertPayload` | Optional | | | | `channels` | array of string | Optional | Channel slugs. When omitted, API key scope determines recipients. | **Min Items**: `1` | | `target` | `ChannelTarget` | Optional | | | | `tags` | `TagSlugs` | Optional | Optional tags to organize and filter notification history. Omit this field on later updates to keep the current tags, send tags again to replace them, or send an empty array to clear them. | | **Additional Properties**: `false` **metrics** ```json { "content_state": { "title": "Server Health", "subtitle": "prod-web-1", "type": "metrics", "metrics": [ { "label": "CPU", "value": 27, "unit": "%" }, { "label": "MEM", "value": 64, "unit": "%" } ] } } ``` **channel targeted** ```json { "channels": [ "ops" ], "content_state": { "title": "Server Health", "subtitle": "prod-web-1", "type": "metrics", "metrics": [ { "label": "CPU", "value": 27, "unit": "%" }, { "label": "MEM", "value": 64, "unit": "%" } ] } } ``` **timer** ```json { "content_state": { "title": "Benchmark Run", "subtitle": "sampling", "type": "timer", "duration_seconds": 300, "color": "cyan" } } ``` **approval secondary actions** ```json { "content_state": { "title": "Approval Needed", "message": "Should I send the follow-up email to Brightlane?", "type": "alert", "color": "cyan" }, "action": { "title": "Send", "type": "webhook", "url": "https://example.com/hooks/approvals/send", "method": "POST", "body": { "approval_id": "appr_123" } }, "secondary_action": { "title": "Deny", "type": "webhook", "url": "https://example.com/hooks/approvals/deny", "method": "POST", "body": { "approval_id": "appr_123" } } } ``` **Organize notification history with tags** ```json { "content_state": { "title": "Search Reindex", "subtitle": "catalog-v2", "type": "progress", "percentage": 42 }, "tags": [ "user:382", "search-reindex" ] } ``` ## Responses ### 200 Stream reconciled Content type: `application/json` ### Schema: LiveActivityStreamPutResponse Returned after a managed stream request is reconciled. | Field | Type | Presence | Description | Constraints | | --- | --- | --- | --- | --- | | `success` | boolean | Required | | | | `operation` | string | Required | | **Enum**: `["started","updated","rotated","noop","paused"]` | | `stream_key` | string | Required | | | | `activity_id` | string or null | Optional | | | | `previous_activity_id` | string | Optional | | | | `devices_notified` | integer | Optional | | | | `devices_queued` | integer | Optional | | | | `users_notified` | integer | Optional | | | | `effective_channel_slugs` | array of string or null | Optional | | | | `tags` | `TagSlugs` | Optional | | | | `warning` | string | Optional | Present on `updated` responses when the current Live Activity has received more than 12 updates and has averaged more than one update every 2 minutes since it started. The update is still sent, but iOS may throttle Live Activities that update this often. | | | `timestamp` | `string` | Required | | | | `ignored` | boolean | Optional | True when the request had no effect. | | | `remote_push_sent` | boolean | Optional | | | | `message` | string | Optional | | | | `errors` | array of string | Optional | Per-device delivery errors when some devices could not be reached. | | **Additional Properties**: `false` **started** ```json { "success": true, "operation": "started", "stream_key": "prod-web-1", "activity_id": "h8QmSyYFTuwOIF6Wh3YcZlzHLhUcr034", "devices_notified": 2, "timestamp": "2025-08-12T12:00:00.000Z" } ``` **noop** ```json { "success": true, "operation": "noop", "stream_key": "prod-web-1", "activity_id": "h8QmSyYFTuwOIF6Wh3YcZlzHLhUcr034", "timestamp": "2025-08-12T12:05:00.000Z" } ``` **paused** ```json { "success": true, "operation": "paused", "stream_key": "prod-web-1", "activity_id": null, "timestamp": "2025-08-12T12:10:00.000Z" } ``` **tagged** ```json { "success": true, "operation": "started", "stream_key": "search-reindex", "activity_id": "h8QmSyYFTuwOIF6Wh3YcZlzHLhUcr034", "devices_notified": 2, "tags": [ "user:382", "search-reindex" ], "timestamp": "2025-08-12T12:00:00.000Z" } ``` ### 400 Bad request (invalid stream_key, payload, action, or channel targeting input) Content type: `application/json` ### Schema: BadRequestError | Field | Type | Presence | Description | Constraints | | --- | --- | --- | --- | --- | | `error` | string | Required | | | | `message` | string | Required | | | **Additional Properties**: `true` **invalid stream key** ```json { "error": "Invalid stream_key", "message": "stream_key must contain only letters, numbers, underscores, and hyphens" } ``` **invalid target** ```json { "error": "Invalid channel targeting", "message": "channels must contain at least one channel" } ``` **invalid tags** ```json { "error": "Invalid tags", "code": "invalid_tags", "message": "tags must contain at most 20 unique values" } ``` ### 402 Trial expired, trial allowance exhausted, or paid usage cap reached Content type: `application/json` ### Schema: BillingBlockedError | Field | Type | Presence | Description | Constraints | | --- | --- | --- | --- | --- | | `error` | string | Required | | **Enum**: `["trial_expired","trial_exhausted","billing_overage_cap_reached"]` | | `message` | string | Required | | | | `trial_period` | object | Optional | | | | `trial_period.started_at` | `string` | Required | | | | `trial_period.ends_at` | `string` | Required | | | | `upgrade_url` | `string` | Required | | | **Additional Properties**: `true` **trial expired** ```json { "error": "trial_expired", "message": "Your free trial has ended. Start a subscription or lifetime membership to resume using ActivitySmith: https://activitysmith.com/app/account?billing=upgrade", "trial_period": { "started_at": "2026-09-01T00:00:00.000Z", "ends_at": "2026-09-08T00:00:00.000Z" }, "upgrade_url": "https://activitysmith.com/app/account?billing=upgrade" } ``` ### 403 Forbidden (API key scope or channel assignment violation) Content type: `application/json` ### Schema: ForbiddenError | Field | Type | Presence | Description | Constraints | | --- | --- | --- | --- | --- | | `error` | string | Required | | | | `message` | string | Required | | | **Additional Properties**: `true` **channel scope violation** ```json { "error": "Invalid channel targeting", "message": "This API key can only target assigned channels. Requested channels include channels outside this key scope." } ``` ### 422 No paired devices on the account, or no devices matched the effective channel target Content type: `application/json` ### Schema: NoRecipientsError | Field | Type | Presence | Description | Constraints | | --- | --- | --- | --- | --- | | `error` | string | Required | | | | `code` | string | Optional | Machine-readable reason. no_paired_devices: the account has no active paired iOS devices; pair an iPhone with the ActivitySmith app. no_recipients_found: devices are paired, but none matched the targeted channels. Treat unknown values as a generic no-delivery error. | | | `message` | string | Required | | | | `app_store_url` | `string` | Optional | ActivitySmith App Store link. Present when code is no_paired_devices. | | | `effective_channel_slugs` | array of string or null | Optional | | | **Additional Properties**: `true` **no paired devices** ```json { "error": "No paired devices", "code": "no_paired_devices", "message": "No active iOS devices are paired yet. Download ActivitySmith from the App Store and pair your device.", "effective_channel_slugs": null, "app_store_url": "https://apps.apple.com/us/app/activitysmith/id6752254835" } ``` **no channel recipients** ```json { "error": "No recipients found", "code": "no_recipients_found", "message": "No active iOS devices matched the targeted channels.", "effective_channel_slugs": [ "ops" ] } ``` ### 429 Rate limit exceeded Content type: `application/json` **oneOf** Schema: `RateLimitError` Schema: `LiveActivityLimitError` **rate limited** ```json { "error": "Rate limit exceeded", "message": "Too many requests, please try again later." } ``` **concurrent live activity limit reached** ```json { "error": "Live Activity limit reached", "message": "iOS supports up to 5 concurrent Live Activities per app on a device. End an active Live Activity before starting another.", "limit": 5, "active": 5 } ``` [Download the OpenAPI specification](/openapi.json) --- Source: https://activitysmith.com/docs/api-reference/endpoint/live-activity-stream-end # End Live Activity Stream Use this endpoint when the process you are tracking is finished and you no longer want the Live Activity on your devices. ActivitySmith ends the current Live Activity for this stream and dismisses it from devices. If you need direct lifecycle control, use /live-activity/start, /live-activity/update, and /live-activity/end instead. Use secondary_action for a second button on alert, progress, segmented_progress, and value Live Activities. ```http DELETE https://activitysmith.com/api/live-activity/stream/{stream_key} ``` ## Authentication Use your [API key](/docs/api-keys) in the request header. ```http Authorization: Bearer $YOUR_API_KEY ``` ## Parameters ### stream_key path parameter. Required. Stable identifier for one ongoing thing. Allowed characters: letters, numbers, underscores, and hyphens. Type: string **Max Length**: `255`; **Pattern**: `^[A-Za-z0-9_-]+$` ## Request examples ```javascript Node import ActivitySmith from "activitysmith"; const activitysmith = new ActivitySmith({ apiKey: process.env.ACTIVITYSMITH_API_KEY, }); await activitysmith.liveActivities.endStream("prod-web-1", { content_state: { title: "Server Health", subtitle: "prod-web-1", type: "metrics", metrics: [ { label: "CPU", value: 7, unit: "%" }, { label: "MEM", value: 38, unit: "%" }, ], }, }); ``` ```python Python import os from activitysmith import ActivitySmith activitysmith = ActivitySmith(api_key=os.environ["ACTIVITYSMITH_API_KEY"]) activitysmith.live_activities.end_stream( "prod-web-1", { "content_state": { "title": "Server Health", "subtitle": "prod-web-1", "type": "metrics", "metrics": [ {"label": "CPU", "value": 7, "unit": "%"}, {"label": "MEM", "value": 38, "unit": "%"}, ], }, }, ) ``` ```go Go package main import ( "log" activitysmithsdk "github.com/ActivitySmithHQ/activitysmith-go" "github.com/ActivitySmithHQ/activitysmith-go/generated" ) func main() { activitysmith, err := activitysmithsdk.New("YOUR-API-KEY") if err != nil { log.Fatal(err) } _, err = activitysmith.LiveActivities.EndStream("prod-web-1", activitysmithsdk.LiveActivityStreamEndInput{ Title: "Server Health", Subtitle: "prod-web-1", Type: "metrics", Metrics: []generated.ActivityMetric{ {Label: "CPU", Value: 7, Unit: generated.PtrString("%")}, {Label: "MEM", Value: 38, Unit: generated.PtrString("%")}, }, }) if err != nil { log.Fatal(err) } } ``` ```php PHP liveActivities->endStream('prod-web-1', [ 'content_state' => [ 'title' => 'Server Health', 'subtitle' => 'prod-web-1', 'type' => 'metrics', 'metrics' => [ ['label' => 'CPU', 'value' => 7, 'unit' => '%'], ['label' => 'MEM', 'value' => 38, 'unit' => '%'], ], ], ]); ``` ```ruby Ruby require "activitysmith" activitysmith = ActivitySmith::Client.new(api_key: ENV.fetch("ACTIVITYSMITH_API_KEY")) activitysmith.live_activities.end_stream( "prod-web-1", { content_state: { title: "Server Health", subtitle: "prod-web-1", type: "metrics", metrics: [ { label: "CPU", value: 7, unit: "%" }, { label: "MEM", value: 38, unit: "%" } ] } } ) ``` ```bash cURL curl -X DELETE "https://activitysmith.com/api/live-activity/stream/prod-web-1" \ -H "Authorization: Bearer $YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "content_state": { "title": "Server Health", "subtitle": "prod-web-1", "type": "metrics", "metrics": [ { "label": "CPU", "value": 7, "unit": "%" }, { "label": "MEM", "value": 38, "unit": "%" } ] } }' ``` ## Body Content type: `application/json` ### Schema: LiveActivityStreamDeleteRequest Optional payload for ending a managed stream. When omitted, ActivitySmith ends the stream using the latest known state when possible. | Field | Type | Presence | Description | Constraints | | --- | --- | --- | --- | --- | | `metadata` | `Metadata` | Optional | | | | `tags` | `TagSlugs` | Optional | Omit to preserve Tags, supply a list to replace them, or [] to clear them in the final activity history. | | | `content_state` | `StreamContentState` | Optional | | | | `action` | `LiveActivityAction` | Optional | | | | `secondary_action` | `LiveActivityAction` | Optional | Optional secondary action button. Supported for alert, progress, segmented_progress, and value Live Activities. Uses the same open_url, shortcuts://, and webhook shapes as action. | | | `alert` | `AlertPayload` | Optional | | | **Additional Properties**: `false` **default** ```json {} ``` **with content state** ```json { "content_state": { "title": "Server Health", "subtitle": "prod-web-1", "type": "metrics", "metrics": [ { "label": "CPU", "value": 0, "unit": "%" }, { "label": "MEM", "value": 0, "unit": "%" } ], "auto_dismiss_minutes": 2 } } ``` ## Responses ### 200 Managed stream ended Content type: `application/json` ### Schema: LiveActivityStreamDeleteResponse Returned after a managed stream is ended and removed. | Field | Type | Presence | Description | Constraints | | --- | --- | --- | --- | --- | | `success` | boolean | Required | | | | `operation` | string | Required | | **Enum**: `["ended"]` | | `stream_key` | string | Required | | | | `activity_id` | string or null | Optional | | | | `devices_queued` | integer | Optional | | | | `devices_notified` | integer | Optional | | | | `timestamp` | `string` | Required | | | | `ignored` | boolean | Optional | True when the stream was already ended and the request had no effect. | | | `message` | string | Optional | | | | `forced_completion` | boolean | Optional | | | | `delivered` | boolean | Optional | Present when the stream had a current Live Activity. True when the end was sent to at least one device, or queued for a device that has not registered yet. False when no device received it, so the Live Activity may stay on the Lock Screen until iOS removes it or someone dismisses it. | | | `warning` | string | Optional | Explains why the end may not have removed the Live Activity, for example because iOS had already ended a Live Activity that started more than 8 hours ago. | | | `errors` | array of string | Optional | Per-device delivery errors when some devices could not be reached. | | **Additional Properties**: `false` **ended** ```json { "success": true, "operation": "ended", "stream_key": "prod-web-1", "activity_id": "h8QmSyYFTuwOIF6Wh3YcZlzHLhUcr034", "devices_queued": 1, "delivered": true, "timestamp": "2025-08-12T12:10:00.000Z" } ``` **not delivered after ios limit** ```json { "success": true, "operation": "ended", "stream_key": "prod-web-1", "activity_id": "h8QmSyYFTuwOIF6Wh3YcZlzHLhUcr034", "forced_completion": true, "delivered": false, "warning": "This Live Activity started more than 8 hours ago, so iOS had already ended it and no device received the end. It stays on the Lock Screen until iOS removes it (up to 4 hours later) or someone dismisses it.", "timestamp": "2025-08-12T12:10:00.000Z" } ``` **already inactive** ```json { "success": true, "operation": "ended", "stream_key": "prod-web-1", "activity_id": null, "timestamp": "2025-08-12T12:10:00.000Z" } ``` ### 400 Bad request (invalid stream_key or action) Content type: `application/json` ### Schema: BadRequestError | Field | Type | Presence | Description | Constraints | | --- | --- | --- | --- | --- | | `error` | string | Required | | | | `message` | string | Required | | | **Additional Properties**: `true` **invalid stream key** ```json { "error": "Invalid stream_key", "message": "stream_key must contain only letters, numbers, underscores, and hyphens" } ``` ### 404 Managed stream not found Content type: `application/json` ### Schema: NotFoundError | Field | Type | Presence | Description | Constraints | | --- | --- | --- | --- | --- | | `error` | string | Required | | | | `message` | string | Required | | | **Additional Properties**: `true` **not found** ```json { "error": "Live Activity stream not found", "message": "No Live Activity stream found in this account for stream_key: prod-web-1. The stream may have already ended or been deleted." } ``` ### 429 Rate limit exceeded Content type: `application/json` ### Schema: RateLimitError | Field | Type | Presence | Description | Constraints | | --- | --- | --- | --- | --- | | `code` | string | Optional | | **Enum**: `["rate_limited"]` | | `error` | string | Required | | | | `message` | string | Required | | | **Additional Properties**: `false` **rate limited** ```json { "error": "Rate limit exceeded", "message": "Too many requests, please try again later." } ``` [Download the OpenAPI specification](/openapi.json) --- Source: https://activitysmith.com/docs/api-reference/endpoint/live-activity-start # Start Live Activity Start a Live Activity (legacy manual lifecycle) Legacy manual lifecycle endpoint. For new integrations, use PUT /live-activity/stream/{stream_key} so ActivitySmith can manage start, update, rotation, and end state for you. This endpoint remains supported for existing integrations and advanced lifecycle control. Starts a Live Activity on devices matched by API key scope and optional target channels. Supports segmented_progress, progress, metrics, stats, alert, timer, and value activity types. For segmented_progress activities, number_of_steps can be changed later during update or end calls if the workflow changes. Use secondary_action for a second button on alert, progress, segmented_progress, and value Live Activities. Optional tags to organize and filter notification history. ```http POST https://activitysmith.com/api/live-activity/start ``` ## Authentication Use your [API key](/docs/api-keys) in the request header. ```http Authorization: Bearer $YOUR_API_KEY ``` ## Request examples ```javascript Node import ActivitySmith from "activitysmith"; const activitysmith = new ActivitySmith({ apiKey: process.env.ACTIVITYSMITH_API_KEY, }); const start = await activitysmith.liveActivities.start({ content_state: { title: "Nightly database backup", subtitle: "create snapshot", number_of_steps: 3, current_step: 1, type: "segmented_progress", color: "yellow", }, }); const activityId = start.activity_id; ``` ```python Python import os from activitysmith import ActivitySmith activitysmith = ActivitySmith(api_key=os.environ["ACTIVITYSMITH_API_KEY"]) start = activitysmith.live_activities.start({ "content_state": { "title": "Nightly database backup", "subtitle": "create snapshot", "number_of_steps": 3, "current_step": 1, "type": "segmented_progress", "color": "yellow", }, }) activity_id = start.activity_id ``` ```go Go package main import ( "log" activitysmithsdk "github.com/ActivitySmithHQ/activitysmith-go" ) func main() { activitysmith, err := activitysmithsdk.New("YOUR-API-KEY") if err != nil { log.Fatal(err) } start, err := activitysmith.LiveActivities.Start(activitysmithsdk.LiveActivityStartInput{ Title: "Nightly database backup", Subtitle: "create snapshot", NumberOfSteps: 3, CurrentStep: 1, Type: "segmented_progress", Color: "yellow", }) if err != nil { log.Fatal(err) } activityID := start.GetActivityId() _ = activityID } ``` ```php PHP liveActivities->start([ 'content_state' => [ 'title' => 'Nightly database backup', 'subtitle' => 'create snapshot', 'number_of_steps' => 3, 'current_step' => 1, 'type' => 'segmented_progress', 'color' => 'yellow', ], ]); $activityId = $start->getActivityId(); ``` ```ruby Ruby require "activitysmith" activitysmith = ActivitySmith::Client.new(api_key: ENV.fetch("ACTIVITYSMITH_API_KEY")) start = activitysmith.live_activities.start( content_state: { title: "Nightly database backup", subtitle: "create snapshot", number_of_steps: 3, current_step: 1, type: "segmented_progress", color: "yellow" } ) activity_id = start.activity_id ``` ```bash cURL curl -X POST "https://activitysmith.com/api/live-activity/start" \ -H "Authorization: Bearer $YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "content_state": { "title": "Nightly database backup", "subtitle": "create snapshot", "number_of_steps": 3, "current_step": 1, "type": "segmented_progress", "color": "yellow" } }' ``` ## Body Content type: `application/json` ### Schema: LiveActivityStartRequest Start a new Live Activity. The response includes activity_id for later update and end calls. | Field | Type | Presence | Description | Constraints | | --- | --- | --- | --- | --- | | `metadata` | `Metadata` | Optional | | | | `content_state` | `ContentStateStart` | Required | | | | `action` | `LiveActivityAction` | Optional | | | | `secondary_action` | `LiveActivityAction` | Optional | Optional secondary action button. Supported for alert, progress, segmented_progress, and value Live Activities. Uses the same open_url, shortcuts://, and webhook shapes as action. | | | `alert` | `AlertPayload` | Optional | | | | `target` | `ChannelTarget` | Optional | | | | `tags` | `TagSlugs` | Optional | | | **Additional Properties**: `false` **segmented progress** ```json { "content_state": { "title": "Nightly database backup", "subtitle": "create snapshot", "number_of_steps": 3, "current_step": 1, "type": "segmented_progress", "color": "yellow" } } ``` **progress** ```json { "content_state": { "title": "EV Charging", "subtitle": "Added 30 mi range", "percentage": 15, "type": "progress", "color": "lime" } } ``` **metrics** ```json { "content_state": { "title": "Server Health", "subtitle": "prod-web-1", "type": "metrics", "metrics": [ { "label": "CPU", "value": 21, "unit": "%" }, { "label": "MEM", "value": 64, "unit": "%" } ] } } ``` **open url action** ```json { "content_state": { "title": "Deploying payments-api", "subtitle": "Running database migrations", "number_of_steps": 5, "current_step": 3, "type": "segmented_progress" }, "action": { "title": "Open Workflow", "type": "open_url", "url": "https://github.com/acme/payments-api/actions/runs/1234567890" } } ``` **segmented progress channel targeted** ```json { "content_state": { "title": "Nightly database backup", "subtitle": "create snapshot", "number_of_steps": 3, "current_step": 1, "type": "segmented_progress", "color": "yellow" }, "target": { "channels": [ "devs", "ops" ] } } ``` **Current revenue with a badge and footer button** ```json { "content_state": { "type": "value", "title": "Current revenue", "subtitle": "Today", "value": "$1,240", "color": "cyan", "icon": "dollarsign.circle", "badge": { "title": "Live", "color": "green" } }, "action": { "title": "Dashboard", "type": "open_url", "url": "https://example.com/dashboard" } } ``` **timer** ```json { "content_state": { "title": "Benchmark Run", "subtitle": "sampling", "type": "timer", "duration_seconds": 300, "color": "cyan" } } ``` **approval secondary actions** ```json { "content_state": { "title": "Approval Needed", "message": "Should I send the follow-up email to Brightlane?", "type": "alert", "color": "cyan" }, "action": { "title": "Send", "type": "webhook", "url": "https://example.com/hooks/approvals/send", "method": "POST", "body": { "approval_id": "appr_123" } }, "secondary_action": { "title": "Deny", "type": "webhook", "url": "https://example.com/hooks/approvals/deny", "method": "POST", "body": { "approval_id": "appr_123" } } } ``` **Organize notification history with tags** ```json { "content_state": { "title": "Nightly database backup", "subtitle": "create snapshot", "number_of_steps": 3, "current_step": 1, "type": "segmented_progress", "color": "yellow" }, "tags": [ "user:382", "database-backup" ] } ``` ## Responses ### 200 Live Activity started Content type: `application/json` ### Schema: LiveActivityStartResponse Returned after a Live Activity starts. Save activity_id and use it for all later updates and for the final end call. | Field | Type | Presence | Description | Constraints | | --- | --- | --- | --- | --- | | `success` | boolean | Required | | | | `devices_notified` | integer | Optional | | | | `users_notified` | integer | Optional | | | | `activity_id` | string | Required | | | | `effective_channel_slugs` | array of string or null | Optional | | | | `tags` | `TagSlugs` | Optional | | | | `timestamp` | `string` | Required | | | | `ended_activity_id` | string | Optional | Present when starting this Live Activity ended an older one to stay within the device limit. | | | `message` | string | Optional | | | | `errors` | array of string | Optional | Per-device delivery errors when some devices could not be reached. | | **Additional Properties**: `false` **segmented progress** ```json { "success": true, "activity_id": "pLAr-Hnq9ZFW4sxlk43Lhbuok4GLh7UW", "devices_notified": 2, "users_notified": 1, "timestamp": "2026-01-28T09:57:22.929Z" } ``` **segmented progress channel targeted** ```json { "success": true, "activity_id": "pLAr-Hnq9ZFW4sxlk43Lhbuok4GLh7UW", "devices_notified": 2, "users_notified": 1, "effective_channel_slugs": [ "devs", "ops" ], "timestamp": "2026-01-28T09:57:22.929Z" } ``` **tagged** ```json { "success": true, "activity_id": "pLAr-Hnq9ZFW4sxlk43Lhbuok4GLh7UW", "devices_notified": 2, "users_notified": 1, "tags": [ "user:382", "database-backup" ], "timestamp": "2026-01-28T09:57:22.929Z" } ``` ### 400 Bad request (invalid payload or channel targeting input) Content type: `application/json` ### Schema: BadRequestError | Field | Type | Presence | Description | Constraints | | --- | --- | --- | --- | --- | | `error` | string | Required | | | | `message` | string | Required | | | **Additional Properties**: `true` **invalid target** ```json { "error": "Invalid channel targeting", "message": "target.channels must be an array of channel slugs" } ``` **invalid tags** ```json { "error": "Invalid tags", "code": "invalid_tags", "message": "tags must use 1-64 lowercase letters, numbers, dashes, underscores, periods, or colons" } ``` ### 402 Billing access required Content type: `application/json` ### Schema: BillingBlockedError | Field | Type | Presence | Description | Constraints | | --- | --- | --- | --- | --- | | `error` | string | Required | | **Enum**: `["trial_expired","trial_exhausted","billing_overage_cap_reached"]` | | `message` | string | Required | | | | `trial_period` | object | Optional | | | | `trial_period.started_at` | `string` | Required | | | | `trial_period.ends_at` | `string` | Required | | | | `upgrade_url` | `string` | Required | | | **Additional Properties**: `true` ### 403 Forbidden (API key scope or channel assignment violation) Content type: `application/json` ### Schema: ForbiddenError | Field | Type | Presence | Description | Constraints | | --- | --- | --- | --- | --- | | `error` | string | Required | | | | `message` | string | Required | | | **Additional Properties**: `true` **channel scope violation** ```json { "error": "Invalid channel targeting", "message": "This API key can only target assigned channels. Requested channels include channels outside this key scope." } ``` ### 422 No paired devices on the account, or no devices matched the effective channel target Content type: `application/json` ### Schema: NoRecipientsError | Field | Type | Presence | Description | Constraints | | --- | --- | --- | --- | --- | | `error` | string | Required | | | | `code` | string | Optional | Machine-readable reason. no_paired_devices: the account has no active paired iOS devices; pair an iPhone with the ActivitySmith app. no_recipients_found: devices are paired, but none matched the targeted channels. Treat unknown values as a generic no-delivery error. | | | `message` | string | Required | | | | `app_store_url` | `string` | Optional | ActivitySmith App Store link. Present when code is no_paired_devices. | | | `effective_channel_slugs` | array of string or null | Optional | | | **Additional Properties**: `true` **no paired devices** ```json { "error": "No paired devices", "code": "no_paired_devices", "message": "No active iOS devices are paired yet. Download ActivitySmith from the App Store and pair your device.", "effective_channel_slugs": null, "app_store_url": "https://apps.apple.com/us/app/activitysmith/id6752254835" } ``` **no channel recipients** ```json { "error": "No recipients found", "code": "no_recipients_found", "message": "No active iOS devices matched the targeted channels.", "effective_channel_slugs": [ "marketing" ] } ``` ### 429 Rate limit exceeded Content type: `application/json` **oneOf** Schema: `RateLimitError` Schema: `LiveActivityLimitError` **rate limited** ```json { "error": "Rate limit exceeded", "message": "Too many requests, please try again later." } ``` **concurrent live activity limit reached** ```json { "error": "Live Activity limit reached", "message": "iOS supports up to 5 concurrent Live Activities per app on a device. End an active Live Activity before starting another.", "limit": 5, "active": 5 } ``` [Download the OpenAPI specification](/openapi.json) --- Source: https://activitysmith.com/docs/api-reference/endpoint/live-activity-update # Update Live Activity Update a Live Activity (legacy manual lifecycle) Legacy manual lifecycle endpoint. For new integrations, use PUT /live-activity/stream/{stream_key} so ActivitySmith can manage start, update, rotation, and end state for you. This endpoint remains supported for existing integrations and advanced lifecycle control. Updates an existing Live Activity. If the per-activity token is not registered yet, the update is queued. Supports segmented_progress, progress, metrics, stats, alert, timer, and value activity types. For segmented_progress activities, you can increase or decrease number_of_steps here as the workflow changes. For timer activities, send duration_seconds only when you want to reset the timer window; omit it to keep the current timer running. Use secondary_action for a second button on alert, progress, segmented_progress, and value Live Activities. ```http POST https://activitysmith.com/api/live-activity/update ``` ## Authentication Use your [API key](/docs/api-keys) in the request header. ```http Authorization: Bearer $YOUR_API_KEY ``` ## Request examples ```javascript Node import ActivitySmith from "activitysmith"; const activitysmith = new ActivitySmith({ apiKey: process.env.ACTIVITYSMITH_API_KEY, }); await activitysmith.liveActivities.update({ activity_id: "pLAr-Hnq9ZFW4sxlk43Lhbuok4GLh7UW", content_state: { title: "Nightly database backup", subtitle: "upload archive", number_of_steps: 3, current_step: 2, }, }); ``` ```python Python import os from activitysmith import ActivitySmith activitysmith = ActivitySmith(api_key=os.environ["ACTIVITYSMITH_API_KEY"]) activitysmith.live_activities.update({ "activity_id": "pLAr-Hnq9ZFW4sxlk43Lhbuok4GLh7UW", "content_state": { "title": "Nightly database backup", "subtitle": "upload archive", "number_of_steps": 3, "current_step": 2, }, }) ``` ```go Go package main import ( "log" activitysmithsdk "github.com/ActivitySmithHQ/activitysmith-go" ) func main() { activitysmith, err := activitysmithsdk.New("YOUR-API-KEY") if err != nil { log.Fatal(err) } _, err = activitysmith.LiveActivities.Update(activitysmithsdk.LiveActivityUpdateInput{ ActivityID: "pLAr-Hnq9ZFW4sxlk43Lhbuok4GLh7UW", Title: "Nightly database backup", Subtitle: "upload archive", NumberOfSteps: 3, CurrentStep: 2, }) if err != nil { log.Fatal(err) } } ``` ```php PHP liveActivities->update([ 'activity_id' => 'pLAr-Hnq9ZFW4sxlk43Lhbuok4GLh7UW', 'content_state' => [ 'title' => 'Nightly database backup', 'subtitle' => 'upload archive', 'number_of_steps' => 3, 'current_step' => 2, ], ]); ``` ```ruby Ruby require "activitysmith" activitysmith = ActivitySmith::Client.new(api_key: ENV.fetch("ACTIVITYSMITH_API_KEY")) activitysmith.live_activities.update( activity_id: "pLAr-Hnq9ZFW4sxlk43Lhbuok4GLh7UW", content_state: { title: "Nightly database backup", subtitle: "upload archive", number_of_steps: 3, current_step: 2 } ) ``` ```bash cURL curl -X POST "https://activitysmith.com/api/live-activity/update" \ -H "Authorization: Bearer $YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "activity_id": "pLAr-Hnq9ZFW4sxlk43Lhbuok4GLh7UW", "content_state": { "title": "Nightly database backup", "subtitle": "upload archive", "number_of_steps": 3, "current_step": 2 } }' ``` ## Body Content type: `application/json` ### Schema: LiveActivityUpdateRequest Update an existing Live Activity by activity_id. | Field | Type | Presence | Description | Constraints | | --- | --- | --- | --- | --- | | `metadata` | `Metadata` | Optional | | | | `activity_id` | string | Required | | | | `tags` | array of string | Optional | Tags for notification history. Omit to keep existing Tags, supply an array to replace them, or send an empty array to clear them. | **Max Items**: `20` Item constraints: **Min Length**: `1`; **Max Length**: `64` | | `content_state` | `ContentStateUpdate` | Required | | | | `action` | `LiveActivityAction` | Optional | | | | `secondary_action` | `LiveActivityAction` | Optional | Optional secondary action button. Supported for alert, progress, segmented_progress, and value Live Activities. Uses the same open_url, shortcuts://, and webhook shapes as action. | | **Additional Properties**: `false` **segmented progress** ```json { "activity_id": "pLAr-Hnq9ZFW4sxlk43Lhbuok4GLh7UW", "content_state": { "title": "Nightly database backup", "subtitle": "upload archive", "number_of_steps": 3, "current_step": 2 } } ``` **progress** ```json { "activity_id": "pLAr-Hnq9ZFW4sxlk43Lhbuok4GLh7UW", "content_state": { "title": "EV Charging", "subtitle": "Added 120 mi range", "percentage": 60 } } ``` **metrics** ```json { "activity_id": "pLAr-Hnq9ZFW4sxlk43Lhbuok4GLh7UW", "content_state": { "title": "Server Health", "subtitle": "prod-web-1", "type": "metrics", "metrics": [ { "label": "CPU", "value": 25, "unit": "%" }, { "label": "MEM", "value": 67, "unit": "%" } ] } } ``` **webhook action** ```json { "activity_id": "pLAr-Hnq9ZFW4sxlk43Lhbuok4GLh7UW", "content_state": { "title": "Reindexing product search", "subtitle": "Shard 7 of 12", "number_of_steps": 12, "current_step": 7 }, "action": { "title": "Pause Reindex", "type": "webhook", "url": "https://ops.example.com/hooks/search/reindex/pause", "method": "POST", "body": { "job_id": "reindex-2026-03-19", "requested_by": "activitysmith_live_activity", "reason": "paused_from_ios_live_activity" } } } ``` **timer preserve window** ```json { "activity_id": "pLAr-Hnq9ZFW4sxlk43Lhbuok4GLh7UW", "content_state": { "title": "Benchmark Run", "subtitle": "checking p95 latency", "type": "timer" } } ``` **timer reset window** ```json { "activity_id": "pLAr-Hnq9ZFW4sxlk43Lhbuok4GLh7UW", "content_state": { "title": "Benchmark Run", "subtitle": "retrying sample", "type": "timer", "duration_seconds": 180 } } ``` ## Responses ### 200 Live Activity updated (or queued) Content type: `application/json` ### Schema: LiveActivityUpdateResponse Returned after a Live Activity update is sent or queued. | Field | Type | Presence | Description | Constraints | | --- | --- | --- | --- | --- | | `success` | boolean | Required | | | | `activity_id` | string | Required | | | | `devices_queued` | integer | Optional | | | | `devices_notified` | integer | Optional | | | | `timestamp` | `string` | Required | | | | `users_notified` | integer | Optional | | | | `effective_channel_slugs` | array of string or null | Optional | | | | `tags` | `TagSlugs` | Optional | | | | `operation` | string | Optional | Present when the update started a new Live Activity for a managed stream. | | | `stream_key` | string | Optional | | | | `previous_activity_id` | string | Optional | | | | `errors` | array of string | Optional | Per-device delivery errors when some devices could not be reached. | | **Additional Properties**: `false` **sent** ```json { "success": true, "activity_id": "pLAr-Hnq9ZFW4sxlk43Lhbuok4GLh7UW", "devices_notified": 2, "devices_queued": 0, "timestamp": "2026-01-28T09:57:26.056Z" } ``` ### 403 Forbidden (activity not owned by this API key account) Content type: `application/json` ### Schema: ForbiddenError | Field | Type | Presence | Description | Constraints | | --- | --- | --- | --- | --- | | `error` | string | Required | | | | `message` | string | Required | | | **Additional Properties**: `true` **forbidden** ```json { "error": "Forbidden", "message": "This API key cannot update this Live Activity" } ``` ### 429 Rate limit exceeded Content type: `application/json` ### Schema: RateLimitError | Field | Type | Presence | Description | Constraints | | --- | --- | --- | --- | --- | | `code` | string | Optional | | **Enum**: `["rate_limited"]` | | `error` | string | Required | | | | `message` | string | Required | | | **Additional Properties**: `false` **rate limited** ```json { "error": "Rate limit exceeded", "message": "Too many requests, please try again later." } ``` [Download the OpenAPI specification](/openapi.json) --- Source: https://activitysmith.com/docs/api-reference/endpoint/live-activity-end # End Live Activity End a Live Activity (legacy manual lifecycle) Legacy manual lifecycle endpoint. For new integrations, use DELETE /live-activity/stream/{stream_key} to end a managed Live Activity stream. This endpoint remains supported for existing integrations and advanced lifecycle control. Ends a Live Activity and archives its lifecycle. Supports segmented_progress, progress, metrics, stats, alert, timer, and value activity types. For segmented_progress activities, you can send the latest number_of_steps here if the workflow changed after start. Use secondary_action for a second button on alert, progress, segmented_progress, and value Live Activities. Ending a Live Activity that already ended returns 200 with ignored: true and sends nothing to devices, so retries are safe. ```http POST https://activitysmith.com/api/live-activity/end ``` ## Authentication Use your [API key](/docs/api-keys) in the request header. ```http Authorization: Bearer $YOUR_API_KEY ``` ## Request examples ```javascript Node import ActivitySmith from "activitysmith"; const activitysmith = new ActivitySmith({ apiKey: process.env.ACTIVITYSMITH_API_KEY, }); await activitysmith.liveActivities.end({ activity_id: "pLAr-Hnq9ZFW4sxlk43Lhbuok4GLh7UW", content_state: { title: "Nightly database backup", subtitle: "verify restore", number_of_steps: 3, current_step: 3, auto_dismiss_minutes: 2, }, }); ``` ```python Python import os from activitysmith import ActivitySmith activitysmith = ActivitySmith(api_key=os.environ["ACTIVITYSMITH_API_KEY"]) activitysmith.live_activities.end({ "activity_id": "pLAr-Hnq9ZFW4sxlk43Lhbuok4GLh7UW", "content_state": { "title": "Nightly database backup", "subtitle": "verify restore", "number_of_steps": 3, "current_step": 3, "auto_dismiss_minutes": 2, }, }) ``` ```go Go package main import ( "log" activitysmithsdk "github.com/ActivitySmithHQ/activitysmith-go" ) func main() { activitysmith, err := activitysmithsdk.New("YOUR-API-KEY") if err != nil { log.Fatal(err) } _, err = activitysmith.LiveActivities.End(activitysmithsdk.LiveActivityEndInput{ ActivityID: "pLAr-Hnq9ZFW4sxlk43Lhbuok4GLh7UW", Title: "Nightly database backup", Subtitle: "verify restore", NumberOfSteps: 3, CurrentStep: 3, AutoDismissMinutes: 2, }) if err != nil { log.Fatal(err) } } ``` ```php PHP liveActivities->end([ 'activity_id' => 'pLAr-Hnq9ZFW4sxlk43Lhbuok4GLh7UW', 'content_state' => [ 'title' => 'Nightly database backup', 'subtitle' => 'verify restore', 'number_of_steps' => 3, 'current_step' => 3, 'auto_dismiss_minutes' => 2, ], ]); ``` ```ruby Ruby require "activitysmith" activitysmith = ActivitySmith::Client.new(api_key: ENV.fetch("ACTIVITYSMITH_API_KEY")) activitysmith.live_activities.end( activity_id: "pLAr-Hnq9ZFW4sxlk43Lhbuok4GLh7UW", content_state: { title: "Nightly database backup", subtitle: "verify restore", number_of_steps: 3, current_step: 3, auto_dismiss_minutes: 2 } ) ``` ```bash cURL curl -X POST "https://activitysmith.com/api/live-activity/end" \ -H "Authorization: Bearer $YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "activity_id": "pLAr-Hnq9ZFW4sxlk43Lhbuok4GLh7UW", "content_state": { "title": "Nightly database backup", "subtitle": "verify restore", "number_of_steps": 3, "current_step": 3, "auto_dismiss_minutes": 2 } }' ``` ## Body Content type: `application/json` ### Schema: LiveActivityEndRequest End an existing Live Activity by activity_id. | Field | Type | Presence | Description | Constraints | | --- | --- | --- | --- | --- | | `metadata` | `Metadata` | Optional | | | | `activity_id` | string | Required | | | | `tags` | array of string | Optional | Tags for notification history. Omit to keep existing Tags, supply an array to replace them, or send an empty array to clear them. | **Max Items**: `20` Item constraints: **Min Length**: `1`; **Max Length**: `64` | | `content_state` | `ContentStateEnd` | Required | | | | `action` | `LiveActivityAction` | Optional | | | | `secondary_action` | `LiveActivityAction` | Optional | Optional secondary action button. Supported for alert, progress, segmented_progress, and value Live Activities. Uses the same open_url, shortcuts://, and webhook shapes as action. | | **Additional Properties**: `false` **segmented progress** ```json { "activity_id": "pLAr-Hnq9ZFW4sxlk43Lhbuok4GLh7UW", "content_state": { "title": "Nightly database backup", "subtitle": "verify restore", "number_of_steps": 3, "current_step": 3, "auto_dismiss_minutes": 2 } } ``` **progress** ```json { "activity_id": "pLAr-Hnq9ZFW4sxlk43Lhbuok4GLh7UW", "content_state": { "title": "EV Charging", "subtitle": "Added 200 mi range", "percentage": 100, "auto_dismiss_minutes": 2 } } ``` **metrics** ```json { "activity_id": "pLAr-Hnq9ZFW4sxlk43Lhbuok4GLh7UW", "content_state": { "title": "Server Health", "subtitle": "prod-web-1", "type": "metrics", "metrics": [ { "label": "CPU", "value": 0, "unit": "%" }, { "label": "MEM", "value": 0, "unit": "%" } ], "auto_dismiss_minutes": 2 } } ``` **open url action** ```json { "activity_id": "pLAr-Hnq9ZFW4sxlk43Lhbuok4GLh7UW", "content_state": { "title": "Deploying payments-api", "subtitle": "Production rollout complete", "number_of_steps": 5, "current_step": 5, "auto_dismiss_minutes": 10 }, "action": { "title": "Open Workflow", "type": "open_url", "url": "https://github.com/acme/payments-api/actions/runs/1234567890" } } ``` **timer** ```json { "activity_id": "pLAr-Hnq9ZFW4sxlk43Lhbuok4GLh7UW", "content_state": { "title": "Benchmark Run", "subtitle": "complete", "type": "timer", "auto_dismiss_minutes": 2 } } ``` ## Responses ### 200 Live Activity ended Content type: `application/json` ### Schema: LiveActivityEndResponse Returned after a Live Activity end event is sent or queued. | Field | Type | Presence | Description | Constraints | | --- | --- | --- | --- | --- | | `success` | boolean | Required | | | | `activity_id` | string | Required | | | | `devices_queued` | integer | Optional | | | | `devices_notified` | integer | Optional | | | | `timestamp` | `string` | Required | | | | `ignored` | boolean | Optional | True when the Live Activity had already ended and the request had no effect. | | | `message` | string | Optional | | | | `end_reason` | string or null | Optional | | | | `forced_completion` | boolean | Optional | True when the Live Activity was marked complete without a confirmed APNs end delivery. | | | `warning` | string | Optional | | | | `errors` | array of string | Optional | Per-device delivery errors when some devices could not be reached. | | **Additional Properties**: `false` **segmented progress** ```json { "success": true, "activity_id": "pLAr-Hnq9ZFW4sxlk43Lhbuok4GLh7UW", "devices_notified": 2, "devices_queued": 0, "timestamp": "2026-01-28T09:57:29.258Z" } ``` ### 403 Forbidden (activity not owned by this API key account) Content type: `application/json` ### Schema: ForbiddenError | Field | Type | Presence | Description | Constraints | | --- | --- | --- | --- | --- | | `error` | string | Required | | | | `message` | string | Required | | | **Additional Properties**: `true` **forbidden** ```json { "error": "Forbidden", "message": "This API key cannot end this Live Activity" } ``` ### 429 Rate limit exceeded Content type: `application/json` ### Schema: RateLimitError | Field | Type | Presence | Description | Constraints | | --- | --- | --- | --- | --- | | `code` | string | Optional | | **Enum**: `["rate_limited"]` | | `error` | string | Required | | | | `message` | string | Required | | | **Additional Properties**: `false` **rate limited** ```json { "error": "Rate limit exceeded", "message": "Too many requests, please try again later." } ``` [Download the OpenAPI specification](/openapi.json) --- Source: https://activitysmith.com/docs/api-reference/endpoint/metric-upsert # Create or Update Metric Creates a metric for widgets, or updates the fields sent for an existing metric. Omitted fields keep their current values, so repeating the same request does not change the metric. Changing between the string format and a numeric format clears the latest value. Shares the metric account allowance of 300 requests per minute and is not a billable metric update. ```http PUT https://activitysmith.com/api/metrics/{key} ``` ## Authentication Use your [API key](/docs/api-keys) in the request header. ```http Authorization: Bearer $YOUR_API_KEY ``` ## Parameters ### key path parameter. Required. Metric key. Lowercase letters, numbers, dots, underscores, and dashes are allowed. Type: string **Min Length**: `1`; **Max Length**: `64`; **Pattern**: `^[a-z0-9][a-z0-9_.-]{0,63}$` ## Request examples ```javascript Node import ActivitySmith from "activitysmith"; const activitysmith = new ActivitySmith({ apiKey: process.env.ACTIVITYSMITH_API_KEY, }); await activitysmith.metrics.create("mrr", { label: "MRR", format: "currency", currency_code: "USD", }); ``` ```python Python import os from activitysmith import ActivitySmith activitysmith = ActivitySmith(api_key=os.environ["ACTIVITYSMITH_API_KEY"]) activitysmith.metrics.create( "mrr", label="MRR", format="currency", currency_code="USD", ) ``` ```go Go package main import ( "log" activitysmithsdk "github.com/ActivitySmithHQ/activitysmith-go" ) func main() { activitysmith, err := activitysmithsdk.New("YOUR-API-KEY") if err != nil { log.Fatal(err) } _, err = activitysmith.Metrics.Create("mrr", activitysmithsdk.MetricInput{ Label: "MRR", Format: "currency", CurrencyCode: "USD", }) if err != nil { log.Fatal(err) } } ``` ```php PHP metrics->create( 'mrr', label: 'MRR', format: 'currency', currencyCode: 'USD', ); ``` ```ruby Ruby require "activitysmith" activitysmith = ActivitySmith::Client.new(api_key: ENV.fetch("ACTIVITYSMITH_API_KEY")) activitysmith.metrics.create( "mrr", label: "MRR", format: "currency", currency_code: "USD" ) ``` ```bash CLI activitysmith metrics create mrr \ --label MRR \ --format currency \ --currency-code USD ``` ```bash cURL curl -X PUT "https://activitysmith.com/api/metrics/mrr" \ -H "Authorization: Bearer $YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "label": "MRR", "format": "currency", "currency_code": "USD" }' ``` ## Body Content type: `application/json` ### Schema: MetricUpsertRequest Metric definition. Omitted fields keep their current values, or use defaults for a new metric: a label made from the key and the number format. | Field | Type | Presence | Description | Constraints | | --- | --- | --- | --- | --- | | `label` | string | Optional | Name shown on the widget. | **Min Length**: `1`; **Max Length**: `80` | | `format` | string | Optional | How widgets display the value: number (1,234), currency (requires currency_code), percent (send 99.9 to show 99.9%), unit (a number with a unit suffix, such as 120 ms), or string (text up to 64 characters). Defaults to number for a new metric. | **Enum**: `["number","currency","percent","unit","string"]` | | `currency_code` | string | Optional | 3-letter ISO 4217 currency code, such as USD. Required for the currency format. | **Pattern**: `^[A-Za-z]{3}$` | | `unit` | string | Optional | Unit suffix for the unit format, such as ms or GB. | **Max Length**: `16` | | `unit_spacing` | string | Optional | For the unit format: none shows 120ms, space shows 120 ms. | **Enum**: `["none","space"]` | **Additional Properties**: `false` ```json { "label": "MRR", "format": "currency", "currency_code": "USD" } ``` ## Responses ### 200 Metric updated Content type: `application/json` ### Schema: MetricResponse | Field | Type | Presence | Description | Constraints | | --- | --- | --- | --- | --- | | `metric` | `Metric` | Required | | | **Additional Properties**: `false` **updated** ```json { "metric": { "public_id": "x8Kq2mVn4pLr7sTw9yZa", "key": "mrr", "label": "MRR", "format": "currency", "currency_code": "USD", "unit": null, "unit_spacing": "none", "latest_value": null, "latest_value_at": null, "created_at": "2026-10-26T09:00:00.000Z", "updated_at": "2026-10-26T09:00:00.000Z" } } ``` ### 201 Metric created Content type: `application/json` Schema: [MetricResponse](#schema-metricresponse) **created** ```json { "metric": { "public_id": "x8Kq2mVn4pLr7sTw9yZa", "key": "mrr", "label": "MRR", "format": "currency", "currency_code": "USD", "unit": null, "unit_spacing": "none", "latest_value": null, "latest_value_at": null, "created_at": "2026-10-26T09:00:00.000Z", "updated_at": "2026-10-26T09:00:00.000Z" } } ``` ### 400 Bad request (invalid key or definition) Content type: `application/json` ### Schema: MetricError | Field | Type | Presence | Description | Constraints | | --- | --- | --- | --- | --- | | `error` | string | Required | | | | `message` | string | Optional | | | **Additional Properties**: `true` **missing currency** ```json { "error": "currency_code is required for currency metrics" } ``` ### 409 Metric limit reached Content type: `application/json` Schema: [MetricError](#schema-metricerror) **limit reached** ```json { "error": "Metric limit reached", "code": "metric_limit_reached", "message": "This account already has 100 metrics. Delete unused metrics before adding more." } ``` ### 429 Rate limit exceeded Content type: `application/json` ### Schema: RateLimitError | Field | Type | Presence | Description | Constraints | | --- | --- | --- | --- | --- | | `code` | string | Optional | | **Enum**: `["rate_limited"]` | | `error` | string | Required | | | | `message` | string | Required | | | **Additional Properties**: `false` **rate limited** ```json { "error": "Rate limit exceeded", "message": "Too many requests, please try again later." } ``` [Download the OpenAPI specification](/openapi.json) --- Source: https://activitysmith.com/docs/api-reference/endpoint/metric-value-update # Update Metric Value Updates the latest value for a metric displayed in ActivitySmith widgets. If no metric uses the key yet, the first value creates one: the label comes from the key, numeric values get the number format, and text values get the string format. To choose a currency, percent, or unit format, create the metric first with PUT /metrics/{key} or in the web app. A deleted metric is not recreated by new values; the request returns 404 with code metric_deleted. Each account can have up to 100 metrics created through the API. Metric updates have an independent 300-requests-per-minute account allowance. They do not consume the Push Notification, badge, or Live Activity allowances. ```http POST https://activitysmith.com/api/metrics/{key}/value ``` ## Authentication Use your [API key](/docs/api-keys) in the request header. ```http Authorization: Bearer $YOUR_API_KEY ``` ## Parameters ### key path parameter. Required. Metric key. A key that has never been used creates the metric. Lowercase letters, numbers, dots, underscores, and dashes are allowed. Type: string **Min Length**: `1`; **Max Length**: `64`; **Pattern**: `^[a-z0-9][a-z0-9_.-]{0,63}$` ## Request examples ```javascript Node import ActivitySmith from "activitysmith"; const activitysmith = new ActivitySmith({ apiKey: process.env.ACTIVITYSMITH_API_KEY, }); await activitysmith.metrics.update("deploy.success_rate", 99.9); ``` ```python Python import os from activitysmith import ActivitySmith activitysmith = ActivitySmith(api_key=os.environ["ACTIVITYSMITH_API_KEY"]) activitysmith.metrics.update("deploy.success_rate", 99.9) ``` ```go Go package main import ( "log" activitysmithsdk "github.com/ActivitySmithHQ/activitysmith-go" ) func main() { activitysmith, err := activitysmithsdk.New("YOUR-API-KEY") if err != nil { log.Fatal(err) } _, err = activitysmith.Metrics.Update("deploy.success_rate", 99.9) if err != nil { log.Fatal(err) } } ``` ```php PHP metrics->update('deploy.success_rate', 99.9); ``` ```ruby Ruby require "activitysmith" activitysmith = ActivitySmith::Client.new(api_key: ENV.fetch("ACTIVITYSMITH_API_KEY")) activitysmith.metrics.update("deploy.success_rate", 99.9) ``` ```bash cURL curl -X POST "https://activitysmith.com/api/metrics/deploy.success_rate/value" \ -H "Authorization: Bearer $YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "value": 99.9 }' ``` ## Body Content type: `application/json` ### Schema: MetricValueUpdateRequest Latest metric value to display in widgets. | Field | Type | Presence | Description | Constraints | | --- | --- | --- | --- | --- | | `value` | number or string (**Min Length**: `1`; **Max Length**: `64`) | Required | | | | `timestamp` | `string` | Optional | Optional ISO timestamp for when the metric value was measured. Defaults to the server receive time. | | **Additional Properties**: `false` ```json { "value": 42 } ``` ## Responses ### 200 Metric value updated Content type: `application/json` ### Schema: MetricValueUpdateResponse | Field | Type | Presence | Description | Constraints | | --- | --- | --- | --- | --- | | `success` | boolean | Required | | | | `created` | boolean | Optional | true when this request created the metric because no metric used the key yet. | | **Additional Properties**: `false` **success** ```json { "success": true } ``` **created** ```json { "success": true, "created": true } ``` ### 400 Bad request (invalid key or value) Content type: `application/json` ### Schema: MetricError | Field | Type | Presence | Description | Constraints | | --- | --- | --- | --- | --- | | `error` | string | Required | | | | `message` | string | Optional | | | **Additional Properties**: `true` **invalid value** ```json { "error": "value must be a finite number" } ``` ### 404 Metric deleted or not found Content type: `application/json` Schema: [MetricError](#schema-metricerror) **not found** ```json { "error": "Metric not found" } ``` **deleted** ```json { "error": "Metric deleted", "code": "metric_deleted", "message": "The metric with this key was deleted. Create it again before sending new values.", "key": "deploy.success_rate" } ``` ### 409 Metric limit reached Content type: `application/json` Schema: [MetricError](#schema-metricerror) **limit reached** ```json { "error": "Metric limit reached", "code": "metric_limit_reached", "message": "This account already has 100 metrics. Delete unused metrics before adding more." } ``` ### 429 Rate limit exceeded Content type: `application/json` ### Schema: RateLimitError | Field | Type | Presence | Description | Constraints | | --- | --- | --- | --- | --- | | `code` | string | Optional | | **Enum**: `["rate_limited"]` | | `error` | string | Required | | | | `message` | string | Required | | | **Additional Properties**: `false` **rate limited** ```json { "error": "Rate limit exceeded", "message": "Too many requests, please try again later." } ``` [Download the OpenAPI specification](/openapi.json) --- Source: https://activitysmith.com/docs/api-reference/endpoint/app-icon-badge-count # Set App Icon Badge Shows a number on the ActivitySmith app icon. Requires Push Notifications enabled for ActivitySmith on the device. ```http POST https://activitysmith.com/api/badge ``` ## Authentication Use your [API key](/docs/api-keys) in the request header. ```http Authorization: Bearer $YOUR_API_KEY ``` ## Request examples ```javascript Node await activitysmith.badgeCount(8333); ``` ```python Python activitysmith.badge_count(8333) ``` ```go Go activitysmith.BadgeCount(8333) ``` ```php PHP $activitysmith->badgeCount(8333); ``` ```ruby Ruby activitysmith.badge_count(8333) ``` ```bash CLI activitysmith badge 8333 ``` ```bash cURL curl -X POST "https://activitysmith.com/api/badge" \ -H "Authorization: Bearer $YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "badge": 8333 }' ``` ## Body Content type: `application/json` ### Schema: AppIconBadgeCountUpdateRequest | Field | Type | Presence | Description | Constraints | | --- | --- | --- | --- | --- | | `badge` | integer | Required | The count to show on the ActivitySmith app icon. Send 0 to clear it. | **Minimum**: `0`; **Maximum**: `2147483647` | | `target` | `ChannelTarget` | Optional | | | **Additional Properties**: `false` **set count** ```json { "badge": 8333 } ``` **clear count** ```json { "badge": 0 } ``` **channel targeted** ```json { "badge": 3, "target": { "channels": [ "sales", "customer-success" ] } } ``` ## Responses ### 200 App Icon Badge updated Content type: `application/json` ### Schema: AppIconBadgeCountUpdateResponse | Field | Type | Presence | Description | Constraints | | --- | --- | --- | --- | --- | | `success` | boolean | Required | | | | `badge` | integer | Required | | **Minimum**: `0`; **Maximum**: `2147483647` | | `devices_updated` | integer | Required | Number of devices whose App Icon Badge was updated. | | | `users_updated` | integer | Required | Number of account users with at least one updated device. | | | `devices_notified` | integer | Optional | Deprecated compatibility alias for devices_updated. | **Deprecated**: `true` | | `users_notified` | integer | Optional | Deprecated compatibility alias for users_updated. | **Deprecated**: `true` | | `effective_channel_slugs` | array of string or null | Required | | | | `timestamp` | `string` | Required | | | | `devices_targeted` | integer | Optional | Number of device tokens targeted. | | | `devices_deactivated` | integer | Optional | Number of device tokens deactivated because APNs reported them unregistered. | | | `devices_unregistered` | integer | Optional | Number of targeted device tokens APNs reported as unregistered. | | **Additional Properties**: `false` **default** ```json { "success": true, "badge": 8333, "devices_updated": 2, "users_updated": 1, "effective_channel_slugs": null, "timestamp": "2026-07-10T12:00:00.000Z" } ``` **channel targeted** ```json { "success": true, "badge": 3, "devices_updated": 2, "users_updated": 1, "effective_channel_slugs": [ "sales", "customer-success" ], "timestamp": "2026-07-10T12:00:00.000Z" } ``` ### 400 Bad request Content type: `application/json` ### Schema: BadRequestError | Field | Type | Presence | Description | Constraints | | --- | --- | --- | --- | --- | | `error` | string | Required | | | | `message` | string | Required | | | **Additional Properties**: `true` ### 402 Billing access required Content type: `application/json` ### Schema: BillingBlockedError | Field | Type | Presence | Description | Constraints | | --- | --- | --- | --- | --- | | `error` | string | Required | | **Enum**: `["trial_expired","trial_exhausted","billing_overage_cap_reached"]` | | `message` | string | Required | | | | `trial_period` | object | Optional | | | | `trial_period.started_at` | `string` | Required | | | | `trial_period.ends_at` | `string` | Required | | | | `upgrade_url` | `string` | Required | | | **Additional Properties**: `true` ### 403 Forbidden Content type: `application/json` ### Schema: ForbiddenError | Field | Type | Presence | Description | Constraints | | --- | --- | --- | --- | --- | | `error` | string | Required | | | | `message` | string | Required | | | **Additional Properties**: `true` ### 422 No matching devices found, or a targeted device needs to reconnect Content type: `application/json` **oneOf** Schema: `NoRecipientsError` Schema: [AppIconBadgeCountUpdateError](#schema-appiconbadgecountupdateerror) ### 429 Rate limit exceeded Content type: `application/json` ### Schema: RateLimitError | Field | Type | Presence | Description | Constraints | | --- | --- | --- | --- | --- | | `code` | string | Optional | | **Enum**: `["rate_limited"]` | | `error` | string | Required | | | | `message` | string | Required | | | **Additional Properties**: `false` ### 502 App Icon Badge could not be updated Content type: `application/json` ### Schema: AppIconBadgeCountUpdateError | Field | Type | Presence | Description | Constraints | | --- | --- | --- | --- | --- | | `error` | string | Required | | | | `code` | string | Required | | **Enum**: `["badge_device_disconnected","badge_update_failed"]` | | `message` | string | Required | | | | `badge` | integer | Required | | **Minimum**: `0`; **Maximum**: `2147483647` | | `devices_targeted` | integer | Optional | | | | `devices_updated` | integer | Required | | | | `users_updated` | integer | Optional | | | | `devices_notified` | integer | Optional | Deprecated compatibility alias for devices_updated. | **Deprecated**: `true` | | `effective_channel_slugs` | array of string or null | Optional | | | **Additional Properties**: `true` [Download the OpenAPI specification](/openapi.json) --- Source: https://activitysmith.com/docs/api-reference/endpoint/account-devices # List Paired Devices Lists the iPhones and iPads paired to the account, active devices first. Use it to check that a device is paired before you send, or to find device IDs for Channels. An empty list means no device is paired yet: install the ActivitySmith app from the App Store and sign in. Channel-scoped API keys cannot list devices. ```http GET https://activitysmith.com/api/account/devices ``` ## Authentication Use your [API key](/docs/api-keys) in the request header. ```http Authorization: Bearer $YOUR_API_KEY ``` ## Parameters ### limit query parameter. Optional. Maximum devices to return, 1 to 100. Defaults to 100. Type: integer **Minimum**: `1`; **Maximum**: `100`; **Default**: `100` ### offset query parameter. Optional. Devices to skip. Use meta.next_offset from the previous page. Type: integer **Minimum**: `0`; **Default**: `0` ### include_inactive query parameter. Optional. Include devices that can no longer receive deliveries, such as unpaired phones. Type: boolean **Default**: `false` ## Request examples ```javascript Node import ActivitySmith from "activitysmith"; const activitysmith = new ActivitySmith({ apiKey: process.env.ACTIVITYSMITH_API_KEY, }); const { devices } = await activitysmith.devices.list(); for (const device of devices) { console.log(device.device_name, device.system_name, device.is_active); } ``` ```python Python import os from activitysmith import ActivitySmith activitysmith = ActivitySmith(api_key=os.environ["ACTIVITYSMITH_API_KEY"]) result = activitysmith.devices.list() for device in result.devices: print(device.device_name, device.system_name, device.is_active) ``` ```go Go package main import ( "fmt" "log" activitysmithsdk "github.com/ActivitySmithHQ/activitysmith-go" ) func main() { activitysmith, err := activitysmithsdk.New("YOUR-API-KEY") if err != nil { log.Fatal(err) } result, err := activitysmith.Devices.List(activitysmithsdk.DeviceListInput{}) if err != nil { log.Fatal(err) } for _, device := range result.GetDevices() { fmt.Println(device.GetDeviceName(), device.GetSystemName(), device.GetIsActive()) } } ``` ```php PHP devices->list(); foreach ($result->getDevices() as $device) { echo $device->getDeviceName() . ' ' . $device->getSystemName() . PHP_EOL; } ``` ```ruby Ruby require "activitysmith" activitysmith = ActivitySmith::Client.new(api_key: ENV.fetch("ACTIVITYSMITH_API_KEY")) result = activitysmith.devices.list result.devices.each do |device| puts [device.device_name, device.system_name, device.is_active].join(" ") end ``` ```bash CLI activitysmith devices list ``` ```bash cURL curl "https://activitysmith.com/api/account/devices" \ -H "Authorization: Bearer $YOUR_API_KEY" ``` ## Responses ### 200 Paired devices Content type: `application/json` ### Schema: AccountDeviceListResponse | Field | Type | Presence | Description | Constraints | | --- | --- | --- | --- | --- | | `devices` | array of `AccountDevice` | Required | | | | `meta` | object | Required | | | | `meta.total` | integer | Required | Devices matching the filter. | | | `meta.limit` | integer | Required | | | | `meta.offset` | integer | Required | | | | `meta.has_more` | boolean | Required | | | | `meta.next_offset` | integer or null | Required | Offset for the next page, or null on the last page. | | | `meta.include_inactive` | boolean | Required | | | **default** ```json { "devices": [ { "user_email": "you@example.com", "device_id": "4F1C2A8E-7B3D-4E21-9A6C-1D2E3F4A5B6C", "device_type": "ios", "is_active": true, "token_status": { "push": true, "start_live_activity": true }, "app_version": "1.17.0", "device_name": "iPhone", "system_name": "iOS", "system_version": "27.0", "created_at": "2026-10-01T09:00:00.000Z", "updated_at": "2026-10-26T12:00:00.000Z" } ], "meta": { "total": 1, "limit": 100, "offset": 0, "has_more": false, "next_offset": null, "include_inactive": false } } ``` **no devices** ```json { "devices": [], "meta": { "total": 0, "limit": 100, "offset": 0, "has_more": false, "next_offset": null, "include_inactive": false } } ``` ### 403 The API key is limited to Channels Content type: `application/json` ### Schema: ForbiddenError | Field | Type | Presence | Description | Constraints | | --- | --- | --- | --- | --- | | `error` | string | Required | | | | `message` | string | Required | | | **Additional Properties**: `true` ### 429 Rate limit exceeded Content type: `application/json` ### Schema: RateLimitError | Field | Type | Presence | Description | Constraints | | --- | --- | --- | --- | --- | | `code` | string | Optional | | **Enum**: `["rate_limited"]` | | `error` | string | Required | | | | `message` | string | Required | | | **Additional Properties**: `false` [Download the OpenAPI specification](/openapi.json)