> ## 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 an agent trigger

> Create a `schedule` or `webhook` trigger.

A schedule takes exactly one of `cron_expression` (recurring, five-field cron) or `run_at` (one time, ISO 8601). `timezone` defaults to the caller's profile timezone. A webhook takes `prompt` and returns `webhook_url` in this response only; the URL embeds the trigger's secret, so store it or fetch it again from the reveal endpoint.

Connector-event triggers and agent-built triggers cannot be created here. Team API keys are not accepted: a trigger runs later on the creating member's credentials.




## OpenAPI

````yaml post /agents/{agent_id}/triggers
openapi: 3.0.0
info:
  title: Public API
  version: 1.0.0
servers:
  - url: https://api.gumloop.com/api/v1
security: []
paths:
  /agents/{agent_id}/triggers:
    post:
      tags:
        - Agents
      summary: Create an agent trigger
      description: >
        Create a `schedule` or `webhook` trigger.


        A schedule takes exactly one of `cron_expression` (recurring, five-field
        cron) or `run_at` (one time, ISO 8601). `timezone` defaults to the
        caller's profile timezone. A webhook takes `prompt` and returns
        `webhook_url` in this response only; the URL embeds the trigger's
        secret, so store it or fetch it again from the reveal endpoint.


        Connector-event triggers and agent-built triggers cannot be created
        here. Team API keys are not accepted: a trigger runs later on the
        creating member's credentials.
      operationId: createAgentTrigger
      parameters:
        - in: path
          name: agent_id
          required: true
          schema:
            type: string
          description: ID of a custom agent.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - type
                - prompt
              properties:
                type:
                  type: string
                  enum:
                    - schedule
                    - webhook
                prompt:
                  type: string
                  description: The message the agent receives when the trigger fires.
                name:
                  type: string
                  nullable: true
                  description: Label shown in the triggers list.
                cron_expression:
                  type: string
                  nullable: true
                  description: Schedule only. Five-field cron, e.g. `0 9 * * 1-5`.
                run_at:
                  type: string
                  format: date-time
                  nullable: true
                  description: >-
                    Schedule only. One-time run; must be in the future.
                    Interpreted in `timezone` when it has no offset.
                timezone:
                  type: string
                  nullable: true
                  description: >-
                    Schedule only. IANA name. Defaults to the caller's profile
                    timezone.
                pass_raw_data:
                  type: boolean
                  default: false
                  description: >-
                    Webhook only. Forward the request body to the agent instead
                    of `prompt`.
                enabled:
                  type: boolean
                  default: true
                max_failures:
                  type: integer
                  nullable: true
                  description: >-
                    Consecutive failures before the trigger disables itself.
                    Defaults to 3 (1 for one-time runs).
            examples:
              schedule:
                summary: Weekday schedule
                value:
                  type: schedule
                  name: Morning digest
                  prompt: Summarize overnight support tickets.
                  cron_expression: 0 9 * * 1-5
                  timezone: America/Los_Angeles
              webhook:
                summary: Webhook
                value:
                  type: webhook
                  prompt: Handle the incoming ticket.
      responses:
        '201':
          description: >-
            The created trigger. For a webhook, `webhook_url` is populated here
            only.
          content:
            application/json:
              schema:
                type: object
                properties:
                  trigger:
                    $ref: '#/components/schemas/AgentTrigger'
        '400':
          description: >-
            Invalid body (`trigger_invalid_cron_expression`,
            `trigger_run_at_in_past`, `trigger_invalid_timezone`), or a platform
            agent (`agent_not_customizable`).
        '401':
          description: Unauthorized — missing or invalid API key, or a team API key.
        '403':
          description: Forbidden — the caller cannot create triggers on this agent.
        '404':
          description: Agent not found.
      security:
        - bearerAuth: []
      x-codeSamples:
        - lang: bash
          label: cURL
          source: >
            curl -X POST
            'https://api.gumloop.com/api/v1/agents/abc123DEFghiJKL/triggers' \
              -H 'Authorization: Bearer YOUR_ACCESS_TOKEN' \
              -H 'Content-Type: application/json' \
              -d '{
                "type": "schedule",
                "name": "Morning digest",
                "prompt": "Summarize overnight support tickets.",
                "cron_expression": "0 9 * * 1-5",
                "timezone": "America/Los_Angeles"
              }'
        - lang: python
          label: Python
          source: |
            from gumloop import Gumloop

            client = Gumloop(access_token="YOUR_ACCESS_TOKEN")

            schedule = client.agents.create_trigger(
                "abc123DEFghiJKL",
                type="schedule",
                name="Morning digest",
                prompt="Summarize overnight support tickets.",
                cron_expression="0 9 * * 1-5",
                timezone="America/Los_Angeles",
            )

            webhook = client.agents.create_trigger(
                "abc123DEFghiJKL", type="webhook", prompt="Handle the incoming ticket."
            )
            print(webhook.trigger.webhook_url)
components:
  schemas:
    AgentTrigger:
      type: object
      properties:
        id:
          type: string
          example: trg_7f1a2b
        agent_id:
          type: string
          example: abc123DEFghiJKL
        type:
          type: string
          description: >-
            `schedule` and `webhook` can be created, fully edited and deleted
            through the API. Other types (connector events, agent-built
            triggers) can be renamed, reworded, paused and resumed, but their
            settings live on the trigger page.
          example: schedule
        name:
          type: string
          nullable: true
        prompt:
          type: string
          nullable: true
          description: The message the agent receives when the trigger fires.
        cron_expression:
          type: string
          nullable: true
          description: Five-field cron, for recurring schedules.
          example: 0 9 * * 1-5
        run_at:
          type: string
          format: date-time
          nullable: true
          description: One-time run, for `schedule` triggers created with `run_at`.
        timezone:
          type: string
          nullable: true
          example: America/Los_Angeles
        pass_raw_data:
          type: boolean
          nullable: true
          description: >-
            Webhook only. `true` forwards the request body to the agent instead
            of `prompt`.
        enabled:
          type: boolean
        status:
          type: string
          nullable: true
        max_failures:
          type: integer
          nullable: true
          description: Consecutive failures before the trigger disables itself.
        webhook_url:
          type: string
          nullable: true
          description: >-
            Only on the create response. Fetch it later with `GET
            /agents/{agent_id}/triggers/{trigger_id}/webhook-url`; it embeds the
            trigger's secret.
        created_at:
          type: string
          format: date-time
          nullable: true
        last_run_at:
          type: string
          format: date-time
          nullable: true
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: >-
        A personal API key or an [OAuth 2.0](/api-reference/oauth) access token.
        Personal API keys also require the `x-auth-key` header with your user
        ID.

````