This API is subject to change. Bug fixes and new features will be released based on developer feedback throughout the preview period.
Triggered when a badge is created.
function wixBadges_onBadgeCreated(event: BadgeCreated): void;
// Place this code in the events.js file
// of your site's Backend section.
// Add the file if it doesn't exist.
export function wixBadges_onBadgeCreated(event) {
const eventTime = event.metadata.eventTime;
const badgeID = event.entity._id;
console.log(`Badge ${badgeID} has been created at ${eventTime}`);
}
/* Full event object:
* {
* "entity": {
* "_createdDate": "2024-03-29T09:00:20.395Z",
* "_id": "3e536ad8-486e-45d8-9c0a-eab0cce4f98c",
* "_updatedDate": "2024-03-29T09:00:20.395Z",
* "backgroundColor": "#FA8704",
* "icon": "https://static.wixstatic.com/shapes/cb523e8b3f9b4908b85a4a1c577af32b.svg",
* "permissionsEnabled": false,
* "slug": "super-contributer",
* "textColor": "#FFFFFF",
* "title": "Super Contributer"
* },
* "metadata": {
* "entityId": "3e536ad8-486e-45d8-9c0a-eab0cce4f98c",
* "eventTime": "2024-03-29T09:00:20.500072301Z",
* "id": "b34080a9-798f-4dce-84cd-53a313bcff24",
* "triggeredByAnonymizeRequest": false
* }
* }
*/
This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.