<commit_before># Triggering pipelines through the API

> **Notes**:
>
> - [Introduced](https://about.gitlab.com/2015/08/22/gitlab-7-14-released/) in GitLab 7.14.
> - GitLab 8.12 has a completely redesigned job permissions system. Read all
>   about the [new model and its implications](../../user/project/new_ci_build_permissions_model.md#pipeline-triggers).

Triggers can be used to force a pipeline rerun of a specific `ref` (branch or
tag) with an API call.

## Authentication tokens

The following methods of authentication are supported.

### Trigger token

A unique trigger token can be obtained when [adding a new trigger](#adding-a-new-trigger).

## Adding a new trigger

You can add a new trigger by going to your project's
**Settings ➔ CI/CD** under **Triggers**. The **Add trigger** button will
create a new token which you can then use to trigger a rerun of this
particular project's pipeline.

Every new trigger you create, gets assigned a different token which you can
then use inside your scripts or `.gitlab-ci.yml`. You also have a nice
overview of the time the triggers were last used.

![Triggers page overview](img/triggers_page.png)

## Taking ownership of a trigger

> **Note**:
GitLab 9.0 introduced a trigger ownership to solve permission problems.

Each created trigger when run will impersonate their associated user including
their access to projects and their project permissions.

You can take ownership of existing triggers by clicking *Take ownership*.
From now on the trigger will be run as you.

## Revoking a trigger

You can revoke a trigger any time by going at your project's
**Settings ➔ CI/CD** under **Triggers** and hitting the **Revoke** button.
The action is irreversible.

## Triggering a pipeline

> **Notes**:
>
> - Valid refs are only the branches and tags. If you pass a commit SHA as a ref,
>   it will not trigger a job.
> - If your project is public, passing the token in plain text is probably not the
>   wisest idea, so you might want to use a
>   [variable](../variables/README.md#variables) for that purpose.

To trigger a job you need to send a `POST` request to GitLab's API endpoint:

```
POST /projects/:id/trigger/pipeline
```

The required parameters are the [trigger's `token`](#authentication-tokens)
and the Git `ref` on which the trigger will be performed. Valid refs are the
branch and the tag. The `:id` of a project can be found by
[querying the API](../../api/projects.md) or by visiting the **CI/CD**
settings page which provides self-explanatory examples.

When a rerun of a pipeline is triggered, the information is exposed in GitLab's
UI under the **Jobs** page and the jobs are marked as triggered 'by API'.

![Marked rebuilds as  on jobs page](img/builds_page.png)

---
<commit_msg>Resolve "A lot of Trigger Token is Accessible from Internet because of the Documentation"<commit_after># Triggering pipelines through the API

> **Notes**:
>
> - [Introduced](https://about.gitlab.com/2015/08/22/gitlab-7-14-released/) in GitLab 7.14.
> - GitLab 8.12 has a completely redesigned job permissions system. Read all
>   about the [new model and its implications](../../user/project/new_ci_build_permissions_model.md#pipeline-triggers).

Triggers can be used to force a pipeline rerun of a specific `ref` (branch or
tag) with an API call.

## Authentication tokens

The following methods of authentication are supported.

### Trigger token

A unique trigger token can be obtained when [adding a new trigger](#adding-a-new-trigger).

DANGER: **Danger:**
Passing plain text tokens in public projects is a security issue. Potential
attackers can impersonate the user that exposed their trigger token publicly in
their `.gitlab-ci.yml` file. Use [variables](../variables/README.md#variables)
to protect trigger tokens.

## Adding a new trigger

You can add a new trigger by going to your project's
**Settings ➔ CI/CD** under **Triggers**. The **Add trigger** button will
create a new token which you can then use to trigger a rerun of this
particular project's pipeline.

Every new trigger you create, gets assigned a different token which you can
then use inside your scripts or `.gitlab-ci.yml`. You also have a nice
overview of the time the triggers were last used.

![Triggers page overview](img/triggers_page.png)

## Taking ownership of a trigger

> **Note**:
GitLab 9.0 introduced a trigger ownership to solve permission problems.

Each created trigger when run will impersonate their associated user including
their access to projects and their project permissions.

You can take ownership of existing triggers by clicking *Take ownership*.
From now on the trigger will be run as you.

## Revoking a trigger

You can revoke a trigger any time by going at your project's
**Settings ➔ CI/CD** under **Triggers** and hitting the **Revoke** button.
The action is irreversible.

## Triggering a pipeline

> **Notes**:
>
> - Valid refs are only the branches and tags. If you pass a commit SHA as a ref,
>   it will not trigger a job.

To trigger a job you need to send a `POST` request to GitLab's API endpoint:

```
POST /projects/:id/trigger/pipeline
```

The required parameters are the [trigger's `token`](#authentication-tokens)
and the Git `ref` on which the trigger will be performed. Valid refs are the
branch and the tag. The `:id` of a project can be found by
[querying the API](../../api/projects.md) or by visiting the **CI/CD**
settings page which provides self-explanatory examples.

When a rerun of a pipeline is triggered, the information is exposed in GitLab's
UI under the **Jobs** page and the jobs are marked as triggered 'by API'.

![Marked rebuilds as  on jobs page](img/builds_page.png)

---

{'fraction_non_alphanumeric': 0.08713254708678049, 'fraction_numerical': 0.006688963210702341, 'mean_word_length': 4.193784277879342, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 26, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3678950', 'n_tokens_mistral': 1652, 'n_tokens_neox': 1565, 'n_words': 804}