Skip to main content
A Darvas Pro+ webhook sends a signed POST to your HTTPS endpoint each time an event it subscribes to happens. Darvas sends an event as soon as it stores the event, usually within a second.

Plans

Webhooks are part of Darvas Pro+. A Pro+ account can have 15 webhooks on at once. A webhook that is off does not count toward the 15. Darvas Free and Darvas Pro, including Pro through an OKX account opened with Darvas, have no webhooks. When Pro+ ends, your webhooks stop receiving new events and show Paused by plan. You can still read their deliveries and delete them. When Pro+ comes back, they turn on again, oldest first, up to the plan’s limit. A webhook you turned off stays off.

Add a webhook

Add a webhook in your Darvas settings:
  1. Open Settings and choose Webhooks.
  2. Select Add webhook.
  3. Give the webhook a Name of up to 100 characters, if you like. Without one, the list shows the host of its URL.
  4. Enter the Endpoint URL, a public https:// address.
  5. Under Events, tick a whole group, such as Alarms, or single event types.
  6. Select Add webhook, then Copy secret to copy the signing secret, whsec_....
Darvas shows the signing secret only once, when you add the webhook. Store it with your server before you select I saved my secret. You need it to verify each delivery. Each webhook in the list shows On, Off or Paused by plan, the number of failed deliveries in a row, and these buttons: A test event has livemode: false, the type of the webhook’s first event and this object:
Each webhook gets one test event a minute. Deliveries lists each delivery with its event type, its status (Delivered, Pending or Failed), the HTTP status your endpoint answered, or No answer, and the number of attempts. Refresh reads the list again.

Events

A webhook receives only the types you choose. An event of your account, such as an alarm’s fire, goes only to your own webhooks. ETF flow updates and data events go to every webhook that subscribes to them. venue.connection_ended counts only connections that end after you add your first webhook with this type, so a new webhook gets no old ends.

Alarm objects

Every alarm event has these fields in data.object: Each alarm type adds its own fields: In alarm.custom_indicator.triggered, alert is the alertcondition() title that fired, alert for an alert() call, or null for a mark.

Other objects

The reason of venue.connection_ended is expired when the access ran out, and ended when it was revoked or the venue refused the key. The reason of alarm.paused is one of these:

Deliveries

Each delivery is a POST of this JSON envelope:
created is the Unix time in seconds when Darvas stored the event. The request has these headers:
  • Content-Type: application/json
  • User-Agent: Darvas-Webhook/1.0
  • Darvas-Signature: t=<unix seconds>,v1=<hex>
Answer with any 2xx status within ten seconds. Do slow work after you answer, such as from a queue. Darvas does not follow redirects. Each webhook receives its events one at a time, oldest first, so a slow endpoint delays only its own events. The same event can arrive twice, and a retry can arrive after a newer event. Use id to skip an event you have handled.

Verify the signature

v1 is the HMAC-SHA256 of <t>.<raw body> under your signing secret, in hex. Before you trust a delivery:
  1. Compute the HMAC over the raw body as you received it. A body that you parsed and serialized again does not match.
  2. Compare it with v1 in constant time.
  3. Refuse a t that is more than five minutes away from your clock.
In Python, pass the raw body as bytes, such as request.get_data() in Flask:

Retries and failures

  • A delivery fails when your endpoint does not answer with a 2xx within ten seconds, or cannot be reached.
  • Darvas tries a failed delivery again about a minute later, and once more about ten minutes after that. After the third failed attempt, the delivery is marked dead.
  • After 50 failed attempts in a row, Darvas turns the webhook off. Fix your endpoint, then turn the webhook on again in settings. Turning it on sets the failure count to 0.
  • Darvas keeps events and their deliveries for 30 days.

Endpoint rules

Darvas refuses a URL that breaks one of these rules when you add or change a webhook:
  • The URL uses https.
  • The URL has no user name or password.
  • The host is a public name with a dot, not a name that ends in .local, .internal, .localhost, .test or .invalid.
  • An IP address host is public. Private, loopback, link-local, shared, documentation, multicast and reserved ranges are refused, for IPv4 and IPv6.
  • The URL has at most 2,000 characters, and the name and the URL have no control characters.
At each delivery, Darvas resolves the host again. If any address of the host is not public, the delivery fails, so a name that later points to a private address receives nothing.