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

# Create a webhook waiter

> **Private beta:** [request access](https://trigger.dev/webhooks-beta) to use webhooks.
Create a waiter on an endpoint. A waiter is a waitpoint that completes when a matching delivery arrives on the endpoint, so a run waiting on its id resumes with the verified event. It only matches deliveries that arrive after it was created. Omit `match` to get a waiter with its own `url`, for providers that take a webhook URL per request.



## OpenAPI

````yaml v3-openapi POST /api/v1/webhooks/endpoints/{endpointId}/waiters
openapi: 3.1.0
info:
  title: Trigger.dev v3 REST API
  description: >-
    The REST API lets you trigger and manage runs on Trigger.dev. You can
    trigger a run, get the status of a run, and get the results of a run. 
  version: 2024-04
  license:
    name: Apache 2.0
    url: https://www.apache.org/licenses/LICENSE-2.0.html
servers:
  - url: https://api.trigger.dev
    description: Trigger.dev API
security: []
paths:
  /api/v1/webhooks/endpoints/{endpointId}/waiters:
    parameters:
      - $ref: '#/components/parameters/webhookEndpointId'
    post:
      tags:
        - webhooks
      summary: Create a webhook waiter
      description: >-
        **Private beta:** [request access](https://trigger.dev/webhooks-beta) to
        use webhooks.

        Create a waiter on an endpoint. A waiter is a waitpoint that completes
        when a matching delivery arrives on the endpoint, so a run waiting on
        its id resumes with the verified event. It only matches deliveries that
        arrive after it was created. Omit `match` to get a waiter with its own
        `url`, for providers that take a webhook URL per request.
      operationId: create_webhook_waiter_v1
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateWebhookWaiterRequest'
      responses:
        '200':
          description: Waiter created, or the existing waiter for this idempotency key
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CreateWebhookWaiterResponse'
        '401':
          description: Unauthorized request
        '404':
          description: >-
            No active endpoint with this id in the environment's current
            deployment
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WebhookWaiterErrorResponse'
        '422':
          description: >-
            A limit was reached (`webhook_waiter_limit`), the filter doesn't
            parse (`webhook_filter_invalid`), or the request is invalid
            (`invalid_request`), for example an unknown `match` path or a bad
            `timeout`
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WebhookWaiterErrorResponse'
      security:
        - secretKey: []
      x-codeSamples:
        - lang: typescript
          source: |-
            import { webhooks } from "@trigger.dev/sdk";
            import { stripe } from "./trigger/stripe";

            const waiter = await webhooks.waiter.create(stripe, {
              match: { "event.data.object.metadata.orderId": orderId },
              timeout: "1h",
            });

            // Wait on it inside a task
            const { event } = await webhooks.waiter.wait(waiter.id).unwrap();
        - lang: curl
          label: Create a webhook waiter
          source: >-
            curl -X POST
            "https://api.trigger.dev/api/v1/webhooks/endpoints/stripe/waiters" \
              -H "Authorization: Bearer $TRIGGER_SECRET_KEY" \
              -H "Content-Type: application/json" \
              -d '{"match": {"event.data.object.metadata.orderId": "order_123"}, "timeout": "1h"}'
components:
  parameters:
    webhookEndpointId:
      in: path
      name: endpointId
      required: true
      schema:
        type: string
      description: >-
        The endpoint's declared id (the `id` passed to
        `webhooks.endpoint.define`) or its `wh_` id. A value starting with `wh_`
        is always a generated id, since declared ids can't start with `wh_`. A
        declared id names the endpoint's declared instance in the key's
        environment.
      example: stripe
  schemas:
    CreateWebhookWaiterRequest:
      type: object
      properties:
        match:
          type: object
          description: >-
            Up to five paths, each mapped to the value it must equal. `event.*`
            reads the event body, `header.*` a request header (case-insensitive)
            and `webhook.*` the endpoint (`id`, `source`, `externalRef`,
            `tenantId` or `deliveryId`). Omit it to create a waiter with its own
            `url`.
          additionalProperties:
            oneOf:
              - type: string
              - type: number
              - type: boolean
          example:
            event.type: payment_intent.succeeded
            event.data.object.metadata.orderId: order_123
        filter:
          type: string
          description: >-
            A [filter](/webhooks/filters) the event must also pass, checked
            after `match`.
          example: event.data.object.amount > 1000
        timeout:
          type: string
          description: >-
            A duration such as `30m` or `1h`, or an ISO 8601 date. Defaults to
            24 hours, up to 90 days.
          example: 1h
        tags:
          oneOf:
            - type: string
            - type: array
              items:
                type: string
          description: >-
            Up to 10 tags, added to the `webhook:<endpoint id>` tag every waiter
            gets.
        idempotencyKey:
          type: string
          description: >-
            A create with a key already used in the environment returns the
            original waiter with `isCached: true`, even if it has completed.
        idempotencyKeyTTL:
          type: string
          description: How long the idempotency key lasts, such as `1h` or `30d`.
    CreateWebhookWaiterResponse:
      type: object
      required:
        - id
        - expiresAt
        - isCached
      properties:
        id:
          type: string
          description: >-
            The waiter's id, which is also its waitpoint id. Wait on it with
            `webhooks.waiter.wait()` or `wait.forToken()`.
          example: waitpoint_abc123
        url:
          type: string
          description: >-
            Only for a waiter created without `match`: the URL to give the
            provider as its per-request webhook. A delivery to it is verified
            with the endpoint's source and resumes only this waiter.
        expiresAt:
          type: string
          format: date-time
          description: When the waiter times out.
        isCached:
          type: boolean
          description: >-
            `true` if an existing waiter was returned for the same
            `idempotencyKey`.
    WebhookWaiterErrorResponse:
      type: object
      required:
        - error
        - code
      properties:
        error:
          type: string
        code:
          type: string
          enum:
            - webhook_waiter_limit
            - webhook_endpoint_not_found
            - webhook_filter_invalid
            - invalid_request
        reason:
          type: string
          enum:
            - environment_limit
            - endpoint_limit
            - shape_limit
            - timeout_too_long
          description: For `webhook_waiter_limit`, which limit was reached.
  securitySchemes:
    secretKey:
      type: http
      scheme: bearer
      description: >
        Use a named environment API key. It starts with `tr_dev_sk_`,
        `tr_prod_sk_`, `tr_stg_sk_`, etc.


        Create a named API key in the API Keys section of your Trigger.dev
        project dashboard. Choose the narrowest access preset that supports your
        integration.


        Our TypeScript SDK will default to using the value of the
        `TRIGGER_SECRET_KEY` environment variable if it is set. If you are using
        the SDK in a different environment, you can set the key using the
        `configure` function.


        ```typescript

        import { configure } from "@trigger.dev/sdk";


        configure({ accessToken: "tr_dev_sk_1234" });

        ```

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.