> For the complete documentation index, see [llms.txt](https://codemash.gitbook.io/codemash/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://codemash.gitbook.io/codemash/cloud/membership/users/edit.md).

# Edit a user

Edit a user — change the profile, set roles, change marketing preferences and see the logins.

**Where:** Membership → Users → click a name · `/projects/<project>/membership/users/<userId>/edit`

## Before you start

* The user exists — see [Add a user](/codemash/cloud/membership/users/new.md).
* You need the `membership:update` permission on users.

## Steps

1. In **Users**, click the name, for example `ghopper`. The user opens with two ids at the top: **Contact id — this person** (`ct_5NLscr55MQTYmGk072vwnw`) and one **Login id** per login (`usr_6UMSWzqF7e28l72daFjBaa`). Use the login id where a login is asked for, for example the Admin Portal service user. Below are four tabs; the open tab is kept in the address (`#roles`, `#marketing-preferences`, `#identification`).

   <figure><img src="https://712692422-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FHy372bqsaex2cqS3ikhL%2Fuploads%2Fgit-blob-c3156273a87ec6b54e84ff8e5cd373ec9bbf8339%2Fusers-edit-1.png?alt=media" alt="User ghopper with Contact id ct_5NLscr55MQTYmGk072vwnw, Login id usr_6UMSWzqF7e28l72daFjBaa, the tabs User, Roles, Marketing preferences, Identification and the Personal Information block"><figcaption><p>The user, <strong>User</strong> tab.</p></figcaption></figure>
2. On the **User** tab, change the profile and press **Save**:

   | Field                                                                  | Required | What it does                                   | Example                     |
   | ---------------------------------------------------------------------- | -------- | ---------------------------------------------- | --------------------------- |
   | First Name, Last Name                                                  | no       | Name parts.                                    | `Grace`, `Hopper`           |
   | Full Name                                                              | no       | The full form of the name.                     | `Rear Admiral Grace Hopper` |
   | Display Name                                                           | no       | The name in the users list and the page title. | `Grace Hopper`              |
   | Birth Date, Gender                                                     | no       | Profile fields.                                | —                           |
   | Company                                                                | no       | The company of the person.                     | `Acme Labs`                 |
   | Phone                                                                  | no       | A phone on the profile.                        | —                           |
   | Country, Address, Address 2, City, State / Province, ZIP / Postal code | no       | The address.                                   | —                           |

   <figure><img src="https://712692422-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FHy372bqsaex2cqS3ikhL%2Fuploads%2Fgit-blob-3257431712fdb221fc37484935aa248e5d9bbd60%2Fusers-edit-2.png?alt=media" alt="User tab filled: First Name Grace, Last Name Hopper, Full Name Rear Admiral Grace Hopper, Display Name Grace Hopper, Company Acme Labs"><figcaption><p>The profile, changed.</p></figcaption></figure>
3. On the **Roles** tab, tick the roles and press **Save roles**. **Reset** brings back the saved choice. The roles are stored on the person and copied to every login. When the project has AI plans, the tab also has **AI plan** with **Save AI plan**.

   <figure><img src="https://712692422-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FHy372bqsaex2cqS3ikhL%2Fuploads%2Fgit-blob-36de2777486d645fde3f463c55e02111818f194e%2Fusers-edit-4.png?alt=media" alt="Roles tab of Ada Lovelace with Managed only ticked, support-agent and content-editor not ticked, Reset and Save roles"><figcaption><p>The <strong>Roles</strong> tab.</p></figcaption></figure>
4. On the **Marketing preferences** tab, choose what the person receives. The **Marketing** and **Transactional** tabs list your topics, grouped as in [Settings → Communication](/codemash/cloud/membership/settings/communication.md); each topic has one switch per delivery channel it offers (Email, Push, SMS). A switch saves at once.

   <figure><img src="https://712692422-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FHy372bqsaex2cqS3ikhL%2Fuploads%2Fgit-blob-ccdbf43db549ac5cf721be2466ff7cde4e20f6ea%2Fusers-edit-6.png?alt=media" alt="Marketing preferences of Ada Lovelace: Marketing tab, group marketing-newsletters with Newsletter (Email) and Event Invitations (Email, Push), group marketing-promotions with Promotions (Email, Push)"><figcaption><p>The <strong>Marketing preferences</strong> tab.</p></figcaption></figure>
5. The **Identification** tab lists the logins with their type and status. **Map an existing login** attaches a login to this person by its id (`usr_…`) — only for a login that was not linked on its own.

   <figure><img src="https://712692422-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FHy372bqsaex2cqS3ikhL%2Fuploads%2Fgit-blob-9942c12a9d67bca57ed33fcd023826d8fa21b74c%2Fusers-edit-8.png?alt=media" alt="Identification tab: one login ada.lovelace@example.com, type Email, status Registered, and Map an existing login with an input and the Map button"><figcaption><p>The <strong>Identification</strong> tab.</p></figcaption></figure>

{% hint style="warning" %}
Today **Save roles** fails: the toast says *CM-ERRORS-INFRA-NORBIX-001: A temporary internal error occurred* and the roles are not saved. The same call fails from code (`setContactRoles`). Until it is fixed, set the roles on the login with `assignRolePermissions` (below), or pick them when you [add the user](/codemash/cloud/membership/users/new.md); the **Roles** tab does not show roles set that way.
{% endhint %}

<figure><img src="https://712692422-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FHy372bqsaex2cqS3ikhL%2Fuploads%2Fgit-blob-9bf8743776bff5bb4ba048bca814d1095bf5c400%2Fusers-edit-5.png?alt=media" alt="Roles tab after Save roles: an error toast CM-ERRORS-INFRA-NORBIX-001 A temporary internal error occurred"><figcaption><p>The error after <strong>Save roles</strong>.</p></figcaption></figure>

{% hint style="warning" %}
The switches on **Marketing preferences** are always drawn in the off position, and the tab does not reload after a click. The click is saved: after switching **Promotions → Email**, the user's preferences hold `Email: blockedTags Marketing: ["promotions"]`. Reload the page to work from the saved state.
{% endhint %}

<figure><img src="https://712692422-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FHy372bqsaex2cqS3ikhL%2Fuploads%2Fgit-blob-ccdbf43db549ac5cf721be2466ff7cde4e20f6ea%2Fusers-edit-6.png?alt=media" alt="Marketing preferences after a click on Promotions Email: the switches look the same as before"><figcaption><p>After a click: the saved change is not drawn.</p></figcaption></figure>

## Result

After **Save** on the **User** tab, the title shows the new display name and the users list shows it too.

<figure><img src="https://712692422-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FHy372bqsaex2cqS3ikhL%2Fuploads%2Fgit-blob-6be16f4ca91bfc6f65ea5d703cf0692420c53c92%2Fusers-edit-3.png?alt=media" alt="The user after save, title Grace Hopper, with the saved profile fields"><figcaption><p>The saved profile.</p></figcaption></figure>

A change of the user runs the **When updated** trigger — see [Triggers](/codemash/cloud/membership/triggers.md).

## Change or remove it later

* **Delete** — the **Delete** button at the top: [Delete a user](/codemash/cloud/membership/users/delete.md).
* **Block, unblock, verify a login** — the user screen has no buttons for this. Use `blockUser` / `unblockUser` from code ([Block User](/codemash/api-reference/membership/users/block-user.md), [Unblock User](/codemash/api-reference/membership/users/unblock-user.md)).

## Do it from code

```ts
await norbix.hub.membership.updateContact({
  contactId,
  ContactId: contactId, // the id again in the body, see the hint below
  displayName: 'Dorothy Vaughan',
  company: 'Acme Labs',
});
const { item } = await norbix.hub.membership.getContact({ contactId });
console.log(item.displayName, item.company, item.auths.map((a) => a.id));
```

```sh
norbix raw -X PATCH /v2/membership/users/ct_3UQJuVSkkKg4ieb5fsAk5S -b '{"contactId":"ct_3UQJuVSkkKg4ieb5fsAk5S","company":"Acme Labs"}'
```

{% hint style="info" %}
The update request needs the user id in the body as well as in the address; the SDK and the CLI send it only in the address and get *missing required properties including: 'contactId'*. That is why the snippet repeats it as `ContactId` and the CLI line uses `norbix raw`.
{% endhint %}

Roles on a login (works today — pass role **names**, not role ids; an id is accepted but nothing is stored): `await norbix.api.membership.assignRolePermissions({ id: 'usr_54bPhijPmABCWtGf30TeZ1', roles: ['Editor'] })`. The client setup is on the [Membership page](/codemash/cloud/membership.md#use-it-from-code). API: [Update Contact](/codemash/api-reference/membership/users/update-contact.md) · [Get Contact](/codemash/api-reference/membership/users/get-contact.md) · [Assign Role Permissions](/codemash/api-reference/membership/users/assign-role-permissions.md) · [Set Contact Roles](/codemash/api-reference/membership/users/set-contact-roles.md) · [Set Contact Tag Subscription](/codemash/api-reference/membership/users/set-contact-tag-subscription.md) · [Map Auth To User](/codemash/api-reference/membership/users/map-auth-to-user.md)
