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

# Create a Webhook

> Register an HTTPS endpoint to receive events for this project. The response includes the signing secret, which is shown only here and when the secret is rotated. Store it before discarding the response. An endpoint may only be registered once per project.



## OpenAPI

````yaml post /v1/webhooks
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/webhooks:
    post:
      summary: Create a Webhook
      description: >-
        Register an HTTPS endpoint to receive events for this project. The
        response includes the signing secret, which is shown only here and when
        the secret is rotated. Store it before discarding the response. An
        endpoint may only be registered once per project.
      operationId: Webhooks_create
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                endpoint:
                  description: >-
                    HTTPS URL that event deliveries are POSTed to. Must be
                    publicly reachable.
                  type: string
                  format: uri
                  maxLength: 2048
                  pattern: ^https://[^/?#]+
                eventTypes:
                  description: >-
                    Event types this webhook subscribes to. Unknown types are
                    rejected.
                  type: array
                  items:
                    type: string
                    enum:
                      - functions.builds.running
                      - functions.builds.completed
                      - functions.builds.failed
                      - functions.invocations.pending
                      - functions.invocations.running
                      - functions.invocations.completed
                      - functions.invocations.failed
                  minItems: 1
                  uniqueItems: true
              additionalProperties: false
              required:
                - endpoint
                - eventTypes
      responses:
        '201':
          description: The webhook has been created.
          content:
            application/json:
              schema:
                description: The created webhook, including its signing secret.
                allOf:
                  - $ref: '#/components/schemas/Webhook'
                  - type: object
                    properties:
                      secret:
                        description: >-
                          HMAC-SHA256 signing secret, prefixed `whsec_`. Shown
                          once here; store it now. Use it to verify the
                          signature on every delivery.
                        type: string
                    required:
                      - secret
      x-codeSamples:
        - lang: javascript
          label: Node.js
          source: |-
            import Browserbase from "@browserbasehq/sdk";

            const bb = new Browserbase({
              apiKey: process.env.BROWSERBASE_API_KEY,
            });

            const webhook = await bb.webhooks.create({
              endpoint: "https://example.com/browserbase/events",
              eventTypes: ["functions.invocations.completed"],
            });

            console.log(webhook.secret);
        - lang: python
          label: Python
          source: |-
            import os

            from browserbase import Browserbase

            bb = Browserbase(api_key=os.environ["BROWSERBASE_API_KEY"])

            webhook = bb.webhooks.create(
                endpoint="https://example.com/browserbase/events",
                event_types=["functions.invocations.completed"],
            )

            print(webhook.secret)
        - lang: bash
          label: cURL
          source: |-
            curl --request POST \
              --url https://api.browserbase.com/v1/webhooks \
              --header 'Content-Type: application/json' \
              --header "X-BB-API-Key: $BROWSERBASE_API_KEY" \
              --data '{
                "endpoint": "https://example.com/browserbase/events",
                "eventTypes": ["functions.invocations.completed"]
              }'
components:
  schemas:
    Webhook:
      description: >-
        A delivery endpoint for a project. Browserbase POSTs a signed event to
        it whenever one of its subscribed event types occurs. The signing secret
        is returned only when it is created or rotated.
      type: object
      properties:
        id:
          description: Unique identifier for the webhook.
          type: string
        projectId:
          description: The project the webhook belongs to.
          type: string
        endpoint:
          description: >-
            HTTPS URL that event deliveries are POSTed to. Must be publicly
            reachable.
          type: string
          format: uri
          maxLength: 2048
          pattern: ^https://[^/?#]+
        eventTypes:
          description: Event types this webhook subscribes to. Unknown types are rejected.
          type: array
          items:
            type: string
            enum:
              - functions.builds.running
              - functions.builds.completed
              - functions.builds.failed
              - functions.invocations.pending
              - functions.invocations.running
              - functions.invocations.completed
              - functions.invocations.failed
          minItems: 1
          uniqueItems: true
        createdAt:
          type: string
          format: date-time
        updatedAt:
          type: string
          format: date-time
      required:
        - id
        - projectId
        - endpoint
        - eventTypes
        - createdAt
        - updatedAt
  securitySchemes:
    BrowserbaseAuth:
      type: apiKey
      in: header
      name: X-BB-API-Key
      description: Your [Browserbase API Key](https://www.browserbase.com/settings).

````