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

# Save trigger definition

> Create and save a new trigger definition for Jira, Jira Automation, Slack, Linear, Cron, generic Webhook, or HackerOne sources.



## OpenAPI

````yaml https://app.cotool.ai/api/docs/openapi.json post /api/agents/{agentId}/trigger/save
openapi: 3.1.0
info:
  title: Cotool API
  version: 1.0.0
  description: >-
    # Cotool API Documentation


    The Cotool API allows you to interact with the Cotool platform
    programmatically, enabling you to build powerful integrations and automate
    your workflows.


    ## Getting an API Key


    Follow these steps to generate your API key:


    1. **Log in** to the Cotool web interface

    2. **Navigate** to `/settings/api-keys`

    3. **Click** "Generate Key"

    4. **Copy and store** your API key securely ⚠️ *It won't be shown again*


    ## API Key Authentication


    For programmatic access and integrations, use your API key with the
    Authorization header:


    ```http

    Authorization: Bearer your_api_key_here

    ```


    ```bash

    curl -X GET "https://app.cotool.ai/api/endpoint" \
      -H "Authorization: Bearer your_api_key_here" \
      -H "Content-Type: application/json"
    ```
servers:
  - url: https://app.cotool.ai
    description: Production server
security:
  - ApiKeyAuth: []
paths:
  /api/agents/{agentId}/trigger/save:
    post:
      tags:
        - Agent Triggers
      summary: Save trigger definition
      description: >-
        Create and save a new trigger definition for Jira, Jira Automation,
        Slack, Linear, Cron, generic Webhook, or HackerOne sources.
      parameters:
        - in: path
          name: agentId
          description: Unique identifier of the agent
          schema:
            type: string
            format: uuid
            description: Unique identifier of the agent
          required: true
      requestBody:
        content:
          application/json:
            schema:
              oneOf:
                - type: object
                  properties:
                    triggerId:
                      type: string
                      format: uuid
                      description: Unique identifier for the trigger
                    name:
                      type: string
                      description: Display name for the trigger
                    description:
                      type: string
                      description: Optional description of what this trigger does
                    secret:
                      type: string
                      description: Secret for webhook authentication
                    webhookUrl:
                      type: string
                      description: Webhook URL for Jira to call
                    source:
                      type: string
                      const: jira
                    createAlert:
                      type: boolean
                      description: Whether each trigger invocation should create an alert
                  required:
                    - triggerId
                    - name
                    - secret
                    - webhookUrl
                    - source
                - type: object
                  properties:
                    triggerId:
                      type: string
                      format: uuid
                      description: Unique identifier for the trigger
                    name:
                      type: string
                      description: Display name for the trigger
                    description:
                      type: string
                      description: Optional description of what this trigger does
                    secret:
                      type: string
                      description: Authentication token for Jira Automation
                    webhookUrl:
                      type: string
                      description: Webhook URL for Jira Automation to call
                    source:
                      type: string
                      const: jira-automation
                    createAlert:
                      type: boolean
                      description: Whether each trigger invocation should create an alert
                  required:
                    - triggerId
                    - name
                    - secret
                    - webhookUrl
                    - source
                - type: object
                  properties:
                    name:
                      type: string
                      description: Display name for the trigger
                    description:
                      type: string
                      description: Optional description of what this trigger does
                    source:
                      type: string
                      const: slack
                    allowedUserIds:
                      type: array
                      items:
                        type: string
                      description: >-
                        Optional array of Slack user IDs allowed to trigger this
                        agent
                    allowedUsergroupIds:
                      type: array
                      items:
                        type: string
                      description: >-
                        Optional array of Slack usergroup IDs allowed to trigger
                        this agent
                    allowedChannelIds:
                      type: array
                      items:
                        type: string
                      description: >-
                        Optional array of Slack channel IDs where this trigger
                        is allowed
                    createAlert:
                      type: boolean
                      description: Whether each trigger invocation should create an alert
                  required:
                    - name
                    - source
                - type: object
                  properties:
                    triggerId:
                      type: string
                      format: uuid
                      description: >-
                        Unique identifier for the trigger (required for
                        legacy-webhook mode)
                    name:
                      type: string
                      description: Display name for the trigger
                    description:
                      type: string
                      description: Optional description of what this trigger does
                    secret:
                      type: string
                      description: >-
                        Secret for webhook authentication (required for
                        legacy-webhook mode)
                    webhookUrl:
                      type: string
                      description: >-
                        Webhook URL for Linear to call (required for
                        legacy-webhook mode)
                    source:
                      type: string
                      const: linear
                    linearMode:
                      type: string
                      enum:
                        - agent-session
                        - legacy-webhook
                      description: Agent Session mode (default) or legacy webhook mode
                    createAlert:
                      type: boolean
                      description: Whether each trigger invocation should create an alert
                  required:
                    - name
                    - source
                - type: object
                  properties:
                    name:
                      type: string
                      description: Display name for the trigger
                    description:
                      type: string
                      description: Optional description of what this trigger does
                    source:
                      type: string
                      const: cron
                    schedule:
                      type: string
                      description: >-
                        Cron schedule expression (e.g., "0 9 * * 1-5" for
                        weekdays at 9 AM)
                    createAlert:
                      type: boolean
                      description: Whether each trigger invocation should create an alert
                  required:
                    - name
                    - source
                    - schedule
                - type: object
                  properties:
                    triggerId:
                      type: string
                      format: uuid
                      description: Unique identifier for the trigger
                    name:
                      type: string
                      description: Display name for the trigger
                    description:
                      type: string
                      description: Optional description of what this trigger does
                    secret:
                      type: string
                      description: Authentication token for the webhook
                    webhookUrl:
                      type: string
                      description: Webhook URL for external services to call
                    source:
                      type: string
                      const: webhook
                    createAlert:
                      type: boolean
                      description: Whether each trigger invocation should create an alert
                  required:
                    - triggerId
                    - name
                    - secret
                    - webhookUrl
                    - source
                - type: object
                  properties:
                    triggerId:
                      type: string
                      format: uuid
                      description: Unique identifier for the trigger
                    name:
                      type: string
                      description: Display name for the trigger
                    description:
                      type: string
                      description: Optional description of what this trigger does
                    emailAddress:
                      type: string
                      description: Email address for the trigger
                    source:
                      type: string
                      const: email
                    createAlert:
                      type: boolean
                      description: Whether each trigger invocation should create an alert
                  required:
                    - triggerId
                    - name
                    - emailAddress
                    - source
                - type: object
                  properties:
                    triggerId:
                      type: string
                      format: uuid
                      description: Unique identifier for the trigger
                    name:
                      type: string
                      description: Display name for the trigger
                    description:
                      type: string
                      description: Optional description of what this trigger does
                    secret:
                      type: string
                      description: >-
                        HackerOne signing secret used to verify the
                        X-H1-Signature header
                    webhookUrl:
                      type: string
                      description: Webhook URL for HackerOne to call
                    source:
                      type: string
                      const: hackerone
                    createAlert:
                      type: boolean
                      description: Whether each trigger invocation should create an alert
                  required:
                    - triggerId
                    - name
                    - secret
                    - webhookUrl
                    - source
                - type: object
                  properties:
                    triggerId:
                      type: string
                      format: uuid
                      description: Unique identifier for the trigger
                    name:
                      type: string
                      description: Display name for the trigger
                    description:
                      type: string
                      description: Optional description of what this trigger does
                    secret:
                      type: string
                      description: >-
                        Bugcrowd-generated signing secret used to verify the
                        X-Bugcrowd-Digest signature
                    webhookUrl:
                      type: string
                      description: Webhook URL for Bugcrowd to call
                    source:
                      type: string
                      const: bugcrowd
                    createAlert:
                      type: boolean
                      description: Whether each trigger invocation should create an alert
                  required:
                    - triggerId
                    - name
                    - secret
                    - webhookUrl
                    - source
              description: >-
                Request body for creating a new trigger, with different fields
                required based on the source type
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  data:
                    type: object
                    properties:
                      id:
                        type: string
                        format: uuid
                      agentId:
                        type: string
                        format: uuid
                      organizationId:
                        type: string
                        format: uuid
                      source:
                        type: string
                        enum:
                          - jira
                          - jira-automation
                          - slack
                          - linear
                          - cron
                          - webhook
                          - email
                          - bugcrowd
                          - hackerone
                      name:
                        type: string
                      description:
                        type:
                          - string
                          - 'null'
                      enabled:
                        type: boolean
                      createdAt:
                        type: string
                      updatedAt:
                        type: string
                      secret:
                        type:
                          - string
                          - 'null'
                      cronSchedule:
                        type:
                          - string
                          - 'null'
                      emailAddress:
                        type:
                          - string
                          - 'null'
                      config:
                        type: object
                        additionalProperties: {}
                      lastRunAttemptedAt:
                        type:
                          - string
                          - 'null'
                      lastRunSucceededAt:
                        type:
                          - string
                          - 'null'
                    required:
                      - id
                      - agentId
                      - organizationId
                      - source
                      - name
                      - enabled
                      - createdAt
                      - updatedAt
                      - config
                required:
                  - success
                  - data
        '400':
          description: Bad request — input validation failed or the request was malformed
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ValidationError'
        '401':
          description: Unauthorized — missing or invalid API key / session
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '403':
          description: Forbidden — the authenticated user lacks the required permissions
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PermissionError'
        '500':
          description: Internal server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
      x-codeSamples:
        - lang: shell
          label: cURL
          source: >-
            curl -X POST
            "https://app.cotool.ai/api/agents/:agentId/trigger/save" \
              -H "Authorization: Bearer YOUR_API_KEY" \
              -H "Content-Type: application/json" \
              -d '{"triggerId":"string","name":"string","description":"string","secret":"string","webhookUrl":"string","source":"jira","createAlert":true}'
components:
  schemas:
    ValidationError:
      type: object
      properties:
        error:
          type: string
          description: Error message describing what went wrong
        issues:
          type: array
          description: >-
            Detailed validation issues, present when request or response schema
            validation fails
          items:
            type: object
            additionalProperties: true
      required:
        - error
    Error:
      type: object
      properties:
        error:
          type: string
          description: Error message describing what went wrong
      required:
        - error
    PermissionError:
      type: object
      properties:
        error:
          type: string
          description: Error message describing what went wrong
        missingPerms:
          type: array
          description: Permissions the authenticated user is missing for this operation
          items:
            type: string
      required:
        - error
  securitySchemes:
    ApiKeyAuth:
      type: http
      scheme: bearer
      bearerFormat: API Key
      description: >-
        API Key authentication for programmatic access. Include your API key in
        the Authorization header as: `Bearer your_api_key_here`

````