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

# Attach a Secret to a Function

> 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.



## OpenAPI

````yaml post /v1/functions/{id}/secrets
openapi: 3.0.0
info:
  title: Browserbase API
  description: Browserbase API for 3rd party developers
  version: v1
servers:
  - url: https://api.browserbase.com
    description: Public endpoint
    variables: {}
security:
  - BrowserbaseAuth: []
tags: []
paths:
  /v1/functions/{id}/secrets:
    post:
      summary: Attach a Secret to a Function
      description: >-
        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.
      operationId: Functions_attachSecret
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
            format: uuid
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                secretId:
                  description: >-
                    The id of the project secret to attach (the `id` returned by
                    POST /v1/secrets). Idempotent: re-attaching an
                    already-attached secret succeeds.
                  type: string
                  format: uuid
              required:
                - secretId
      responses:
        '204':
          description: The secret was attached to the function.
        '400':
          description: Invalid request. The Function ID and secret ID must be UUIDs.
          content:
            application/json:
              schema:
                type: object
                properties:
                  statusCode:
                    description: HTTP status code
                    type: integer
                  error:
                    description: HTTP error name
                    type: string
                  message:
                    description: Human-readable error message
                    type: string
                required:
                  - statusCode
                  - error
                  - message
        '404':
          description: The Function or secret does not exist in the project.
          content:
            application/json:
              schema:
                type: object
                properties:
                  statusCode:
                    description: HTTP status code
                    type: integer
                  error:
                    description: HTTP error name
                    type: string
                  message:
                    description: Human-readable error message
                    type: string
                required:
                  - statusCode
                  - error
                  - message
components:
  securitySchemes:
    BrowserbaseAuth:
      type: apiKey
      in: header
      name: X-BB-API-Key
      description: Your [Browserbase API Key](https://www.browserbase.com/settings).

````