# Trigger a build for a git tag using the API

**URL:** <https://travis-ci.community/t/trigger-a-build-for-a-git-tag-using-the-api/7318>\
**Category:** Travis CI Discussions & Feedback\
**Tags:** api\
**Created:** [February 21, 2020, 9:02pm UTC](https://travis-ci.community/t/trigger-a-build-for-a-git-tag-using-the-api/7318 "2020-02-21T21:02:48Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Morten](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/morten/32/3889_2.png) [@Morten](https://travis-ci.community/u/Morten)\
**Post date:** [February 21, 2020, 9:02pm UTC](https://travis-ci.community/t/trigger-a-build-for-a-git-tag-using-the-api/7318/1 "2020-02-21T21:02:49Z")

</div>

I’m trying to trigger a build using the API ([https://docs.travis-ci.com/user/triggering-builds/](https://docs.travis-ci.com/user/triggering-builds/)), but instead of triggering it for a branch, I want to trigger it for a tag. I tried setting `"tag": "v2.1.0"` in the `request`, but that just triggers a build for the master branch. Is there any way to trigger a build for a tag instead? Thanks.

---

<div class="post-metadata">

**Author:** ![BanzaiMan](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/banzaiman/32/67_2.png) [@BanzaiMan](https://travis-ci.community/u/BanzaiMan)\
**Post date:** [February 21, 2020, 9:37pm UTC](https://travis-ci.community/t/trigger-a-build-for-a-git-tag-using-the-api/7318/2 "2020-02-21T21:37:10Z")

</div>

You can pass the tag to `branch`:

```auto
body='{
  "request": {
    "branch":"any_tag_you_want"
  }
}'

```

---

<div class="post-metadata">

**Author:** ![Morten](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/morten/32/3889_2.png) [@Morten](https://travis-ci.community/u/Morten)\
**Post date:** [February 21, 2020, 10:13pm UTC](https://travis-ci.community/t/trigger-a-build-for-a-git-tag-using-the-api/7318/3 "2020-02-21T22:13:36Z")

</div>

Thanks. I just tried that, but Travis still treats it as a branch and not as a tag. Explicitly specifying `TRAVIS_TAG` as well did the job though. For reference, here’s my (working) request:

```json
{
	"request": {
		"branch": "v2.1.0",
		"config": {
			"merge_mode": "deep_merge",
			"env": [
				"TRAVIS_TAG=v2.1.0"
			]
		}
	}
}

```
