---
title: "Create trigger"
method: POST
path: "/projects/{project_id}/pipeline-definitions/{pipeline_definition_id}/triggers"
tags: ["Trigger"]
---

# Create trigger

`POST /projects/{project_id}/pipeline-definitions/{pipeline_definition_id}/triggers`

## Request

- Base URL: `https://circleci.com/api/v2`
- URL: `https://circleci.com/api/v2/projects/{project_id}/pipeline-definitions/{pipeline_definition_id}/triggers`
- Auth: one of:
  - API key in header `Circle-Token`
  - HTTP bearer
  - HTTP basic
  - API key in query parameter `circle-token`

Create a trigger for a given pipeline definition. Currently only supported for pipeline definitions where `config_source.provider` is `github_oauth`, `github_app`, `github_server`, or `schedule`. [Share feedback](https://circleci.canny.io/cloud-feature-requests/p/project-administration-apis) about our Project Administration APIs.

## Path parameters

- `project_id` string, required
- `pipeline_definition_id` string, required

## Request body

- CreateTriggerRequest
  - `event_source` object, required: The source of events to use for this trigger. The `repo` object must be specified when `provider` is `github_app`, `github_server`, or `github_oauth`, the `webhook` object may only be specified when `provider` is `webhook`, and the `schedule` object must be specified when `provider` is `schedule`.
    - `provider` string, required: The integration provider for this resource. Currently `github_app`, `github_server`, `github_oauth`, `webhook`, and `schedule` are the only supported values.
    - `repo` object: Information pertaining to the repository used as a source of events for this trigger, if applicable.
      - `external_id` string, required: External identifier for the repository, as defined by the respective version control provider.
    - `webhook` object: Information pertaining to the custom webhook being used as a source of events for this trigger, if applicable.
      - `sender` string: The sender of the webhook.
    - `schedule` object: Schedule configuration for this trigger. Only applicable when `provider` is `schedule`.
      - `cron_expression` string: A cron expression defining when the trigger fires (e.g. `*/5 * * * *` for every 5 minutes).
      - `attribution_actor` 'current' | 'system': The actor to attribute pipeline runs to. Use `current` to attribute runs to the user who created the trigger, or `system` to attribute runs to the CircleCI system actor.
  - `event_preset` 'all-pushes' | 'only-tags' | 'default-branch-pushes' | 'only-build-prs' | 'only-open-prs' | 'only-labeled-prs' | 'only-merged-prs' | 'only-ready-for-review-prs' | 'only-build-pushes-to-non-draft-prs' | 'only-merged-or-closed-prs' | 'pr-comment-equals-run-ci' | 'non-draft-pr-opened' | 'pushes-to-merge-queues': The name of the event preset to use when filtering events for this trigger. When `event_source.provider` is `github_app` or `github_server`, all preset values are supported. When `event_source.provider` is `github_oauth`, this field is **required** and only the following values are accepted: `all-pushes`, `only-build-prs`. Not applicable when `event_source.provider` is `webhook` or `schedule`.
  - `checkout_ref` string: The ref to use when checking out code for pipeline runs created from this trigger. Always required when `event_source.provider` is `webhook` or `schedule`. When `event_source.provider` is `github_app` or `github_server`, only expected if the event source repository (identified by `event_source.repo.external_id`) is different to the checkout source repository of the associated Pipeline Definition. Otherwise, must be omitted.
  - `config_ref` string: The ref to use when fetching config for pipeline runs created from this trigger. Always required when `event_source.provider` is `webhook` or `schedule`. When `event_source.provider` is `github_app` or `github_server`, only expected if the event source repository (identified by `event_source.repo.external_id`) is different to the config source repository of the associated Pipeline Definition. Otherwise, must be omitted.
  - `event_name` string: The name of the triggering event. Required when `provider` is `webhook` or `schedule`. Should not be set for other providers.
  - `disabled` boolean: Whether the trigger should be disabled upon creation. Not supported for triggers where `event_source.provider` is `github_oauth`.
  - `parameters` object: Pipeline parameters to pass when running pipelines from this trigger. Currently only supported for triggers where `event_source.provider` is `schedule`.

## Response `200`

Successful response.

- Trigger
  - `id` string, uuid: The unique ID of the trigger.
  - `event_name` string: The name of the event that will trigger the pipeline.
  - `event_source` object: The source of events to use for this trigger. Will contain either a `repo`, `webhook`, or `schedule` object depending on the `provider`. (The `github_app`, `github_server`, and `github_oauth` providers imply a `repo`, `webhook` implies a `webhook`, and `schedule` implies a `schedule`.)
    - `provider` string: The integration provider for this resource. One of `github_app`, `github_server`, `github_oauth`, `webhook`, or `schedule`.
    - `repo` object: Information pertaining to the repository used as a source of events for this trigger, if applicable.
      - `full_name` string: The fully-qualified name of the repository.
      - `external_id` string: External identifier for the repository, as defined by the respective version control provider.
    - `webhook` object: Information pertaining to the custom webhook used as a source of events for this trigger, if applicable.
      - `url` string: The URL to use when triggering this webhook.
      - `sender` string: The name of the webhook sender.
    - `schedule` object: Information pertaining to the schedule used as a source of events for this trigger, if applicable.
      - `cron_expression` string: The cron expression defining when this trigger fires.
      - `attribution_actor` object: The actor that pipeline runs from this trigger are attributed to. On creation, callers supply `current` or `system` as a string; the response returns the resolved actor as an object containing their user ID.
        - `id` string, uuid: The unique ID of the user that pipeline runs are attributed to.
  - `event_preset` 'all-pushes' | 'only-tags' | 'default-branch-pushes' | 'only-build-prs' | 'only-open-prs' | 'only-labeled-prs' | 'only-merged-prs' | 'only-ready-for-review-prs' | 'only-build-pushes-to-non-draft-prs' | 'only-merged-or-closed-prs' | 'pr-comment-equals-run-ci' | 'non-draft-pr-opened' | 'pushes-to-merge-queues': The name of the event preset to use when filtering events for this trigger. When `event_source.provider` is `github_app` or `github_server`, all preset values are supported. When `event_source.provider` is `github_oauth`, this field is **required** and only the following values are accepted: `all-pushes`, `only-build-prs`. Not applicable when `event_source.provider` is `webhook` or `schedule`.
  - `checkout_ref` string: The ref to use when checking out code for pipeline runs created from this trigger. If empty, the ref provided in the trigger event is used.
  - `config_ref` string: The ref to use when fetching config for pipeline runs created from this trigger. If empty, the ref provided in the trigger event is used.
  - `disabled` boolean: Whether the trigger is disabled. Not supported for triggers where `event_source.provider` is `github_oauth`.
  - `parameters` object: Pipeline parameters passed when running pipelines from this trigger. Currently only supported for triggers where `event_source.provider` is `schedule`.

## Other responses

- `400`: Unexpected request body provided.
- `401`: Credentials provided are invalid.
- `404`: Entity not found.
- `500`: Internal server error.

---

[API](https://skmtc.dev/circleci/apis/circleci-api.md) - [All operations](https://skmtc.dev/circleci/apis/circleci-api/llms.txt) - [OpenAPI document](https://skmtc.dev/circleci/apis/circleci-api/revisions/b9c0e0c24058?raw)
