calcom/cal.diy · error · BadRequestException

DELEGATION_CREDENTIAL_ERROR trigger is only available for or

Error message

DELEGATION_CREDENTIAL_ERROR trigger is only available for organization webhooks

What it means

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.

Source

Thrown at apps/api/v2/src/modules/webhooks/services/user-webhooks.service.ts:16

import { PipedInputWebhookType } from "@/modules/webhooks/pipes/WebhookInputPipe";
import { validateWebhookUrl } from "@/modules/webhooks/utils/validate-webhook-url";
import { WebhooksRepository } from "@/modules/webhooks/webhooks.repository";
import { BadRequestException, ConflictException, Injectable } from "@nestjs/common";

import { WebhookTriggerEvents } from "@calcom/prisma/enums";

@Injectable()
export class UserWebhooksService {
  constructor(private readonly webhooksRepository: WebhooksRepository) {}

  async createUserWebhook(userId: number, body: PipedInputWebhookType) {
    validateWebhookUrl(body.subscriberUrl);

    if (body.eventTriggers.includes(WebhookTriggerEvents.DELEGATION_CREDENTIAL_ERROR)) {
      throw new BadRequestException(
        "DELEGATION_CREDENTIAL_ERROR trigger is only available for organization webhooks"
      );
    }

    const existingWebhook = await this.webhooksRepository.getUserWebhookByUrl(userId, body.subscriberUrl);
    if (existingWebhook) {
      throw new ConflictException("Webhook with this subscriber url already exists for this user");
    }

    return this.webhooksRepository.createUserWebhook(userId, {
      ...body,
      payloadTemplate: body.payloadTemplate ?? null,
      secret: body.secret ?? null,
    });
  }

  async getUserWebhooksPaginated(userId: number, skip: number, take: number) {
    return this.webhooksRepository.getUserWebhooksPaginated(userId, skip, take);

View on GitHub (pinned to 176037d0af)

Solutions

  1. Remove DELEGATION_CREDENTIAL_ERROR from eventTriggers for user webhooks.
  2. Use the organization-webhooks endpoint if that trigger is required.
  3. Filter triggers by webhook scope in the client.

Example fix

// before
body.eventTriggers = ['DELEGATION_CREDENTIAL_ERROR', 'BOOKING_CREATED'];
// after
body.eventTriggers = ['BOOKING_CREATED'];
Defensive patterns

Strategy: validation

Validate before calling

const ORG_ONLY_TRIGGERS = new Set(['DELEGATION_CREDENTIAL_ERROR']);
body.eventTriggers = body.eventTriggers.filter(t => !ORG_ONLY_TRIGGERS.has(t));

Type guard

const isOrgOnlyTrigger = (t: string): boolean => t === 'DELEGATION_CREDENTIAL_ERROR';

Try / catch

try { await api.createUserWebhook(userId, body); }
catch (e) {
  if (e.status === 400 && /DELEGATION_CREDENTIAL_ERROR/.test(e.message)) {
    body.eventTriggers = body.eventTriggers.filter(t => t !== 'DELEGATION_CREDENTIAL_ERROR');
  } else throw e;
}

Prevention

When it happens

Trigger: POSTing a user webhook whose eventTriggers array contains DELEGATION_CREDENTIAL_ERROR.

Common situations: Sharing a trigger list across scopes; UI not filtering triggers by scope; enum added in a newer version.

Related errors


AI-assisted analysis of calcom/cal.diy@176037d0af (2026-08-12). Data as JSON: /api/errors/99d2661ba3361f62. Report an issue: GitHub.