Class DonationAlertsCustomAlertsApi

API for managing Donation Alerts custom alerts.

Custom alerts allow developers to create fully customizable notifications that broadcast to a streamer's audience. These alerts can include custom headers, messages, images, and sounds for a tailored viewer experience.

Important: For the custom alert to display, the streamer must configure a variation in the Alerts widget with the "Custom alerts" type.

Hierarchy

  • BaseApi
    • DonationAlertsCustomAlertsApi

Methods

  • Sends a custom alert to the authorized streamer.

    This method sends a custom-designed alert to the specified user (streamer). The customizable fields include the header, message, image, and sound. To display in the streamer's widget, the alert type must be configured as "Custom alerts" in their settings.

    Parameters

    • user: UserIdResolvable

      The ID of the user to send the custom alert to.

    • data: DonationAlertsSendCustomAlertData

      The data object containing properties for the custom alert, such as header, message, or sound URL.

    • OptionalrateLimiterOptions: RateLimiterRequestOptions

      Optional rate limiting configuration.

    Returns Promise<DonationAlertsCustomAlert>

    An instance of the newly created DonationAlertsCustomAlert.

    Requires the oauth-custom_alert-store scope.

    HttpError if the HTTP status code is outside the range of 200–299.

    UnregisteredUserError if the specified user is not registered in the authentication provider.

    MissingScopeError if the access token lacks the necessary oauth-custom_alert-store scope.

    const customAlert = await customAlertsApi.sendCustomAlert(userId, {
    externalId: 'unique-alert-id',
    header: 'Custom Title!',
    message: 'Custom message.',
    shouldShow: true, // Will be displayed
    imageUrl: 'https://example.com/image.jpg',
    soundUrl: 'https://example.com/sound.mp3'
    });

    console.log(`Custom alert sent! Header: ${customAlert.header}; Message: ${customAlert.message}`);