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

# Trigger and Gate Flow Checks in Your CI/CD Pipeline

> Trigger TYAN flow runs directly from GitHub Actions, GitLab CI, or any CI pipeline and block deploys when critical flows fail.

You can call the TYAN API from any CI/CD pipeline to run your flows as a deployment gate — automatically verifying that critical app journeys still work before every release ships to users. If a flow fails, the pipeline exits with a non-zero code and blocks the deploy.

## Prerequisites

Grab your API key from **Settings → API Keys** in your TYAN workspace, then store it as a secret in your CI environment (`TYAN_API_KEY`). You'll also need your flow's ID (`FLOW_ID`), visible on the flow detail page.

## GitHub Actions

Add the following job to your workflow file. It triggers a flow run, then polls the result every five seconds for up to one minute — passing or failing the job based on the outcome.

```yaml theme={null}
name: Verify App Flows
on: [push]
jobs:
  verify:
    runs-on: ubuntu-latest
    steps:
      - name: Trigger flow run
        run: |
          RUN=$(curl -s -X POST https://api.testyourappnow.com/v1/flows/${{ secrets.FLOW_ID }}/run \
            -H "Authorization: Bearer ${{ secrets.TYAN_API_KEY }}" \
            -H "Content-Type: application/json")
          RUN_ID=$(echo $RUN | jq -r '.run_id')
          echo "RUN_ID=$RUN_ID" >> $GITHUB_ENV
          echo "Run ID: $RUN_ID"
      - name: Poll for result
        run: |
          for i in $(seq 1 12); do
            STATUS=$(curl -s https://api.testyourappnow.com/v1/runs/$RUN_ID \
              -H "Authorization: Bearer ${{ secrets.TYAN_API_KEY }}" | jq -r '.status')
            echo "Status: $STATUS"
            if [ "$STATUS" = "passed" ]; then exit 0; fi
            if [ "$STATUS" = "failed" ]; then exit 1; fi
            sleep 5
          done
          exit 1
```

Store `TYAN_API_KEY` and `FLOW_ID` under **Settings → Secrets and variables → Actions** in your GitHub repository.

## GitLab CI

Add a `verify-flows` job to your `.gitlab-ci.yml`. Set `TYAN_API_KEY` and `FLOW_ID` as CI/CD variables under **Settings → CI/CD → Variables** in your GitLab project.

```yaml theme={null}
verify-flows:
  stage: test
  script:
    - |
      RUN=$(curl -s -X POST https://api.testyourappnow.com/v1/flows/${FLOW_ID}/run \
        -H "Authorization: Bearer ${TYAN_API_KEY}" \
        -H "Content-Type: application/json")
      RUN_ID=$(echo $RUN | jq -r '.run_id')
      for i in $(seq 1 12); do
        STATUS=$(curl -s https://api.testyourappnow.com/v1/runs/${RUN_ID} \
          -H "Authorization: Bearer ${TYAN_API_KEY}" | jq -r '.status')
        if [ "$STATUS" = "passed" ]; then exit 0; fi
        if [ "$STATUS" = "failed" ]; then exit 1; fi
        sleep 5
      done
      exit 1
```

## Other CI Providers

The examples above use plain `curl` and `jq`, so the same pattern works in any CI environment — CircleCI, Bitbucket Pipelines, Jenkins, or a plain shell script. Inject `TYAN_API_KEY` and `FLOW_ID` as environment variables and paste in the poll loop.

<Tip>
  Run a whole group of related flows at once by tagging them in TYAN (for example, `checkout` or `onboarding`) and passing the `?tag=` query parameter to the run endpoint. This lets a single CI step verify every flow in a feature area without listing individual flow IDs.
</Tip>

<Note>
  See the [Flows API reference](/api/flows) for the full list of request parameters, response fields, and supported status values.
</Note>
