How to set environment variable using netlify api

I’m trying to deploy the website to Netlify using the available API, like the code below:

axios.post(
    "https://api.netlify.com/api/v1/sites",
    {
      name: "dival bangun",
      repo: {
        provider: "github",
        id: 652968452,
        repo: "sarrahman-keramik/webstore-mitra",
        private: false,
        branch: "main",
        cmd: "npm run build",
        dir: ".next",
        deploy_key_id: netlifyConfig.DEPLOY_KEY_ID,
      },
      build_settings: {
        env: {
          "NEXT_PUBLIC_NAMEAPP": "dival bangun",
        },
      },
    },
    {
      headers: {
        Authorization: `Bearer ${process.env.NETLIFY_API_TOKEN}`,
        "Content-Type": "application/json",
      },
    }
  );

But why aren’t the environment variables appearing after the website is successfully deployed?

Hello @sarrahman.dev, thanks for the post and welcome.
Kindly check the link below on how you can programmatically set the environment variable using Netlify API.

Thanks.