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:
      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, thanks for the post and welcome.
Kindly check the link below on how you can programmatically set the environment variable using Netlify API.