---
title: "Attach a Secret to a Function"
method: POST
path: "/v1/functions/{id}/secrets"
---

# Attach a Secret to a Function

`POST /v1/functions/{id}/secrets`

## Request

- Base URL: `https://api.browserbase.com`
- URL: `https://api.browserbase.com/v1/functions/{id}/secrets`
- Auth: API key in header `X-BB-API-Key`

Attach a secret to a Function, taking effect on the Function's next invocation. Note: Attaching a secret that is already attached succeeds to support idempotency.

## Path parameters

- `id` string, uuid, required

## Request body

- object
  - `secretId` string, uuid, required: The id of the project secret to attach (the `id` returned by POST /v1/secrets). Idempotent: re-attaching an already-attached secret succeeds.

## Response `204`

The secret was attached to the function.

## Other responses

- `400`: Invalid request. The Function ID and secret ID must be UUIDs.
- `404`: The Function or secret does not exist in the project.

## Changes

- **2026-10-16** `266d5199a560`: 1 info
  - endpoint added

[Operation history](https://skmtc.dev/browserbase/apis/browserbase-api/changes/v1/functions/:id/secrets/post.md)

---

[API](https://skmtc.dev/browserbase/apis/browserbase-api.md) - [All operations](https://skmtc.dev/browserbase/apis/browserbase-api/llms.txt) - [OpenAPI document](https://skmtc.dev/browserbase/apis/browserbase-api/revisions/106c5f72c742?raw)
