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 Body required
Section titled “Request Body required ” Media type application/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
Example revenueDrop
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 type application/json
object
success
required
boolean
error
required
Human-readable message.
string
code
required
Machine-readable error code.
string
Example
{ "success": false}