# Share a secret with projects

Keep one value in your organization, such as a monitoring service's key, and give it to all of its projects or the ones you choose.

Share an organization's secret with its projects, so that each has it without a copy of its own to keep up to date. To do it, you need Owner or Secret Manager Admin on the organization.

## Share a secret [#share-a-secret]

1. In your organization, click **Access**, then **Secrets**, and then the secret.
2. Click the **Sharing** tab, and then **Change sharing**.
3. Select **All projects**, which includes projects created later, or **Selected projects** and select them.
4. Click **Save**.

Each project has the secret at once, under the same name, as its organization's. Its versions stay the organization's: a new version reaches every project, and a project can't add one.

A project that already has a secret by the same name keeps its own, and gets the shared one only once its own is deleted or renamed.

## Stop sharing it with a project [#stop-sharing-it-with-a-project]

:::warning
A project loses the secret at once, with every grant of it to that project's agents and every binding they made of it. Their commands no longer get it.
:::

1. On the secret's **Sharing** tab, click **Change sharing**.
2. Remove the project, or select **No projects**.
3. Click **Save**.

A project can't delete a secret its organization shares with it. Ask an organization Owner to stop sharing it instead.

## Delete a shared secret [#delete-a-shared-secret]

kosem doesn't delete an organization's secret while projects have it. Stop sharing it with every project, as above, and then delete it.

## Use the API [#use-the-api]

Set your API key ([Call the API](/get-started/call-the-api)), your organization's ID, the secret's ID and the project's ID, then update `availability`:

```sh
export KOSEM_API_KEY='kosem_sk_…'
export KOSEM_ORG='org_01m5r8w2k3e9vbt6g0d4x7qz1h'
export KOSEM_SECRET='sec_01m5rd7wq3e9vbt6g0d4x7qz1p'
export KOSEM_PROJECT='prj_01m5r9dh9mf0ps98ktkap3562c'

curl -s -X PATCH "https://api.kosem.ai/v1/organizations/$KOSEM_ORG/secrets/$KOSEM_SECRET" \
  -H "Authorization: Bearer $KOSEM_API_KEY" \
  -H "Content-Type: application/json" \
  -d "{\"availability\": {\"allProjects\": false, \"projects\": [\"projects/$KOSEM_PROJECT\"]}}"
```

`{"allProjects": true, "projects": []}` shares it with every project, and `{"allProjects": false, "projects": []}` with none.

## Related [#related]

- [Secrets](/concepts/secrets#organization-secrets-and-project-secrets)
- [Create and read a secret](/guides/secrets/create-a-secret)
