API guide/v2/webhooks

Webhooks

Configure an endpoint that receives Earnings API event deliveries, verifies signatures, and responds with a 2xx status after processing.

Authentication

Base URL

https://api.earningsapi.com/v2/webhooks

These routes manage the same endpoint and subscriptions as your dashboard.

In API keys, turn on “Allow webhook management and test deliveries with this key” for your chosen key. This grants all three webhook permissions. Existing keys receive no webhook permissions automatically. Send an active account key in the x-api-key header and JSON bodies with Content-Type: application/json. Query parameter authentication used by data endpoints does not apply here.

webhooks:read permits reads, webhooks:write permits configuration changes and secret rotation, and webhooks:test permits test sends. Permissions are independent; write does not grant read or test. Keep API keys and signing secrets on your server, out of browser code, URLs, and logs.

Plans and limits

Free

1webhook slot

Enabled template × symbol

Pro

5webhook slots

Enabled template × symbol

Get Pro before the price goes up.

Upgrade to Pro

One enabled template × symbol uses one slot. Disabled templates use no slots.

Management endpoints

Paths below are relative to the management base URL. Supported operations return HTTP 200 on success, including creation and deletion.

MethodPathPermissionRequest and response
GET/endpointwebhooks:readRead the endpoint; returns { endpoint: null } if none exists. Never returns the full secret.
PUT/endpointwebhooks:writeCreate or update with { "url": "https://receiver.example/earnings" }. Returns { endpoint }; the secret is included only when first created.
DELETE/endpointwebhooks:writeDisable all subscriptions first. Returns { endpoint: null }, including when already absent.
POST/endpoint/rotate-secretwebhooks:writeNo body required. Returns { endpoint } with a new secret. The previous secret is replaced immediately.
GET/subscriptionswebhooks:readReturns { subscriptions: [...] } with all four templates, including disabled defaults with revision 0.
PUT/subscriptions/{templateId}webhooks:writeReplace enabled and symbols using expectedRevision. Returns { subscription, baselineInitialization, cancellation }.
POST/testwebhooks:testSend { "templateId": "earnings_result", "symbol": "AAPL" }. Requires that template and symbol to be enabled. Sends synthetic data to the saved endpoint.

There is no public delivery-history, replay, or subscription DELETE route. Disable a template with PUT and enabled: false, or remove a symbol by submitting the remaining symbol list. A test response reports that attempt only.

Create an endpoint and subscribe

Replace the example URL with your own public HTTPS receiver and configure your API key as shown. This example follows your selected code environment. It reads the current revision and adds AAPL while preserving existing symbols. Grant all three permissions to run every step, including the optional test.

Management quickstartPython
import os
import requests

BASE_URL = "https://api.earningsapi.com/v2/webhooks"
API_KEY = os.environ["EARNINGS_API_KEY"]
RECEIVER_URL = "https://receiver.example/earnings"
TEMPLATE_ID = "earnings_result"
SYMBOL = "AAPL"

def api(method, path, body=None):
    response = requests.request(
        method, BASE_URL + path,
        headers={"x-api-key": API_KEY},
        json=body, timeout=30,
    )
    response.raise_for_status()
    return response.json()

# 1. Save your public HTTPS receiver.
endpoint = api("PUT", "/endpoint", {"url": RECEIVER_URL})
# Store endpoint["endpoint"]["secret"] securely if returned.

# 2. Read the current revision and preserve existing symbols.
subscriptions = api("GET", "/subscriptions")["subscriptions"]
current = next(s for s in subscriptions if s["templateId"] == TEMPLATE_ID)
symbols = list(dict.fromkeys([*current["symbols"], SYMBOL]))

# 3. Enable the subscription using the revision you just read.
result = api("PUT", "/subscriptions/" + TEMPLATE_ID, {
    "enabled": True,
    "symbols": symbols,
    "expectedRevision": current["revision"],
})
print(result)

# 4. Optional: send synthetic data to your real receiver.
# print(api("POST", "/test", {"templateId": TEMPLATE_ID, "symbol": SYMBOL}))

Every subscription update requires a boolean enabled, a symbols array, and a non-negative integer expectedRevision. The array replaces the entire symbol list for that template. At most 100 input symbols are accepted, each 1–32 characters using letters, digits, dots, carets, hyphens, or slashes. Symbols are uppercased, hyphens/slashes become dots, and duplicates are removed. An enabled template needs at least one symbol and must fit your plan limit.

Read the current revision immediately before saving. A successful save increments it. On 409 WEBHOOK_REVISION_CONFLICT, read again and reconcile your intended changes instead of blindly resubmitting. To disable, send {"enabled":false,"symbols":[],"expectedRevision":1} with the actual current revision, then delete the endpoint only after all templates are disabled.

Notifications cover future changes. Enabling a subscription does not replay historical events or immediately send the current earnings data. Use the test operation to check your receiver. Tests use synthetic values and are attempted once, without retries.

Responses and configuration changes

Endpoint objects contain id, uid, url, secretLast4, createdAt, and updatedAt. The public API includes secret only on creation or rotation. Store it securely before discarding that response; ordinary reads and URL updates do not reveal it.

Endpoint creation responseJSON
{
  "endpoint": {
    "id": "example_account",
    "uid": "example_account",
    "url": "https://receiver.example/earnings",
    "secretLast4": "0000",
    "secret": "whsec_EXAMPLE_ONLY_0000",
    "createdAt": "2026-11-05T12:00:00.000Z",
    "updatedAt": "2026-11-05T12:00:00.000Z"
  }
}

GET /subscriptions returns all four templates in subscriptions. Each has uid, endpointId, templateId, enabled, symbols, revision, createdAt, and updatedAt. Unsaved templates have an empty symbol list, enabled: false, revision 0, and null timestamps.

PUT /subscriptions/{templateId} returns the saved subscription, baselineInitialization setup details (or null), and cancellation metadata when disabled (otherwise null). These setup details do not confirm a delivery.

Test responseJSON
{
  "message": "Test webhook delivered.",
  "deliveryId": "del_test_EXAMPLE_ONLY",
  "responseStatus": 200,
  "responseBody": "OK"
}

The test response includes a preview of the receiver response body. If a mutation succeeds but its management audit record cannot be saved, the response adds auditRecorded: false. The operation has already executed; do not repeat it just to record an audit event.

Disabling a subscription or removing a symbol cancels queued deliveries and scheduled retries. Re-enabling never restores canceled deliveries. A request already in progress may complete, but it will not be retried after cancellation.

Changing the endpoint URL preserves queued events and uses the latest URL for subsequent attempts. A request already in progress may still use the previous URL or secret. Rotation replaces the signing secret immediately for new requests; coordinate receiver deployment accordingly.

Management errors

Errors from supported operations use {"message":"...","code":"..."}, with additional fields where applicable. An unsupported route or method returns 405 with a message.

HTTPCodeMeaning and next step
400WEBHOOK_REQUEST_FAILEDInvalid URL, template, symbol list, revision type, or missing endpoint/enabled subscription. Fix the request.
401WEBHOOK_REQUEST_FAILEDMissing or malformed x-api-key header.
403WEBHOOK_REQUEST_FAILEDInvalid, inactive, disabled, or revoked API key, or invalid account plan.
403WEBHOOK_SCOPE_REQUIREDEnable the required permission on this key in the dashboard.
403WEBHOOK_SLOT_LIMIT_REACHEDThe proposed change exceeds the plan limit. limit and used describe the limit and proposed total usage.
404WEBHOOK_REQUEST_FAILEDEndpoint not found when rotating its secret, or account not found when saving a subscription.
409WEBHOOK_REVISION_CONFLICTRead subscriptions again, reconcile your change, and submit the current revision.
409WEBHOOK_REQUEST_FAILEDEnabled subscriptions prevent endpoint deletion, or a test was canceled by a concurrent change.
428WEBHOOK_REVISION_REQUIREDRead subscriptions and include expectedRevision.
429RATE_LIMIT_EXCEEDEDWait for Retry-After (seconds); retryAfterSeconds is also in the JSON body.
502WEBHOOK_BASELINE_UNAVAILABLEWebhook setup could not be completed; the subscription update was not saved. Retry later.
502WEBHOOK_TEST_FAILEDThe receiver returned non-2xx or the test request failed. Inspect deliveryId and responseStatus when provided.
500WEBHOOK_REQUEST_FAILEDUnexpected server failure. Read the current configuration before retrying a mutation.
Error response · HTTP 403JSON
{
  "message": "Webhook slot limit reached.",
  "code": "WEBHOOK_SLOT_LIMIT_REACHED",
  "limit": 1,
  "used": 2
}

After a network timeout on a configuration change, read the endpoint or subscriptions to determine whether it succeeded before retrying. A failed test may have reached your receiver even if its response was lost. Deduplicate by delivery ID.

Delivery request

Earnings API sends each delivery as an HTTP POST to your saved endpoint URL. The HTTP format and JSON payloads are the same in every environment; setup and receiver examples follow your selected code environment.

Webhook endpoint must use HTTPS.

Hosted webhook delivery requires a public https:// URL.

localhost and private network URLs are not supported. Use an HTTPS tunnel for local testing.

HTTP delivery formatHTTP
POST https://your-domain.com/webhooks/earnings
Content-Type: application/json
User-Agent: EarningsAPI-Webhooks/1.0
X-EarningsAPI-Delivery-Id: {deliveryId}
X-EarningsAPI-Timestamp: {unixTimestamp}
X-EarningsAPI-Signature: sha256={hmac}

Webhook payload examples

Use template_id and event_type to route each delivery, then read the fields in data for the subscribed symbol. The payload id matches the delivery ID header; created_at is an ISO timestamp and context.symbol identifies the symbol. Change events include changed_fields; upcoming events use earnings_schedule_upcoming.entered. Tests contain synthetic data and use a del_test_ delivery ID; the payload has no separate test flag.

Earnings scheduleJSON
{
  "id": "del_7a871a19a44926c2496db1ed39a997dc",
  "created_at": "2026-07-09T12:03:10Z",
  "template_id": "earnings_schedule",
  "event_type": "earnings_schedule.changed",
  "context": {
    "symbol": "ASML"
  },
  "data": {
    "date": "2026-07-15",
    "time": "time-pre-market",
    "epsEstimate": 7.98,
    "revenueEstimate": 10331810000,
    "eps": null,
    "revenue": null
  },
  "changed_fields": ["revenueEstimate"]
}

An upcoming earnings date marked data.scheduleProvenance.kind = "provisional_date_only" is a forecast and may change. Time, estimates, and results remain null when unavailable.

Signature verification

Use the webhook secret from your dashboard to verify the HMAC signature before trusting the body. Verify against the raw request body, then use the delivery id for idempotency.

Signature formulaPseudocode
expected = "sha256=" + HMAC_SHA256(secret, timestamp + rawBody)

Use the exact raw request body bytes. Do not parse JSON and stringify it again before verification.

Do not insert a separator between timestamp and rawBody; timestamp + "." + rawBody will not match.

Compare with the X-EarningsAPI-Signature value after handling the sha256= prefix consistently. Use a constant-time comparison and reject stale timestamps using a replay window appropriate to your receiver. Keep deduplication records across retries.

Receiver examplePython
import hashlib
import hmac
import os
from flask import Flask, jsonify, request

app = Flask(__name__)

def verify_earnings_api_webhook(raw_body, timestamp, signature, secret):
    signed_payload = timestamp.encode("utf-8") + raw_body
    expected = hmac.new(
        secret.encode("utf-8"),
        signed_payload,
        hashlib.sha256,
    ).hexdigest()
    signature_hex = (signature or "").removeprefix("sha256=")
    return hmac.compare_digest(signature_hex, expected)

@app.post("/webhooks/earnings")
def earnings_api_webhook():
    raw_body = request.get_data()
    timestamp = request.headers.get("X-EarningsAPI-Timestamp", "")
    signature = request.headers.get("X-EarningsAPI-Signature", "")

    if not verify_earnings_api_webhook(
        raw_body,
        timestamp,
        signature,
        os.environ["EARNINGS_API_WEBHOOK_SECRET"],
    ):
        return jsonify({"error": "Invalid signature"}), 401

    delivery_id = request.headers.get("X-EarningsAPI-Delivery-Id")
    payload = request.get_json()
    # Use delivery_id for idempotency before running your workflow.

    return jsonify({"received": True}), 200

Receiver flow

StepWhat to do
1Verify X-EarningsAPI-Signature with your webhook secret.
2Deduplicate by X-EarningsAPI-Delivery-Id.
3Check template_id and event_type.
4Store data or run your internal workflow.
5Return any 2xx response after successful processing.

Delivery status

2xx response

Only a 2xx response is marked delivered with deliveredAt and the response status.

Redirect, non-2xx, or timeout

3xx redirects are not followed. 4xx, 5xx, and timeouts are treated as failed or retryable attempts.

Retries and timing

Delivery requests time out after 10 seconds. Persist or enqueue accepted work promptly, then return 2xx. Non-2xx responses, including redirects, and network failures can be retried while the subscription remains enabled.

Deliveries use up to three attempts by default. Retries are scheduled after 60 seconds and then 300 seconds; actual arrival times can vary. Tests have a single attempt. If the outcome of an interrupted request cannot be confirmed, it is not automatically retried.

Use the delivery ID for idempotency. Do not assume exactly-once delivery, chronological arrival, or automatic replay of historical events. Disabling a template or removing a symbol prevents further retries for canceled work.

How it fits together

Your subscriptions choose which event templates and symbols are sent to your endpoint.

New queued events retain the values captured when the change was detected, so later source updates do not change an event that is awaiting delivery.

Each attempt signs and sends the event to the current endpoint URL. Your receiver verifies the signature and deduplicates by delivery ID before returning 2xx.

Data API quota and limits

FeatureFreePlusPro
API usage & data
Rate limit60 / min150 / min300 / min
Request quota600 / 30 daysUnlimitedUnlimited
Historical data24 monthsAll availableAll available
Earnings & economic refreshDailyDailyEvery 5 mins
Endpoint access
Insider TradesUnavailableUnavailableIncluded
Earnings Release TimesUnavailableUnavailableIncluded
Keys & webhooks
Active API keys11Up to 3
Webhook slots115

Refresh times apply to earnings and economic values for today and upcoming dates. Past dates use the latest available values on each plan. Dates and Free quota resets use New York time. Historical access applies to supported endpoints.

View plans in dashboard