// ─── Account ─────────────────────────────────────────────
interface Account {
plan: "active" | "inactive";
monitorsAllowed: number;
monitorsUsed: number;
currentPeriod?: {
start: string;
end: string;
capMicrocents: string;
usedMicrocents: string;
};
}
// ─── API Keys ────────────────────────────────────────────
// Returned when creating a new key (includes full key)
interface ApiKeyCreated {
id: string;
fullKey: string;
prefix: string;
name: string;
createdAt: string;
}
// Returned when listing keys (full key is never exposed)
interface ApiKey {
id: string;
name: string;
prefix: string;
isActive: boolean;
createdAt: string;
lastUsedAt?: string;
}
// ─── Monitors ────────────────────────────────────────────
interface Monitor {
id: string;
username: string;
xUserId: string;
eventTypes: EventType[];
isActive: boolean;
createdAt: string;
}
type EventType = "tweet.new" | "tweet.quote" | "tweet.reply" | "tweet.retweet";
// ─── Events ──────────────────────────────────────────────
interface Event {
id: string;
type: EventType;
monitorId: string;
username: string;
occurredAt: string;
data: EventData;
xEventId?: string;
}
interface EventData {
tweetId: string;
text: string;
metrics: {
likes: number;
retweets: number;
replies: number;
};
}
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[];
isActive: boolean;
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 ─────────────────────────────────────
// What your webhook endpoint receives as the POST body
interface WebhookPayload {
id: string;
type: EventType;
monitorId: string;
username: string;
occurredAt: string;
data: EventData;
}
// ─── Error Response ──────────────────────────────────────
interface ApiError {
error: string;
limit?: number; // only present for monitor_limit_reached
}
// ─── Request Bodies ──────────────────────────────────────
interface CreateMonitorRequest {
username: string;
eventTypes: EventType[];
}
interface UpdateMonitorRequest {
eventTypes?: EventType[];
isActive?: boolean;
}
interface CreateWebhookRequest {
url: string;
eventTypes: EventType[];
}
interface UpdateWebhookRequest {
url?: string;
eventTypes?: EventType[];
isActive?: boolean;
}
interface CreateApiKeyRequest {
name?: string;
}