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
const crowdinModule = require('@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: __dirname,
imagePath: __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'));
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. Required for Cloudflare Workers. Default: false.
  • 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)

For Cloudflare Workers, set deferResponse: true to prevent execution context termination 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.