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_idIDでトピックを取得します。
PUT/api/event_streams/topics/:topic_idトピックを更新します。
PUT/api/event_streams/topics/:topic_id/purgeトピックをパージします。
DELETE/api/event_streams/topics/:topic_idトピックを削除します。

ベストプラクティス

トピックを変更するエンドポイント(作成および更新)では、URLではなくリクエスト本文でパラメーターを定義することをお勧めします。

トピックの一覧表示

オプションのフィルタリング、並べ替え、およびレスポンスにトピックスキーマを含める機能を使用して、イベントトピックのリストを取得します。

shell
GET /api/event_streams/topics

クエリパラメーター

名前タイプ説明
namestring
任意
大文字と小文字を区別するタイトルでイベントトピックをフィルタリングします。 部分一致をサポートしているため、タイトルの一部を検索できます。
sortstring
任意
結果の並べ替え方法を定義します。 オプションにはactivity(最新のアクティビティを先頭に表示)、nameidがあります。 デフォルトでidに設定されます。
include_schemaboolean
optional
trueに設定すると、各イベントトピックのスキーマがレスポンスペイロードに含まれます。 デフォルトではfalseに設定されます。

サンプルリクエスト

このリクエストは、名前にキーワードOrderを含むイベントトピックを取得します。 結果はイベントトピックIDで並べ替えられ、各イベントトピックのスキーマがレスポンスペイロードに含まれます。

shell
curl  -X GET "https://www.workato.com/api/event_streams/topics?name=Order&sort=id&include_schema=true" \
      -H 'Authorization: Bearer <api_token>'

レスポンス

json
{
    "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."
        }
    ]
}

トピックの作成

新しいイベントトピックを作成します。

shell
POST /api/event_streams/topics
名前タイプ説明
namestring
必須
新しいトピックの名前。
schemaarray
必須
新しいトピックのスキーマ定義。 有効なWorkatoスキーマ形式に準拠している必要があります。
schema[control_type]string
必須
トピックスキーマ内のフィールドのコントロールタイプ。
schema[label]string
必須
トピックスキーマ内のフィールドに表示されるラベル。
schema[name]string
必須
トピックスキーマ内のフィールドの名前識別子。
schema[optional]boolean
必須
フィールドが任意かどうかを指定します。
schema[type]string
必須
スキーマ内のフィールドのデータ型。
retentionnumber
optional
トピックの保持時間(秒)。 指定しない場合、デフォルトは168時間(604,800秒)です。
説明string
任意
新しいトピックの説明。

サンプルリクエスト

このリクエストは、Order deliveredという名前の新しいイベントトピックを作成します。 このトピックには、注文ID、配達日、注文を配達する担当者またはサービスに関する任意情報などの詳細が含まれます。

shell
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."
         }'

レスポンス

json
{
    "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でイベントトピックを取得します。

shell
GET /api/event_streams/topics/:topic_id

URLパラメーター

名前タイプ説明
topic_idnumber
必須
取得するイベントトピックのID。

サンプルリクエスト

このリクエストは、一意のID(334527)でOrder deliveredイベントトピックを取得します。

shell
curl  -X GET "https://www.workato.com/api/event_streams/topics/334527" \
      -H 'Authorization: Bearer <api_token>'

レスポンス

json
{
    "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."
    }
}

トピックの更新

イベントトピックを更新します。

shell
PUT /api/event_streams/topics/:topic_id

URLパラメーター

名前タイプ説明
topic_idnumber
必須
更新するイベントトピックのID。
名前タイプ説明
namestring
任意
更新されたトピックの名前。
schemaarray
optional
更新されたトピックのスキーマ定義。 有効なWorkatoスキーマ形式に準拠している必要があります。
schema[control_type]string
任意
トピックスキーマ内のフィールドのコントロールタイプ。
schema[label]string
任意
トピックスキーマ内のフィールドに表示されるラベル。
schema[name]string
任意
トピックスキーマ内のフィールドの名前識別子。
schema[optional]boolean
optional
フィールドが任意かどうかを指定します。
schema[type]string
任意
スキーマ内のフィールドのデータ型。
retentionnumber
optional
トピックの保持時間(秒)。 指定しない場合、デフォルトは168時間(604,800秒)です。
説明string
任意
更新されたトピックの説明。

サンプルリクエスト

このリクエストは、Recipientという名前の新しいフィールドを追加して、Order deliveredイベントトピックのトピックスキーマを更新します。

shell
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"
                }
            ]
         }'

レスポンス

json
{
    "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."
    }
}

トピックのパージ

イベントトピックの履歴からすべてのメッセージを消去し、トピック統計をリセットします。

shell
PUT /api/event_streams/topics/:topic_id/purge
名前タイプ説明
topic_idstring
必須
パージするイベントトピックのID。

サンプルリクエスト

このリクエストは、Order deliveredイベントトピックの履歴からすべてのメッセージを消去し、トピック統計をリセットします。

shell
curl  -X PUT "https://www.workato.com/api/event_streams/topics/334527/purge" \
      -H 'Authorization: Bearer <api_token>'

レスポンス

json
{
    "data": {
        "status": "success"
    }
}

トピックの削除

イベントトピックを削除します。

shell
DELETE /api/event_streams/topics/:topic_id

URLパラメーター

名前タイプ説明
topic_idnumber
必須
削除するイベントトピックのID。

サンプルリクエスト

このリクエストは、Order deliveredイベントトピックを削除します。

shell
curl  -X DELETE "https://www.workato.com/api/event_streams/topics/334527" \
      -H 'Authorization: Bearer <api_token>'

レスポンス

json
{
    "data": {
        "status": "success"
    }
}

Last updated: