Skip to content

Webhook

rblxopencloud.Webhook(secret=None, api_key=None)

Represents a Roblox outgoing webhook. It is used to validate and process webhook events.

Parameters:

Name Type Description Default
secret Optional[Union[str, bytes]]

Random letters only known by Roblox and the server to validate requests.

None
api_key Optional[str]

Your API key created from Creator Dashboard with access to all objects that are generated in events.

None

Attributes:

Name Type Description
secret Optional[bytes]

The webhook secret only known by Roblox and the recieving agent.

process_notification(body, secret_header=None, validate_signature=True)

Processes a HTTP webhook event and returns a response text and status code tuple.

Example

Since the webhook section of the library was designed specificly for Flask, it is very easy to implement with Flask. Here's an example:

    @app.route('/webhook-roblox', methods=["POST"])
    def webhook_roblox():
        return webhook.process_notification(body=request.data, secret_header=request.headers["Roblox-Signature"])
If you're using another framework, it will be slightly more complex to work it out.

Parameters:

Name Type Description Default
body bytes

The HTTP raw body.

required
secret_header bytes

The raw value of the Roblox-Signature header.

None
validate_signature bool

Wether to validate the signature or not. This should not be disabled in production.

True

Returns:

Type Description
tuple[str, int]

A tuple with the string response in the first index, and the status code in the second index. Designed to be put straight into the return route in Flask.

Raises:

Type Description
UnknownEventType

The library recieved a webhook payload for an unknown type.

UnhandledEventType

The library recieved a webhook payload that doesn't have any handler function attached.

Note

If an exception is raised in the notification handler, then it will be raised from this method. Therefore, any exception could be raised by this method.

event(func)

Register event callbacks with this decorator. The allowed function names, and the notification type they return is as follows:

Event Name Notification Type Event Description
on_test rblxopencloud.TestNotification Triggers when the user clicks 'Test Response' on the Webhook configuration page
on_right_to_erasure_request rblxopencloud.RightToErasureRequestNotification Triggers when a right to erause request is recieved.
Example

This will print the user ID and effected experiences for every right to erasure request that is recieved.

@webhook.event
def on_right_to_erasure_request(notification):
    print(notification.user_id, notification.experiences)

rblxopencloud.Notification

Represents a recieved base webhook event.

Warning

This class isn't designed to be created by users. It is returned by some decorated functions from Webhook.event().

Attributes:

Name Type Description
notification_id str

The notifications unique ID. If an ID is repeated, assume it is a duplicate and ignore it.

timestamp datetime

The time the notification was created.

webhook Webhook

The webhook that the notifcation came from.

rblxopencloud.TestNotification

Bases: Notification

Represents a recieved webhook event triggered by the user pressing 'Test Response' on the webhook configuration page.

Warning

This class isn't designed to be created by users. It is returned by some decorated functions from Webhook.event().

Attributes:

Name Type Description
notification_id str

The notifications unique ID. If an ID is repeated, assume it is a duplicate and ignore it.

timestamp datetime

The time the notification was created.

webhook Webhook

The webhook that the notifcation came from.

user User

The user that clicked the test button.

rblxopencloud.RightToErasureRequestNotification

Bases: Notification

Represents a recieved webhook event triggered by a user requesting Roblox to erase all their user data.

Warning

This class isn't designed to be created by users. It is returned by some decorated functions from Webhook.event().

Attributes:

Name Type Description
notification_id str

The notifications unique ID. If an ID is repeated, assume it is a duplicate and ignore it.

timestamp datetime

The time the notification was created.

webhook Webhook

The webhook that the notifcation came from.

user_id int

The ID of the user who requested their data to be erased.

experiences list[Experience]

A list of experiences the user potentially has saved data.