Triggering pipeline via v2 api fails with 404 project not found

we have a cli tool that ulitimately uses a url like :

function getPipelineUrl({ user, vcs, repo }) {
  return `https://circleci.com/api/v2/project/${vcs}/${user}/${repo}/pipeline/`;
}

// gets called with cli flags like --user, --vcs, --repo, --token etc.

we end up calling it like :


      - reckon/trigger_workflows:
          branch: <<pipeline.git.branch>>
          commit_ref_stash: ./development_commit
          enable_workflow_parameter: enable_development_build
          packagename_parameter: build_packagename
          packageroot_parameter: build_packageroot
          commitref_parameter: build_commitref
          tag_pattern: "^(@somereponame.*)@v.*-dev$"
          vcs_type: <<pipeline.project.type>>
          requires:
            - reckon/process_changesets

which ends up calling :

        yarn deploy-tags
        --token=${<<parameters.token>>}
        --user=${<<parameters.user>>}
        --repo=${<<parameters.repo_name>>}
        --vcs=<<parameters.vcs_type>>
        --tags.pattern="<<parameters.tag_pattern>>"
        --workflow.params.enable=<<parameters.enable_workflow_parameter>>
        --workflow.params.package=<<parameters.packagename_parameter>>
        --workflow.params.root=<<parameters.packageroot_parameter>>
        --workflow.params.commit=<<parameters.commitref_parameter>>

heres some parameter specs for this job:


  token:
    description: What is the VCS for this project
    type: env_var_name
    default: CIRCLE_TOKEN

  repo_name:
    type: env_var_name
    description: The repo to trigger the workflow on
    default: CIRCLE_PROJECT_REPONAME

  user:
    description: Username for the Project
    type: env_var_name
    default: CIRCLE_PROJECT_USERNAME

  vcs_type:
    description: What is the VCS for this project
    type: string
    default: ''

These all get filled in nicely.

but for the last two days, a POST request with a correct CIRCLE_TOKEN to https://circleci.com/api/v2/project/${vcs}/${user}/${repo}/pipeline/ results in a 404 project not found.

Urgently need assistance here.

Hi @zeno.at.reckon! Welcome to the CircleCI community!

Assuming that the variables are properly interpolated, this issue could be authentication related.

Are you using a project API token, as opposed to a personal API token?

Note that CircleCI API v2 only supports personal API tokens.

@yannCI

ugh. so what happens when I leave the company? all our CICD becomes broken?

What was the reasoning behind that?

@zeno.at.reckon,

I can understand why project API tokens not being supported by our API v2 may be more challenging for some use-cases.

When the v2 API was designed, the decision was made to restrict access to personal API tokens.
Part of the motivation revolved around tying all access to a specific user and the pass-thru permissions of that user to the backing VCS (Github, Bitbucket).
This also allows a more obvious permissions path as there is now a 1-1 relationship between what a user can access and what the token can access.
In the case of the project token, there could be confusion about what specific actions that token could perform.

A suggestion would be to create a machine user (that has appropriate permissions to the repository/project) and use the token of that user.