Skip to content

Webhook

The module allows you to create subscriptions for events that occur in the Crowdin project or organization. It’s not necessary to subscribe to events every time after creating a new project, events will come from all resources allowed for the application.

index.js
import crowdinModule from '@crowdin/app-project-module';
const app = crowdinModule.express();
const configuration = {
baseUrl: 'https://123.ngrok.io',
clientId: 'clientId',
clientSecret: 'clientSecret',
name: 'Sample App',
identifier: 'sample-app',
description: 'Sample App description',
dbFolder: import.meta.dirname,
imagePath: import.meta.dirname + '/logo.png',
webhooks: [
{
events: ['file.added', 'file.updated', 'file.deleted', 'file.reverted'],
callback({client, events, webhookContext}) {
console.log('File events:', events);
}
}
]
}
const crowdinApp = crowdinModule.addCrowdinEndpoints(app, configuration);
app.listen(3000, () => console.log('Crowdin app started'));

To register or update webhooks programmatically (for example during app setup), use createOrUpdateWebhook and related helpers from App Functions.

Parameter
Description
eventsList of events to subscribe the application. See available events.
callbackThis function is called when the app receives events.
deferResponseOptional. If true, the HTTP response is sent after webhook processing completes. Default: false, or true with the Cloudflare Workers adapter.
  • client - Crowdin API client.
  • events - Array of webhook event objects.
  • webhookContext - Object containing webhook context information:
    • domain - Crowdin domain
    • organizationId - Organization ID
    • userId - User ID (user who installed the application)
    • agentId - Agent ID (if authenticationType is crowdin_agent)

Crowdin sends the events of an app in one POST /webhooks request, as the events array, and follows its delivery rules: each event is sent once, and the request waits 30 seconds for a 2XX answer. After any other answer or a timeout the event does not come again.

The module answers the request itself:

AnswerWhen
200The signature is valid. With deferResponse, the callback has also finished.
401The app is not installed in the organization that sent the request.
403The X-Crowdin-Signature header does not match the request body.
500With deferResponse, the callback threw. The error is logged.

What this means for the callback:

  • Filter the events. They come from every project the app can access, so compare the project in the payload with the one the callback is for.
  • With deferResponse, finish within 30 seconds. The answer waits for the callback, so a slower callback is a failed delivery. For longer work, save what the event needs in the callback and do the work in a background job.
  • Catch up on what was missed. An event sent while the app was unavailable is gone, so an app that must not miss a change also reads the state through the API, for example on a schedule.

The Cloudflare Workers adapter sets deferResponse: true on every webhook that does not set the option, so the example below is only needed when you wire the Worker yourself. Without it, the Worker can stop before webhook processing completes.

worker.js
webhooks: [{
events: ['file.added', 'file.updated'],
deferResponse: true, // Required for Workers
callback: async ({ client, events }) => {
// Process webhook events
for (const event of events) {
await processEvent(event, client);
}
}
}]

Why needed: Workers terminate execution immediately after HTTP response is sent. deferResponse: true sends the response after callback completion, ensuring proper execution.