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

# Create a trigger

> Creates a cron or webhook trigger that starts sessions on this environment unattended. A webhook trigger's response carries `webhook_url` and the signing `secret`, shown only here and on rotate-secret. Refused (400 `ask_not_allowed`) when the environment's latest version asks for approval: nobody is there to answer.



## OpenAPI

````yaml /api-reference/openapi.json post /v1/environments/{env_id}/triggers
openapi: 3.1.0
info:
  title: Veri API
  description: >-
    REST API for the Veri RL post-training platform. All requests require a
    Bearer API key (`vk_` prefix).
  license:
    name: ''
  version: 0.1.0
servers:
  - url: https://api.veri.studio
    description: Production
security: []
tags:
  - name: Training jobs
    description: Create, monitor, and manage training jobs.
  - name: Datasets
    description: Upload and connect training datasets.
  - name: Deployments
    description: Serve trained models and run inference.
  - name: Volumes
    description: Persistent file storage mounted into jobs.
  - name: Models
    description: Custom model registry deployments serve from.
  - name: Regions
    description: Discover available launch regions.
  - name: GPU
    description: Live GPU availability by provider and region.
  - name: Code artifacts
    description: Upload custom training script bundles.
  - name: Billing
    description: Credit balance and transaction history.
  - name: API keys
    description: Create and revoke API keys.
  - name: Account
    description: The authenticated caller's identity.
  - name: Settings
    description: Account-level integrations (Weights & Biases).
  - name: Metrics
    description: Prometheus metrics export for your own observability stack.
  - name: Evaluators
    description: 'Evaluators: versioned scoring rules (LLM judge, code, human).'
  - name: Experiments
    description: >-
      Experiments: offline runs of a pinned dataset snapshot through a target,
      scored by pinned evaluators.
  - name: Annotation queues
    description: >-
      Human review: queue traces, threads and experiment items, reserve one at a
      time, score them and feed corrections back into datasets.
  - name: Monitors
    description: >-
      Monitors: evaluators scoring a sampled share of a deployment's live
      traffic.
  - name: Observability
    description: Agent conversations, agents and their traffic.
  - name: Public runs
    description: Unauthenticated reads of runs their owners published to Explore.
paths:
  /v1/environments/{env_id}/triggers:
    post:
      tags:
        - Triggers
      summary: Create a trigger
      description: >-
        Creates a cron or webhook trigger that starts sessions on this
        environment unattended. A webhook trigger's response carries
        `webhook_url` and the signing `secret`, shown only here and on
        rotate-secret. Refused (400 `ask_not_allowed`) when the environment's
        latest version asks for approval: nobody is there to answer.
      operationId: create
      parameters:
        - name: env_id
          in: path
          description: Environment ID
          required: true
          schema:
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/TriggerCreateRequest'
        required: true
      responses:
        '201':
          description: The new trigger (with its secret, for a webhook trigger)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TriggerResponse'
        '400':
          description: >-
            Invalid definition, an environment that asks for approval, or
            triggers disabled
        '404':
          description: Environment (or reuse session) not in this workspace
        '429':
          description: The workspace already has its maximum of active triggers
      security:
        - bearerAuth: []
components:
  schemas:
    TriggerCreateRequest:
      type: object
      required:
        - kind
        - prompt
      properties:
        name:
          type:
            - string
            - 'null'
          description: Display name, at most 64 characters.
        kind:
          type: string
          description: '`cron` or `webhook`.'
        cron:
          type:
            - string
            - 'null'
          description: >-
            cron: a five-field POSIX cron expression (minute granularity;
            weekdays

            0-6 = Sunday-Saturday) or an @nickname (@hourly, @daily, ...).
        timezone:
          type:
            - string
            - 'null'
          description: 'cron: IANA time zone the expression is read in (default UTC).'
        provider:
          type:
            - string
            - 'null'
          description: >-
            webhook: `github`, `gitlab` or `custom` (Standard Webhooks;
            default).
        prompt:
          type: string
          description: >-
            The message each firing sends. `{{payload}}` = the webhook body as
            JSON

            (at most 16 KiB), `{{.a.b}}` = one field of it; missing fields
            render

            empty. Cron firings have no payload.
        session_mode:
          type:
            - string
            - 'null'
          description: |-
            `fresh` (default): a new session per firing, ended when the run
            completes. `reuse`: wake `reuse_session_id`, send, pause it again.
        reuse_session_id:
          type:
            - string
            - 'null'
        budget_usd:
          type:
            - number
            - 'null'
          format: double
          description: Spend ceiling per fresh session in USD (default 2.00).
        output:
          oneOf:
            - type: 'null'
            - $ref: '#/components/schemas/TriggerOutput'
              description: >-
                Where results go besides `trigger.execution.*` webhooks (default
                none).
    TriggerResponse:
      type: object
      required:
        - object
        - id
        - environment_id
        - kind
        - session_mode
        - prompt
        - budget_usd
        - output
        - status
        - consecutive_failures
        - created_by
        - created_at
        - updated_at
      properties:
        object:
          type: string
        id:
          type: string
        environment_id:
          type: string
        name:
          type:
            - string
            - 'null'
        kind:
          type: string
          description: cron | webhook
        provider:
          type:
            - string
            - 'null'
          description: 'webhook: github | gitlab | custom'
        cron:
          type:
            - string
            - 'null'
        timezone:
          type:
            - string
            - 'null'
        session_mode:
          type: string
          description: fresh | reuse
        reuse_session_id:
          type:
            - string
            - 'null'
        prompt:
          type: string
        budget_usd:
          type: number
          format: double
        output:
          $ref: '#/components/schemas/TriggerOutput'
          description: Slack URLs are masked.
        status:
          type: string
          description: active | paused
        paused_reason:
          type:
            - string
            - 'null'
          description: |-
            Why the trigger is paused, when it was not paused by hand (five
            consecutive failures, a deleted environment, ...).
        consecutive_failures:
          type: integer
          format: int32
        next_fire_at:
          type:
            - string
            - 'null'
          format: date-time
          description: 'cron: when it fires next (absent while paused).'
        webhook_url:
          type:
            - string
            - 'null'
          description: 'webhook: the URL to give the provider.'
        secret:
          type:
            - string
            - 'null'
          description: |-
            webhook: the signing secret. Returned ONLY by create and
            rotate-secret; store it then.
        previous_secret_expires_at:
          type:
            - string
            - 'null'
          format: date-time
          description: |-
            webhook: until when the previous secret still verifies (rotation
            grace).
        last_execution:
          oneOf:
            - type: 'null'
            - $ref: '#/components/schemas/TriggerExecutionResponse'
        created_by:
          type: string
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time
    TriggerOutput:
      type: object
      description: |-
        Where a finished firing's result goes besides the outbox (which always
        carries `trigger.execution.*` to the workspace's subscribed endpoints):
        `none`, `webhook` (outbox only) or `slack` (incoming webhook URL).
        `email` is coming soon: refused with 400 until email delivery launches.
      required:
        - kind
      properties:
        kind:
          type: string
          description: none | webhook | slack
        target:
          type:
            - string
            - 'null'
          description: >-
            slack: the `https://hooks.slack.com/...` URL (masked on read).
            Absent

            for none and webhook.
    TriggerExecutionResponse:
      type: object
      required:
        - object
        - id
        - trigger_id
        - kind
        - status
        - created_at
      properties:
        object:
          type: string
        id:
          type: string
        trigger_id:
          type: string
        kind:
          type: string
          description: 'What fired it: cron | webhook | manual'
        status:
          type: string
          description: pending | running | succeeded | failed | cancelled
        delivery_id:
          type:
            - string
            - 'null'
          description: |-
            The provider's delivery id (webhook-id, X-GitHub-Delivery,
            X-Gitlab-Event-UUID); a second delivery with the same id is ignored.
        session_id:
          type:
            - string
            - 'null'
        failure_reason:
          type:
            - string
            - 'null'
        payload_excerpt:
          type:
            - string
            - 'null'
          description: The first 4 KiB of the webhook body.
        result_excerpt:
          type:
            - string
            - 'null'
          description: The first 2 KiB of the run's last agent message.
        output_error:
          type:
            - string
            - 'null'
          description: Set when the Slack output (or the session teardown) failed.
        started_at:
          type:
            - string
            - 'null'
          format: date-time
        finished_at:
          type:
            - string
            - 'null'
          format: date-time
        created_at:
          type: string
          format: date-time
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: API key
      description: API key with the `vk_` prefix. Create one from the dashboard.

````

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