{"record":{"id":"5d7ef36eefc1ab43","repo":"calcom/cal.diy","slug":"delegation-credential-error-trigger-is-only-availa-5d7ef3","errorCode":null,"errorMessage":"DELEGATION_CREDENTIAL_ERROR trigger is only available for organization webhooks","messagePattern":"DELEGATION_CREDENTIAL_ERROR trigger is only available for organization webhooks","errorType":"http","errorClass":"BadRequestException","httpStatus":400,"severity":"error","filePath":"apps/api/v2/src/modules/webhooks/services/team-event-type-webhooks.service.ts","lineNumber":15,"sourceCode":"import { WebhookTriggerEvents } from \"@calcom/prisma/enums\";\nimport { BadRequestException, ConflictException, Injectable } from \"@nestjs/common\";\nimport type { PipedInputWebhookType } from \"@/modules/webhooks/pipes/WebhookInputPipe\";\nimport { validateWebhookUrl } from \"@/modules/webhooks/utils/validate-webhook-url\";\nimport { WebhooksRepository } from \"@/modules/webhooks/webhooks.repository\";\n\n@Injectable()\nexport class TeamEventTypeWebhooksService {\n  constructor(private readonly webhooksRepository: WebhooksRepository) {}\n\n  async createTeamEventTypeWebhook(eventTypeId: number, body: PipedInputWebhookType) {\n    validateWebhookUrl(body.subscriberUrl);\n\n    if (body.eventTriggers.includes(WebhookTriggerEvents.DELEGATION_CREDENTIAL_ERROR)) {\n      throw new BadRequestException(\n        \"DELEGATION_CREDENTIAL_ERROR trigger is only available for organization webhooks\"\n      );\n    }\n\n    const existingWebhook = await this.webhooksRepository.getEventTypeWebhookByUrl(\n      eventTypeId,\n      body.subscriberUrl\n    );\n    if (existingWebhook) {\n      throw new ConflictException(\"Webhook with this subscriber url already exists for this event type\");\n    }\n    return this.webhooksRepository.createEventTypeWebhook(eventTypeId, {\n      ...body,\n      payloadTemplate: body.payloadTemplate ?? null,\n      secret: body.secret ?? null,\n    });\n  }\n","sourceCodeStart":1,"sourceCodeEnd":33,"githubUrl":"https://github.com/calcom/cal.diy/blob/176037d0afbe572f870a3c702985e7cd83fe6c0c/apps/api/v2/src/modules/webhooks/services/team-event-type-webhooks.service.ts#L1-L33","documentation":"TeamEventTypeWebhooksService.createTeamEventTypeWebhook rejects DELEGATION_CREDENTIAL_ERROR in eventTriggers with BadRequestException (HTTP 400). Team event-type webhooks, like regular event-type webhooks, are not organization webhooks, so the trigger is forbidden. Identical logic to EventTypeWebhooksService.","triggerScenarios":"POSTing a team event-type webhook whose eventTriggers array contains DELEGATION_CREDENTIAL_ERROR.","commonSituations":"Reusing a trigger set from an organization webhook; UI surfacing triggers without scope awareness; copy-paste between scopes.","solutions":["Drop DELEGATION_CREDENTIAL_ERROR from eventTriggers for team event-type webhooks.","Use the organization-webhooks endpoint if you need that trigger.","Scope-filter trigger options in the client UI."],"exampleFix":"// before\nbody.eventTriggers = ['DELEGATION_CREDENTIAL_ERROR', 'BOOKING_CANCELLED'];\n// after\nbody.eventTriggers = ['BOOKING_CANCELLED'];","handlingStrategy":"validation","validationCode":"const ORG_ONLY_TRIGGERS = new Set(['DELEGATION_CREDENTIAL_ERROR']);\nbody.eventTriggers = body.eventTriggers.filter(t => !ORG_ONLY_TRIGGERS.has(t));","typeGuard":"const isOrgOnlyTrigger = (t: string): boolean => t === 'DELEGATION_CREDENTIAL_ERROR';","tryCatchPattern":"try { await api.createTeamEventTypeWebhook(eventTypeId, body); }\ncatch (e) {\n  if (e.status === 400 && /DELEGATION_CREDENTIAL_ERROR/.test(e.message)) {\n    body.eventTriggers = body.eventTriggers.filter(t => t !== 'DELEGATION_CREDENTIAL_ERROR');\n  } else throw e;\n}","preventionTips":["Filter triggers by webhook scope before submit.","Keep one shared allow-list helper for all webhook scopes.","Use the organization-webhooks endpoint when the org-only trigger is required."],"tags":["webhooks","validation","event-triggers","team","bad-request"],"backgroundTag":null,"analyzedSha":"176037d0afbe572f870a3c702985e7cd83fe6c0c","analyzedAt":"2026-08-12T19:12:41.464Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}