> ## Documentation Index
> Fetch the complete documentation index at: https://docs.benzinga.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Webhook 配信のテスト

> このエンドポイントは、連携を確認できるように、テストデータを利用中のWebhookエンドポイントに送信します

## 概要

このエンドポイントを使用して、設定済みのエンドポイントにテスト用のWebhook通知を送信します。これにより、本番環境でライブデータを受信する前に、Webhook連携が正しく動作していることを検証できます。

## 連携のテスト

このエンドポイントを呼び出すと、Benzinga は設定した `destination` URL にテスト用の Webhook ペイロードを送信します。このテスト配信は、本番環境の Webhook 配信と同じフォーマットおよびリトライロジックに従います。

### 想定される内容

1. **即時レスポンス**: テスト配信が正常にトリガーされると、API は `200` ステータスコードを返します
2. **テストペイロード**: webhook エンドポイントには、本番データと同じ形式のテストペイロードが送信されます
3. **配信ヘッダー**: テスト配信には、本番配信と同様に `X-BZ-Delivery` ヘッダーが含まれます

### 統合を検証する

このエンドポイントを使用して、次の点を確認します:

* Webhook エンドポイントがインターネットからアクセス可能であること
* エンドポイントが Webhook ペイロード形式を正しく解析できること
* エンドポイントが適切なステータスコード（成功時は 2xx）を返すこと
* エンドポイントが 30 秒以内に応答すること
* 冪等性ロジックが `X-BZ-Delivery` ヘッダーとペイロードの `id` フィールドを正しく処理できること

## ベストプラクティス

* まずは本番環境ではない webhook エンドポイントでテストする
* エンドポイントが `200` または `204` のステータスコードで応答することを確認する
* ログ出力と監視でテスト配信が記録されていることを確認する
* テスト配信 ID を用いて重複排除ロジックが正しく動作することを確認する
* 一時的にエラーステータスコードを返すことでエラーシナリオをテストする

## トラブルシューティング

### 424 配信エラー

`424` ステータスコードを受信した場合、システムがテストペイロードを宛先エンドポイントに配信できなかったことを意味します。よくある原因は次のとおりです。

* 宛先 URL がインターネットからアクセスできない
* 宛先エンドポイントがエラーステータスコードを返している
* ネットワーク接続の問題
* 宛先エンドポイントでの SSL/TLS 証明書エラー

### 400 無効なリクエスト

必須パラメータがすべて指定されており、形式が正しいことを確認してください。

* `destination` は有効な HTTPS URL である必要があります
* `version` は `webhook/v1` である必要があります
* `kind` は `News/v1` である必要があります

```json Response (200 OK) theme={null}
{
  "status": "success"
}
```

```json Response (400 Bad Request) theme={null}
{
  "error": "Invalid destination URL"
}
```

```json Response (424 Failed Dependency) theme={null}
{
  "error": "Failed to deliver test payload to destination"
}
```

```json Response (401 Unauthorized) theme={null}
{
  "ok": false,
  "errors": [
    {
      "code": "auth_failed",
      "id": "unauthorized",
      "value": "Invalid or missing authentication token"
    }
  ]
}
```

```json Response (404 Not Found) theme={null}
{
  "ok": false,
  "errors": [
    {
      "code": "no_data_found",
      "id": "not_found",
      "value": "No data found for the specified parameters"
    }
  ]
}
```

```json Response (500 Internal Server Error) theme={null}
{
  "ok": false,
  "errors": [
    {
      "code": "internal_server_error",
      "id": "server_error",
      "value": "An unexpected error occurred while processing your request"
    }
  ]
}
```


## OpenAPI

````yaml ja/openapi/webhook_api.spec.yml GET /api/v1/webhook/test
openapi: 3.0.0
info:
  contact: {}
  description: Webhook のテスト配信を行い、連携が正しく動作していることを確認します
  title: Webhook API
  version: 1.0.0
servers:
  - url: https://api.benzinga.com
security: []
paths:
  /api/v1/webhook/test:
    get:
      summary: Webhook 配信をテストする
      description: このエンドポイントは、連携を確認できるように、テストデータを利用中のWebhookエンドポイントに送信します
      operationId: get-webhook-test
      parameters:
        - name: destination
          in: query
          required: true
          description: テストデータの送信先となる webhook エンドポイントの url
          schema:
            type: string
            format: uri
          example: https://your-endpoint.com/webhook
        - name: version
          in: query
          required: true
          description: API バージョン。現在は webhook/v1。
          schema:
            type: string
            enum:
              - webhook/v1
            default: webhook/v1
        - name: kind
          in: query
          required: true
          description: テストペイロード内のメッセージ kind を識別します。
          schema:
            type: string
            enum:
              - News/v1
              - Signals/v1
              - Earnings/v1
              - Ratings/v1
              - Dividends/v1
              - IPOs/v1
              - Guidance/v1
              - Splits/v1
              - OptionActivity/v1
              - Conference/v1
              - Economics/v1
              - Offerings/v1
              - MA/v1
              - Retail/v1
              - FDA/v1
              - WIIMs/v1
              - SECInsiderTransaction/v1
              - GovernmentTrade/v1
            default: News/v1
        - name: token
          in: query
          required: false
          description: 本番利用向けにデータを変換するためのトークンを指定します
          schema:
            type: string
      responses:
        '200':
          description: 成功 - テスト Webhook を正常に送信しました
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: string
                    example: success
        '400':
          description: 無効なリクエストです。詳細はレスポンスボディを確認してください。
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Invalid destination URL
        '424':
          description: 配信エラー - テストペイロードの配信中にシステムでエラーが発生しました
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Failed to deliver test payload to destination
        '500':
          description: 内部サーバーエラー
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Internal server error
      security:
        - ApiKeyAuth: []
components:
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: Key
      description: Benzinga の API キー

````