# Set build command from API

**URL:** <https://answers.netlify.com/t/set-build-command-from-api/54977>\
**Category:** Support\
**Tags:** building, deployment\
**Created:** [April 14, 2022, 9:07pm UTC](https://answers.netlify.com/t/set-build-command-from-api/54977 "2022-04-14T21:07:19Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![saad.bahir.1](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/saad.bahir.1/32/23695_2.png) [@saad.bahir.1](https://answers.netlify.com/u/saad.bahir.1)\
**Post date:** [April 14, 2022, 9:07pm UTC](https://answers.netlify.com/t/set-build-command-from-api/54977/1 "2022-04-14T21:07:19Z")

</div>

Hello all,

When I set a build command from the netlify API, it doesn’t reflect on my portal

For example

```auto
curl --location --request PATCH 'https://api.netlify.com/api/v1/sites/$SITE_ID' \
--header 'Authorization: Bearer $TOKEN' \
--header 'Content-Type: application/json' \
--data-raw '{
    "build_settings": {
        "cmd": "yarn build"
    }
}'

```

Is the body correct?  
Thank you!

Saad

---

<div class="post-metadata">

**Author:** ![luke](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/luke/32/39_2.png) [@luke](https://answers.netlify.com/u/luke)\
**Post date:** [April 15, 2022, 4:42am UTC](https://answers.netlify.com/t/set-build-command-from-api/54977/2 "2022-04-15T04:42:01Z")

</div>

It all looks correct to me, @saad.bahir.1. However, I do see one issue. These two options need to be **double quoted** and not single quoted:

```nohighlight
'https://api.netlify.com/api/v1/sites/$SITE_ID'

```

and:

```nohighlight
--header 'Authorization: Bearer $TOKEN'

```

In other words, it should be this:

```nohighlight
curl --location --request PATCH "https://api.netlify.com/api/v1/sites/$SITE_ID" \
--header "Authorization: Bearer $TOKEN" \
--header 'Content-Type: application/json' \
--data-raw '{
    "build_settings": {
        "cmd": "yarn build"
    }
}'

```

This is because single quotes will prevent the expansion of the environment variables. If you want the environment variables to be interpreted, then double quotes must be used around those strings.

You can use single quotes elsewhere where no shell expansion is being used.

If this doesn’t fix it, please let us know.

---

<div class="post-metadata">

**Author:** ![saad.bahir.1](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/saad.bahir.1/32/23695_2.png) [@saad.bahir.1](https://answers.netlify.com/u/saad.bahir.1)\
**Post date:** [April 15, 2022, 11:49am UTC](https://answers.netlify.com/t/set-build-command-from-api/54977/3 "2022-04-15T11:49:02Z")

</div>

Thank you Luke for your feedback

Unfortunately, the quotes are just a translation of my Postman query to a Curl command, so I didn’t set those quotes

It looks like the PATCH command above actually works

However, when I create a site, that build command doesn’t appear in the response or in the UI

```auto
curl --location --request POST 'https://api.netlify.com/api/v1/sites' \
--header 'Authorization: Bearer $TOKEN' \
--header 'Content-Type: application/json' \
--data-raw '{
  "custom_domain": "customsubdomain",
  "name": "customname",
  "repo": {
    "provider": "gitlab",
    "repo": "username/repo",
    "private": true,
    "branch": "branch"
  },
  "build_settings": {
    "cmd": "yarn build",
    "env": {
      "custom_env": "custom_value"
    }
  }
}'

```

---

<div class="post-metadata">

**Author:** ![hrishikesh](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/hrishikesh/32/74607_2.png) [@hrishikesh](https://answers.netlify.com/u/hrishikesh)\
**Post date:** [April 17, 2022, 5:25pm UTC](https://answers.netlify.com/t/set-build-command-from-api/54977/4 "2022-04-17T17:25:30Z")

</div>

Hey @saad.bahir.1,

Could you share the site ID in this case?

---

<div class="post-metadata">

**Author:** ![luke](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/luke/32/39_2.png) [@luke](https://answers.netlify.com/u/luke)\
**Post date:** [April 18, 2022, 4:21am UTC](https://answers.netlify.com/t/set-build-command-from-api/54977/5 "2022-04-18T04:21:03Z")

</div>

Hi, @saad.bahir.1. There are a number of topics about this here on the support forums. It is true that not all attributes can be configured on the initial site creation. For those attributes you must create the site with one API call and they update the attributes with a second API call after the first.

If there are other questions, please let us know.
