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

# TwittrAPI webhooks

> TwittrAPI incoming webhooks in Corsair: the event paths to subscribe to, the payload each event carries, and the response data.

The TwittrAPI plugin handles incoming webhooks. Point your provider’s subscription URL at your Corsair HTTP handler (see [Overview](https://docs.corsair.dev/plugins/twittrapi/overview.md) for setup context and the exact URL shape).

> [!NOTE]
>
> **New to Corsair?** See [webhooks](https://docs.corsair.dev/concepts/webhooks.md) and [hooks](https://docs.corsair.dev/concepts/hooks.md).

## Webhook map

* `tweets`
  * `test` (`tweets.test`)
  * `tweet` (`tweets.tweet`)

## HTTP handler setup

```ts app/api/webhook/route.ts theme={null}
import { processWebhook } from "corsair";
import { corsair } from "@/server/corsair";

export async function POST(request: Request) {
    const headers = Object.fromEntries(request.headers);
    // With multiTenancy, give each tenant its own URL (/api/webhook?tenantId=acme):
    // the query says whose account, secret and hooks handle the delivery.
    const query = Object.fromEntries(new URL(request.url).searchParams);
    // The raw text, not request.json(): signatures are checked over the exact bytes sent.
    const body = await request.text();
    const result = await processWebhook(corsair, headers, body, query);
    if (!result.plugin) {
        return Response.json({ success: false }, { status: 404 });
    }
    // A refusal (bad signature) carries no status and answers 400; a handler
    // that threw comes back with 500, so the sender retries it.
    const status =
        result.response?.success === false ? (result.response.statusCode ?? 400) : 200;
    return Response.json(result.response ?? { success: true }, {
        status,
        headers: result.responseHeaders,
    });
}
```

## Events

## Tweets

### Test

`tweets.test`

Test event sent from POST /monitors/webhooks/{id}/test

**Payload**

| Name | Type | Required | Description |
| - | - | - | - |
| `event` | `test` | Yes | — |
| `id` | `string` | Yes | — |
| `monitoredUserId` | `string` | No | — |
| `tweetId` | `string` | No | — |
| `tweetCreatedAt` | `string` | No | — |
| `detectedAt` | `string` | No | — |
| `tweet` | `object` | No | — |

> [accordion] tweet full type
>
> ```ts theme={null}
> {
>   id: string,
>   url: string,
>   text: string,
>   createdAt: string | null,
>   lang: string | null,
>   author: {
>     id: string,
>     username: string,
>     name: string,
>     description: string,
>     location: string,
>     url: string | null,
>     createdAt: string | null,
>     avatarUrl: string | null,
>     bannerUrl: string | null,
>     verified: boolean,
>     verifiedType: string | null,
>     protected: boolean,
>     counts: {
>       followers: number,
>       following: number,
>       tweets: number,
>       likes: number,
>       media: number,
>       listed: number
>     },
>     pinnedTweetIds: string[],
>     isAutomated: boolean
>   } | null,
>   counts: {
>     likes: number,
>     retweets: number,
>     replies: number,
>     quotes: number,
>     bookmarks: number,
>     views: number | null
>   },
>   media: {
>     type: string,
>     url: string,
>     previewUrl: string,
>     width: number,
>     height: number,
>     altText: string | null,
>     durationMs: number | null
>   }[],
>   urls: string[],
>   hashtags: string[],
>   mentions: {
>     id: string,
>     username: string
>   }[],
>   replyTo: {
>     tweetId: string,
>     userId: string,
>     username: string
>   } | null,
>   conversationId: string | null,
>   isPinned: boolean,
>   source: string | null,
>   quoted?: {
>     id: string,
>     url: string,
>     text: string,
>     createdAt: string | null,
>     lang: string | null,
>     author: {
>       id: string,
>       username: string,
>       name: string,
>       description: string,
>       location: string,
>       url: string | null,
>       createdAt: string | null,
>       avatarUrl: string | null,
>       bannerUrl: string | null,
>       verified: boolean,
>       verifiedType: string | null,
>       protected: boolean,
>       counts: {
>         followers: number,
>         following: number,
>         tweets: number,
>         likes: number,
>         media: number,
>         listed: number
>       },
>       pinnedTweetIds: string[],
>       isAutomated: boolean
>     } | null,
>     counts: {
>       likes: number,
>       retweets: number,
>       replies: number,
>       quotes: number,
>       bookmarks: number,
>       views: number | null
>     },
>     media: {
>       type: string,
>       url: string,
>       previewUrl: string,
>       width: number,
>       height: number,
>       altText: string | null,
>       durationMs: number | null
>     }[],
>     urls: string[],
>     hashtags: string[],
>     mentions: {
>       id: string,
>       username: string
>     }[],
>     replyTo: {
>       tweetId: string,
>       userId: string,
>       username: string
>     } | null,
>     conversationId: string | null,
>     isPinned: boolean,
>     source: string | null,
>     quoted?: (recursive) | {
>       id: string,
>       unavailable: true
>     } | null,
>     retweetOf?: {
>       id: string,
>       url: string,
>       text: string,
>       createdAt: string | null,
>       lang: string | null,
>       author: {
>         id: string,
>         username: string,
>         name: string,
>         description: string,
>         location: string,
>         url: string | null,
>         createdAt: string | null,
>         avatarUrl: string | null,
>         bannerUrl: string | null,
>         verified: boolean,
>         verifiedType: string | null,
>         protected: boolean,
>         counts: {
>           followers: number,
>           following: number,
>           tweets: number,
>           likes: number,
>           media: number,
>           listed: number
>         },
>         pinnedTweetIds: string[],
>         isAutomated: boolean
>       } | null,
>       counts: {
>         likes: number,
>         retweets: number,
>         replies: number,
>         quotes: number,
>         bookmarks: number,
>         views: number | null
>       },
>       media: {
>         type: string,
>         url: string,
>         previewUrl: string,
>         width: number,
>         height: number,
>         altText: string | null,
>         durationMs: number | null
>       }[],
>       urls: string[],
>       hashtags: string[],
>       mentions: {
>         id: string,
>         username: string
>       }[],
>       replyTo: {
>         tweetId: string,
>         userId: string,
>         username: string
>       } | null,
>       conversationId: string | null,
>       isPinned: boolean,
>       source: string | null,
>       quoted?: (recursive) | {
>         id: string,
>         unavailable: true
>       } | null,
>       retweetOf?: (recursive) | null
>     } | null
>   } | {
>     id: string,
>     unavailable: true
>   } | null,
>   retweetOf?: {
>     id: string,
>     url: string,
>     text: string,
>     createdAt: string | null,
>     lang: string | null,
>     author: {
>       id: string,
>       username: string,
>       name: string,
>       description: string,
>       location: string,
>       url: string | null,
>       createdAt: string | null,
>       avatarUrl: string | null,
>       bannerUrl: string | null,
>       verified: boolean,
>       verifiedType: string | null,
>       protected: boolean,
>       counts: {
>         followers: number,
>         following: number,
>         tweets: number,
>         likes: number,
>         media: number,
>         listed: number
>       },
>       pinnedTweetIds: string[],
>       isAutomated: boolean
>     } | null,
>     counts: {
>       likes: number,
>       retweets: number,
>       replies: number,
>       quotes: number,
>       bookmarks: number,
>       views: number | null
>     },
>     media: {
>       type: string,
>       url: string,
>       previewUrl: string,
>       width: number,
>       height: number,
>       altText: string | null,
>       durationMs: number | null
>     }[],
>     urls: string[],
>     hashtags: string[],
>     mentions: {
>       id: string,
>       username: string
>     }[],
>     replyTo: {
>       tweetId: string,
>       userId: string,
>       username: string
>     } | null,
>     conversationId: string | null,
>     isPinned: boolean,
>     source: string | null,
>     quoted?: {
>       id: string,
>       url: string,
>       text: string,
>       createdAt: string | null,
>       lang: string | null,
>       author: {
>         id: string,
>         username: string,
>         name: string,
>         description: string,
>         location: string,
>         url: string | null,
>         createdAt: string | null,
>         avatarUrl: string | null,
>         bannerUrl: string | null,
>         verified: boolean,
>         verifiedType: string | null,
>         protected: boolean,
>         counts: {
>           followers: number,
>           following: number,
>           tweets: number,
>           likes: number,
>           media: number,
>           listed: number
>         },
>         pinnedTweetIds: string[],
>         isAutomated: boolean
>       } | null,
>       counts: {
>         likes: number,
>         retweets: number,
>         replies: number,
>         quotes: number,
>         bookmarks: number,
>         views: number | null
>       },
>       media: {
>         type: string,
>         url: string,
>         previewUrl: string,
>         width: number,
>         height: number,
>         altText: string | null,
>         durationMs: number | null
>       }[],
>       urls: string[],
>       hashtags: string[],
>       mentions: {
>         id: string,
>         username: string
>       }[],
>       replyTo: {
>         tweetId: string,
>         userId: string,
>         username: string
>       } | null,
>       conversationId: string | null,
>       isPinned: boolean,
>       source: string | null,
>       quoted?: (recursive) | {
>         id: string,
>         unavailable: true
>       } | null,
>       retweetOf?: (recursive) | null
>     } | {
>       id: string,
>       unavailable: true
>     } | null,
>     retweetOf?: (recursive) | null
>   } | null
> }
> ```

> [accordion] Response data full type
>
> ```ts theme={null}
> {
>   event: test,
>   id: string,
>   monitoredUserId?: string,
>   tweetId?: string,
>   tweetCreatedAt?: string,
>   detectedAt?: string,
>   tweet?: {
>     id: string,
>     url: string,
>     text: string,
>     createdAt: string | null,
>     lang: string | null,
>     author: {
>       id: string,
>       username: string,
>       name: string,
>       description: string,
>       location: string,
>       url: string | null,
>       createdAt: string | null,
>       avatarUrl: string | null,
>       bannerUrl: string | null,
>       verified: boolean,
>       verifiedType: string | null,
>       protected: boolean,
>       counts: {
>         followers: number,
>         following: number,
>         tweets: number,
>         likes: number,
>         media: number,
>         listed: number
>       },
>       pinnedTweetIds: string[],
>       isAutomated: boolean
>     } | null,
>     counts: {
>       likes: number,
>       retweets: number,
>       replies: number,
>       quotes: number,
>       bookmarks: number,
>       views: number | null
>     },
>     media: {
>       type: string,
>       url: string,
>       previewUrl: string,
>       width: number,
>       height: number,
>       altText: string | null,
>       durationMs: number | null
>     }[],
>     urls: string[],
>     hashtags: string[],
>     mentions: {
>       id: string,
>       username: string
>     }[],
>     replyTo: {
>       tweetId: string,
>       userId: string,
>       username: string
>     } | null,
>     conversationId: string | null,
>     isPinned: boolean,
>     source: string | null,
>     quoted?: {
>       id: string,
>       url: string,
>       text: string,
>       createdAt: string | null,
>       lang: string | null,
>       author: {
>         id: string,
>         username: string,
>         name: string,
>         description: string,
>         location: string,
>         url: string | null,
>         createdAt: string | null,
>         avatarUrl: string | null,
>         bannerUrl: string | null,
>         verified: boolean,
>         verifiedType: string | null,
>         protected: boolean,
>         counts: {
>           followers: number,
>           following: number,
>           tweets: number,
>           likes: number,
>           media: number,
>           listed: number
>         },
>         pinnedTweetIds: string[],
>         isAutomated: boolean
>       } | null,
>       counts: {
>         likes: number,
>         retweets: number,
>         replies: number,
>         quotes: number,
>         bookmarks: number,
>         views: number | null
>       },
>       media: {
>         type: string,
>         url: string,
>         previewUrl: string,
>         width: number,
>         height: number,
>         altText: string | null,
>         durationMs: number | null
>       }[],
>       urls: string[],
>       hashtags: string[],
>       mentions: {
>         id: string,
>         username: string
>       }[],
>       replyTo: {
>         tweetId: string,
>         userId: string,
>         username: string
>       } | null,
>       conversationId: string | null,
>       isPinned: boolean,
>       source: string | null,
>       quoted?: (recursive) | {
>         id: string,
>         unavailable: true
>       } | null,
>       retweetOf?: {
>         id: string,
>         url: string,
>         text: string,
>         createdAt: string | null,
>         lang: string | null,
>         author: {
>           id: string,
>           username: string,
>           name: string,
>           description: string,
>           location: string,
>           url: string | null,
>           createdAt: string | null,
>           avatarUrl: string | null,
>           bannerUrl: string | null,
>           verified: boolean,
>           verifiedType: string | null,
>           protected: boolean,
>           counts: {
>             followers: number,
>             following: number,
>             tweets: number,
>             likes: number,
>             media: number,
>             listed: number
>           },
>           pinnedTweetIds: string[],
>           isAutomated: boolean
>         } | null,
>         counts: {
>           likes: number,
>           retweets: number,
>           replies: number,
>           quotes: number,
>           bookmarks: number,
>           views: number | null
>         },
>         media: {
>           type: string,
>           url: string,
>           previewUrl: string,
>           width: number,
>           height: number,
>           altText: string | null,
>           durationMs: number | null
>         }[],
>         urls: string[],
>         hashtags: string[],
>         mentions: {
>           id: string,
>           username: string
>         }[],
>         replyTo: {
>           tweetId: string,
>           userId: string,
>           username: string
>         } | null,
>         conversationId: string | null,
>         isPinned: boolean,
>         source: string | null,
>         quoted?: (recursive) | {
>           id: string,
>           unavailable: true
>         } | null,
>         retweetOf?: (recursive) | null
>       } | null
>     } | {
>       id: string,
>       unavailable: true
>     } | null,
>     retweetOf?: {
>       id: string,
>       url: string,
>       text: string,
>       createdAt: string | null,
>       lang: string | null,
>       author: {
>         id: string,
>         username: string,
>         name: string,
>         description: string,
>         location: string,
>         url: string | null,
>         createdAt: string | null,
>         avatarUrl: string | null,
>         bannerUrl: string | null,
>         verified: boolean,
>         verifiedType: string | null,
>         protected: boolean,
>         counts: {
>           followers: number,
>           following: number,
>           tweets: number,
>           likes: number,
>           media: number,
>           listed: number
>         },
>         pinnedTweetIds: string[],
>         isAutomated: boolean
>       } | null,
>       counts: {
>         likes: number,
>         retweets: number,
>         replies: number,
>         quotes: number,
>         bookmarks: number,
>         views: number | null
>       },
>       media: {
>         type: string,
>         url: string,
>         previewUrl: string,
>         width: number,
>         height: number,
>         altText: string | null,
>         durationMs: number | null
>       }[],
>       urls: string[],
>       hashtags: string[],
>       mentions: {
>         id: string,
>         username: string
>       }[],
>       replyTo: {
>         tweetId: string,
>         userId: string,
>         username: string
>       } | null,
>       conversationId: string | null,
>       isPinned: boolean,
>       source: string | null,
>       quoted?: {
>         id: string,
>         url: string,
>         text: string,
>         createdAt: string | null,
>         lang: string | null,
>         author: {
>           id: string,
>           username: string,
>           name: string,
>           description: string,
>           location: string,
>           url: string | null,
>           createdAt: string | null,
>           avatarUrl: string | null,
>           bannerUrl: string | null,
>           verified: boolean,
>           verifiedType: string | null,
>           protected: boolean,
>           counts: {
>             followers: number,
>             following: number,
>             tweets: number,
>             likes: number,
>             media: number,
>             listed: number
>           },
>           pinnedTweetIds: string[],
>           isAutomated: boolean
>         } | null,
>         counts: {
>           likes: number,
>           retweets: number,
>           replies: number,
>           quotes: number,
>           bookmarks: number,
>           views: number | null
>         },
>         media: {
>           type: string,
>           url: string,
>           previewUrl: string,
>           width: number,
>           height: number,
>           altText: string | null,
>           durationMs: number | null
>         }[],
>         urls: string[],
>         hashtags: string[],
>         mentions: {
>           id: string,
>           username: string
>         }[],
>         replyTo: {
>           tweetId: string,
>           userId: string,
>           username: string
>         } | null,
>         conversationId: string | null,
>         isPinned: boolean,
>         source: string | null,
>         quoted?: (recursive) | {
>           id: string,
>           unavailable: true
>         } | null,
>         retweetOf?: (recursive) | null
>       } | {
>         id: string,
>         unavailable: true
>       } | null,
>       retweetOf?: (recursive) | null
>     } | null
>   }
> }
> ```

**`webhookHooks` example**

```ts theme={null}
twittrapi({
    webhookHooks: {
        tweets: {
            test: {
                before(ctx, args) {
                    return { ctx, args };
                },
                after(ctx, response) {
                },
            },
        },
    },
})
```

***

### Tweet

`tweets.tweet`

A watched X account posted a new tweet

**Payload**

| Name | Type | Required | Description |
| - | - | - | - |
| `event` | `tweet` | Yes | — |
| `id` | `string` | Yes | — |
| `monitoredUserId` | `string` | Yes | — |
| `tweetId` | `string` | Yes | — |
| `tweetCreatedAt` | `string` | Yes | — |
| `detectedAt` | `string` | Yes | — |
| `tweet` | `object` | No | — |

> [accordion] tweet full type
>
> ```ts theme={null}
> {
>   id: string,
>   url: string,
>   text: string,
>   createdAt: string | null,
>   lang: string | null,
>   author: {
>     id: string,
>     username: string,
>     name: string,
>     description: string,
>     location: string,
>     url: string | null,
>     createdAt: string | null,
>     avatarUrl: string | null,
>     bannerUrl: string | null,
>     verified: boolean,
>     verifiedType: string | null,
>     protected: boolean,
>     counts: {
>       followers: number,
>       following: number,
>       tweets: number,
>       likes: number,
>       media: number,
>       listed: number
>     },
>     pinnedTweetIds: string[],
>     isAutomated: boolean
>   } | null,
>   counts: {
>     likes: number,
>     retweets: number,
>     replies: number,
>     quotes: number,
>     bookmarks: number,
>     views: number | null
>   },
>   media: {
>     type: string,
>     url: string,
>     previewUrl: string,
>     width: number,
>     height: number,
>     altText: string | null,
>     durationMs: number | null
>   }[],
>   urls: string[],
>   hashtags: string[],
>   mentions: {
>     id: string,
>     username: string
>   }[],
>   replyTo: {
>     tweetId: string,
>     userId: string,
>     username: string
>   } | null,
>   conversationId: string | null,
>   isPinned: boolean,
>   source: string | null,
>   quoted?: {
>     id: string,
>     url: string,
>     text: string,
>     createdAt: string | null,
>     lang: string | null,
>     author: {
>       id: string,
>       username: string,
>       name: string,
>       description: string,
>       location: string,
>       url: string | null,
>       createdAt: string | null,
>       avatarUrl: string | null,
>       bannerUrl: string | null,
>       verified: boolean,
>       verifiedType: string | null,
>       protected: boolean,
>       counts: {
>         followers: number,
>         following: number,
>         tweets: number,
>         likes: number,
>         media: number,
>         listed: number
>       },
>       pinnedTweetIds: string[],
>       isAutomated: boolean
>     } | null,
>     counts: {
>       likes: number,
>       retweets: number,
>       replies: number,
>       quotes: number,
>       bookmarks: number,
>       views: number | null
>     },
>     media: {
>       type: string,
>       url: string,
>       previewUrl: string,
>       width: number,
>       height: number,
>       altText: string | null,
>       durationMs: number | null
>     }[],
>     urls: string[],
>     hashtags: string[],
>     mentions: {
>       id: string,
>       username: string
>     }[],
>     replyTo: {
>       tweetId: string,
>       userId: string,
>       username: string
>     } | null,
>     conversationId: string | null,
>     isPinned: boolean,
>     source: string | null,
>     quoted?: (recursive) | {
>       id: string,
>       unavailable: true
>     } | null,
>     retweetOf?: {
>       id: string,
>       url: string,
>       text: string,
>       createdAt: string | null,
>       lang: string | null,
>       author: {
>         id: string,
>         username: string,
>         name: string,
>         description: string,
>         location: string,
>         url: string | null,
>         createdAt: string | null,
>         avatarUrl: string | null,
>         bannerUrl: string | null,
>         verified: boolean,
>         verifiedType: string | null,
>         protected: boolean,
>         counts: {
>           followers: number,
>           following: number,
>           tweets: number,
>           likes: number,
>           media: number,
>           listed: number
>         },
>         pinnedTweetIds: string[],
>         isAutomated: boolean
>       } | null,
>       counts: {
>         likes: number,
>         retweets: number,
>         replies: number,
>         quotes: number,
>         bookmarks: number,
>         views: number | null
>       },
>       media: {
>         type: string,
>         url: string,
>         previewUrl: string,
>         width: number,
>         height: number,
>         altText: string | null,
>         durationMs: number | null
>       }[],
>       urls: string[],
>       hashtags: string[],
>       mentions: {
>         id: string,
>         username: string
>       }[],
>       replyTo: {
>         tweetId: string,
>         userId: string,
>         username: string
>       } | null,
>       conversationId: string | null,
>       isPinned: boolean,
>       source: string | null,
>       quoted?: (recursive) | {
>         id: string,
>         unavailable: true
>       } | null,
>       retweetOf?: (recursive) | null
>     } | null
>   } | {
>     id: string,
>     unavailable: true
>   } | null,
>   retweetOf?: {
>     id: string,
>     url: string,
>     text: string,
>     createdAt: string | null,
>     lang: string | null,
>     author: {
>       id: string,
>       username: string,
>       name: string,
>       description: string,
>       location: string,
>       url: string | null,
>       createdAt: string | null,
>       avatarUrl: string | null,
>       bannerUrl: string | null,
>       verified: boolean,
>       verifiedType: string | null,
>       protected: boolean,
>       counts: {
>         followers: number,
>         following: number,
>         tweets: number,
>         likes: number,
>         media: number,
>         listed: number
>       },
>       pinnedTweetIds: string[],
>       isAutomated: boolean
>     } | null,
>     counts: {
>       likes: number,
>       retweets: number,
>       replies: number,
>       quotes: number,
>       bookmarks: number,
>       views: number | null
>     },
>     media: {
>       type: string,
>       url: string,
>       previewUrl: string,
>       width: number,
>       height: number,
>       altText: string | null,
>       durationMs: number | null
>     }[],
>     urls: string[],
>     hashtags: string[],
>     mentions: {
>       id: string,
>       username: string
>     }[],
>     replyTo: {
>       tweetId: string,
>       userId: string,
>       username: string
>     } | null,
>     conversationId: string | null,
>     isPinned: boolean,
>     source: string | null,
>     quoted?: {
>       id: string,
>       url: string,
>       text: string,
>       createdAt: string | null,
>       lang: string | null,
>       author: {
>         id: string,
>         username: string,
>         name: string,
>         description: string,
>         location: string,
>         url: string | null,
>         createdAt: string | null,
>         avatarUrl: string | null,
>         bannerUrl: string | null,
>         verified: boolean,
>         verifiedType: string | null,
>         protected: boolean,
>         counts: {
>           followers: number,
>           following: number,
>           tweets: number,
>           likes: number,
>           media: number,
>           listed: number
>         },
>         pinnedTweetIds: string[],
>         isAutomated: boolean
>       } | null,
>       counts: {
>         likes: number,
>         retweets: number,
>         replies: number,
>         quotes: number,
>         bookmarks: number,
>         views: number | null
>       },
>       media: {
>         type: string,
>         url: string,
>         previewUrl: string,
>         width: number,
>         height: number,
>         altText: string | null,
>         durationMs: number | null
>       }[],
>       urls: string[],
>       hashtags: string[],
>       mentions: {
>         id: string,
>         username: string
>       }[],
>       replyTo: {
>         tweetId: string,
>         userId: string,
>         username: string
>       } | null,
>       conversationId: string | null,
>       isPinned: boolean,
>       source: string | null,
>       quoted?: (recursive) | {
>         id: string,
>         unavailable: true
>       } | null,
>       retweetOf?: (recursive) | null
>     } | {
>       id: string,
>       unavailable: true
>     } | null,
>     retweetOf?: (recursive) | null
>   } | null
> }
> ```

> [accordion] Response data full type
>
> ```ts theme={null}
> {
>   event: tweet,
>   id: string,
>   monitoredUserId: string,
>   tweetId: string,
>   tweetCreatedAt: string,
>   detectedAt: string,
>   tweet?: {
>     id: string,
>     url: string,
>     text: string,
>     createdAt: string | null,
>     lang: string | null,
>     author: {
>       id: string,
>       username: string,
>       name: string,
>       description: string,
>       location: string,
>       url: string | null,
>       createdAt: string | null,
>       avatarUrl: string | null,
>       bannerUrl: string | null,
>       verified: boolean,
>       verifiedType: string | null,
>       protected: boolean,
>       counts: {
>         followers: number,
>         following: number,
>         tweets: number,
>         likes: number,
>         media: number,
>         listed: number
>       },
>       pinnedTweetIds: string[],
>       isAutomated: boolean
>     } | null,
>     counts: {
>       likes: number,
>       retweets: number,
>       replies: number,
>       quotes: number,
>       bookmarks: number,
>       views: number | null
>     },
>     media: {
>       type: string,
>       url: string,
>       previewUrl: string,
>       width: number,
>       height: number,
>       altText: string | null,
>       durationMs: number | null
>     }[],
>     urls: string[],
>     hashtags: string[],
>     mentions: {
>       id: string,
>       username: string
>     }[],
>     replyTo: {
>       tweetId: string,
>       userId: string,
>       username: string
>     } | null,
>     conversationId: string | null,
>     isPinned: boolean,
>     source: string | null,
>     quoted?: {
>       id: string,
>       url: string,
>       text: string,
>       createdAt: string | null,
>       lang: string | null,
>       author: {
>         id: string,
>         username: string,
>         name: string,
>         description: string,
>         location: string,
>         url: string | null,
>         createdAt: string | null,
>         avatarUrl: string | null,
>         bannerUrl: string | null,
>         verified: boolean,
>         verifiedType: string | null,
>         protected: boolean,
>         counts: {
>           followers: number,
>           following: number,
>           tweets: number,
>           likes: number,
>           media: number,
>           listed: number
>         },
>         pinnedTweetIds: string[],
>         isAutomated: boolean
>       } | null,
>       counts: {
>         likes: number,
>         retweets: number,
>         replies: number,
>         quotes: number,
>         bookmarks: number,
>         views: number | null
>       },
>       media: {
>         type: string,
>         url: string,
>         previewUrl: string,
>         width: number,
>         height: number,
>         altText: string | null,
>         durationMs: number | null
>       }[],
>       urls: string[],
>       hashtags: string[],
>       mentions: {
>         id: string,
>         username: string
>       }[],
>       replyTo: {
>         tweetId: string,
>         userId: string,
>         username: string
>       } | null,
>       conversationId: string | null,
>       isPinned: boolean,
>       source: string | null,
>       quoted?: (recursive) | {
>         id: string,
>         unavailable: true
>       } | null,
>       retweetOf?: {
>         id: string,
>         url: string,
>         text: string,
>         createdAt: string | null,
>         lang: string | null,
>         author: {
>           id: string,
>           username: string,
>           name: string,
>           description: string,
>           location: string,
>           url: string | null,
>           createdAt: string | null,
>           avatarUrl: string | null,
>           bannerUrl: string | null,
>           verified: boolean,
>           verifiedType: string | null,
>           protected: boolean,
>           counts: {
>             followers: number,
>             following: number,
>             tweets: number,
>             likes: number,
>             media: number,
>             listed: number
>           },
>           pinnedTweetIds: string[],
>           isAutomated: boolean
>         } | null,
>         counts: {
>           likes: number,
>           retweets: number,
>           replies: number,
>           quotes: number,
>           bookmarks: number,
>           views: number | null
>         },
>         media: {
>           type: string,
>           url: string,
>           previewUrl: string,
>           width: number,
>           height: number,
>           altText: string | null,
>           durationMs: number | null
>         }[],
>         urls: string[],
>         hashtags: string[],
>         mentions: {
>           id: string,
>           username: string
>         }[],
>         replyTo: {
>           tweetId: string,
>           userId: string,
>           username: string
>         } | null,
>         conversationId: string | null,
>         isPinned: boolean,
>         source: string | null,
>         quoted?: (recursive) | {
>           id: string,
>           unavailable: true
>         } | null,
>         retweetOf?: (recursive) | null
>       } | null
>     } | {
>       id: string,
>       unavailable: true
>     } | null,
>     retweetOf?: {
>       id: string,
>       url: string,
>       text: string,
>       createdAt: string | null,
>       lang: string | null,
>       author: {
>         id: string,
>         username: string,
>         name: string,
>         description: string,
>         location: string,
>         url: string | null,
>         createdAt: string | null,
>         avatarUrl: string | null,
>         bannerUrl: string | null,
>         verified: boolean,
>         verifiedType: string | null,
>         protected: boolean,
>         counts: {
>           followers: number,
>           following: number,
>           tweets: number,
>           likes: number,
>           media: number,
>           listed: number
>         },
>         pinnedTweetIds: string[],
>         isAutomated: boolean
>       } | null,
>       counts: {
>         likes: number,
>         retweets: number,
>         replies: number,
>         quotes: number,
>         bookmarks: number,
>         views: number | null
>       },
>       media: {
>         type: string,
>         url: string,
>         previewUrl: string,
>         width: number,
>         height: number,
>         altText: string | null,
>         durationMs: number | null
>       }[],
>       urls: string[],
>       hashtags: string[],
>       mentions: {
>         id: string,
>         username: string
>       }[],
>       replyTo: {
>         tweetId: string,
>         userId: string,
>         username: string
>       } | null,
>       conversationId: string | null,
>       isPinned: boolean,
>       source: string | null,
>       quoted?: {
>         id: string,
>         url: string,
>         text: string,
>         createdAt: string | null,
>         lang: string | null,
>         author: {
>           id: string,
>           username: string,
>           name: string,
>           description: string,
>           location: string,
>           url: string | null,
>           createdAt: string | null,
>           avatarUrl: string | null,
>           bannerUrl: string | null,
>           verified: boolean,
>           verifiedType: string | null,
>           protected: boolean,
>           counts: {
>             followers: number,
>             following: number,
>             tweets: number,
>             likes: number,
>             media: number,
>             listed: number
>           },
>           pinnedTweetIds: string[],
>           isAutomated: boolean
>         } | null,
>         counts: {
>           likes: number,
>           retweets: number,
>           replies: number,
>           quotes: number,
>           bookmarks: number,
>           views: number | null
>         },
>         media: {
>           type: string,
>           url: string,
>           previewUrl: string,
>           width: number,
>           height: number,
>           altText: string | null,
>           durationMs: number | null
>         }[],
>         urls: string[],
>         hashtags: string[],
>         mentions: {
>           id: string,
>           username: string
>         }[],
>         replyTo: {
>           tweetId: string,
>           userId: string,
>           username: string
>         } | null,
>         conversationId: string | null,
>         isPinned: boolean,
>         source: string | null,
>         quoted?: (recursive) | {
>           id: string,
>           unavailable: true
>         } | null,
>         retweetOf?: (recursive) | null
>       } | {
>         id: string,
>         unavailable: true
>       } | null,
>       retweetOf?: (recursive) | null
>     } | null
>   }
> }
> ```

**`webhookHooks` example**

```ts theme={null}
twittrapi({
    webhookHooks: {
        tweets: {
            tweet: {
                before(ctx, args) {
                    return { ctx, args };
                },
                after(ctx, response) {
                },
            },
        },
    },
})
```

***


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.