Docs
TikTok LIVE Alerts

TikTok LIVE Alerts

How to create and manage live alerts for TikTok LIVE events using the Euler Stream API.

Live Alerts let you subscribe to real-time TikTok LIVE notifications. These are especially useful for responding to transaction updates, account activity, and other event-driven behaviors in your applications.

Creating and Managing Alerts

To work with alerts programmatically in a Node.js application, use the @eulerstream/euler-api-sdk package. This SDK provides methods to create, delete, and list alerts, as well as manage their delivery targets.

If you are using tiktok-live-connector in NodeJS, the package is already bundled in. You can access it via connection.signer, which is an instance of EulerStreamApiClient.

Installation

npm install @eulerstream/euler-api-sdk

Example: Create an Alert

const fetchResponse = await sdk.alertsApi.createAlert(
  process.env.EULER_ACCOUNT_ID,
  {
    unique_id: uniqueId.trim(),
  },
  {
    params: {
      read_only: true,
    }
  }
);

Example: Delete an Alert

const fetchResponse = await sdk.alertsApi.deleteAlert(
  process.env.EULER_ACCOUNT_ID,
  alertId
);

Example: List All Alerts

const fetchResponse = await sdk.alertsApi.listAlerts(
  process.env.EULER_ACCOUNT_ID,
  true
);

Managing Alert Targets (Webhooks)

Alerts are delivered to endpoints known as alert targets via HTTP webhooks.

Create an Alert Target

const fetchResponse = await sdk.alertTargetsApi.createAlertTarget(
  process.env.EULER_ACCOUNT_ID,
  alertId,
  {
    url: env.NEXT_PUBLIC_APP_URL + "/api/webhooks/alerts", // Where to deliver the alerts
    metadata: config, // Optional metadata for the target. Hard-limit of 2MB.
  }
);

Delete an Alert Target

const fetchResponse = await sdk.alertTargetsApi.deleteAlertTarget(
  process.env.EULER_ACCOUNT_ID,
  alertId,
  targetId
);

List Alert Targets

const fetchResponse = await sdk.alertTargetsApi.listAlertTargets(
  process.env.EULER_ACCOUNT_ID,
  alertId
);

Validating Webhook Requests

When you receive a webhook, validate the x-webhook-signature header to ensure authenticity. This signature is an HMAC SHA256 hash of the request body, signed with your webhook secret, which you can find in the Dashboard.

Signature Validation Logic

import crypto from 'crypto';
 
/**
* Generates an HMAC SHA256 signature for the given payload using the provided secret.
*
* @param secret The secret key used for signing the payload.
* @param payload The raw body of the webhook payload to sign.
*/
function generateSignature(secret: string, payload: string): string {
  return crypto
    .createHmac('sha256', secret)
    .update(payload)
    .digest('hex');
}
 
/**
* Checks if the received signature matches the expected signature for the given payload.
*
* @param secret The secret key used for signing the payload.
* @param payload The raw body of the webhook payload to check.
* @param receivedSignature The signature received in the webhook request header.
*/
export function checkWebSocketSecret(secret: string, payload: string, receivedSignature: string): boolean {
  const expectedSignature = generateSignature(secret, payload);
  try {
    return crypto.timingSafeEqual(
      Buffer.from(receivedSignature, 'hex'),
      Buffer.from(expectedSignature, 'hex')
    );
  } catch {
    return false;
  }
}

Be sure to use the EXACT request body received in the webhook, as any changes will result in a different signature.


OpenAPI Documentation

The official OpenAPI documentation for the Euler Alerts API describes all available endpoints, parameters, response types, and expected payloads. You can use this specification to:

  • Understand how to format API calls
  • Auto-generate client SDKs
  • Explore edge cases and optional parameters

Visit the OpenAPI Reference for more.


Summary

TikTok LIVE alerts provide real-time visibility on creators' room info & status. Use the @eulerstream/euler-api-sdk to manage alerts in your backend, subscribe to webhook endpoints, and validate delivery using HMAC signatures. By utilizing LIVE alerts you can build resilient, responsive integrations with the Euler ecosystem.