Alerts

Create a price alert

Changed on

Creates a threshold alert on commodity_code. Delivery is by email; set webhook_url to also send an alert.triggered webhook. A webhook_url must match an active endpoint registered with POST /v1/webhooks for the alert.triggered event; otherwise the request is rejected with 422 and errors.webhook_url.

Plan limits: Free 1 alert, Developer 20, Starter and Professional 100, Scale unlimited. Reaching the limit returns 422 with error: "Alert limit reached" and an upgrade message.

post/v1/alerts

Request

  • Base URL
    https://api.oilpriceapi.com
  • Auth
    API key in header Authorization

Request body

Example request

{
  "price_alert": {
    "name": "Brent above 95",
    "commodity_code": "BRENT_CRUDE_USD",
    "condition_operator": "greater_than",
    "condition_value": 95,
    "webhook_url": "https://example.com/hooks/opa",
    "enabled": true,
    "cooldown_minutes": 60
  }
}

Response

Alert created

idinteger
namestring nullable
commodity_codestring
alert_typestring nullable
delivery_modestring
condition_operatorstring nullable
condition_valuenumber nullable
conditionstring nullable
summarystring nullable
webhook_urlstring nullable
has_webhookboolean
enabledboolean
cooldown_minutesinteger
trigger_countinteger
last_triggered_atstring date-time nullable
metadataobject
created_atstring date-time
updated_atstring date-time

Example response

{
  "id": 1234,
  "name": "Brent above 95",
  "commodity_code": "BRENT_CRUDE_USD",
  "alert_type": "threshold",
  "delivery_mode": "threshold",
  "condition_operator": "greater_than",
  "condition_value": 95,
  "condition": "BRENT_CRUDE_USD > 95.0",
  "enabled": true,
  "cooldown_minutes": 60
}

Changes

    • breaking

      added required request body

    • info

      api operation id postV1Alerts removed and replaced with createV1Alert

    • info

      added the media type application/json for the response with the status

    3 more changes in this revision