> To build or manage a Wix site with an AI agent, follow https://www.wix.com/headless/skill.md
> It builds a new Wix site or puts your own site online, from a prompt, and keeps changing it afterwards. The pages are code in any web technology, and Wix runs the backend.
> It works through the Wix plugin (the Wix MCP and the Wix skills), the Wix CLI or no Wix login, and puts the site live on Wix hosting or on another host.
> Business features include a store, bookings, events and tickets, a restaurant, a blog, forms, members and many more.
> Read the Wix skills online at https://www.wix.com/skills
> 
> 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`).
> - If a reference page seems to be missing its schema (parameters, return types, or type definitions), append `?schema=true` to its `.md` URL (e.g. `https://dev.wix.com/docs/contexts/contexts/stores/category-info/use-category-info-context.md?schema=true`).
> - Top-level index of all portals: https://dev.wix.com/docs/llms.txt
> - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt

# Method name: updateBadge(badgeId: string, badgeInfo: BadgeInfo)

# Method package: wixMembersBackend

# Method menu location: wixMembersBackend --> Badges --> updateBadge

# Method Link: https://dev.wix.com/docs/velo/apis/wix-members-backend/badges/update-badge.md

# Method Description:

Updates a badge.

The `updateBadge()` function returns a Promise
that resolves to the updated badge.

Only the properties passed in the `BadgeInfo` object will be updated. All other properties will remain the same.

Because the badge `slug` is based on the badge `title`,
if you change `title`, `slug` is updated accordingly.

`badgeId` must be an ID from your site's
`Members/Badges` collection.
Typically, you retrieve the ID from the collection using a query or through a dataset.



# Method Code Examples:

*** Note: do not assume any prop names or enum values other than the ones in the example.

## Update a badge

```javascript
import { Permissions, webMethod } from 'wix-web-module';
import { badges } from 'wix-members-backend';

export const myUpdateBadgeFunction = webMethod(Permissions.Anyone, () => {
  const badgeId = "571495e9-98af-4ec9-b854-16c0293c9312"
  const badgeInfo = {
    title: "Updated Rising Star",
    description: "Contributed 5... wait, no... 10 posts this month!",
    backgroundColor: "#FED8B1",
    textColor: "#000000",
    icon: "https://static.wixstatic.com/shapes/132b9a3d51884000acaf705eeeb0e296.svg"
  };

  return badges.updateBadge(badgeId, badgeInfo)
    .then((badge) => {
      const badgeTitle = badge.title;
      const badgeSlug = badge.slug;
      return badge;
    })
    .catch((error) => {
      console.error(error);
    });
});

/*
 * Promise resolves to:
 * {
 *   "_id": "571495e9-98af-4ec9-b854-16c0293c9312",
 *   "_createdDate": "2021-05-20T00:02:18.794Z",
 *   "_updatedDate": "2021-05-20T05:41:55.691Z",
 *   "title": "Updated Rising Star",
 *   "slug": "updated-rising-star",
 *   "description": "Contributed 5... wait, no... 10 posts this month!",
 *   "backgroundColor": "#FED8B1",
 *   "textColor": "#000000",
 *   "icon": "https://static.wixstatic.com/shapes/132b9a3d51884000acaf705eeeb0e296.svg",
 *   "roleId": "571495e9-98af-4ec9-b854-16c0293c9312"
 * }
 */
```

## Update only a badge's title and slug

```javascript
import { Permissions, webMethod } from 'wix-web-module';
import { badges } from 'wix-members-backend';

export const myUpdateBadgeFunction = webMethod(Permissions.Anyone, () => {
  const badgeId = "95fad9e6-d4dc-4d84-98a2-ae8660cce599";
  const badgeInfo = {
    title: "Fancypants New Title"
  };

  return badges.updateBadge(badgeId, badgeInfo)
    .then((badge) => {
      const badgeTitle = badge.title;
      const badgeSlug = badge.slug;
      return badge;
    })
    .catch((error) => {
      console.error(error);
    });
});

/*
 * Promise resolves to:
 * {
 *   "_id": "95fad9e6-d4dc-4d84-98a2-ae8660cce599",
 *   "_createdDate": "2021-05-06T12:53:57.984Z",
 *   "_updatedDate": "2021-05-20T05:44:50.199Z",
 *   "title": "Fancypants New Title",
 *   "slug": "fancypants-new-title",
 *   "description": "",
 *   "backgroundColor": "#796EFF",
 *   "textColor": "#FFFFFF",
 *   "icon": "",
 *   "roleId": "95fad9e6-d4dc-4d84-98a2-ae8660cce599"
 * }
 */
```

---