> 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/policies/edit.md).

# Edit a policy

Change a policy's permission statements, or look at a system policy.

**Where:** Membership → Policies → click a policy · `/projects/<project>/membership/policies/<policyId>/edit`

## Before you start

* The policy exists — see [Create a policy](/codemash/cloud/membership/policies/new.md). System policies open read only.
* You need the `membership:update` permission on policies.

## Steps

1. Under **Custom Policies**, click the policy, for example `orders-read`. The screen **Editing policy** opens with the saved document. It now has a `pid` key with the policy id (`pol_1oRlzIGnF3lzemVoX1nwyy`) — leave it in place.

   <figure><img src="https://712692422-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FHy372bqsaex2cqS3ikhL%2Fuploads%2Fgit-blob-f14aaba972f8545e8acfef47d4b3b3dda267f971%2Fpolicies-edit-1.png?alt=media" alt="Editing policy orders-read with the saved document and its pid"><figcaption><p>The saved document.</p></figcaption></figure>
2. Change the document, for example add the `invoices` collection to `resources` and change `description`.

   | Key                       | What you change      | Example                                         |
   | ------------------------- | -------------------- | ----------------------------------------------- |
   | `description`             | The text.            | `Read every order and invoice in the database.` |
   | `permissions[].resources` | Add or remove items. | `…:database:collection:invoices`                |

   <figure><img src="https://712692422-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FHy372bqsaex2cqS3ikhL%2Fuploads%2Fgit-blob-8e16080b288613332897df5cc93d53a2e529ad44%2Fpolicies-edit-2.png?alt=media" alt="The edited document with two resources, orders and invoices; Policy document is valid against the schema"><figcaption><p>The changed document, valid.</p></figcaption></figure>
3. Press **Save**.

A **System** policy opens as **Displaying system policy**: the document is shown as a read only tree, with **Cancel** only.

<figure><img src="https://712692422-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FHy372bqsaex2cqS3ikhL%2Fuploads%2Fgit-blob-86381bd2e633a291a2548d59d4a237dcca95ad5b%2Fpolicies-edit-3.png?alt=media" alt="Displaying system policy Membership — full access: allow membership:* on *:*:membership:*:*, pid pol_3lDsaoP8uCtr50wYpCQw7R"><figcaption><p>A system policy, read only.</p></figcaption></figure>

## Result

Cloud goes back to **Policies**. The new permissions apply at once to every role — and through the roles, every user — that carries the policy.

## Change or remove it later

* **Delete** — [Delete a policy](/codemash/cloud/membership/policies/delete.md).

## Do it from code

```ts
const updated = { ...document, pid: id, description: 'Read every invoice and credit note.' };
await norbix.hub.membership.updatePolicy({
  id, policyName: updated.name, description: updated.description,
  policyDocumentJson: JSON.stringify(updated),
});
```

```sh
norbix hub membership policy get pol_1oRlzIGnF3lzemVoX1nwyy
```

`document` and `id` come from the [create example](/codemash/cloud/membership/policies/new.md#do-it-from-code); send the whole document, it replaces the old one. The client setup is on the [Membership page](/codemash/cloud/membership.md#use-it-from-code). API: [Update Policy](/codemash/api-reference/membership/policies/update-policy.md) · [Get Policy](/codemash/api-reference/membership/policies/get-policy.md)
