Event streams
次のエンドポイントを使用すると、イベントトピックを管理できます。
EVENT STREAMSのAPIドメインと名前空間の違い
Event streams APIは2つのカテゴリに分かれています。 各カテゴリでは異なるドメインと名前空間を使用します。
パブリックAPI
次のエンドポイントはevent-streamsドメインを使用します:
- メッセージを消費
POST /api/v1/topics/:topic_id/consume - メッセージをパブリッシュ
POST /api/v1/topics/:topic_id/publish - メッセージのバッチをパブリッシュ
POST /api/v1/batch/topics/:topic_id/publish
詳細については、Event streams public APIドキュメントを参照してください。
Developer API
次のエンドポイントでは、標準のDeveloper APIベースURLを使用します:
- トピックをリスト
GET /api/event_streams/topics - トピックを作成
POST /api/event_streams/topics - IDでトピックを取得
GET /api/event_streams/topics/:topic_id - トピックを更新
PUT /api/event_streams/topics/:topic_id - トピックをパージ
PUT /api/event_streams/topics/:topic_id/purge - トピックを削除
DELETE /api/event_streams/topics/:topic_id
レート制限
Event streams Developer APIリソースには、次のレート制限があります:
| タイプ | リソース | 制限 |
|---|---|---|
| すべて | すべてのEvent streamsエンドポイント | 1分あたり60リクエスト |
さらに、Event streams Developer APIリソースには次のペイロード制限があります:
| タイプ | リソース | 制限 |
|---|---|---|
| すべて | すべてのEvent streamsエンドポイント | 最大ペイロードサイズ: 1 MB |
クイックリファレンス
| タイプ | リソース | 説明 |
|---|---|---|
| GET | /api/event_streams/topics | トピックのリストを取得します。 |
| POST | /api/event_streams/topics | トピックを作成します。 |
| GET | /api/event_streams/topics/:topic_id | IDでトピックを取得します。 |
| PUT | /api/event_streams/topics/:topic_id | トピックを更新します。 |
| PUT | /api/event_streams/topics/:topic_id/purge | トピックをパージします。 |
| DELETE | /api/event_streams/topics/:topic_id | トピックを削除します。 |
トピックの一覧表示
オプションのフィルタリング、並べ替え、およびレスポンスにトピックスキーマを含める機能を使用して、イベントトピックのリストを取得します。
GET /api/event_streams/topicsクエリパラメーター
| 名前 | タイプ | 説明 |
|---|---|---|
| name | string 任意 | 大文字と小文字を区別するタイトルでイベントトピックをフィルタリングします。 部分一致をサポートしているため、タイトルの一部を検索できます。 |
| sort | string 任意 | 結果の並べ替え方法を定義します。 オプションにはactivity(最新のアクティビティを先頭に表示)、name、idがあります。 デフォルトでidに設定されます。 |
| include_schema | boolean optional | trueに設定すると、各イベントトピックのスキーマがレスポンスペイロードに含まれます。 デフォルトではfalseに設定されます。 |
サンプルリクエスト
このリクエストは、名前にキーワードOrderを含むイベントトピックを取得します。 結果はイベントトピックIDで並べ替えられ、各イベントトピックのスキーマがレスポンスペイロードに含まれます。
curl -X GET "https://www.workato.com/api/event_streams/topics?name=Order&sort=id&include_schema=true" \
-H 'Authorization: Bearer <api_token>'レスポンス
{
"count": 2,
"data": [
{
"id": 334525,
"name": "Order placed",
"created_at": "2024-09-25T09:47:54.089-07:00",
"updated_at": "2024-09-25T09:47:54.089-07:00",
"retention": 604800,
"schema": [
{
"control_type": "text",
"label": "Order ID",
"name": "OrderId",
"optional": false,
"type": "string"
},
{
"control_type": "text",
"label": "Customer ID",
"name": "CustomerId",
"optional": false,
"type": "string"
},
{
"control_type": "text",
"label": "Amount",
"name": "Amount",
"optional": false,
"type": "string"
},
{
"control_type": "date",
"label": "Order date",
"name": "OrderDate",
"optional": false,
"parse_output": "date_conversion",
"render_input": "date_conversion",
"type": "date_time"
}
],
"description": "Triggered when a new order is placed."
},
{
"id": 334526,
"name": "Order shipped",
"created_at": "2024-09-25T09:51:12.130-07:00",
"updated_at": "2024-09-25T09:51:12.130-07:00",
"retention": 604800,
"schema": [
{
"control_type": "text",
"label": "Order ID",
"name": "OrderId",
"optional": false,
"type": "string"
},
{
"control_type": "text",
"label": "Shipping carrier",
"name": "ShippingCarrier",
"optional": false,
"type": "string"
},
{
"control_type": "text",
"label": "Tracking number",
"name": "TrackingNumber",
"optional": false,
"type": "string"
},
{
"control_type": "date",
"label": "Shipped date",
"name": "ShippedDate",
"optional": false,
"parse_output": "date_conversion",
"render_input": "date_conversion",
"type": "date_time"
}
],
"description": "Triggered when an order is shipped."
}
]
}トピックの作成
新しいイベントトピックを作成します。
POST /api/event_streams/topics| 名前 | タイプ | 説明 |
|---|---|---|
| name | string 必須 | 新しいトピックの名前。 |
| schema | array 必須 | 新しいトピックのスキーマ定義。 有効なWorkatoスキーマ形式に準拠している必要があります。 |
| schema[control_type] | string 必須 | トピックスキーマ内のフィールドのコントロールタイプ。 |
| schema[label] | string 必須 | トピックスキーマ内のフィールドに表示されるラベル。 |
| schema[name] | string 必須 | トピックスキーマ内のフィールドの名前識別子。 |
| schema[optional] | boolean 必須 | フィールドが任意かどうかを指定します。 |
| schema[type] | string 必須 | スキーマ内のフィールドのデータ型。 |
| retention | number optional | トピックの保持時間(秒)。 指定しない場合、デフォルトは168時間(604,800秒)です。 |
| 説明 | string 任意 | 新しいトピックの説明。 |
サンプルリクエスト
このリクエストは、Order deliveredという名前の新しいイベントトピックを作成します。 このトピックには、注文ID、配達日、注文を配達する担当者またはサービスに関する任意情報などの詳細が含まれます。
curl -X POST "https://www.workato.com/api/event_streams/topics" \
-H 'Authorization: Bearer <api_token>' \
-H "Content-Type: application/json" \
-d '{
"name": "Order delivered",
"schema": [
{
"control_type": "text",
"label": "Order ID",
"name": "OrderId",
"optional": false,
"type": "string"
},
{
"control_type": "date",
"label": "Delivery date",
"name": "DeliveryDate",
"optional": false,
"type": "date_time"
},
{
"control_type": "text",
"label": "Delivered by",
"name": "DeliveredBy",
"optional": true,
"type": "string"
}
],
"description": "Triggered when an order is delivered."
}'レスポンス
{
"data": {
"id": 334527,
"name": "Order delivered",
"created_at": "2024-09-25T09:56:32.986-07:00",
"updated_at": "2024-09-25T09:56:32.986-07:00",
"retention": 604800,
"schema": [
{
"control_type": "text",
"label": "Order ID",
"name": "OrderId",
"optional": false,
"type": "string"
},
{
"control_type": "date",
"label": "Delivery date",
"name": "DeliveryDate",
"optional": false,
"type": "date_time"
},
{
"control_type": "text",
"label": "Delivered by",
"name": "DeliveredBy",
"optional": true,
"type": "string"
}
],
"description": "Triggered when an order is delivered."
}
}IDでトピックを取得
IDでイベントトピックを取得します。
GET /api/event_streams/topics/:topic_idURLパラメーター
| 名前 | タイプ | 説明 |
|---|---|---|
| topic_id | number 必須 | 取得するイベントトピックのID。 |
サンプルリクエスト
このリクエストは、一意のID(334527)でOrder deliveredイベントトピックを取得します。
curl -X GET "https://www.workato.com/api/event_streams/topics/334527" \
-H 'Authorization: Bearer <api_token>'レスポンス
{
"data": {
"id": 334527,
"name": "Order delivered",
"created_at": "2024-09-25T09:56:32.986-07:00",
"updated_at": "2024-09-25T09:56:32.986-07:00",
"retention": 604800,
"schema": [
{
"control_type": "text",
"label": "Order ID",
"name": "OrderId",
"optional": false,
"type": "string"
},
{
"control_type": "date",
"label": "Delivery date",
"name": "DeliveryDate",
"optional": false,
"type": "date_time"
},
{
"control_type": "text",
"label": "Delivered by",
"name": "DeliveredBy",
"optional": true,
"type": "string"
}
],
"description": "Triggered when an order is delivered."
}
}トピックの更新
イベントトピックを更新します。
PUT /api/event_streams/topics/:topic_idURLパラメーター
| 名前 | タイプ | 説明 |
|---|---|---|
| topic_id | number 必須 | 更新するイベントトピックのID。 |
| 名前 | タイプ | 説明 |
|---|---|---|
| name | string 任意 | 更新されたトピックの名前。 |
| schema | array optional | 更新されたトピックのスキーマ定義。 有効なWorkatoスキーマ形式に準拠している必要があります。 |
| schema[control_type] | string 任意 | トピックスキーマ内のフィールドのコントロールタイプ。 |
| schema[label] | string 任意 | トピックスキーマ内のフィールドに表示されるラベル。 |
| schema[name] | string 任意 | トピックスキーマ内のフィールドの名前識別子。 |
| schema[optional] | boolean optional | フィールドが任意かどうかを指定します。 |
| schema[type] | string 任意 | スキーマ内のフィールドのデータ型。 |
| retention | number optional | トピックの保持時間(秒)。 指定しない場合、デフォルトは168時間(604,800秒)です。 |
| 説明 | string 任意 | 更新されたトピックの説明。 |
サンプルリクエスト
このリクエストは、Recipientという名前の新しいフィールドを追加して、Order deliveredイベントトピックのトピックスキーマを更新します。
curl -X PUT "https://www.workato.com/api/event_streams/topics/334527" \
-H 'Authorization: Bearer <api_token>' \
-H "Content-Type: application/json" \
-d '{
"schema": [
{
"control_type": "text",
"label": "Order ID",
"name": "OrderId",
"optional": false,
"type": "string"
},
{
"control_type": "date",
"label": "Delivery date",
"name": "DeliveryDate",
"optional": false,
"type": "date_time"
},
{
"control_type": "text",
"label": "Delivered by",
"name": "DeliveredBy",
"optional": true,
"type": "string"
},
{
"control_type": "text",
"label": "Recipient",
"name": "Recipient",
"optional": false,
"type": "string"
}
]
}'レスポンス
{
"data": {
"id": 334527,
"name": "Order delivered",
"created_at": "2024-09-25T09:56:32.986-07:00",
"updated_at": "2024-09-25T09:56:32.986-07:00",
"retention": 604800,
"schema": [
{
"control_type": "text",
"label": "Order ID",
"name": "OrderId",
"optional": false,
"type": "string"
},
{
"control_type": "date",
"label": "Delivery date",
"name": "DeliveryDate",
"optional": false,
"type": "date_time"
},
{
"control_type": "text",
"label": "Delivered by",
"name": "DeliveredBy",
"optional": true,
"type": "string"
},
{
"control_type": "text",
"label": "Recipient",
"name": "Recipient",
"optional": false,
"type": "string"
}
],
"description": "Triggered when an order is delivered."
}
}トピックのパージ
イベントトピックの履歴からすべてのメッセージを消去し、トピック統計をリセットします。
PUT /api/event_streams/topics/:topic_id/purge| 名前 | タイプ | 説明 |
|---|---|---|
| topic_id | string 必須 | パージするイベントトピックのID。 |
サンプルリクエスト
このリクエストは、Order deliveredイベントトピックの履歴からすべてのメッセージを消去し、トピック統計をリセットします。
curl -X PUT "https://www.workato.com/api/event_streams/topics/334527/purge" \
-H 'Authorization: Bearer <api_token>'レスポンス
{
"data": {
"status": "success"
}
}トピックの削除
イベントトピックを削除します。
DELETE /api/event_streams/topics/:topic_idURLパラメーター
| 名前 | タイプ | 説明 |
|---|---|---|
| topic_id | number 必須 | 削除するイベントトピックのID。 |
サンプルリクエスト
このリクエストは、Order deliveredイベントトピックを削除します。
curl -X DELETE "https://www.workato.com/api/event_streams/topics/334527" \
-H 'Authorization: Bearer <api_token>'レスポンス
{
"data": {
"status": "success"
}
}Last updated: