# Events を送信

## Events を送信

Workflow block、REST API、または edge device backup を使用して Vision Events を送信できます。

* [Workflow Block](#workflow-block) - Workflows のユーザーは、公式の Roboflow block を使うのが最も簡単だと感じるでしょう
* [REST API](#rest-api) - Workflows 外でモデルをデプロイするユーザーは、REST API を使用できます
* [Edge Device Backup](#edge-device-backup) - Roboflow Edge デバイスをデプロイするユーザーは、デバイス上のローカル event store からの自動バックアップを設定するのが最も便利です

### Workflow Block

ほとんどのユーザーに推奨される方法です。 **Vision Event** block を任意の Roboflow Workflow に追加すると、コード不要で推論結果から自動的に events を作成できます。

#### セットアップ

{% stepper %}
{% step %}
**Workflow Editor を開く**

移動する **Workflows** を workspace で開き、events を追加したい workflow を開きます。
{% endstep %}

{% step %}
**Vision Event Block を追加**

block catalog で "Vision Event" を検索し、workflow に追加します。
{% endstep %}

{% step %}
**入力を接続**

画像入力と model prediction の出力を Vision Event block に接続します。
{% endstep %}

{% step %}
**ユースケースを設定**

Use Case 名（`useCaseId`）を設定します。また、上流の blocks からカスタム metadata をマッピングすることもできます。
{% endstep %}

{% step %}
**Workflow をデプロイ**

workflow をデプロイまたは更新します。workflow が実行されるたびに events が自動的に作成されます。
{% endstep %}
{% endstepper %}

{% hint style="info" %}
Workflow block は、画像のアップロードと event の作成を1つのステップで処理します。
{% endhint %}

### REST API

Workflows を使用しないカスタム統合やパイプラインの場合、REST API を介して直接 events を送信できます。完全なリクエストおよびレスポンスの schema については、 [Vision Events API Reference](https://docs.roboflow.com/developer/rest-api/vision-events).

#### 認証

すべての write endpoint には、 `visionEvents.write` または `device.update` scope を持つ API key が必要です。API key は Bearer token として渡してください:

```
Authorization: Bearer YOUR_API_KEY
```

#### エンドツーエンドの例: 画像をアップロード + Event を作成

{% hint style="warning" %}
events を送信する前に Use Case を作成する必要があります。 `useCaseId` が存在しない場合、その event は拒否されます。
{% endhint %}

API 経由で events を送信する場合、まず画像をアップロードし、次にアップロードした画像を参照する event を作成します。

**手順1: 画像をアップロード**

```bash
curl -X POST "https://api.roboflow.com/vision-events/upload" \\
  -H "Authorization: Bearer YOUR_API_KEY" \
  -F "file=@inspection_photo.jpg"
```

**レスポンス:**

```json
{
  "success": true,
  "sourceId": "abc123def456",
  "url": "https://storage.googleapis.com/your-workspace/abc123def456/original.jpg"
}
```

**手順2: アップロードした画像を参照して event を作成**

```bash
curl -X POST "https://api.roboflow.com/vision-events" \\
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -d '{
    "eventType": "quality_check",
    "useCaseId": "assembly-line-qa",
    "timestamp": "2026-03-30T14:30:00.000Z",
    "deviceId": "factory-cam-01",
    "streamId": "line-3",
    "images": [
      {
        "sourceId": "abc123def456",
        "objectDetections": [
          {
            "class": "defect",
            "x": 320,
            "y": 240,
            "width": 50,
            "height": 40,
            "confidence": 0.95
          }
        ]
      }
    ],
    "eventData": {
      "result": "fail"
    },
    "customMetadata": {
      "line_id": "line-3",
      "shift": "morning",
      "part_number": "PN-4421"
    }
  }'
```

**レスポンス:**

```json
{
  "eventId": "evt-789ghi",
  "created": true
}
```

#### イベントを一括作成

batch endpoint を使用して、1回のリクエストで最大100件の events を送信できます:

```bash
curl -X POST "https://api.roboflow.com/vision-events/batch" \\
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -d '{
    "events": [
      {
        "eventType": "quality_check",
        "useCaseId": "alksjdflaalsf32",
        "eventData": { "result": "pass" },
        "customMetadata": { "line_id": "line-1" }
      },
      {
        "eventType": "quality_check",
        "useCaseId": "alksjdflaalsf32",
        "eventData": { "result": "fail" },
        "customMetadata": { "line_id": "line-2" }
      }
    ]
  }'
```

{% hint style="info" %}
1回の batch リクエストにつき最大100件の events です。
{% endhint %}

### Edge Device Backup

接続が断続的になる可能性がある enterprise デプロイメントでは、edge device が events をローカルに保存し、接続が回復すると Roboflow に同期します。

{% hint style="info" %}
Edge Device Backup には Deployment Manager が必要です。 [Deployment Manager のドキュメント](/roboflow/roboflow-jp/deploy/device-manager.md) を参照してセットアップ手順を確認してください。
{% endhint %}

Vision Events backup を有効にするには:

1. Open **Deployment Manager** を workspace で開く
2. 設定する device を選択
3. 有効にする **Vision Events Backup** を device の Event Store 設定で有効にします
4. events は device 上のローカル event store に書き込まれます
5. device が再接続すると、events は自動的に Roboflow に同期されます

同期が完了すると、events は Vision Events dashboard に表示されます。

<figure><img src="/files/3b0e22e47e107d1820c244ed494a81e69fc04820" alt="" width="375"><figcaption></figcaption></figure>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.roboflow.com/roboflow/roboflow-jp/deploy/vision-events/send-events.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
