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

# Create event trigger

> Create an event trigger for the specified agent so it runs automatically when the configured provider event fires. Prerequisite gaps that do not prevent the trigger from being saved (e.g. a missing Procore company/project mapping or credentials) are returned in the `warnings` array on the response rather than failing the request. An agent may only have one event trigger — attempting to create a second is rejected with a 409 error.



## OpenAPI

````yaml post /agents/{agent_id}/event-triggers
openapi: 3.0.3
info:
  version: 0.1.1
  title: Datagrid API
  description: Datagrid API
servers:
  - url: https://api.datagrid.com/v1
security:
  - BearerAuth: []
paths:
  /agents/{agent_id}/event-triggers:
    post:
      tags:
        - Event Triggers
      summary: Create event trigger
      description: >-
        Create an event trigger for the specified agent so it runs automatically
        when the configured provider event fires. Prerequisite gaps that do not
        prevent the trigger from being saved (e.g. a missing Procore
        company/project mapping or credentials) are returned in the `warnings`
        array on the response rather than failing the request. An agent may only
        have one event trigger — attempting to create a second is rejected with
        a 409 error.
      operationId: CreateAgentEventTrigger
      parameters:
        - name: agent_id
          in: path
          required: true
          description: The ID of the agent to create the event trigger for.
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateAgentEventTriggerRequest'
      responses:
        '201':
          description: Created event trigger
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AgentEventTriggerMutationResult'
        '400':
          description: >-
            Bad request. The body failed validation — e.g. an unknown property,
            an invalid `trigger_source`, a blank or over-long `trigger_event`,
            or an over-long `name`/`description`/`run_conditions`.
        '404':
          description: >-
            Not found. The specified agent does not exist, or the authenticated
            API key does not have permission to access it.
        '409':
          description: Conflict. The agent already has an event trigger.
        '429':
          description: >-
            Rate limit exceeded. The request has been throttled because the rate
            limit for this endpoint has been reached. Check the `Retry-After`
            response header and retry after the specified number of seconds.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RateLimitError'
components:
  schemas:
    CreateAgentEventTriggerRequest:
      type: object
      required:
        - enabled
        - trigger_source
        - trigger_event
      properties:
        enabled:
          type: boolean
          description: >-
            Whether the trigger should be active immediately. Set to `false` to
            create it in a paused state.
        trigger_source:
          $ref: '#/components/schemas/AgentEventTriggerSource'
        trigger_event:
          type: string
          maxLength: 255
          description: >-
            The event that fires the agent, in `"ResourceName:eventType"` format
            (e.g. `"Tasks:create"`). Required even when `enabled` is `false`.
        name:
          type: string
          description: Optional name for the App Event automation.
          maxLength: 255
          nullable: true
        description:
          type: string
          description: Optional description of what the App Event automation does.
          maxLength: 1000
          nullable: true
        run_conditions:
          type: string
          description: >-
            Optional natural-language conditions that must hold for the agent to
            run when the event fires.
          maxLength: 3000
          nullable: true
        response_thread:
          $ref: '#/components/schemas/AgentEventTriggerResponseThread'
          nullable: true
    AgentEventTriggerMutationResult:
      allOf:
        - $ref: '#/components/schemas/AgentEventTrigger'
        - type: object
          required:
            - warnings
          properties:
            warnings:
              type: array
              description: >-
                Non-fatal issues surfaced while wiring up the trigger (e.g.
                Procore company/project/credential prerequisite gaps). An empty
                array means the trigger was configured with no issues. Each
                entry pairs a stable machine-readable `code` with a
                human-readable `message`.
              items:
                type: object
                required:
                  - code
                  - message
                properties:
                  code:
                    type: string
                    description: >-
                      Stable machine-readable identifier for the warning (e.g.
                      `procore_not_connected`, `registration_failed`). Safe to
                      branch on without parsing `message`.
                  message:
                    type: string
                    description: Human-readable explanation of the warning.
    RateLimitError:
      type: object
      description: >-
        Returned when the rate limit is exceeded. Rate limits are enforced per
        teamspace, endpoint path, and HTTP method over a 60-second sliding
        window. Each endpoint may have its own limit — check the
        X-RateLimit-Limit response header for the effective value.
      required:
        - error
        - message
        - retryable
        - status_code
      properties:
        status_code:
          type: integer
          description: The HTTP status code (429).
        statusCode:
          type: integer
          deprecated: true
          description: Deprecated. Use status_code instead.
        error:
          type: string
          enum:
            - rate_limit_exceeded
          description: The error code identifying this as a rate limit error.
        message:
          type: string
          description: A human-readable error message.
        mitigation:
          type: string
          description: Suggested action to resolve the error.
        retryable:
          type: boolean
          description: Whether the request can be retried after a delay.
        details:
          type: object
          properties:
            reason:
              type: string
              description: A detailed explanation of why the rate limit was exceeded.
    AgentEventTriggerSource:
      type: string
      description: >-
        The external provider that emits the event. Currently only Procore is
        supported.
      enum:
        - procore
    AgentEventTriggerResponseThread:
      type: string
      description: >-
        Controls how the agent's response conversation is threaded when the
        trigger fires. `create_new_thread_each_time` starts a fresh thread for
        every event; when omitted, responses reuse a single thread.
      enum:
        - create_new_thread_each_time
    AgentEventTrigger:
      type: object
      required:
        - object
        - id
        - enabled
        - trigger_source
        - trigger_event
        - name
        - description
        - run_conditions
        - response_thread
        - created_at
        - updated_at
      properties:
        object:
          type: string
          enum:
            - event_trigger
          description: The object type, always 'event_trigger'.
        id:
          type: string
          description: Unique identifier for the event trigger.
        enabled:
          type: boolean
          description: >-
            Whether the trigger is active. When `false` the agent does not run
            in response to the event until it is re-enabled.
        trigger_source:
          $ref: '#/components/schemas/AgentEventTriggerSource'
        trigger_event:
          type: string
          description: >-
            The event that fires the agent, in `"ResourceName:eventType"` format
            (e.g. `"Tasks:create"`, `"Project Users:update"`).
        name:
          type: string
          description: User-provided name for the App Event automation.
          nullable: true
        description:
          type: string
          description: User-provided description of what the App Event automation does.
          nullable: true
        run_conditions:
          type: string
          description: >-
            Optional natural-language conditions that must hold for the agent to
            run when the event fires. When null, the agent runs on every
            matching event.
          nullable: true
        response_thread:
          $ref: '#/components/schemas/AgentEventTriggerResponseThread'
          nullable: true
        created_at:
          type: string
          format: date-time
          description: ISO 8601 timestamp of when the event trigger was created.
        updated_at:
          type: string
          format: date-time
          description: ISO 8601 timestamp of the last modification to the event trigger.
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer

````