Widgets EndpointsView Markdown ↗

Update Metric Value

Updates the latest value for a metric displayed in ActivitySmith widgets. Create the metric in the web app first, then update its value using the key. Metric updates have an independent 300-requests-per-minute account allowance. They do not consume the Push Notification, badge, or Live Activity allowances.

POST https://activitysmith.com/api/metrics/{key}/value

Authentication#

Use your API key in the request header.

Authorization: Bearer $YOUR_API_KEY

Parameters#

key#

path parameter. Required.

Metric key configured in the web app. 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#

import ActivitySmith from "activitysmith";
const activitysmith = new ActivitySmith({
apiKey: process.env.ACTIVITYSMITH_API_KEY,
});
await activitysmith.metrics.update("deploy.success_rate", 99.9);

Bodyapplication/json

Latest metric value to display in widgets.

valuenumber or string (Min Length: 1; Max Length: 64)required
timestampstring<date-time>
Optional ISO timestamp for when the metric value was measured. Defaults to the server receive time.

Additional Properties: false

{
"value": 42
}

Responses#

200#

Metric value updated

Content type: application/json

Schema: MetricValueUpdateResponse#

successbooleanrequired

Additional Properties: false

success

{
"success": true
}

400#

Bad request (invalid key or value)

Content type: application/json

Schema: MetricError#

errorstringrequired
messagestring

Additional Properties: true

invalid value

{
"error": "value must be a finite number"
}

404#

Metric not found

Content type: application/json

Schema: MetricError

not found

{
"error": "Metric not found"
}

429#

Rate limit exceeded

Content type: application/json

Schema: RateLimitError#

codestring
Enum: ["rate_limited"]
errorstringrequired
messagestringrequired

Additional Properties: false

rate limited

{
"error": "Rate limit exceeded",
"message": "Too many requests, please try again later."
}

Download the OpenAPI specification