# How do I use my API Token to Trigger a Pipeline?

**URL:** <https://community.jenkins.io/t/how-do-i-use-my-api-token-to-trigger-a-pipeline/6864>\
**Category:** Ask a question\
**Tags:** question, pipeline\
**Created:** [April 15, 2023, 6:23am UTC](https://community.jenkins.io/t/how-do-i-use-my-api-token-to-trigger-a-pipeline/6864 "2023-04-15T06:23:24Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![David-R](https://dub1.discourse-cdn.com/flex013/user_avatar/community.jenkins.io/david-r/32/3186_2.png) [@David-R](https://community.jenkins.io/u/David-R)\
**Post date:** [April 15, 2023, 6:23am UTC](https://community.jenkins.io/t/how-do-i-use-my-api-token-to-trigger-a-pipeline/6864/1 "2023-04-15T06:23:24Z")

</div>

I went through this [guide](https://edwardbeazer.com/jenkins-setup-for-unreal-engine/) and created a API Token that gets triggered, but the guide didn’t mention how I trigger a Pipeline with the API Token. I tried something like this in my pipeline script:

```auto
pipeline 
{
	triggers {
            GenericTrigger(
                causeString: "//Lyra/Main stream has been updated",
                token: "1h32h255941e654eej454kj34453y2"
        )
    }
...

```

I found online an example with GenericTrigger but I get this error:

> WorkflowScript: 13: Invalid trigger type “GenericTrigger”. Valid trigger types: [upstream, cron, githubBranches, githubPullRequests, githubPush, p4Trigger, pollSCM] @ line 13, column 9.  
> GenericTrigger(  
> ^

It mentioned “p4Trigger” but I couldn’t find anything online on how to use it. I feel like I’m misunderstanding how this works. Can someone enlighten me, please? 🙏

---

<div class="post-metadata">

**Author:** ![mawinter69](https://dub1.discourse-cdn.com/flex013/user_avatar/community.jenkins.io/mawinter69/32/1625_2.png) [@mawinter69](https://community.jenkins.io/u/mawinter69)\
**Post date:** [April 15, 2023, 11:00am UTC](https://community.jenkins.io/t/how-do-i-use-my-api-token-to-trigger-a-pipeline/6864/2 "2023-04-15T11:00:20Z")

</div>

I assume you created a personal API token. This API token is used like your password, e.g. when using curl you use  
`curl -u 'user:token' <url>`  
instead of  
`curl -u 'user:password' <url>`  
There is no need to define anything in the pipeline itself. It is even bad to put this token in the pipeline code as anyone that has access to it can now login to your Jenkins with your username.

The `GenericTrigger` you used requires the plugin [Generic Webhook Trigger](https://plugins.jenkins.io/generic-webhook-trigger/) to be installed which then allows you to trigger jobs without using a personal API token.
