SDK ReferenceTypeScript SDK

SessionWebhooks

Usage

Access this class through the composio.sessionWebhooks property:

const composio = new Composio({ apiKey: 'your-api-key' });
const result = await composio.sessionWebhooks.list();

Methods

parse()

Verify and parse an event Composio sent to the session webhook URL.

Composio sends one before or after each tool or proxy call that a hook with a webhook handler applies to, and waits for the endpoint's answer. The signature is always verified, with the project's session webhook secret. The event is returned as Composio sent it, with the field names of the webhook reference.

Pass the raw, unparsed request body: the signature covers its exact bytes.

async parse(params: ParseSessionWebhookParams): Promise<SessionWebhookEvent>

Parameters

NameTypeDescription
paramsParseSessionWebhookParamsThe request and how to verify it

Returns

Promise<SessionWebhookEvent> — The verified event

Example

// Next.js App Router, at the project's session webhook URL
export async function POST(request: Request) {
  const hook = await composio.sessions.webhooks.parse({
    body: await request.text(),
    headers: request.headers,
    verifySecret: process.env.COMPOSIO_SESSION_WEBHOOK_SECRET!,
  });

  // Keep a confidential project out of every call and every result
  if (JSON.stringify(hook.data).includes('Project Titan')) {
    return Response.json({ action: 'block', message: 'Project Titan is confidential' });
  }
  return Response.json({ action: 'continue' });
}