> Portal Navigation: > > - Append `.md` to any URL under `https://dev.wix.com/docs/` to get its markdown version. > - Pages are either content pages (article or reference text) or menu pages (a list of links to child pages). > - To get a menu page, truncate any URL to a parent path and append `.md` (e.g. `https://dev.wix.com/docs/sdk.md`, `https://dev.wix.com/docs/sdk/core-modules.md`). > - Top-level index of all portals: https://dev.wix.com/docs/llms.txt > - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt # CreateBadge # Package: activity # Namespace: Badges # Method link: https://dev.wix.com/docs/api-reference/crm/members-contacts/members/activity/badges-v4/create-badge.md ## Permission Scopes: Manage Badges: SCOPE.DC-MEMBERS.MANAGE-BADGES ## Introduction Creates a badge. --- ## REST API ### Schema ``` Method: createBadge Description: Creates a badge. URL: https://www.wixapis.com/badges/v4/badges Method: POST # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present. Required parameters: badge, badge.title, badge.backgroundColor, badge.textColor Method parameters: param name: badge | type: Badge | description: A badge is a visible label displayed on a site member's profile. Site owners can create badges to categorize members and optionally grant them special permissions to access specific pages. Badges are managed separately from their assignment to members. To assign badges to members, use the [Badge Assignments](https://dev.wix.com/docs/api-reference/crm/members-contacts/members/activity/badge-assignments/introduction.md) API. For more information, see [Creating and Managing Member Badges](https://support.wix.com/en/article/site-members-creating-and-managing-member-badges). | required: true - name: title | type: string | description: Badge title displayed on the member's profile. | required: true - name: description | type: string | description: Badge description explaining its purpose or criteria for earning it. - name: backgroundColor | type: string | description: Badge background color in hexadecimal RGB format. | required: true - name: textColor | type: string | description: Badge text color in hexadecimal RGB format. | required: true - name: icon | type: Image | description: Badge icon image. Any image format is accepted with automatic conversion and resizing handled by the system. SVG format is recommended as it is resolution independent and looks great at any scale. - name: id | type: string | description: [WixMedia](https://support.wix.com/en/article/wix-media-about-the-media-manager) image GUID. If you pass the GUID, you don't need to pass `url`. - name: url | type: string | description: Image URL. Could be any image from the internet. - name: altText | type: string | description: Image alt text. - name: permissionsEnabled | type: boolean | description: Whether the badge grants special permissions to access specific members-only pages. When `true`, members with this badge receive special permissions. Site owners can configure these permissions in the site dashboard. For more information, see [Creating and Managing Member Badges](https://support.wix.com/en/article/site-members-creating-and-managing-member-badges). Return type: CreateBadgeResponse - name: badge | type: Badge | description: Created badge. - name: id | type: string | description: Badge GUID. - name: revision | type: string | description: Revision number, which increments by 1 each time the badge is updated. To prevent conflicting changes, the current revision must be passed when updating the badge. - name: title | type: string | description: Badge title displayed on the member's profile. - name: description | type: string | description: Badge description explaining its purpose or criteria for earning it. - name: backgroundColor | type: string | description: Badge background color in hexadecimal RGB format. - name: textColor | type: string | description: Badge text color in hexadecimal RGB format. - name: icon | type: Image | description: Badge icon image. Any image format is accepted with automatic conversion and resizing handled by the system. SVG format is recommended as it is resolution independent and looks great at any scale. - name: id | type: string | description: [WixMedia](https://support.wix.com/en/article/wix-media-about-the-media-manager) image GUID. If you pass the GUID, you don't need to pass `url`. - name: url | type: string | description: Image URL. Could be any image from the internet. - name: height | type: integer | description: Original image height. - name: width | type: integer | description: Original image width. - name: altText | type: string | description: Image alt text. - name: filename | type: string | description: Image filename. Only applicable when passing `id`. - name: permissionsEnabled | type: boolean | description: Whether the badge grants special permissions to access specific members-only pages. When `true`, members with this badge receive special permissions. Site owners can configure these permissions in the site dashboard. For more information, see [Creating and Managing Member Badges](https://support.wix.com/en/article/site-members-creating-and-managing-member-badges). - name: slug | type: string | description: URL-friendly slug for the badge, automatically generated from the title. Generated by converting the title to lowercase, replacing spaces with hyphens, and removing special characters. - name: createdDate | type: string | description: Date and time the badge was created. - name: updatedDate | type: string | description: Date and time the badge was last updated. ``` ### Examples ### Create Badge ```curl curl -X POST \ 'https://www.wixapis.com/badges/v4/badges' \ -H 'Authorization: ' \ -H 'Content-Type: application/json' \ -d '{ "badge": { "title": "Top Contributor", "description": "Awarded for being a top contributor in the community", "backgroundColor": "#2A5FA7", "textColor": "#FFFFFF", "icon": { "url": "https://example.com/badge-icon.png" }, "permissionsEnabled": true } }' ``` --- ## JavaScript SDK ### Schema ``` Method: wixClientAdmin.activity.Badges.createBadge(badge) Description: Creates a badge. # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present. Required parameters: badge, badge.title, badge.backgroundColor, badge.textColor Method parameters: param name: badge | type: Badge | description: A badge is a visible label displayed on a site member's profile. Site owners can create badges to categorize members and optionally grant them special permissions to access specific pages. Badges are managed separately from their assignment to members. To assign badges to members, use the [Badge Assignments](https://dev.wix.com/docs/api-reference/crm/members-contacts/members/activity/badge-assignments/introduction.md) API. For more information, see [Creating and Managing Member Badges](https://support.wix.com/en/article/site-members-creating-and-managing-member-badges). | required: true - name: title | type: string | description: Badge title displayed on the member's profile. | required: true - name: description | type: string | description: Badge description explaining its purpose or criteria for earning it. - name: backgroundColor | type: string | description: Badge background color in hexadecimal RGB format. | required: true - name: textColor | type: string | description: Badge text color in hexadecimal RGB format. | required: true - name: icon | type: string | description: Badge icon image. Any image format is accepted with automatic conversion and resizing handled by the system. SVG format is recommended as it is resolution independent and looks great at any scale. - name: permissionsEnabled | type: boolean | description: Whether the badge grants special permissions to access specific members-only pages. When `true`, members with this badge receive special permissions. Site owners can configure these permissions in the site dashboard. For more information, see [Creating and Managing Member Badges](https://support.wix.com/en/article/site-members-creating-and-managing-member-badges). Return type: PROMISE - name: _id | type: string | description: Badge GUID. - name: revision | type: string | description: Revision number, which increments by 1 each time the badge is updated. To prevent conflicting changes, the current revision must be passed when updating the badge. - name: title | type: string | description: Badge title displayed on the member's profile. - name: description | type: string | description: Badge description explaining its purpose or criteria for earning it. - name: backgroundColor | type: string | description: Badge background color in hexadecimal RGB format. - name: textColor | type: string | description: Badge text color in hexadecimal RGB format. - name: icon | type: string | description: Badge icon image. Any image format is accepted with automatic conversion and resizing handled by the system. SVG format is recommended as it is resolution independent and looks great at any scale. - name: permissionsEnabled | type: boolean | description: Whether the badge grants special permissions to access specific members-only pages. When `true`, members with this badge receive special permissions. Site owners can configure these permissions in the site dashboard. For more information, see [Creating and Managing Member Badges](https://support.wix.com/en/article/site-members-creating-and-managing-member-badges). - name: slug | type: string | description: URL-friendly slug for the badge, automatically generated from the title. Generated by converting the title to lowercase, replacing spaces with hyphens, and removing special characters. - name: _createdDate | type: Date | description: Date and time the badge was created. - name: _updatedDate | type: Date | description: Date and time the badge was last updated. ``` ### Examples ### createBadge ```javascript import { badgesV2 } from '@wix/members'; async function createBadge(badge) { const response = await badgesV2.createBadge(badge); }; ``` ### createBadge (with elevated permissions) ```javascript import { badgesV2 } from '@wix/members'; import { auth } from '@wix/essentials'; async function myCreateBadgeMethod(badge) { const elevatedCreateBadge = auth.elevate(badgesV2.createBadge); const response = await elevatedCreateBadge(badge); } ``` ### createBadge (self-hosted) Self-hosted SDK calls require you to [create a client](https://dev.wix.com/docs/sdk/articles/work-with-the-sdk/about-the-wix-client.md). ```javascript import { createClient } from '@wix/sdk'; import { badgesV2 } from '@wix/members'; // Import the auth strategy for the relevant access type // Import the relevant host module if needed const myWixClient = createClient ({ modules: { badgesV2 }, // Include the auth strategy and host as relevant }); async function createBadge(badge) { const response = await myWixClient.badgesV2.createBadge(badge); }; ``` ---