The Events API allows you to dispatch custom events to guilds, triggering Luau script execution within the Template Worker environment.
Event Dispatching
Dispatch a custom event to a guild and receive the execution results. This allows you to trigger custom Luau scripts and receive their output.
Endpoint: POST /guilds/{guild_id}/events
curl -X POST https://splashtail-staging.antiraid.xyz/guilds/123456789012345678/events \
-H "Authorization: YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"name": "WebCustomAction",
"data": {
"Text": "Hello from the API!"
}
}'
The Discord ID of the guild to dispatch the event to
The event name. Must start with “Web” for security reasons.
The event data to pass to the Luau script. Can be any valid KhronosValue type.
KhronosValue Types
The data field accepts various types of values. Here are the available KhronosValue types:
Simple Types
{
"name" : "WebExample" ,
"data" : {
"Text" : "Hello, World!"
}
}
{
"name" : "WebExample" ,
"data" : {
"Integer" : 42
}
}
{
"name" : "WebExample" ,
"data" : {
"Float" : 3.14159
}
}
{
"name" : "WebExample" ,
"data" : {
"Boolean" : true
}
}
{
"name" : "WebExample" ,
"data" : "Null"
}
Complex Types
{
"name" : "WebExample" ,
"data" : {
"List" : [
{ "Text" : "first" },
{ "Integer" : 2 },
{ "Boolean" : true }
]
}
}
{
"name" : "WebExample" ,
"data" : {
"Map" : [
[{ "Text" : "key1" }, { "Text" : "value1" }],
[{ "Text" : "key2" }, { "Integer" : 42 }]
]
}
}
LazyStringMap (Simple Object)
{
"name" : "WebExample" ,
"data" : {
"LazyStringMap" : {
"action" : "update" ,
"target" : "user_settings"
}
}
}
Special Types
{
"name" : "WebExample" ,
"data" : {
"Timestamptz" : "2026-02-28T12:00:00Z"
}
}
{
"name" : "WebExample" ,
"data" : {
"Buffer" : [ 72 , 101 , 108 , 108 , 111 ]
}
}
{
"name" : "WebExample" ,
"data" : {
"Vector" : [ 1.0 , 2.5 , 3.7 ]
}
}
Response
The API returns the result of the Luau script execution as a KhronosValue.
Success Response
Complex Response
{
"Text" : "Action completed successfully"
}
The response format depends on what your Luau script returns. It will always be a valid KhronosValue type.
Event Name Restrictions
For security reasons, all event names dispatched through the public API must start with “Web” .
✅ Valid: WebCustomAction, WebUserUpdate, WebDataSync
❌ Invalid: CustomAction, UserUpdate, InternalEvent
This restriction ensures that only web-safe events can be triggered externally.
Example Use Cases
Trigger a Custom Action
curl -X POST https://splashtail-staging.antiraid.xyz/guilds/123456789012345678/events \
-H "Authorization: YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"name": "WebUserAction",
"data": {
"LazyStringMap": {
"action": "vote",
"option": "yes"
}
}
}'
Pass Structured Data
curl -X POST https://splashtail-staging.antiraid.xyz/guilds/123456789012345678/events \
-H "Authorization: YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"name": "WebFormSubmit",
"data": {
"Map": [
[{"Text": "username"}, {"Text": "john_doe"}],
[{"Text": "age"}, {"Integer": 25}],
[{"Text": "verified"}, {"Boolean": true}],
[{"Text": "tags"}, {
"List": [
{"Text": "developer"},
{"Text": "contributor"}
]
}]
]
}
}'
Error Handling
Invalid Event Name
Bot Not In Guild
Execution Error
{
"message" : "Event name must start with 'Web' for security reasons" ,
"code" : "Forbidden"
}
Best Practices
Always validate event names before sending (ensure they start with “Web”)
Handle execution errors gracefully - scripts may timeout or fail
Keep event data payloads reasonably sized
Use LazyStringMap for simple key-value data instead of complex Map structures
Test your Luau scripts thoroughly before deploying to production
Luau Script Integration
To handle custom events in your guild, you’ll need to set up Luau scripts that listen for your custom event names. The event data you send will be available in the Luau script’s event handler.
Example Luau script:
-- Listen for WebCustomAction events
function onWebCustomAction ( event )
local message = event . data . Text or "No message"
-- Process the event
print ( "Received message: " .. message )
-- Return a response
return {
Text = "Action completed: " .. message
}
end
Refer to the Template Worker Luau documentation for more details on writing event handlers.