瀏覽全部文件

Webhook API 參考文件

附簽章、至少一次的事件交付,支援歷史紀錄與重播

目的地

十個需要身分驗證的路由可用於建立、列出、檢視、更新、輪替、測試和刪除目的地,還可讀取設定與交付歷史,並重播單次交付。目的地的篩選條件始終限於帳戶目前有效的國家與資料類別授權。 所有帳戶皆可使用 Webhook。每次投遞依其所含資料的價格計為一次呼叫。 一個帳戶總共最多可保留 25 個目的地,無論是否啟用。建立第 26 個的 POST /v1/webhooks/destinations 會傳回 409 limit_reached,直到刪除一個目的地。

GET /v1/webhooks/destinationsPOST /v1/webhooks/destinationsGET /v1/webhooks/destinations/{destination_id}PATCH /v1/webhooks/destinations/{destination_id}DELETE /v1/webhooks/destinations/{destination_id}POST /v1/webhooks/destinations/{destination_id}/testPOST /v1/webhooks/destinations/{destination_id}/rotate-secretGET /v1/webhooks/destinations/{destination_id}/historyGET /v1/webhooks/destinations/{destination_id}/deliveriesPOST /v1/webhooks/destinations/{destination_id}/deliveries/{delivery_id}/replay

請求欄位

欄位類型規則
url字串必填。最長2,048個字元的HTTPS URL。
countriesISO 3166 alpha-3 代碼陣列必填。1–60個大寫ISO alpha-3代碼,或WLD。
families發布系列代稱陣列必填。從「事件類型」中列出的類別裡選 1 到 8 個。未列出的類別會被拒絕,錯誤中會列出可用的類別。
companies公司 ID 陣列使用 filings 系列時必填,不使用時會被拒絕。1–1,000 個公司 ID,例如 usa:0000320193;未知的 ID 會被拒絕,錯誤中會指明該 ID。
enabled布林值選用。預設值為true。

PATCH 會替換整個設定:每次都需傳送 url、countries、families、enabled,使用 filings 系列時還需傳送 companies。省略 enabled 會重新啟用已停用的目的地。 如果啟用目的地會超出上限,POST 和 PATCH 回傳 409 limit_reached。請先停用或刪除另一個目的地。

目的地欄位

欄位類型含義
destination_iduuid識別目的地。
url字串HTTPS 接收端 URL。
countriesISO 3166 alpha-3 代碼陣列在帳戶目前有效的權限範圍內篩選國家。
families發布系列代稱陣列依發布系列篩選。
enabled布林值表示目的地是否已啟用。
companies公司 ID 陣列被關注的公司。僅當目的地具有 filings 系列時傳送。
config_version整數每次變更設定時遞增;傳送紀錄會記錄傳送時使用的版本。
secret_version整數每次輪替密鑰時遞增。
created_atUTC時間戳記目的地的建立時間。
updated_atUTC時間戳記目的地上次更新的時間。
secret字串僅在建立和輪替密鑰時回傳;請妥善保存,因為之後不會再次顯示。
disabled_reason字串目的地停用原因:customer或plan_limit。plan_limit 表示因目的地數量上限而被停用。目的地啟用時省略。

DELETE 和重新傳送會回傳 204 No Content。測試會回傳 delivery_id(沒有項目加入佇列時省略)和 status(queued、rate_limited 或 disabled);受到速率限制時也會回傳 retry_after_seconds。設定歷程路由會回傳 history,其中每個版本各有一筆紀錄,包含 config_version、url、countries、families、enabled 和 recorded_at。列表路由會回傳 destinations 和 destination_limit,後者是一個帳戶最多可保留的目的地數量(25)。沒有值的欄位會省略,例如已啟用目的地的 disabled_reason。 未知或已刪除的目的地在所有目的地路由上均回傳404 webhook_request_failed。重播無法使用的傳送也回傳同一錯誤。傳送清單的cursor無效時回傳400。503 webhook_unavailable表示目前無法提供Webhook。 測試投遞有帳戶層級的10秒冷卻時間。期間測試路由回傳 status: "rate_limited" 和 retry_after_seconds。

傳送紀錄

傳送紀錄路由使用 limit(1~100,預設為 50)和 cursor 分頁,並回傳 next_cursor(最後一頁為 null)。

欄位類型含義
delivery_id字串識別傳送紀錄。
event_cursor整數識別事件;測試傳送時省略。
is_test布林值僅在測試傳送時傳送,值為 true。
config_version整數該次傳送使用的目的地設定版本。
state列舉傳送狀態:pending、leased、succeeded、failed 或 cancelled。
attempts整數傳送嘗試次數。
replays整數重新傳送次數;僅在大於 0 時傳送。
next_attempt_at時間戳記下次嘗試的時間;僅在狀態為 pending 或 leased 時傳送。
retry_until時間戳記允許重試傳送的截止時間;僅在狀態為 pending 或 leased 時傳送。
last_status整數接收端最近一次回傳的 HTTP 狀態;首次嘗試前省略。
last_error字串最近一次錯誤;沒有錯誤時省略。
created_at時間戳記傳送紀錄的建立時間。
updated_at時間戳記傳送紀錄上次更新的時間。

事件類型

目的地僅在已訂閱類別相符,且符合帳戶目前有效的國家與類別權限時,收到以下事件類型。

目的地可訂閱以下一個或多個類別:gdp、prices、labour、trade、policy_rate、yield_curve、predictions 與 filings。

事件類型含義
release.updated日曆中的發布帶有此前沒有的數字
dataset.published已接受的官方出版品新增參考期間時
yield_curve.published新的殖利率曲線日期被接受時
rate_decision.published央行公布利率決定時,每次會議一次
filing.published當你關注的公司發布申報文件時,每份申報文件傳送一次

目的地只在新數字送達時收到投遞。日期變更、已取消的發布和之後被更改的數字都不會傳送。日期變更請從日曆中查看。

預測事件

訂閱 predictions 類別的目的地在事件停止交易時收到 prediction.event.closed,在事件結算時收到 prediction.event.settled,在事件作廢時收到 prediction.event.voided。每種類型對每個事件最多傳送一次。本文只包含事件狀態,不包含機率或獲勝結果。市場ID為 prediction_event_id;event_id 識別事件。

承載本文

Webhook本文包含schema_version,REST事件則不包含。無值的欄位會被省略。cursor用於排列日誌事件的順序。

經濟資料和發布事件
{
  "schema_version": "1",
  "event_id": "2cdf117d-4a23-4a1f-b68e-93a7e9dc765e",
  "cursor": "1",
  "type": "dataset.published",
  "country": "USA",
  "family": "prices",
  "resource_id": "775d11a3-a6de-52b1-b41b-a236ad595e7a",
  "resource_version": "822e107c-09f6-4736-82e9-082d725398a2",
  "operation": "economics_get_cpi",
  "data": {
    "country": "USA",
    "period": "2026-10",
    "value": "337.511",
    "index_base": "1982-84=100",
    "released_on": "2026-11-10"
  },
  "recorded_at": "2026-11-10T13:31:12Z"
}

operation 指明其最新值保存在 data 中的操作,例如 economics_get_cpi,data 是該國的最新數字,格式與該操作的最新值端點回傳的一致。兩者都在 dataset.published 和 yield_curve.published 上傳送;當投遞時關聯的資料事件存在時,release.updated 也會傳送。data 只讀取一次,因此每次重試和重放都相同;如果無法讀取則省略,屆時請從端點取得該數字。

發布事件使用release_id而非resource_id。 release.updated 事件還帶有 release,即含其 indicators 的日曆修訂。其中的每個時間戳記都是 UTC。

發布更新
{
  "schema_version": "1",
  "event_id": "c3a8e4d0-5b1f-4f7e-9d2a-6e0b8f3a1c57",
  "cursor": "2",
  "type": "release.updated",
  "country": "USA",
  "family": "prices",
  "release_id": "f01e2289-2e17-49b3-9d64-d29118742dee",
  "resource_version": "4d6b0c1e-8a27-4f93-b5c0-71e2a9d3f648",
  "operation": "economics_get_cpi",
  "data": {
    "country": "USA",
    "period": "2026-10",
    "value": "337.511",
    "index_base": "1982-84=100",
    "released_on": "2026-11-10"
  },
  "release": {
    "title": "Consumer Price Index",
    "reference_period": "2026-10",
    "status": "published",
    "schedule": {
      "precision": "exact",
      "at": "2026-11-10T13:30:00Z",
      "timezone": "America/New_York",
      "local_date": "2026-11-10"
    },
    "officially_published_at": "2026-11-10T13:30:00Z",
    "indicators": [
      {
        "measure": "cpi_mom",
        "concept": "cpi",
        "title": "CPI, month over month",
        "period": "2026-10",
        "unit": "percent",
        "transformation": "month_over_month",
        "annualization": "not_annualized",
        "actual": "0.4",
        "previous": "0.6",
        "previous_period": "2026-09",
        "consensus": "0.3",
        "value_status": "available"
      }
    ]
  },
  "recorded_at": "2026-11-10T13:31:12Z"
}

rate_decision.published 事件帶有 decision,其中每個欄位都與利率決議端點回傳的一致,每次會議只傳送一次。country 是作出決議的國家,或作出決議的聯盟的 ID(EMU、WAEMU、CEMAC、ECCU、CBCS 或 IEOM);關注該聯盟成員國的目的地也會收到。之後發生變更的決議不會再傳送。

利率決議
{
  "schema_version": "1",
  "event_id": "8b7f2d19-0c4e-4a63-a1d5-3f9e6c2b7a04",
  "cursor": "3",
  "type": "rate_decision.published",
  "country": "USA",
  "family": "policy_rate",
  "resource_id": "3e0f6a52-9d14-5b87-8c21-d4a7b9e1f063",
  "resource_version": "b1c94e7a-2f56-4d08-93ae-5c7d0e8a1b32",
  "recorded_at": "2026-10-28T18:05:41Z",
  "decision": {
    "decision_id": "e5149a43bf24f96d202a6a8a6700d12b",
    "authority_id": "federal_reserve",
    "authority": "Federal Reserve System",
    "country": "USA",
    "decided_on": "2026-10-28",
    "date_basis": "decision",
    "decision_basis": "committee",
    "evidence_kind": "statement",
    "source_tier": "own",
    "source_publisher": null,
    "source_published_on": null,
    "unchanged_since": null,
    "action": "hold",
    "any_rate_moved": false,
    "currency": null,
    "announced_on": null,
    "effective_on": null,
    "rates": [
      {
        "role": "main",
        "instrument_label": "target range for the federal funds rate",
        "rate": null,
        "lower_bound": "3.75",
        "upper_bound": "4.00",
        "rate_source": "stated"
      }
    ],
    "quotes": [
      {
        "text": "The Committee decided to maintain the target range for the federal funds rate at 3-3/4 to 4 percent",
        "url": "https://www.federalreserve.gov/newsevents/pressreleases/monetary20261028a.htm"
      }
    ],
    "votes_status": "unknown",
    "served_state": "confirmed",
    "from_union": null
  }
}

filing.published 事件帶有 filing 而不是 data:filing_id 是該申報文件的受理編號,當申報文件沒有 fy、fp、period_end、title、url 和 company_name 時會省略這些欄位。每份申報文件只傳送一次,條件是該文件所屬國家在 countries 中,且其公司在 companies 中。如果你關注 subject_id 所指的持股對象公司,13D 或 13G 申報文件也會傳送。

申報文件事件
{
  "schema_version": "1",
  "event_id": "6a1d9c37-4e80-4b25-8f3a-0d7c5e2b9a16",
  "cursor": "4",
  "type": "filing.published",
  "country": "USA",
  "recorded_at": "2026-11-03T13:06:02Z",
  "filing": {
    "filing_id": "0000320193-26-000026",
    "company_id": "usa:0000320193",
    "company_name": "Apple Inc.",
    "form": "10-K",
    "type": "annual",
    "fy": 2026,
    "fp": "FY",
    "period_end": "2026-09-26",
    "url": "https://www.sec.gov/Archives/edgar/data/320193/000032019326000026/0000320193-26-000026-index.htm",
    "filed_at": "2026-11-03T13:05:15Z"
  }
}
預測事件
{
  "schema_version": "1",
  "event_id": "5d0b6f0e-7a1c-4c53-9b5e-2f9c4b1d8a63",
  "cursor": "470",
  "type": "prediction.event.settled",
  "country": "USA",
  "recorded_at": "2026-10-28T20:15:02Z",
  "prediction": {
    "prediction_event_id": "usa-fed-2026-10",
    "topic_id": "usa-fed",
    "shape": "scalar",
    "status": "settled",
    "closes_at": "2026-10-28T17:59:00Z",
    "resolves_at": "2026-10-28T18:00:00Z",
    "settlements": [
      {
        "venue": "kalshi",
        "status": "settled"
      },
      {
        "venue": "polymarket",
        "status": "settled"
      }
    ],
    "release_id": "ae2a77cc-3b5b-4541-a060-3bc2ea1145d9"
  }
}
測試傳送
{
  "schema_version": "1",
  "event_id": "9f1c2a54-3b7d-4e0a-8c46-1d5e7b9a0f32",
  "type": "webhook.test",
  "recorded_at": "2026-10-22T09:00:00Z"
}

測試傳送沒有cursor、release和data。

簽章與重試

  1. 剖析任何JSON之前,先讀取x-narwhal-timestamp(Unix秒)和原始請求本文。
  2. 將目的地的secret作為UTF-8位元組金鑰,計算timestamp + "." + raw_body的HMAC-SHA256,結果使用小寫十六進位。
  3. 以固定時間將結果與x-narwhal-signature中的每個sha256=<hex>值比較。任一值相符即可接受傳送。密鑰輪替後的24小時內,標頭會包含第二個值,由舊密鑰簽章。
  4. 拒絕與本機時鐘相差過大的時間戳記,例如早於五分鐘前的時間戳記,以防重播。

至少投遞一次。請在持久儲存處理結果後才回傳2xx;回應本文會被忽略。event_id 識別事件,是重試和重播時的去重鍵。delivery_id 識別投遞嘗試;重試保留此值,測試投遞也將其用作 event_id。

429或5xx回應、逾時或連線錯誤會以指數退避重試,嘗試間隔最長一小時;429或503附帶Retry-After時可能更長。重新導向或任何其他狀態會導致傳送失敗。 重試期間為投遞建立或最近一次重播後的24小時。

歷史與重播

傳送歷程記錄嘗試狀態和回應狀態。重播會為同一不可變事件建立新的傳送。密鑰輪替有24小時的重疊視窗,接收方可驗證任一簽章。

此頁面對你有幫助嗎?