Create or update a metric definition
PUT
/v1/metric-alerts/definitions
const url = 'https://shareout.site/v1/metric-alerts/definitions';const options = { method: 'PUT', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"artifact_id":"example","metric_id":"example","label":"example","format":"example","source":{"type":"json_path","key":"example","path":"example","table":"example","field":"example","fn":"sum","where":{}}}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request PUT \ --url https://shareout.site/v1/metric-alerts/definitions \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data '{ "artifact_id": "example", "metric_id": "example", "label": "example", "format": "example", "source": { "type": "json_path", "key": "example", "path": "example", "table": "example", "field": "example", "fn": "sum", "where": {} } }'Upserts by (artifact_id, metric_id). Up to 10 metrics per artifact.
Authorizations
Section titled “Authorizations”Request Bodyrequired
Section titled “Request Bodyrequired”Media typeapplication/json
object
artifact_id
required
string
metric_id
required
Stable key referenced by rules. Letters, digits, _, -.
string
label
required
string
format
Display hint: currency:USD, number, percent.
string
source
required
Where a metric value is read from.
object
type
required
string
key
Json_path: the sdk.json key to read.
string
path
Json_path: e.g. $.revenue, $.totals.mrr.
string
table
string
field
string
fn
string
where
Filter using the same operators as sdk.table().query().
object
Responses
Section titled “Responses”Saved
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" ] }}