> ## 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 an app-event agentic automation

> Create an automation that runs an agent when an event happens in a connected app. When `enabled` is `true`, the webhook for the app is registered before the automation is saved. If the save fails, the webhook is removed again. `agent_id` is the ID of the agent and is in the body. The caller needs the manage automations permission.



## OpenAPI

````yaml post /agentic-automations/event
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:
  /agentic-automations/event:
    post:
      tags:
        - Agentic Automations
      summary: Create an app-event agentic automation
      description: >-
        Create an automation that runs an agent when an event happens in a
        connected app. When `enabled` is `true`, the webhook for the app is
        registered before the automation is saved. If the save fails, the
        webhook is removed again. `agent_id` is the ID of the agent and is in
        the body. The caller needs the manage automations permission.
      operationId: CreateAppEventAgenticAutomation
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateAppEventAgenticAutomationRequest'
      responses:
        '201':
          description: Created automation
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AppEventAgenticAutomation'
        '400':
          description: >-
            Bad request. The message says which field is wrong. If more than one
            field is wrong, it says the first one. For example, `trigger_event`
            is not in the form `resource:event`, or `application_id` is not an
            app that can send events.
        '403':
          description: >-
            Forbidden. The caller does not have the manage automations
            permission.
        '404':
          description: Not found. The agent is not visible to the caller.
        '409':
          description: >-
            Conflict. The agent already has an app-event automation. An agent
            can have only one.
        '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'
        '502':
          description: >-
            The app rejected or failed the webhook registration. Nothing is
            saved.
components:
  schemas:
    CreateAppEventAgenticAutomationRequest:
      type: object
      required:
        - agent_id
        - name
        - application_id
        - trigger_event
      properties:
        agent_id:
          type: string
          description: The ID of the agent this automation runs.
        name:
          type: string
          description: Human-readable name for the automation.
          maxLength: 255
        description:
          type: string
          description: Optional free-text description of what this automation does.
          maxLength: 65535
          nullable: true
        enabled:
          type: boolean
          description: >-
            Whether the automation is active. When `true`, the app webhook is
            registered during this request. When `false`, no webhook is
            registered and the automation is saved paused. Defaults to `true`
            when omitted or null.
          nullable: true
        application_id:
          type: string
          description: The connector that sends the event.
          example: connector.procore
          maxLength: 255
        trigger_event:
          type: string
          description: The event to run on, in the form `resource:event`.
          example: RFIs:create
          maxLength: 255
        run_conditions:
          type: string
          description: >-
            Optional free-text conditions an event must meet before the agent
            runs.
          maxLength: 65535
          nullable: true
        output_channel_type:
          type: string
          description: Optional additional delivery transport.
          maxLength: 255
          nullable: true
        output_channel_id:
          type: string
          description: Optional additional delivery address.
          maxLength: 255
          nullable: true
    AppEventAgenticAutomation:
      type: object
      required:
        - object
        - id
        - kind
        - agent_id
        - name
        - description
        - enabled
        - output_channel_type
        - output_channel_id
        - creator_user_id
        - last_updated_by_id
        - created_at
        - updated_at
        - app_event
      properties:
        object:
          type: string
          enum:
            - agentic_automation
          description: The object type, always 'agentic_automation'.
        id:
          type: string
          description: Unique identifier for the automation.
        kind:
          type: string
          enum:
            - app_event
          description: What the automation is. `app_event` for this route.
        agent_id:
          type: string
          description: The ID of the agent this automation runs.
        name:
          type: string
          description: Human-readable name of the automation.
        description:
          type: string
          description: Free-text description of what this automation does.
          nullable: true
        enabled:
          type: boolean
          description: Whether the automation is active.
        output_channel_type:
          type: string
          description: Additional delivery transport, when one is stored.
          nullable: true
        output_channel_id:
          type: string
          description: Additional delivery address, when one is stored.
          nullable: true
        creator_user_id:
          type: string
          description: The user who created the automation.
        last_updated_by_id:
          type: string
          description: The user who last updated the automation.
        created_at:
          type: string
          format: date-time
          description: ISO 8601 timestamp of when the automation was created.
        updated_at:
          type: string
          format: date-time
          description: ISO 8601 timestamp of the last modification.
        app_event:
          type: object
          required:
            - application_id
            - trigger_event
            - source_scope
            - source_metadata
            - run_conditions
            - external_subscription_id
            - expires_at
          properties:
            application_id:
              type: string
              description: The connector that sends the event.
              example: connector.procore
            trigger_event:
              type: string
              description: The event the automation runs on.
              example: RFIs:create
            source_scope:
              type: string
              description: >-
                The scope the app registered the webhook for. Empty when no
                webhook is registered.
            source_metadata:
              type: object
              description: >-
                App-specific details about the registered webhook, such as the
                Procore company and project.
              additionalProperties: true
              nullable: true
            run_conditions:
              type: string
              description: Conditions an event must meet before the agent runs.
              nullable: true
            external_subscription_id:
              type: string
              description: >-
                The app's ID for the registered webhook. Null when the
                automation was saved paused.
              nullable: true
            expires_at:
              type: string
              format: date-time
              description: When the app webhook expires, if it does.
              nullable: true
    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.
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer

````

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