> ## Documentation Index
> Fetch the complete documentation index at: https://docs.gumloop.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Create and use an agent-owned secret

> Create a Vault secret and bind it to a custom agent so everyone who can use the agent can make authenticated API requests without direct Vault access.

Use an **Agent-owned** binding when everyone who can use a custom agent should run it with the same API key, including people outside the agent's home team. The secret stays in its personal or team Vault. Sharing the agent lets people use the secret through the agent without giving them direct access to that Vault.

## Before you start

* You need [permission to edit the custom agent](https://docs.gumloop.com/help/sharing/let-someone-edit-an-agent.md) and access to the Vault secret you want to bind.
* In an organization, your role must grant the **Agent-owned credentials** feature. If **Agent-owned** is unavailable, ask an admin to [enable the feature on your role](https://docs.gumloop.com/help/sharing/enable-agent-owned-credentials.md).
* The agent can't be shared with **Anyone**. Set **Public link access** to **No public link** in the [agent's sharing settings](https://docs.gumloop.com/help/sharing/share-an-agent.md).

## Create, bind, and use the secret

**1. Create a secret in Vault**

Open [your Vault](https://www.gumloop.com/personal/customize/vault). Under **Secrets**, click **Add**, enter a name and the API key, and add the API host under **Allowed domains**. Click **Create**.

If you already have a personal or team secret you can access, skip this step. See [Create a secret](https://docs.gumloop.com/core-concepts/agent_sandbox_and_secrets.md#create-a-secret) for details on allowed domains.

**2. Choose who can use the secret**

Open the custom agent. In the right sidebar, select the **Agent** tab, then open **Secrets** under **What I know**.

![The Agent tab and Secrets row highlighted in the custom agent's right sidebar](https://mintlify.s3.us-west-1.amazonaws.com/agenthub/images/agent-secrets/agent-owned-secret-open-secrets.png)

Click **Add secret**. In **Who can use this secret?**, select **Agent-owned** and click **Continue**.

![Agent-owned selected in the secret scope dialog](https://mintlify.s3.us-west-1.amazonaws.com/agenthub/images/agent-secrets/agent-owned-secret-scope.png)

**3. Name and add the binding**

In **Name**, enter the environment-variable name the agent should use, such as `SUPPORT_API_KEY`. Under **Source**, choose **Existing secret**, select the Vault secret, and click **Add**.

![Add secret to agent dialog with SUPPORT\_API\_KEY as the name and Support API Key selected as the secret](https://mintlify.s3.us-west-1.amazonaws.com/agenthub/images/agent-secrets/agent-owned-secret-binding.png)

**4. Use the secret in an API request**

In the agent's chat, ask it to make an API request and name the variable. For example: “List open tickets from the support API. Use `SUPPORT_API_KEY` to authenticate.”

Sandbox code reads the environment variable. For a new Vault secret, the code gets a stand-in instead of the real API key. Gumloop swaps in the real key when the code sends the stand-in in a [supported authentication header](https://docs.gumloop.com/core-concepts/agent_sandbox_and_secrets.md#use-a-secret-in-api-requests) to an allowed domain. Don't ask the agent to print the key or save it to a file.

If multiple bindings use the same environment-variable name, **Agent-owned** takes precedence over **Personal**, which takes precedence over **Team**. See [Which secret does the agent use?](https://docs.gumloop.com/core-concepts/agent_sandbox_and_secrets.md#runtime-resolution).
