Query history and contacts via Kapso Proxy
masterWhen using the Kapso proxy (baseUrl: "https://api.kapso.ai/meta/whatsapp"), the client can query stored historical data.
Available Resources:
- Conversations: List, get, and update status (e.g.,
ended). - Messages: Query history with filters like
direction,since, andlimit. Supports Graph paging viacursors. - Contacts: List and update contact metadata (e.g.,
tags). - Calls: List and get call logs.
Data Hydration:
To include Kapso-specific extensions in your results, use the fields parameter with buildKapsoFields() or the string "kapso(default)".
fields: "kapso(default)": Includes all Kapso extensions.fields: "kapso(content)": Hydrates normalized messages with original payload fragments.fields: "kapso()": Omits Kapso extras entirely.
import { buildKapsoFields } from '@kapso/whatsapp-cloud-api';
const client = new WhatsAppClient({
baseUrl: "https://api.kapso.ai/meta/whatsapp",
kapsoApiKey: process.env.KAPSO_API_KEY!,
});
// Querying message history
const history = await client.messages.query({
phoneNumberId: "647015955153740",
direction: "inbound",
since: "2025-01-01T00:00:00Z",
limit: 50,
fields: buildKapsoFields(),
});