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

# Webhook アクション

> Webhook アクションとイベント

Webhook には複数のタイプがあり、アクションタイプごとに分類されています。
たとえば、スケジュール投稿は `scheduled` アクション Webhook をトリガーします。
詳細については [Webhook 概要](/apis/webhooks/overview) を参照してください。

Webhook URL を登録した後、イベントが発生すると URL に対して POST リクエストを受信します。
POST リクエストにはイベントの詳細を含む JSON ペイロードが含まれます。

## Scheduled アクション

スケジュール投稿が処理されるとき(成功したか失敗したかを問わず)、選択したソーシャルネットワークに公開された際にこの Webhook 通知を受信します。

たとえば、2026 年 8 月 1 日午後 12:00 に投稿をスケジュールした場合、投稿が公開される正確な時刻に Webhook が送信されます。

Webhook 通知は、[/post](/apis/post/post) エンドポイントの `scheduleDate` フィールドを使用して将来にスケジュールされた投稿に対してのみ送信されます。

### Scheduled イベント

```json theme={"system"}
{
  "action": "scheduled", // The action taken
  "subAction": "tikTokPublished", // Only present when TikTok video publishing complete
  "created": "2023-01-05T01:18:47Z",
  "code": 200, // HTTP response code
  "refId": "140b8700bd6ade089b242d845e268fb886130c53", // User Reference ID
  "status": "success", // success or error
  "id": "TBAAAqAMMpoweA9wKHUp", // Ayrshare id of post
  "errors": [], // List of errors if any occurred
  "postIds": [
    // Individual successful posts status
    {
      "postUrl": "https://www.facebook.com/102775127855689_361718068618052",
      "platform": "facebook",
      "status": "success",
      "id": "102775127855689_361718068618052"
    }
  ],
  "url": "https://mysite.com/webhook" // Your webhook URL
}
```

<Note>
  即時投稿の場合、API は JSON 応答で即座に成功または失敗のレスポンスを返すため、Webhook 通知は受信しません。
  Webhook 通知は、非同期で処理され、ステータスを通知するために別の通知を必要とするため、スケジュール投稿に対してのみ送信されます。
</Note>

### TikTok 公開 Webhook

Ayrshare を通じて TikTok を使用する場合、スケジュール投稿に対して 2 つの異なる Webhook を受信することがあります。

投稿が即時ではなくスケジュールされていた場合、まず標準の **Scheduled Action** Webhook を受信します。
これは、メディアが処理と投稿のために TikTok に正常に送信されたことを示します。

その後、`subAction: tikTokPublished` Webhook を受信します。
これは、TikTok がメディアの処理を完了し、メディアが公開されるとトリガーされます。

この Webhook は、即時投稿とスケジュール投稿の両方で有効化されます。
Ayrshare ダッシュボードでは、このイベントは **tikTok (pub)** としてラベル付けされます。

<Warning>
  `tikTokPublished` Webhook は、[メディアが公開される](/apis/post/social-networks/tiktok#visibility-options) まで送信されません。
  メディアが private、followers、または friends に設定されている場合、Webhook は送信されません。

  `tikTokPublished` Webhook を受信せず、投稿ステータスが `pending` のままの場合、メディアが TikTok によって受け付けられていることを確認するために TikTok モバイルアプリを確認してください。
</Warning>

## Social アクション

ユーザーのプロファイルがソーシャルネットワークをリンクまたはアンリンクした際の通知。

### Social アクションイベント

```json theme={"system"}
{
  "action": "social", // The action taken
  "created": "2023-01-05T01:18:47Z",
  "code": 200, // HTTP response code
  "details": {
    // Optional: if details available
    "status": "error",
    "code": 349,
    "message": "Account locked"
  },
  "displayName": "Instagram Title", // If a user account name is present at the social network
  "hookId": "TKLc30192HLGw5UeJ46",
  "platform": "instagram", // The social platform the action occured
  "refId": "140b8700bd6ade089b242d845e268fb886130c53", // User Reference ID
  "refreshBy": "2022-11-05T12:21:29Z", // Optional: If type is refresh, the date the social network authorization must be refreshed on the social account linkage page
  "source": "system", // Initiated by "system" or "user".
  "title": "User Profile Name", // The user profile's account title
  "type": "link", // Type of action: link, unlink, or refresh
  "url": "https://mysite.com/webhook" // Your webhook URL
}
```

`source` が `system` の場合、Ayrshare がソーシャルネットワーク接続がもはや有効でないなどの理由で自動的にアカウントのリンクを解除したことを意味します。ユーザーが投稿を続けられるように通知することをお勧めします。リンク解除の詳細は `details` フィールドにあります。プライマリアカウントのメールアドレス、または [代替メール](/multiple-users/manage-user-profiles#alternative-emails-for-alerts) が設定されている場合はそこにもメールが送信されます。

`source` が `user` の場合、ユーザーが自分でアカウントを手動でリンク解除するなど、ユーザー自身がアクションを開始したことを意味します。ユーザーが開始したアクションが発生した場合、メールは送信されません。

## Messages アクション

すべての messages エンドポイントおよび webhook にアクセスするには、Messaging アドオンが必要です。

Facebook と Instagram のみ、新しいダイレクトメッセージが到着したとき、ユーザーが読んだとき、またはメッセージに対してリアクションが作成または削除されたときの通知。

X/Twitter Webhook は、Enterprise クライアント向けのオプションとして利用可能です。
Enterprise クライアントになる方法の詳細については、アカウント担当者にお問い合わせください。

### 複数のアプリを持つ Facebook ページのスタンバイカバレッジ

Ayrshare は、標準のメッセージングフィールドに加えて、Facebook の `standby` webhook フィールドをサブスクライブしています。これは、同じ Facebook ページ上の別のアプリが現在スレッド制御を保持している場合(たとえばチャットボットプラットフォームがページのプライマリレシーバーとして設定されている場合、または Meta の Page Inbox がアクティブに会話を処理している場合)でも、Messenger イベントが webhook に配信されることを意味します。

これらのイベントにはスキーマの変更はありません。以下のセクションに文書化されている同じ `messageCreated` / `messageRead` / `reactionCreated` / `messageEdited` ペイロードとして到着します。競合する Messenger アプリがインストールされているページに関して注意すべき点が 2 つあります:

* **インバウンドメッセージ量が増加する場合があります**。以前の動作では、サブスクライブされる前に standby イベントは静かにドロップされていました。新しいトラフィックは、他のアプリによって処理されていたページが受信したメッセージを表します。
* **Ayrshare を通じて送信していないメッセージに対応する `type: "sent"` の `messageCreated` イベントを受信する場合があります**。これらは、ページ上の他の Messenger アプリによって送信されたメッセージのエコーです(Meta はすべての送信のコピーをサブスクライブされているすべてのアプリに配信します)。統合が独自の送信履歴とアウトバウンドトラフィックを照合する場合、その履歴を使用して自分の送信と競合アプリの送信を区別できます。

Ayrshare のみがインストールされているページ(競合する Messenger アプリなし)では、観察可能な唯一の変更は新しい [Message Edit Event](#message-edit-event) です — それ以外はすべて以前の動作と同じに見えます。

### 新規メッセージイベント

新しいメッセージが送信または受信されたときの通知。

<CodeGroup>
  ```json Facebook New Message theme={"system"}
  {
    "action": "messages",
    "conversationId": "t_10161117434308936",
    "created": "2024-06-07T11:58:44Z",
    "hookId": "JC6IgqFjvDliTJ8MLqzE",
    "id": "m_aWdfZAG1faXRlbToxOklHTWVzc2FnZAUlEOjE3ODQxNDUyMjEyNzA",
    "mediaUrls": [],
    "message": "This is an amazing message",
    "platform": "facebook",
    "recipientId": "7270633706358444",
    "refId": "9abf1426d6ce9122ef11c72bd62e59807c5cc083",
    "scheduleDate": "2024-06-07T11:58:44Z",
    "senderDetails": {
      // recipientDetails if type is sent
      "id": "7270633706358444",
      "picture": "https://scontent-ord5-2.cdninstagram.com/v/t51.jpg",
      "username": "SweetMessage",
      "name": "Sweet"
    },
    "senderId": "17841452212707444",
    "subAction": "messageCreated",
    "timeStamp": 1735189325, // Present if Webhook Security enabled
    "title": "Primary Profile",
    "type": "received", // received, sent, or deleted
    "url": "https://mysite.com/webhook" // Your webhook URL
  }
  ```

  ```json Instagram New Message theme={"system"}
  {
    "action": "messages",
    "conversationId": "aWdfZAG06MTpJR01lc3NhZA2VUaHJlYWQ6MTc4",
    "created": "2024-06-07T11:58:44Z",
    "hookId": "JC6IgqFjvDliTJ8MLqzE",
    "id": "aWdfZAG1faXRlbToxOklHTWVzc2FnZAUlEOjE3ODQxNDUyMjEyNzA",
    "mediaUrls": [],
    "message": "This is an amazing message",
    "platform": "instagram",
    "recipientId": "7270633706358444",
    "refId": "9abf1426d6ce9122ef11c72bd62e59807c5cc083",
    "scheduleDate": "2024-06-07T11:58:44Z",
    "senderDetails": {
      // recipientDetails if type is sent
      "id": "7270633706358444",
      "picture": "https://scontent-ord5-2.cdninstagram.com/v/t51.jpg",
      "username": "SweetMessage",
      "name": "Sweet"
    },
    "senderId": "17841452212707444",
    "subAction": "messageCreated",
    "timeStamp": 1735189325, // Present if Webhook Security enabled
    "title": "Primary Profile",
    "type": "received", // received, sent, or deleted
    "url": "https://mysite.com/webhook" // Your webhook URL
  }
  ```
</CodeGroup>

### メッセージ既読イベント

受信者がメッセージを読んだときの通知。

<CodeGroup>
  ```json Facebook Read theme={"system"}
  {
    "action": "messages",
    "conversationId": "t_10161117434308936",
    "created": "2024-06-08T23:33:30Z",
    "hookId": "CviPBMXEy3cdJnK0EESd",
    "platform": "facebook",
    "read": 1717889607802,  // UNIX timestamp of when the message was read
    "readerDetails": {
      "name": "John Smith",
      "id": "7101149746568444",
      "picture": "https://platform-lookaside.fbsbx.com/platform/profilepic"
    },
    "recipientId": "106638148652329",
    "refId": "9abf1426d6ce9122ef11c8932",
    "scheduleDate": "2024-06-08T23:33:30Z",
    "senderId": "7101149746568522",
    "subAction": "messageRead",
    "timeStamp": 1717889610, // Present if Webhook Security enabled
    "title": "Primary Profile",
    "type": "read",
    "url": "https://mysite.com/webhook" // Your webhook URL
  }
  ```

  ```json Instagram Read theme={"system"}
  {
    "action": "messages",
    "conversationId": "t_10161117434308938",
    "created": "2024-06-08T23:33:30Z",
    "hookId": "CviPBMXEy3cdJnK0EESd",
    "platform": "instagram",
    "read": {
      "mid": "aWdfZAG1faXRlbToxOkl" // Instagram message ID
    },
    "readerDetails": {
      "name": "John Smith",
      "id": "7101149746568444",
      "picture": "https://platform-lookaside.fbsbx.com/platform/profilepic",
      "username": "johnsmith"
    },
    "recipientId": "106638148652329",
    "refId": "9abf1426d6ce9122ef11c8932",
    "scheduleDate": "2024-06-08T23:33:30Z",
    "senderId": "7101149746568522",
    "subAction": "messageRead",
    "timeStamp": 1717889610, // Present if Webhook Security enabled
    "title": "Primary Profile",
    "type": "read",
    "url": "https://mysite.com/webhook" // Your webhook URL
  }
  ```
</CodeGroup>

Instagram でメッセージが読まれたとき、webhook ペイロードには読まれた特定のメッセージを一意に識別する `mid` フィールドが含まれます。

Facebook メッセージでは、メッセージの既読は `conversationId` を使用して会話レベルで追跡されます。
既読イベントが発生した場合、`created`(または `read`)タイムスタンプより前のタイムスタンプを持つその会話内のすべてのメッセージは、ユーザーによって読まれたとみなされます。

### リアクション作成および削除イベント

いいねなどのリアクションがメッセージに作成または削除されたときの通知。

<CodeGroup>
  ```json Facebook Reaction theme={"system"}
  {
    "action": "messages",
    "conversationId": "t_10161117434308936",
    "created": "2024-06-06T00:49:18Z",
    "hookId": "LcgLuXzZki15lqBNt69h",
    "mediaUrls": [],
    "platform": "facebook",
    "reaction": "😮",
    "recipientId": "106638148652444",
    "refId": "9abf1426d6ce9432",
    "scheduleDate": "2024-06-06T00:49:18Z",
    "senderId": "7101149746568444",
    "subAction": "reactionCreated", // reactionDeleted if deleted
    "timeStamp": 1717634958, // Present if Webhook Security enabled
    "title": "Primary Profile",
    "type": "reaction",
    "url": "https://mysite.com/webhook" // Your webhook URL
  }
  ```

  ```json Instagram Reaction theme={"system"}
  {
    "action": "messages",
    "conversationId": "aWdfZAG1faXRlbToxOklHTWVzc2FnZAUlEO",
    "created": "2024-06-06T00:49:18Z",
    "hookId": "LcgLuXzZki15lqBNt69h",
    "mediaUrls": [],
    "platform": "instagram",
    "reaction": "😮",
    "recipientId": "106638148652444",
    "refId": "9abf1426d6ce9432",
    "scheduleDate": "2024-06-06T00:49:18Z",
    "senderId": "7101149746568444",
    "subAction": "reactionCreated", // reactionDeleted if deleted
    "timeStamp": 1717634958, // Present if Webhook Security enabled
    "title": "Primary Profile",
    "type": "reaction",
    "url": "https://mysite.com/webhook" // Your webhook URL
  }
  ```
</CodeGroup>

### メッセージ編集イベント

ユーザーが以前に送信したメッセージを編集したときの通知。Facebook と Instagram のダイレクトメッセージで利用可能です。

`messageEdit.mid` フィールドは元の `messageCreated` イベントの `id` と一致するため、消費者は編集を元のメッセージと関連付けることができます。`messageEdit.text` フィールドには、新しい編集済みのメッセージテキストが含まれます。

<CodeGroup>
  ```json Facebook Message Edit theme={"system"}
  {
    "action": "messages",
    "conversationId": "t_10161117434308936",
    "created": "2024-06-06T00:49:18Z",
    "hookId": "LcgLuXzZki15lqBNt69h",
    "id": "m_xyz...",                    // Message ID — matches the original messageCreated event
    "messageEdit": {
      "mid": "m_xyz...",
      "text": "the edited message text"
    },
    "platform": "facebook",
    "recipientId": "106638148652444",
    "refId": "9abf1426d6ce9432",
    "senderId": "7101149746568444",
    "subAction": "messageEdited",
    "timeStamp": 1717634958,              // Present if Webhook Security enabled
    "title": "Primary Profile",
    "type": "edit",
    "url": "https://mysite.com/webhook"   // Your webhook URL
  }
  ```

  ```json Instagram Message Edit theme={"system"}
  {
    "action": "messages",
    "conversationId": "aWdfZAG1faXRlbToxOklHTWVzc2FnZAUlEO",
    "created": "2024-06-06T00:49:18Z",
    "hookId": "LcgLuXzZki15lqBNt69h",
    "id": "aWdfZAG1faXRlbToxOkl",
    "messageEdit": {
      "mid": "aWdfZAG1faXRlbToxOkl",
      "text": "the edited message text"
    },
    "platform": "instagram",
    "recipientId": "106638148652444",
    "refId": "9abf1426d6ce9432",
    "senderId": "7101149746568444",
    "subAction": "messageEdited",
    "timeStamp": 1717634958,              // Present if Webhook Security enabled
    "title": "Primary Profile",
    "type": "edit",
    "url": "https://mysite.com/webhook"   // Your webhook URL
  }
  ```
</CodeGroup>

## Batch アクション

バッチの処理が完了してファイルが利用可能になったときの通知([すべてのユーザープロファイルの取得](/apis/user/batch-all-users) など)。`url` フィールドの事前署名済み URL でファイルにアクセスできます。

### Batch イベント

```json theme={"system"}
{
  "action": "batch",
  "batchType": "users",
  "created": "2024-01-11T22:00:30Z",
  "hookId": "dI3PNhrG83j2FzAFJqkb",
  "refId": "9abf1426d6ce9122ef11c72bd62e59807c5cc083",
  "source": "user",
  "timeStamp": 1705010424, // Present with Webhook Security
  "title": "Primary Profile",
  "type": "batch",
  "url": "https://storage.googleapis.com/batch.ayrshare.com/users/dfdf92jskd933r/users-batch-2024-01-11-22-00.json",
  "urlExpires": "2024-01-18T22:00:04Z",
  "userCount": 73
}
```

## Feed アクション

登録された RSS フィードで新しい RSS フィードアイテムが見つかったときの通知。注意: Webhook がアクティブな場合、新しい RSS アイテムはソーシャルネットワークに自動的に投稿されません。

### Feed イベント

```json theme={"system"}
{
    "action": "feed",
    "created": "2023-01-05T01:18:47Z",
    "code": 200,                                          // HTTP response code
    "refId": "140b8700bd6ade089b242d845e268fb886130c53",  // User Reference ID
    "title": "Title of profile if available",             // optional, only if available
    "data": { ... },
    "url": "https://api.myapp.com/Webhook/Ayrshare/Feed"  // Your webhook URL
}
```

## Mentions アクション

接続されたアカウントがメンションされたときの通知。Facebook と Instagram で利用可能です。

Ayrshare は Meta のネイティブメンションペイロードをそのまま中継し、標準のエンベロープフィールド(`action`, `refId`, `hookId`, `url`, Webhook Security 付きの `timeStamp`)と `subAction` のみを追加します。以下の例は **Instagram** の形式です: `media_id`、メンションがコメント内にある場合は `comment_id`。**Facebook** メンションは、Instagram の例とは異なるフィールドを持つ Meta のネイティブ Page `mention` change として到着します。Facebook のフィールドセットについては、Meta の webhooks リファレンスを参照してください。

### メンションイベント (Instagram)

```json theme={"system"}
{
  "action": "mentions",
  "subAction": "mention",
  "media_id": "17900000000000000",    // Meta media the mention occurred on
  "comment_id": "17900000000000001",  // Present when the mention is in a comment
  "hookId": "dI3PNhrG83j2FzAFJqkb",
  "refId": "9abf1426d6ce9122ef11c72bd62e59807c5cc083",  // User Reference ID
  "timeStamp": 1705010424,             // Present with Webhook Security
  "url": "https://api.myapp.com/Webhook/Ayrshare/Mentions"  // Your webhook URL
}
```

## Comments アクション

接続されたコンテンツにコメントが作成されたときの通知。Facebook と Instagram で利用可能です。

Ayrshare は Meta のネイティブコメントペイロードをそのまま中継し、標準のエンベロープフィールド(`action`, `refId`, `hookId`, `url`, Webhook Security 付きの `timeStamp`)と `subAction` のみを追加します。以下の例は **Instagram** の形式です。**Facebook** コメントは、異なるフィールド名(たとえば `comment_id`, `post_id`, `message`, `from.name` など)を持つ Page `feed` change として到着します。Facebook のフィールドセットについては、Meta の webhooks リファレンスを参照してください。

### コメントイベント (Instagram)

```json theme={"system"}
{
  "action": "comments",
  "subAction": "comment",
  "id": "17900000000000002",           // Comment ID
  "text": "Great post!",
  "from": {
    "id": "1234567890",
    "username": "alice"
  },
  "media": {
    "id": "17900000000000000",         // ID of the commented media
    "media_product_type": "FEED"       // e.g. FEED, REELS, STORY
  },
  "hookId": "dI3PNhrG83j2FzAFJqkb",
  "refId": "9abf1426d6ce9122ef11c72bd62e59807c5cc083",  // User Reference ID
  "timeStamp": 1705010424,             // Present with Webhook Security
  "url": "https://api.myapp.com/Webhook/Ayrshare/Comments"  // Your webhook URL
}
```

## Automations アクション

コメントや DM 自動返信トリガーなど、自動化がユーザーに対して webhook アクションを発火させたときの通知。

### Automation イベント

```json theme={"system"}
{
  "action": "automations",
  "automationId": "a1B2c3D4",
  "triggerId": "t9X8y7Z6",
  "trigger": "comment_keyword",        // The trigger type that fired the automation (varies by automation)
  "platform": "instagram",
  "recipientId": "17841400000000000",
  "recipientUsername": "alice",        // null if unavailable
  "keyword": "INFO",                   // null if not keyword-triggered
  "timestamp": "2026-05-27T22:00:30Z", // When the automation fired (ISO 8601)
  "hookId": "dI3PNhrG83j2FzAFJqkb",
  "refId": "9abf1426d6ce9122ef11c72bd62e59807c5cc083",  // User Reference ID
  "timeStamp": 1705010424,             // Unix timestamp, present with Webhook Security
  "url": "https://api.myapp.com/Webhook/Ayrshare/Automations"  // Your webhook URL
}
```
