{"record":{"id":"99d2661ba3361f62","repo":"calcom/cal.diy","slug":"delegation-credential-error-trigger-is-only-availa-99d266","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/user-webhooks.service.ts","lineNumber":16,"sourceCode":"import { PipedInputWebhookType } from \"@/modules/webhooks/pipes/WebhookInputPipe\";\nimport { validateWebhookUrl } from \"@/modules/webhooks/utils/validate-webhook-url\";\nimport { WebhooksRepository } from \"@/modules/webhooks/webhooks.repository\";\nimport { BadRequestException, ConflictException, Injectable } from \"@nestjs/common\";\n\nimport { WebhookTriggerEvents } from \"@calcom/prisma/enums\";\n\n@Injectable()\nexport class UserWebhooksService {\n  constructor(private readonly webhooksRepository: WebhooksRepository) {}\n\n  async createUserWebhook(userId: 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.getUserWebhookByUrl(userId, body.subscriberUrl);\n    if (existingWebhook) {\n      throw new ConflictException(\"Webhook with this subscriber url already exists for this user\");\n    }\n\n    return this.webhooksRepository.createUserWebhook(userId, {\n      ...body,\n      payloadTemplate: body.payloadTemplate ?? null,\n      secret: body.secret ?? null,\n    });\n  }\n\n  async getUserWebhooksPaginated(userId: number, skip: number, take: number) {\n    return this.webhooksRepository.getUserWebhooksPaginated(userId, skip, take);","sourceCodeStart":1,"sourceCodeEnd":34,"githubUrl":"https://github.com/calcom/cal.diy/blob/176037d0afbe572f870a3c702985e7cd83fe6c0c/apps/api/v2/src/modules/webhooks/services/user-webhooks.service.ts#L1-L34","documentation":"UserWebhooksService.createUserWebhook rejects DELEGATION_CREDENTIAL_ERROR in eventTriggers with BadRequestException (HTTP 400). User-scoped webhooks are not organization webhooks, so the organization-only trigger is disallowed. Same guard pattern as the event-type services.","triggerScenarios":"POSTing a user webhook whose eventTriggers array contains DELEGATION_CREDENTIAL_ERROR.","commonSituations":"Sharing a trigger list across scopes; UI not filtering triggers by scope; enum added in a newer version.","solutions":["Remove DELEGATION_CREDENTIAL_ERROR from eventTriggers for user webhooks.","Use the organization-webhooks endpoint if that trigger is required.","Filter triggers by webhook scope in the client."],"exampleFix":"// before\nbody.eventTriggers = ['DELEGATION_CREDENTIAL_ERROR', 'BOOKING_CREATED'];\n// after\nbody.eventTriggers = ['BOOKING_CREATED'];","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.createUserWebhook(userId, 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 scope before submit.","Centralize trigger metadata (which scopes allow each).","Use organization-webhooks when the org-only trigger is required."],"tags":["webhooks","validation","event-triggers","user","bad-request"],"backgroundTag":null,"analyzedSha":"176037d0afbe572f870a3c702985e7cd83fe6c0c","analyzedAt":"2026-08-12T19:12:41.464Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}