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

# X (Twitter) API TypeScript monitor & webhook types

> Copy TypeScript types for Xquik monitors, events, webhooks, deliveries, and webhook payloads. Use them to type each X (Twitter) monitor handler in your code.

> For the complete documentation index, see [llms.txt](https://docs.xquik.com/llms.txt).

These types belong to the [X API TypeScript types](https://docs.xquik.com/guides/x-api-typescript-types.md) set. Copy them into your `xquik-types.ts` file.

## Types

```typescript theme={"theme":{"light":"github-light","dark":"github-dark"},"languages":{"custom":["/languages/bash.json","/languages/csharp.json","/languages/go.json","/languages/java.json","/languages/javascript.json","/languages/kotlin.json","/languages/php.json","/languages/python.json","/languages/ruby.json","/languages/typescript.json"]}}
// ─── Monitors ────────────────────────────────────────────

interface Monitor {
  id: string;
  username: string;
  xUserId: string;
  eventTypes: EventType[];
  isActive: boolean;
  createdAt: string;
  nextBillingAt: string;
}

interface KeywordMonitor {
  id: string;
  query: string;
  eventTypes: EventType[];
  isActive: boolean;
  createdAt: string;
  nextBillingAt: string;
}

interface PostMetricReading {
  current: number | null;
  gain: number | null;
}

type PostMetric = "views" | "likes" | "retweets" | "replies" | "quotes" | "bookmarks";

interface PostMonitor {
  id: string;
  name?: string;
  postId: string;
  postUrl: string;
  authorId: string;
  authorUsername: string;
  authorName: string;
  text: string;
  postedAt: string;
  eventTypes: PostEventType[];
  isActive: boolean;
  createdAt: string;
  nextBillingAt: string;
  pausedReason?:
    "insufficient_credits" | "x_post_deleted" | "x_post_protected" | "x_post_unavailable";
  pausedAt?: string;
  metrics: Record<PostMetric, PostMetricReading>;
}

// ─── Events ──────────────────────────────────────────────

interface Event {
  id: string;
  type: EventType | PostEventType;
  monitorId: string;
  monitorType: "account" | "keyword" | "post";
  occurredAt: string;
  data: EventData;
  username?: string;
  query?: string;
  keywordMonitorId?: string;
  postId?: string;
  postUrl?: string;
  authorId?: string;
  authorUsername?: string;
  xEventId?: string;
}

interface EventList {
  events: Event[];
  hasMore: boolean;
  nextCursor?: string;
}

// ─── Webhooks ────────────────────────────────────────────

// Returned when creating a webhook (includes signing secret)
interface WebhookCreated {
  id: string;
  url: string;
  eventTypes: EventType[];
  secret: string;
  createdAt: string;
}

// Returned when listing webhooks (secret is never exposed)
interface Webhook {
  id: string;
  url: string;
  eventTypes: EventType[];
  isActive: boolean;
  createdAt: string;
}

// ─── Deliveries ──────────────────────────────────────────

interface Delivery {
  id: string;
  streamEventId: string;
  status: "pending" | "delivered" | "failed" | "exhausted";
  attempts: number;
  lastStatusCode?: number;
  lastError?: string;
  createdAt: string;
  deliveredAt?: string;
}

// ─── Webhook Payload ─────────────────────────────────────

interface WebhookPayload {
  eventType: EventType;
  schemaVersion: 1;
  deliveryId: string;
  streamEventId: string;
  occurredAt: string;
  data: EventData;
  username?: string;
  query?: string;
}

interface WebhookTestPayload {
  eventType: "webhook.test";
  data: { message: string };
  timestamp: string;
}
```

## Next steps

* [X API TypeScript types](https://docs.xquik.com/guides/x-api-typescript-types.md)
* [Shared types](https://docs.xquik.com/guides/x-api-typescript-shared-types.md)


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