Create an alert rule
POST
/v1/metric-alerts
const url = 'https://shareout.site/v1/metric-alerts';const options = { method: 'POST', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"artifact_id":"art_abc123","metric_id":"revenue","name":"Revenue dropped below target","condition":{"op":"lt","value":100000},"schedule":"0 * * * *","destination":{"kind":"slack","config":{"connection":"team","targetType":"channel","channelId":"C0123456789","mode":"message"}},"message":"Revenue is below target.","cooldown_seconds":86400}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://shareout.site/v1/metric-alerts \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data '{ "artifact_id": "art_abc123", "metric_id": "revenue", "name": "Revenue dropped below target", "condition": { "op": "lt", "value": 100000 }, "schedule": "0 * * * *", "destination": { "kind": "slack", "config": { "connection": "team", "targetType": "channel", "channelId": "C0123456789", "mode": "message" } }, "message": "Revenue is below target.", "cooldown_seconds": 86400 }'Authorizations
Section titled “Authorizations”Request Bodyrequired
Section titled “Request Bodyrequired”Media typeapplication/json
object
artifact_id
required
string
metric_id
required
string
name
required
string
condition
required
object
op
required
string
value
required
number
schedule
required
5-field cron expression.
string
destination
required
object
kind
required
string
config
required
Destination config matching the kind (see Jobs config interfaces).
object
message
string
cooldown_seconds
integer
Examples
ExamplerevenueDrop
Slack alert when revenue drops
{ "artifact_id": "art_abc123", "metric_id": "revenue", "name": "Revenue dropped below target", "condition": { "op": "lt", "value": 100000 }, "schedule": "0 * * * *", "destination": { "kind": "slack", "config": { "connection": "team", "targetType": "channel", "channelId": "C0123456789", "mode": "message" } }, "message": "Revenue is below target.", "cooldown_seconds": 86400}Responses
Section titled “Responses”Created
Invalid request
Media typeapplication/json
object
success
required
boolean
error
required
Human-readable message.
string
code
required
Machine-readable error code.
string
request_id
Correlation id (also the X-Request-Id header). Quote it in support tickets.
string
reason
Finer cause under code. For UNAUTHORIZED: missing, invalid, revoked or expired.
string
hint
What to do next, in plain words.
string
suggestion
string
param
The request field at fault.
string
docs
Doc page for this error.
string
redirect_url
string
support
Present on 5xx — how to reach a human.
object
how
string
include
Array<string>
Example
{ "success": false, "support": { "how": "POST /v1/support/tickets", "include": [ "request_id" ] }}