How to hit the CircleCI API

CircleCI's API v2 at https://circleci.com/api/v2 addresses projects by slug: gh/<org>/<repo> for GitHub.

Authentication

Create a personal API token under User Settings → Personal API Tokens and send it as the Circle-Token header. In the examples it's written {{CIRCLECI_TOKEN}}.

Full reference: https://circleci.com/docs/api/v2/

Current user

curl https://circleci.com/api/v2/me \
  -H "Circle-Token: {{CIRCLECI_TOKEN}}"
Run in PostTaco

A project's pipelines

curl https://circleci.com/api/v2/project/gh/{{ORG}}/{{REPO}}/pipeline \
  -H "Circle-Token: {{CIRCLECI_TOKEN}}"
Run in PostTaco

Trigger a pipeline

curl -X POST https://circleci.com/api/v2/project/gh/{{ORG}}/{{REPO}}/pipeline \
  -H "Circle-Token: {{CIRCLECI_TOKEN}}" \
  -H "Content-Type: application/json" \
  -d '{"branch": "main"}'
Run in PostTaco