Webhook map
activityNotecreated(activityNote.created)
contactcreated(contact.created)
leadcreated(lead.created)updated(lead.updated)
opportunitycreated(opportunity.created)
taskcreated(task.created)
HTTP handler setup
app/api/webhook/route.ts
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
Activity Note
Created
activityNote.created
A note activity was created in Close CRM
Payload
| Name | Type | Required | Description |
|---|---|---|---|
subscription_id | string | No | — |
event | object | Yes | — |
event full type
event full type
{
id?: string,
object_type: activity.note,
object_id?: string,
action: created,
organization_id?: string,
data: {
id: string,
lead_id?: string,
note?: string,
user_id?: string | null,
organization_id?: string,
date_created?: string,
date_updated?: string
},
previous_data?: any,
changed_fields?: string[],
date_created?: string,
date_updated?: string,
user_id?: string,
lead_id?: string,
request_id?: string
}
Response data full type
Response data full type
{
subscription_id?: string,
event: {
id?: string,
object_type: activity.note,
object_id?: string,
action: created,
organization_id?: string,
data: {
id: string,
lead_id?: string,
note?: string,
user_id?: string | null,
organization_id?: string,
date_created?: string,
date_updated?: string
},
previous_data?: any,
changed_fields?: string[],
date_created?: string,
date_updated?: string,
user_id?: string,
lead_id?: string,
request_id?: string
}
}
webhookHooks example
close({
webhookHooks: {
activityNote: {
created: {
before(ctx, args) {
return { ctx, args };
},
after(ctx, response) {
},
},
},
},
})
Contact
Created
contact.created
A contact was created in Close CRM
Payload
| Name | Type | Required | Description |
|---|---|---|---|
subscription_id | string | No | — |
event | object | Yes | — |
event full type
event full type
{
id?: string,
object_type: contact,
object_id?: string,
action: created,
organization_id?: string,
data: {
id: string,
lead_id?: string,
name?: string,
title?: string | null,
emails?: {
email: string,
type?: string
}[],
phones?: {
phone: string,
type?: string
}[],
organization_id?: string,
created_by?: string | null,
date_created?: string,
date_updated?: string
},
previous_data?: any,
changed_fields?: string[],
date_created?: string,
date_updated?: string,
user_id?: string,
lead_id?: string,
request_id?: string
}
Response data full type
Response data full type
{
subscription_id?: string,
event: {
id?: string,
object_type: contact,
object_id?: string,
action: created,
organization_id?: string,
data: {
id: string,
lead_id?: string,
name?: string,
title?: string | null,
emails?: {
email: string,
type?: string
}[],
phones?: {
phone: string,
type?: string
}[],
organization_id?: string,
created_by?: string | null,
date_created?: string,
date_updated?: string
},
previous_data?: any,
changed_fields?: string[],
date_created?: string,
date_updated?: string,
user_id?: string,
lead_id?: string,
request_id?: string
}
}
webhookHooks example
close({
webhookHooks: {
contact: {
created: {
before(ctx, args) {
return { ctx, args };
},
after(ctx, response) {
},
},
},
},
})
Lead
Created
lead.created
A lead was created in Close CRM
Payload
| Name | Type | Required | Description |
|---|---|---|---|
subscription_id | string | No | — |
event | object | Yes | — |
event full type
event full type
{
id?: string,
object_type: lead,
object_id?: string,
action: created,
organization_id?: string,
data: {
id: string,
name?: string,
status_id?: string | null,
status_label?: string | null,
description?: string | null,
url?: string | null,
organization_id?: string,
contacts?: Record<string, any>[],
custom?: Record<string, any>,
created_by?: string | null,
updated_by?: string | null,
date_created?: string,
date_updated?: string
},
previous_data?: any,
changed_fields?: string[],
date_created?: string,
date_updated?: string,
user_id?: string,
lead_id?: string,
request_id?: string
}
Response data full type
Response data full type
{
subscription_id?: string,
event: {
id?: string,
object_type: lead,
object_id?: string,
action: created,
organization_id?: string,
data: {
id: string,
name?: string,
status_id?: string | null,
status_label?: string | null,
description?: string | null,
url?: string | null,
organization_id?: string,
contacts?: Record<string, any>[],
custom?: Record<string, any>,
created_by?: string | null,
updated_by?: string | null,
date_created?: string,
date_updated?: string
},
previous_data?: any,
changed_fields?: string[],
date_created?: string,
date_updated?: string,
user_id?: string,
lead_id?: string,
request_id?: string
}
}
webhookHooks example
close({
webhookHooks: {
lead: {
created: {
before(ctx, args) {
return { ctx, args };
},
after(ctx, response) {
},
},
},
},
})
Updated
lead.updated
A lead was updated in Close CRM
Payload
| Name | Type | Required | Description |
|---|---|---|---|
subscription_id | string | No | — |
event | object | Yes | — |
event full type
event full type
{
id?: string,
object_type: lead,
object_id?: string,
action: updated,
organization_id?: string,
data: {
id: string,
name?: string,
status_id?: string | null,
status_label?: string | null,
description?: string | null,
url?: string | null,
organization_id?: string,
contacts?: Record<string, any>[],
custom?: Record<string, any>,
created_by?: string | null,
updated_by?: string | null,
date_created?: string,
date_updated?: string
},
previous_data?: any,
changed_fields?: string[],
date_created?: string,
date_updated?: string,
user_id?: string,
lead_id?: string,
request_id?: string
}
Response data full type
Response data full type
{
subscription_id?: string,
event: {
id?: string,
object_type: lead,
object_id?: string,
action: updated,
organization_id?: string,
data: {
id: string,
name?: string,
status_id?: string | null,
status_label?: string | null,
description?: string | null,
url?: string | null,
organization_id?: string,
contacts?: Record<string, any>[],
custom?: Record<string, any>,
created_by?: string | null,
updated_by?: string | null,
date_created?: string,
date_updated?: string
},
previous_data?: any,
changed_fields?: string[],
date_created?: string,
date_updated?: string,
user_id?: string,
lead_id?: string,
request_id?: string
}
}
webhookHooks example
close({
webhookHooks: {
lead: {
updated: {
before(ctx, args) {
return { ctx, args };
},
after(ctx, response) {
},
},
},
},
})
Opportunity
Created
opportunity.created
An opportunity was created in Close CRM
Payload
| Name | Type | Required | Description |
|---|---|---|---|
subscription_id | string | No | — |
event | object | Yes | — |
event full type
event full type
{
id?: string,
object_type: opportunity,
object_id?: string,
action: created,
organization_id?: string,
data: {
id: string,
lead_id?: string,
lead_name?: string,
status_id?: string,
status_label?: string,
status_type?: string,
value?: number,
value_period?: string,
confidence?: number,
user_id?: string | null,
organization_id?: string,
date_won?: string | null,
date_lost?: string | null,
date_created?: string,
date_updated?: string
},
previous_data?: any,
changed_fields?: string[],
date_created?: string,
date_updated?: string,
user_id?: string,
lead_id?: string,
request_id?: string
}
Response data full type
Response data full type
{
subscription_id?: string,
event: {
id?: string,
object_type: opportunity,
object_id?: string,
action: created,
organization_id?: string,
data: {
id: string,
lead_id?: string,
lead_name?: string,
status_id?: string,
status_label?: string,
status_type?: string,
value?: number,
value_period?: string,
confidence?: number,
user_id?: string | null,
organization_id?: string,
date_won?: string | null,
date_lost?: string | null,
date_created?: string,
date_updated?: string
},
previous_data?: any,
changed_fields?: string[],
date_created?: string,
date_updated?: string,
user_id?: string,
lead_id?: string,
request_id?: string
}
}
webhookHooks example
close({
webhookHooks: {
opportunity: {
created: {
before(ctx, args) {
return { ctx, args };
},
after(ctx, response) {
},
},
},
},
})
Task
Created
task.created
A task was created in Close CRM
Payload
| Name | Type | Required | Description |
|---|---|---|---|
subscription_id | string | No | — |
event | object | Yes | — |
event full type
event full type
{
id?: string,
object_type: string,
object_id?: string,
action: created,
organization_id?: string,
data: {
id: string,
lead_id?: string,
text?: string,
due_date?: string | null,
is_complete?: boolean,
assigned_to?: string | null,
type?: string,
organization_id?: string,
created_by?: string | null,
date_created?: string,
date_updated?: string
},
previous_data?: any,
changed_fields?: string[],
date_created?: string,
date_updated?: string,
user_id?: string,
lead_id?: string,
request_id?: string
}
Response data full type
Response data full type
{
subscription_id?: string,
event: {
id?: string,
object_type: string,
object_id?: string,
action: created,
organization_id?: string,
data: {
id: string,
lead_id?: string,
text?: string,
due_date?: string | null,
is_complete?: boolean,
assigned_to?: string | null,
type?: string,
organization_id?: string,
created_by?: string | null,
date_created?: string,
date_updated?: string
},
previous_data?: any,
changed_fields?: string[],
date_created?: string,
date_updated?: string,
user_id?: string,
lead_id?: string,
request_id?: string
}
}
webhookHooks example
close({
webhookHooks: {
task: {
created: {
before(ctx, args) {
return { ctx, args };
},
after(ctx, response) {
},
},
},
},
})