// Get current app settings
const response = await client.getAppSettings();
console.log("Current event hooks:", response.event_hooks);
// The updateAppSettings method performs upsert and delete operations:
// - Creates new hooks if ID doesn't exist in our database
// - Updates existing hooks if ID matches in our database
// - Deletes hooks that are excluded from the list
// Example 1: Create new event hooks (assuming no existing hooks)
await client.updateAppSettings({
event_hooks: [
{
id: "{generate random uuid}", // New webhook hook
enabled: true,
hook_type: "webhook",
webhook_url: "https://example.com/webhook",
event_types: ["message.new", "message.updated"],
},
{
// You can also create a new hook without providing the ID, the system will generate it
enabled: true,
hook_type: "sqs", // New SQS hook
sqs_queue_url:
"https://sqs.us-east-1.amazonaws.com/123456789012/queue-name",
sqs_region: "us-east-1",
sqs_auth_type: "resource",
event_types: ["user.updated"],
},
],
});
// Example 2: Update existing webhook, add a second webhook, add SNS and pending message
await client.updateAppSettings({
event_hooks: [
{
// Update existing webhook
id: "{id from creation}", // you can provide the ID or not. If you don't provide the ID, the system will generate a new random UUID every time you update the hook. It's up to your convenience.
enabled: true,
hook_type: "webhook",
webhook_url: "https://updated-webhook-url.com", // Changed URL
event_types: ["message.new", "message.updated", "message.deleted"], // Added event type
},
{
id: "{id from creation}", // Keep existing SQS hook unchanged
enabled: true,
hook_type: "sqs",
sqs_queue_url:
"https://sqs.us-east-1.amazonaws.com/123456789012/queue-name",
sqs_region: "us-east-1",
sqs_auth_type: "resource",
event_types: ["user.updated"],
},
{
// Add second webhook
enabled: true,
hook_type: "webhook",
webhook_url: "https://secondary-webhook-url.com",
event_types: [], // for all existing and future event types
},
{
// Add new SNS hook
enabled: true,
hook_type: "sns",
sns_topic_arn: "arn:aws:sns:us-east-1:123456789012:topic-name",
sns_region: "us-east-1",
sns_auth_type: "resource",
event_types: ["channel.updated"],
},
{
// Add new pending message hook
enabled: true,
hook_type: "pending_message",
webhook_url: "http://test-url.com",
timeout_ms: 500,
callback: {
mode: "CALLBACK_MODE_REST",
},
},
],
// Note: Any previously existing hooks not included here will be deleted
});
// Example 3: Delete specific hooks by excluding them
await client.updateAppSettings({
event_hooks: [
{
id: "{id from creation}", // Keep only webhook hook
enabled: true,
hook_type: "webhook",
webhook_url: "https://example.com/webhook",
event_types: ["message.new", "message.updated"],
},
// SQS, SNS, and pending message hooks will be deleted because they're not included
],
});
// Example 4: Delete all event hooks
await client.updateAppSettings({
event_hooks: [], // Empty array deletes all existing hooks
});
Multi-Event Hooks
Overview
Stream now supports configuring multiple webhook endpoints for different event types, giving you more flexibility in handling various events. This feature allows you to route different types of events to different endpoints, making your webhook architecture more organized and efficient.
Migration
If you only see a single webhook URL in your dashboard, your application hasn’t been migrated to the new multi-event hooks system yet. We are currently in the process of gradually rolling out this feature across all Stream applications. Once your app is migrated, you’ll have access to the multi-event hooks configuration described in this section.
Configuration
You can configure multi-event hooks through the Stream Dashboard or using the server-side SDKs.
Using the Dashboard
- Go to the Stream Dashboard
- Select your app
- Navigate to your app’s settings until “Webhook & Event Configuration” section
- Add and configure webhook, SQS, SNS, and pending message
Using Server-Side SDKs
Event hooks are managed using the Update App Settings method, which performs upsert and delete operations:
- Create: New hooks are created if the ID doesn’t exist in our database
- Update: Existing hooks are updated if the ID matches in our database
- Delete: Hooks not included in the request are automatically deleted
You can provide the ID or not. If you don’t provide the ID, the system will generate a new random UUID everytime you update the hook. It’s up to your convenience.
Here’s how to configure event hooks using our server SDKs:
# Get current app settings
response = client.get_app_settings()
print("Current event hooks:", response.get("event_hooks", []))
# The update_app_settings method performs upsert and delete operations:
# - Creates new hooks if ID doesn't exist in our database
# - Updates existing hooks if ID matches in our database
# - Deletes hooks that are excluded from the list
# Example 1: Create new event hooks (assuming no existing hooks)
client.update_app_settings(
event_hooks=[
{
"id": "{generate random uuid}", # New webhook hook
"enabled": True,
"hook_type": "webhook",
"webhook_url": "https://example.com/webhook",
"event_types": ["message.new", "message.updated"]
},
{
# You can also create a new hook without providing the ID, the system will generate it
"enabled": True,
"hook_type": "sqs", # New SQS hook
"sqs_queue_url": "https://sqs.us-east-1.amazonaws.com/123456789012/queue-name",
"sqs_region": "us-east-1",
"sqs_auth_type": "resource",
"event_types": ["user.updated"]
}
]
)
# Example 2: Update existing webhook, add a second webhook, add SNS and pending message
client.update_app_settings(
event_hooks=[
{
# Update existing webhook
"id": "{id from creation}", # you can provide the ID or not. If you don't provide the ID, the system will generate a new random UUID every time you update the hook. It's up to your convenience.
"enabled": True,
"hook_type": "webhook",
"webhook_url": "https://updated-webhook-url.com", # Changed URL
"event_types": ["message.new", "message.updated", "message.deleted"] # Added event type
},
{
"id": "{id from creation}", # Keep existing SQS hook unchanged
"enabled": True,
"hook_type": "sqs",
"sqs_queue_url": "https://sqs.us-east-1.amazonaws.com/123456789012/queue-name",
"sqs_region": "us-east-1",
"sqs_auth_type": "resource",
"event_types": ["user.updated"]
},
{
# Add second webhook
"enabled": True,
"hook_type": "webhook",
"webhook_url": "https://secondary-webhook-url.com",
"event_types": [], # for all existing and future event types
},
{
# Add new SNS hook
"enabled": True,
"hook_type": "sns",
"sns_topic_arn": "arn:aws:sns:us-east-1:123456789012:topic-name",
"sns_region": "us-east-1",
"sns_auth_type": "resource",
"event_types": ["channel.updated"]
},
{
# Add new pending message hook
"enabled": True,
"hook_type": "pending_message",
"webhook_url": "http://test-url.com",
"timeout_ms": 500,
"callback": {
"mode": "CALLBACK_MODE_REST"
}
}
]
# Note: Any previously existing hooks not included here will be deleted
)
# Example 3: Delete specific hooks by excluding them
client.update_app_settings(
event_hooks=[
{
"id": "{id from creation}", # Keep only webhook hook
"enabled": True,
"hook_type": "webhook",
"webhook_url": "https://example.com/webhook",
"event_types": ["message.new", "message.updated"]
}
# SQS, SNS, and pending message hooks will be deleted because they're not included
]
)
# Example 4: Delete all event hooks
client.update_app_settings(event_hooks=[]) # Empty list deletes all existing hooks
# Get current app settings
response = client.get_app_settings
puts "Current event hooks:", response["event_hooks"] || []
# The update_app_settings method performs upsert and delete operations:
# - Creates new hooks if ID doesn't exist in our database
# - Updates existing hooks if ID matches in our database
# - Deletes hooks that are excluded from the list
# Example 1: Create new event hooks (assuming no existing hooks)
client.update_app_settings(
event_hooks: [
{
"id" => "{generate random uuid}", # New webhook hook
"enabled" => true,
"hook_type" => "webhook",
"webhook_url" => "https://example.com/webhook",
"event_types" => ["message.new", "message.updated"]
},
{
# You can also create a new hook without providing the ID, the system will generate it
"enabled" => true,
"hook_type" => "sqs", # New SQS hook
"sqs_queue_url" => "https://sqs.us-east-1.amazonaws.com/123456789012/queue-name",
"sqs_region" => "us-east-1",
"sqs_auth_type" => "resource",
"event_types" => ["user.updated"]
}
]
)
# Example 2: Update existing webhook, add a second webhook, add SNS and pending message
client.update_app_settings(
event_hooks: [
{
# Update existing webhook
"id" => "{id from creation}", # you can provide the ID or not. If you don't provide the ID, the system will generate a new random UUID every time you update the hook. It's up to your convenience.
"enabled" => true,
"hook_type" => "webhook",
"webhook_url" => "https://updated-webhook-url.com", # Changed URL
"event_types" => ["message.new", "message.updated", "message.deleted"] # Added event type
},
{
"id" => "{id from creation}", # Keep existing SQS hook unchanged
"enabled" => true,
"hook_type" => "sqs",
"sqs_queue_url" => "https://sqs.us-east-1.amazonaws.com/123456789012/queue-name",
"sqs_region" => "us-east-1",
"sqs_auth_type" => "resource",
"event_types" => ["user.updated"]
},
{
# Add second webhook
"enabled" => true,
"hook_type" => "webhook",
"webhook_url" => "https://secondary-webhook-url.com",
"event_types" => [], # for all existing and future event types
},
{
# Add new SNS hook
"enabled" => true,
"hook_type" => "sns",
"sns_topic_arn" => "arn:aws:sns:us-east-1:123456789012:topic-name",
"sns_region" => "us-east-1",
"sns_auth_type" => "resource",
"event_types" => ["channel.updated"]
},
{
# Add new pending message hook
"enabled" => true,
"hook_type" => "pending_message",
"webhook_url" => "http://test-url.com",
"timeout_ms" => 500,
"callback" => {
"mode" => "CALLBACK_MODE_REST"
}
}
]
# Note: Any previously existing hooks not included here will be deleted
)
# Example 3: Delete specific hooks by excluding them
client.update_app_settings(
event_hooks: [
{
"id" => "{id from creation}", # Keep only webhook hook
"enabled" => true,
"hook_type" => "webhook",
"webhook_url" => "https://example.com/webhook",
"event_types" => ["message.new", "message.updated"]
}
# SQS, SNS, and pending message hooks will be deleted because they're not included
]
)
# Example 4: Delete all event hooks
client.update_app_settings(event_hooks: []) # Empty array deletes all existing hooks
// Get current app settings
$response = $client->getAppSettings();
echo "Current event hooks: " . json_encode($response['event_hooks'] ?? []);
// The updateAppSettings method performs upsert and delete operations:
// - Creates new hooks if ID doesn't exist in our database
// - Updates existing hooks if ID matches in our database
// - Deletes hooks that are excluded from the list
// Example 1: Create new event hooks (assuming no existing hooks)
$client->updateAppSettings([
'event_hooks' => [
[
'id' => '{generate random uuid}', // New webhook hook
'enabled' => true,
'hook_type' => 'webhook',
'webhook_url' => 'https://example.com/webhook',
'event_types' => ['message.new', 'message.updated']
],
[
// You can also create a new hook without providing the ID, the system will generate it
'enabled' => true,
'hook_type' => 'sqs', // New SQS hook
'sqs_queue_url' => 'https://sqs.us-east-1.amazonaws.com/123456789012/queue-name',
'sqs_region' => 'us-east-1',
'sqs_auth_type' => 'resource',
'event_types' => ['user.updated']
]
]
]);
// Example 2: Update existing webhook, add a second webhook, add SNS and pending message
$client->updateAppSettings([
'event_hooks' => [
[
// Update existing webhook
'id' => '{id from creation}', // you can provide the ID or not. If you don't provide the ID, the system will generate a new random UUID every time you update the hook. It's up to your convenience.
'enabled' => true,
'hook_type' => 'webhook',
'webhook_url' => 'https://updated-webhook-url.com', // Changed URL
'event_types' => ['message.new', 'message.updated', 'message.deleted'] // Added event type
],
[
'id' => '{id from creation}', // Keep existing SQS hook unchanged
'enabled' => true,
'hook_type' => 'sqs',
'sqs_queue_url' => 'https://sqs.us-east-1.amazonaws.com/123456789012/queue-name',
'sqs_region' => 'us-east-1',
'sqs_auth_type' => 'resource',
'event_types' => ['user.updated']
],
[
// Add second webhook
'enabled' => true,
'hook_type' => 'webhook',
'webhook_url' => 'https://secondary-webhook-url.com',
'event_types' => [], // for all existing and future event types
],
[
// Add new SNS hook
'enabled' => true,
'hook_type' => 'sns',
'sns_topic_arn' => 'arn:aws:sns:us-east-1:123456789012:topic-name',
'sns_region' => 'us-east-1',
'sns_auth_type' => 'resource',
'event_types' => ['channel.updated']
],
[
// Add new pending message hook
'enabled' => true,
'hook_type' => 'pending_message',
'webhook_url' => 'http://test-url.com',
'timeout_ms' => 500,
'callback' => [
'mode' => 'CALLBACK_MODE_REST'
]
]
]
// Note: Any previously existing hooks not included here will be deleted
]);
// Example 3: Delete specific hooks by excluding them
$client->updateAppSettings([
'event_hooks' => [
[
'id' => '{id from creation}', // Keep only webhook hook
'enabled' => true,
'hook_type' => 'webhook',
'webhook_url' => 'https://example.com/webhook',
'event_types' => ['message.new', 'message.updated']
]
// SQS, SNS, and pending message hooks will be deleted because they're not included
]
]);
// Example 4: Delete all event hooks
$client->updateAppSettings(['event_hooks' => []]); // Empty array deletes all existing hooks
// Get current app settings
settings, err := client.GetAppSettings(ctx)
if err != nil {
log.Fatal(err)
}
fmt.Printf("Current event hooks: %+v\n", settings.App.EventHooks)
// The UpdateAppSettings method performs upsert and delete operations:
// - Creates new hooks if ID doesn't exist in our database
// - Updates existing hooks if ID matches in our database
// - Deletes hooks that are excluded from the list
// Example 1: Create new event hooks (assuming no existing hooks)
webhookHook := EventHook{
ID: "{generate random uuid}", // New webhook hook
HookType: WebhookHook,
Enabled: true,
EventTypes: []string{"message.new", "message.updated"},
WebhookURL: "https://example.com/webhook",
}
// You can also create a new hook without providing the ID, the system will generate it
sqsHook := EventHook{
HookType: SQSHook, // New SQS hook
Enabled: true,
EventTypes: []string{"user.updated"},
SQSQueueURL: "https://sqs.us-east-1.amazonaws.com/123456789012/queue-name",
SQSRegion: "us-east-1",
SQSAuthType: "resource",
}
_, err = client.UpdateAppSettings(ctx, NewAppSettings().SetEventHooks([]EventHook{webhookHook, sqsHook}))
if err != nil {
log.Fatal(err)
}
// Example 2: Update existing webhook, add a second webhook, add SNS and pending message
// Update existing webhook
webhookHookUpdated := EventHook{
ID: "{id from creation}", // you can provide the ID or not. If you don't provide the ID, the system will generate a new random UUID every time you update the hook. It's up to your convenience.
HookType: WebhookHook,
Enabled: true,
EventTypes: []string{"message.new", "message.updated", "message.deleted"}, // Added event type
WebhookURL: "https://updated-webhook-url.com", // Changed URL
}
sqsHookUnchanged := EventHook{
ID: "{id from creation}", // Keep existing SQS hook unchanged
HookType: SQSHook,
Enabled: true,
EventTypes: []string{"user.updated"},
SQSQueueURL: "https://sqs.us-east-1.amazonaws.com/123456789012/queue-name",
SQSRegion: "us-east-1",
SQSAuthType: "resource",
}
// Add second webhook
secondaryWebhookHook := EventHook{
HookType: WebhookHook,
Enabled: true,
EventTypes: []string{}, // for all existing and future event types
WebhookURL: "https://secondary-webhook-url.com",
}
// Add new SNS hook
snsHook := EventHook{
HookType: SNSHook,
Enabled: true,
EventTypes: []string{"channel.updated"},
SNSTopicARN: "arn:aws:sns:us-east-1:123456789012:topic-name",
SNSRegion: "us-east-1",
SNSAuthType: "resource",
}
// Add new pending message hook
pendingMessageHook := EventHook{
HookType: PendingMessage,
Enabled: true,
WebhookURL: "http://test-url.com",
TimeoutMs: 500,
Callback: &Callback{Mode: CallbackModeREST},
}
_, err = client.UpdateAppSettings(ctx, NewAppSettings().SetEventHooks([]EventHook{webhookHookUpdated, sqsHookUnchanged, secondaryWebhookHook, snsHook, pendingMessageHook}))
// Note: Any previously existing hooks not included here will be deleted
if err != nil {
log.Fatal(err)
}
// Example 3: Delete specific hooks by excluding them
keepWebhookOnly := EventHook{
ID: "{id from creation}", // Keep only webhook hook
HookType: WebhookHook,
Enabled: true,
EventTypes: []string{"message.new", "message.updated"},
WebhookURL: "https://example.com/webhook",
}
_, err = client.UpdateAppSettings(ctx, NewAppSettings().SetEventHooks([]EventHook{keepWebhookOnly}))
// SQS, SNS, and pending message hooks will be deleted because they're not included
if err != nil {
log.Fatal(err)
}
// Example 4: Delete all event hooks
_, err = client.UpdateAppSettings(ctx, NewAppSettings().SetEventHooks([]EventHook{})) // Empty slice deletes all existing hooks
if err != nil {
log.Fatal(err)
}
// Get current app settings
var settings = await client.GetAppSettingsAsync();
Console.WriteLine($"Current event hooks: {settings.App.EventHooks}");
// The UpdateAppSettingsAsync method performs upsert and delete operations:
// - Creates new hooks if ID doesn't exist in our database
// - Updates existing hooks if ID matches in our database
// - Deletes hooks that are excluded from the list
// Example 1: Create new event hooks (assuming no existing hooks)
var webhookHook = new EventHook
{
Id = "{generate random uuid}", // New webhook hook
HookType = HookType.Webhook,
Enabled = true,
EventTypes = new List<string> { "message.new", "message.updated" },
WebhookUrl = "https://example.com/webhook"
};
// You can also create a new hook without providing the ID, the system will generate it
var sqsHook = new EventHook
{
HookType = HookType.SQS, // New SQS hook
Enabled = true,
EventTypes = new List<string> { "user.updated" },
SqsQueueUrl = "https://sqs.us-east-1.amazonaws.com/123456789012/queue-name",
SqsRegion = "us-east-1",
SqsAuthType = AuthType.Resource
};
await client.UpdateAppSettingsAsync(new AppSettingsRequest
{
EventHooks = new List<EventHook> { webhookHook, sqsHook }
});
// Example 2: Update existing webhook, add a second webhook, add SNS and pending message
// Update existing webhook
var webhookHookUpdated = new EventHook
{
Id = "{id from creation}", // you can provide the ID or not. If you don't provide the ID, the system will generate a new random UUID every time you update the hook. It's up to your convenience.
HookType = HookType.Webhook,
Enabled = true,
EventTypes = new List<string> { "message.new", "message.updated", "message.deleted" }, // Added event type
WebhookUrl = "https://updated-webhook-url.com" // Changed URL
};
var sqsHookUnchanged = new EventHook
{
Id = "{id from creation}", // Keep existing SQS hook unchanged
HookType = HookType.SQS,
Enabled = true,
EventTypes = new List<string> { "user.updated" },
SqsQueueUrl = "https://sqs.us-east-1.amazonaws.com/123456789012/queue-name",
SqsRegion = "us-east-1",
SqsAuthType = AuthType.Resource
};
// Add second webhook
var secondaryWebhookHook = new EventHook
{
HookType = HookType.Webhook,
Enabled = true,
EventTypes = new List<string> { }, // for all existing and future event types
WebhookUrl = "https://secondary-webhook-url.com"
};
// Add new SNS hook
var snsHook = new EventHook
{
HookType = HookType.SNS,
Enabled = true,
EventTypes = new List<string> { "channel.updated" },
SnsTopicArn = "arn:aws:sns:us-east-1:123456789012:topic-name",
SnsRegion = "us-east-1",
SnsAuthType = AuthType.Resource
};
// Add new pending message hook
var pendingMessageHook = new EventHook
{
HookType = HookType.PendingMessage,
Enabled = true,
WebhookUrl = "http://test-url.com",
TimeoutMs = 500,
Callback = new CallbackConfig { Mode = CallbackMode.Rest }
};
await client.UpdateAppSettingsAsync(new AppSettingsRequest
{
EventHooks = new List<EventHook> { webhookHookUpdated, sqsHookUnchanged, secondaryWebhookHook, snsHook, pendingMessageHook }
});
// Note: Any previously existing hooks not included here will be deleted
// Example 3: Delete specific hooks by excluding them
var keepWebhookOnly = new EventHook
{
Id = "{id from creation}", // Keep only webhook hook
HookType = HookType.Webhook,
Enabled = true,
EventTypes = new List<string> { "message.new", "message.updated" },
WebhookUrl = "https://example.com/webhook"
};
await client.UpdateAppSettingsAsync(new AppSettingsRequest
{
EventHooks = new List<EventHook> { keepWebhookOnly }
// SQS, SNS, and pending message hooks will be deleted because they're not included
});
// Example 4: Delete all event hooks
await client.UpdateAppSettingsAsync(new AppSettingsRequest
{
EventHooks = new List<EventHook>() // Empty list deletes all existing hooks
});
// Get current app settings
App.AppGetResponse response = App.get().request();
List<App.EventHook> eventHooks = response.getApp().getEventHooks();
System.out.println("Current event hooks: " + eventHooks);
// The update method performs upsert and delete operations:
// - Creates new hooks if ID doesn't exist in our database
// - Updates existing hooks if ID matches in our database
// - Deletes hooks that are excluded from the list
// Example 1: Create new event hooks (assuming no existing hooks)
App.EventHook webhookHook = new App.EventHook();
webhookHook.setId("{generate random uuid}"); // New webhook hook
webhookHook.setHookType(App.HookType.WEBHOOK);
webhookHook.setEnabled(true);
webhookHook.setEventTypes(Arrays.asList("message.new", "message.updated"));
webhookHook.setWebhookURL("https://example.com/webhook");
// You can also create a new hook without providing the ID, the system will generate it
App.EventHook sqsHook = new App.EventHook();
sqsHook.setHookType(App.HookType.SQS); // New SQS hook
sqsHook.setEnabled(true);
sqsHook.setEventTypes(Arrays.asList("user.updated"));
sqsHook.setSqsQueueURL("https://sqs.us-east-1.amazonaws.com/123456789012/queue-name");
sqsHook.setSqsRegion("us-east-1");
sqsHook.setSqsAuthType(App.AuthType.RESOURCE);
App.update().eventHooks(Arrays.asList(webhookHook, sqsHook)).request();
// Example 2: Update existing webhook, add a second webhook, add SNS and pending message
// Update existing webhook
App.EventHook webhookHookUpdated = new App.EventHook();
webhookHookUpdated.setId("{id from creation}"); // you can provide the ID or not. If you don't provide the ID, the system will generate a new random UUID every time you update the hook. It's up to your convenience.
webhookHookUpdated.setHookType(App.HookType.WEBHOOK);
webhookHookUpdated.setEnabled(true);
webhookHookUpdated.setEventTypes(Arrays.asList("message.new", "message.updated", "message.deleted")); // Added event type
webhookHookUpdated.setWebhookURL("https://updated-webhook-url.com"); // Changed URL
App.EventHook sqsHookUnchanged = new App.EventHook();
sqsHookUnchanged.setId("{id from creation}"); // Keep existing SQS hook unchanged
sqsHookUnchanged.setHookType(App.HookType.SQS);
sqsHookUnchanged.setEnabled(true);
sqsHookUnchanged.setEventTypes(Arrays.asList("user.updated"));
sqsHookUnchanged.setSqsQueueURL("https://sqs.us-east-1.amazonaws.com/123456789012/queue-name");
sqsHookUnchanged.setSqsRegion("us-east-1");
sqsHookUnchanged.setSqsAuthType(App.AuthType.RESOURCE);
// Add second webhook
App.EventHook secondaryWebhookHook = new App.EventHook();
secondaryWebhookHook.setHookType(App.HookType.WEBHOOK);
secondaryWebhookHook.setEnabled(true);
secondaryWebhookHook.setEventTypes(Collections.emptyList()); // for all existing and future event types
secondaryWebhookHook.setWebhookURL("https://secondary-webhook-url.com");
// Add new SNS hook
App.EventHook snsHook = new App.EventHook();
snsHook.setHookType(App.HookType.SNS);
snsHook.setEnabled(true);
snsHook.setEventTypes(Arrays.asList("channel.updated"));
snsHook.setSnsTopicARN("arn:aws:sns:us-east-1:123456789012:topic-name");
snsHook.setSnsRegion("us-east-1");
snsHook.setSnsAuthType(App.AuthType.RESOURCE);
// Add new pending message hook
App.EventHook pendingMessageHook = new App.EventHook();
pendingMessageHook.setHookType(App.HookType.PENDING_MESSAGE);
pendingMessageHook.setEnabled(true);
pendingMessageHook.setWebhookURL("http://test-url.com");
pendingMessageHook.setTimeoutMs(500);
App.PendingMessageCallback callback = new App.PendingMessageCallback();
callback.setMode(App.CallbackMode.REST);
pendingMessageHook.setCallback(callback);
App.update().eventHooks(Arrays.asList(webhookHookUpdated, sqsHookUnchanged, secondaryWebhookHook, snsHook, pendingMessageHook)).request();
// Note: Any previously existing hooks not included here will be deleted
// Example 3: Delete specific hooks by excluding them
App.EventHook keepWebhookOnly = new App.EventHook();
keepWebhookOnly.setId("{id from creation}"); // Keep only webhook hook
keepWebhookOnly.setHookType(App.HookType.WEBHOOK);
keepWebhookOnly.setEnabled(true);
keepWebhookOnly.setEventTypes(Arrays.asList("message.new", "message.updated"));
keepWebhookOnly.setWebhookURL("https://example.com/webhook");
App.update().eventHooks(Arrays.asList(keepWebhookOnly)).request();
// SQS, SNS, and pending message hooks will be deleted because they're not included
// Example 4: Delete all event hooks
App.update().eventHooks(Collections.emptyList()).request(); // Empty list deletes all existing hooks
Configuration Options
Each event hook configuration supports different options based on its type:
Common Options
Option | Type | Description | Required |
---|---|---|---|
id | string | Unique identifier for the event hook | Yes for updating hooks. If empty, it will generate an ID. |
enabled | boolean | Boolean flag to enable/disable the hook | Yes |
hook_type | string | Type of hook (“webhook”, “sqs”, “sns”, “pending_message”) | Yes |
product | string | Configure hook for a specific product (“all”, “chat”, “video”, “moderation”, “feeds”) | No. Default is “all”. |
event_types | array | Array of event types this hook should handle | No. Not provided or empty array means subscribe to all existing and future events. |
Webhook Options
Option | Type | Description | Required |
---|---|---|---|
webhook_url | string | The URL where events will be sent. You can use URL templating to handle events. Example: http://my.webhook.host/{{.AppID}}/{{.EventType}} | Yes |
For more information on configuring webhook server, please refer to the Webhooks Overview documentation.
SQS Options
Option | Type | Description | Required |
---|---|---|---|
sqs_queue_url | string | The AWS SQS queue URL | Yes |
sqs_auth_type | string | Authentication type (“keys”, “role”, or “resource”) | Yes |
sqs_key | string | AWS access key ID (if auth_type is “keys”) | Yes if using key auth |
sqs_secret | string | AWS secret access key (if auth_type is “keys”) | Yes if using key auth |
sqs_role_arn | string | AWS IAM role ARN (if auth_type is “role”) | Yes if using role auth |
For more information on configuring SQS server, please refer to the SQS documentation.
SNS Options
Option | Type | Description | Required |
---|---|---|---|
sns_topic_arn | string | The AWS SNS topic ARN | Yes |
sns_auth_type | string | Authentication type (“keys”, “role”, or “resource”) | Yes |
sns_key | string | AWS access key ID (if auth_type is “keys”) | Yes if using key auth |
sns_secret | string | AWS secret access key (if auth_type is “keys”) | Yes if using key auth |
sns_role_arn | string | AWS IAM role ARN (if auth_type is “role”) | Yes if using role auth |
For more information on configuring SNS server, please refer to the SNS documentation.
Pending Message Options
Option | Type | Description | Required |
---|---|---|---|
webhook_url | string | The URL where pending message events will be sent | Yes, except for CALLBACK_MODE_NONE |
timeout_ms | number | Timeout in milliseconds | Yes |
callback.mode | string | Callback mode (“CALLBACK_MODE_NONE”, “CALLBACK_MODE_REST”, “CALLBACK_MODE_TWIRP”) | Yes |
You can configure up to two pending message hooks. Only the first commit will take effect. The second commit will return an error because the message is no longer pending.
For more information on configuring pending messages, please refer to the Pending Messages documentation.