# How to deploy your Node.js app (https://developer.godaddy.com/en/docs/api-users/hosting/workflows/deploy-nodejs-app)

---
title: How to deploy your Node.js app
description: >-
  Deploy your app end to end with the gddy CLI or the REST API. Create an app,
  upload code, attach a hosting plan, publish, and verify it's running.
keywords: >-
  gddy hosting, gddy hosting app create, gddy hosting deployment publish, deploy
  Node.js app CLI, POST /v1/hosting/apps, GET /app-operations, operation status,
  POST /apps/{appId}/imports, import upload, PUT /apps/{appId}/subscription,
  POST /apps/{appId}/deployments, deployment status, async polling pattern
agentNotes:
  scopes:
    - 'hosting.application:create'
    - 'hosting.application:read'
    - 'hosting.source:write'
    - 'hosting.source:read'
    - 'hosting.deployment:execute'
    - 'hosting.subscription:read'
    - 'hosting.subscription:write'
  rateLimit: 10–120 req/min per client IP depending on operation
  failureRecovery: >-
    Creating an app, uploading source, and publishing are async. Poll the status
    endpoint for each until it reaches a terminal state. Attaching a hosting
    plan is synchronous, so there is nothing to poll.
related:
  concepts:
    - title: Hosting core concepts
      href: /docs/api-users/hosting/concepts
    - title: Node.js app requirements
      href: /docs/api-users/hosting/app-requirements
  guides:
    - title: Manage apps
      href: /docs/api-users/hosting/manage-apps
    - title: Attach to a hosting plan
      href: /docs/api-users/hosting/attach-hosting-plan
    - title: Attach domain
      href: /docs/api-users/hosting/attach-domain
  apis:
    - title: Hosting API reference
      href: /docs/references/rest/hosting
pageId: 7de5cdf5-ee50-4944-98f7-771792ddba12
---

## Overview

This walkthrough deploys an app from scratch. By the end, you'll have a running app on the `publish` variant. Creating an app, uploading source, and publishing are async. Each call returns an ID immediately, and you poll until the operation reaches `COMPLETED`.

You can follow the steps with the `gddy` CLI or with the Hosting REST API. The CLI is the recommended path. It signs you in through your browser and asks you to approve each scope the first time a command needs it. The API path uses a Personal Access Token and shows curl, Node, Python, and Go examples. Those examples use `$BASE_URL` for the API gateway host and `$GODADDY_PAT` for the token. Go to [Hosting core concepts](https://developer.godaddy.com/docs/api-users/hosting/concepts#scopes-reference) for the scopes involved.

**CLI**

## Prerequisites for the CLI

The following prerequisites are required before you can deploy your Node.js app:

* the GoDaddy CLI installed and signed in

  Go to [Set up the CLI](https://developer.godaddy.com/docs/api-users/cli/set-up) to install and authenticate `gddy`.

* a zipped Node.js application that meets the [Node.js app requirements](https://developer.godaddy.com/docs/api-users/hosting/app-requirements)

* a web hosting subscription with a free app slot, which you need only to publish

## Deploy your app with the CLI

The following procedure creates an app, uploads source, attaches it to a hosting plan, publishes it to production, and confirms the app is running.

### Create an app with the CLI

`gddy hosting app create` returns an `operationId`, which is `$OPERATION_ID` in the poll command. After the operation reaches `COMPLETED`, its `app.id` field is the app ID, which is `$APP_ID` in every later command.

The following procedure creates the app and polls the operation until provisioning finishes.

1. Create the app:

   ```bash
   gddy hosting app create --app-type NODEJS --name my-first-app
   ```

2. Poll until the operation reaches `COMPLETED` or `FAILED`:

   ```bash
   gddy hosting operation get --operation-id $OPERATION_ID
   ```

### Upload source and preview your app with the CLI

`gddy hosting source upload` accepts a zip and returns an `importId`, which is `$IMPORT_ID` in the poll command. After the import reaches `COMPLETED`, your code runs on the `preview` variant. Preview works without a hosting plan. The preview URL is private, so sign in to your GoDaddy account to open it.

The following procedure zips your app, uploads it, polls the import, and reads the preview URL.

1. Zip the app, leaving out `node_modules`, `.env` files, and `.git`:

   ```bash
   zip -r my-app.zip . -x "node_modules/*" -x ".env*" -x ".git/*"
   ```

2. Upload the zip:

   ```bash
   gddy hosting source upload --app-id $APP_ID --file ./my-app.zip
   ```

3. Poll until the upload reaches a terminal state:

   ```bash
   gddy hosting source status --app-id $APP_ID --import-id $IMPORT_ID
   ```

4. Read the preview URL:

   ```bash
   gddy hosting app get --app-id $APP_ID --fields urls
   ```

### Attach to hosting plan with the CLI

Before you can publish a Node.js app, you must attach it to a web hosting subscription. `gddy hosting subscription list` returns your plans, and each plan has a `subscriptionId` and an `availableSlots` count. Use the `subscriptionId` of a plan with at least one available slot as `$SUBSCRIPTION_ID`. Go to [Attach to a hosting plan](https://developer.godaddy.com/docs/api-users/hosting/attach-hosting-plan) for detailed guidance.

The following procedure finds a hosting plan and attaches the app to it.

1. List your web hosting plans:

   ```bash
   gddy hosting subscription list --hosting-product WEB_HOSTING
   ```

2. Attach the app to a subscription:

   ```bash
   gddy hosting subscription attach --app-id $APP_ID --subscription-id $SUBSCRIPTION_ID
   ```

### Publish your app with the CLI

`gddy hosting deployment publish` builds the latest source, deploys it to the `publish` variant, and returns a `deploymentId`, which is `$DEPLOYMENT_ID` in the poll command.

The following procedure publishes the app and polls the deployment until it finishes.

1. Publish the app:

   ```bash
   gddy hosting deployment publish --app-id $APP_ID
   ```

2. Poll until the deployment reaches a terminal state:

   ```bash
   gddy hosting deployment get --app-id $APP_ID --deployment-id $DEPLOYMENT_ID
   ```

### Verify with the CLI

`gddy hosting app status` returns the application lifecycle in `status` and per-environment detail in `variants`. The app is healthy when `status` is `ACTIVE`. The other values are `CREATING`, `FAILED`, `DELETING`, `SUSPENDED`, and `UNKNOWN`. `UNKNOWN` means the state can't be determined, so don't treat it as healthy. Each entry in `variants` has its own `status`, which is `ACTIVE` when that environment is healthy. It also has a lowercase `lifecycleState`, which is `running` when that environment is up. The other main `lifecycleState` values are `provisioning`, `reloading`, `paused`, `deleting`, and `failed`. Other values are possible.

The following procedure confirms the app is running.

1. Read the app status:

   ```bash
   gddy hosting app status --app-id $APP_ID
   ```

2. Check that `status` is `ACTIVE`, and that the `PUBLISH` entry in `variants` has a `status` of `ACTIVE` and a `lifecycleState` of `running`. The CLI nests these fields under `data`.

3. Open the `urls.publish` address to see the live app. The next step shows how to read it.

### Get app URLs with the CLI

`gddy hosting app get` returns the full app record, including a `urls` object with the URL for each environment. Open `urls.publish` to see the live app. Your code isn't live there until you publish.

The following procedure reads the publish URL.

* Read the app record to get its URLs:

  ```bash
  gddy hosting app get --app-id $APP_ID --fields urls
  ```

## Deploy updates with the CLI

To deploy new code to an existing app, repeat the upload and publish steps. You don't need to create a new app or re-attach it to a hosting plan.

The following procedure uploads new code and publishes it.

1. Upload the updated zip:

   ```bash
   gddy hosting source upload --app-id $APP_ID --file ./my-app.zip
   ```

2. Poll until the upload reaches a terminal state:

   ```bash
   gddy hosting source status --app-id $APP_ID --import-id $IMPORT_ID
   ```

3. Publish the update:

   ```bash
   gddy hosting deployment publish --app-id $APP_ID
   ```

4. Poll until the deployment reaches a terminal state:

   ```bash
   gddy hosting deployment get --app-id $APP_ID --deployment-id $DEPLOYMENT_ID
   ```

**API**

## Prerequisites for the API

The following prerequisites are required before you can deploy your Node.js app:

* a [Personal Access Token](https://developer.godaddy.com/personal-access-token) with the following scopes: `hosting.application:create`, `hosting.application:read`, `hosting.source:write`, `hosting.source:read`, `hosting.deployment:execute`, `hosting.subscription:read`, `hosting.subscription:write`
* a zipped Node.js application that meets the [Node.js app requirements](https://developer.godaddy.com/docs/api-users/hosting/app-requirements)
* a web hosting subscription with a free app slot, which you need only to publish

## Deploy your app with the API

The following procedure creates an app, uploads source, attaches it to a hosting plan, publishes it to production, and confirms the app is running.

### Create an app with the API

`POST /apps?appType=NODEJS` accepts a name and returns `202 Accepted` with an `AppOperation`, including a `links[rel=self]` URL. Poll that URL with `GET /app-operations/{operationId}` until the status reaches `COMPLETED` (success) or `FAILED`. The curl examples use `$OPERATION_ID` for the `operationId` in the create response and `$APP_ID` for `app.id` in the completed operation.

1. Create the app:

   ```bash tab="curl"
   curl -s -X POST "$BASE_URL/v1/hosting/apps?appType=NODEJS" \
     -H "Authorization: Bearer $GODADDY_PAT" \
     -H "Content-Type: application/json" \
     -d '{ "name": "my-first-app" }'
   ```

   ```js tab="Node"
   const res = await fetch(`${process.env.BASE_URL}/v1/hosting/apps?appType=NODEJS`, {
     method: 'POST',
     headers: {
       Authorization: `Bearer ${process.env.GODADDY_PAT}`,
       'Content-Type': 'application/json',
     },
     body: JSON.stringify({ name: 'my-first-app' }),
   });
   const { operationId, links } = await res.json();
   const pollUrl = links.find(l => l.rel === 'self').href;
   ```

   ```python tab="Python"
   import requests, os

   resp = requests.post(
       f"{os.environ['BASE_URL']}/v1/hosting/apps?appType=NODEJS",
       headers={"Authorization": f"Bearer {os.environ['GODADDY_PAT']}"},
       json={"name": "my-first-app"},
   )
   data = resp.json()
   operation_id = data["operationId"]
   poll_url = next(l["href"] for l in data["links"] if l["rel"] == "self")
   ```

   ```go tab="Go"
   body := strings.NewReader(`{"name":"my-first-app"}`)
   req, _ := http.NewRequest("POST", os.Getenv("BASE_URL")+"/v1/hosting/apps?appType=NODEJS", body)
   req.Header.Set("Authorization", "Bearer "+os.Getenv("GODADDY_PAT"))
   req.Header.Set("Content-Type", "application/json")
   resp, _ := http.DefaultClient.Do(req)
   defer resp.Body.Close()
   var result map[string]interface{}
   json.NewDecoder(resp.Body).Decode(&result)
   operationId := result["operationId"].(string)
   // Find poll URL from links array where rel == "self"
   ```

2. Poll until the operation reaches `COMPLETED` or `FAILED`:

   ```bash tab="curl"
   curl -s "$BASE_URL/v1/hosting/app-operations/$OPERATION_ID" \
     -H "Authorization: Bearer $GODADDY_PAT" | jq '{status: .status, appId: .app.id}'
   ```

   ```js tab="Node"
   let data;
   do {
     await new Promise(r => setTimeout(r, 3000));
     const r = await fetch(pollUrl, {
       headers: { Authorization: `Bearer ${process.env.GODADDY_PAT}` },
     });
     data = await r.json();
   } while (data.status !== 'COMPLETED' && data.status !== 'FAILED');
   const appId = data.app.id;
   ```

   ```python tab="Python"
   import time

   while True:
       r = requests.get(
           poll_url,
           headers={"Authorization": f"Bearer {os.environ['GODADDY_PAT']}"},
       )
       data = r.json()
       if data["status"] in ("COMPLETED", "FAILED"):
           break
       time.sleep(3)
   app_id = data["app"]["id"]
   ```

   ```go tab="Go"
   var appID string
   for {
       req, _ := http.NewRequest("GET", pollUrl, nil)
       req.Header.Set("Authorization", "Bearer "+os.Getenv("GODADDY_PAT"))
       resp, _ := http.DefaultClient.Do(req)
       var result map[string]interface{}
       json.NewDecoder(resp.Body).Decode(&result)
       resp.Body.Close()
       status := result["status"].(string)
       if status == "COMPLETED" || status == "FAILED" {
           app := result["app"].(map[string]interface{})
           appID = app["id"].(string)
           break
       }
       time.Sleep(3 * time.Second)
   }
   ```

### Upload source and preview your app with the API

`POST /apps/{appId}/imports` accepts a zip as `multipart/form-data` and returns `202 Accepted` with a `SourceImport` operation. Poll it with `GET /apps/{appId}/imports/{importId}` until the status reaches `COMPLETED` or `FAILED`. The curl examples use `$IMPORT_ID` for the `importId` in the response. After the import reaches `COMPLETED`, your code runs on the `preview` variant, which works without a hosting plan. The preview URL is private, so sign in to your GoDaddy account to open it. Go to [Get app URLs with the API](#get-app-urls-with-the-api) for the request that returns it.

The following procedure zips your app, uploads it, and polls the import.

1. Zip the app, leaving out `node_modules`, `.env` files, and `.git`:

   ```bash
   zip -r my-app.zip . -x "node_modules/*" -x ".env*" -x ".git/*"
   ```

2. Upload the zip:

   ```bash tab="curl"
   curl -s -X POST "$BASE_URL/v1/hosting/apps/$APP_ID/imports" \
     -H "Authorization: Bearer $GODADDY_PAT" \
     -F "file=@./my-app.zip"
   ```

   ```js tab="Node"
   import { createReadStream } from 'fs';
   import FormData from 'form-data';

   const form = new FormData();
   form.append('file', createReadStream('./my-app.zip'));
   const res = await fetch(`${process.env.BASE_URL}/v1/hosting/apps/${appId}/imports`, {
     method: 'POST',
     headers: {
       Authorization: `Bearer ${process.env.GODADDY_PAT}`,
       ...form.getHeaders(),
     },
     body: form,
   });
   const { importId, links } = await res.json();
   const pollUrl = links.find(l => l.rel === 'self').href;
   ```

   ```python tab="Python"
   with open('./my-app.zip', 'rb') as f:
       resp = requests.post(
           f"{os.environ['BASE_URL']}/v1/hosting/apps/{app_id}/imports",
           headers={"Authorization": f"Bearer {os.environ['GODADDY_PAT']}"},
           files={"file": f},
       )
   data = resp.json()
   import_id = data["importId"]
   poll_url = next(l["href"] for l in data["links"] if l["rel"] == "self")
   ```

   ```go tab="Go"
   file, _ := os.Open("./my-app.zip")
   defer file.Close()
   buf := &bytes.Buffer{}
   w := multipart.NewWriter(buf)
   part, _ := w.CreateFormFile("file", "my-app.zip")
   io.Copy(part, file)
   w.Close()
   req, _ := http.NewRequest("POST",
       os.Getenv("BASE_URL")+"/v1/hosting/apps/"+appID+"/imports", buf)
   req.Header.Set("Authorization", "Bearer "+os.Getenv("GODADDY_PAT"))
   req.Header.Set("Content-Type", w.FormDataContentType())
   resp, _ := http.DefaultClient.Do(req)
   defer resp.Body.Close()
   var result map[string]interface{}
   json.NewDecoder(resp.Body).Decode(&result)
   importId := result["importId"].(string)
   // Find poll URL from links array where rel == "self"
   ```

3. Poll until the upload reaches a terminal state:

   ```bash tab="curl"
   curl -s "$BASE_URL/v1/hosting/apps/$APP_ID/imports/$IMPORT_ID" \
     -H "Authorization: Bearer $GODADDY_PAT" | jq .status
   ```

   ```js tab="Node"
   let importStatus;
   do {
     await new Promise(r => setTimeout(r, 2000));
     const r = await fetch(pollUrl, {
       headers: { Authorization: `Bearer ${process.env.GODADDY_PAT}` },
     });
     ({ status: importStatus } = await r.json());
   } while (importStatus !== 'COMPLETED' && importStatus !== 'FAILED');
   ```

   ```python tab="Python"
   while True:
       r = requests.get(
           poll_url,
           headers={"Authorization": f"Bearer {os.environ['GODADDY_PAT']}"},
       )
       import_status = r.json()["status"]
       if import_status in ("COMPLETED", "FAILED"):
           break
       time.sleep(2)
   ```

   ```go tab="Go"
   for {
       req, _ := http.NewRequest("GET", pollUrl, nil)
       req.Header.Set("Authorization", "Bearer "+os.Getenv("GODADDY_PAT"))
       resp, _ := http.DefaultClient.Do(req)
       var result map[string]interface{}
       json.NewDecoder(resp.Body).Decode(&result)
       resp.Body.Close()
       if s := result["status"].(string); s == "COMPLETED" || s == "FAILED" {
           break
       }
       time.Sleep(2 * time.Second)
   }
   ```

### Attach to hosting plan with the API

Before you can publish a Node.js app, you must attach it to a web hosting subscription. Use a valid subscription ID from your GoDaddy account (`GET /subscriptions?hostingProduct=WEB_HOSTING` lists the plans on it). `PUT /apps/{appId}/subscription` attaches the app to one, and the call is synchronous, so there's no operation to poll. The curl example uses `$SUBSCRIPTION_ID` for the `subscriptionId` of a plan with an available slot. Go to [Attach to a hosting plan](https://developer.godaddy.com/docs/api-users/hosting/attach-hosting-plan) for detailed guidance.

* Attach the app to a subscription:

  ```bash tab="curl"
  curl -s -X PUT "$BASE_URL/v1/hosting/apps/$APP_ID/subscription" \
    -H "Authorization: Bearer $GODADDY_PAT" \
    -H "Content-Type: application/json" \
    -d '{ "subscriptionId": "'$SUBSCRIPTION_ID'" }'
  ```

  ```js tab="Node"
  const res = await fetch(`${process.env.BASE_URL}/v1/hosting/apps/${appId}/subscription`, {
    method: 'PUT',
    headers: {
      Authorization: `Bearer ${process.env.GODADDY_PAT}`,
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({ subscriptionId }),
  });
  if (!res.ok) {
    console.error(`Error: ${res.status}`);
    return;
  }
  const result = await res.json();
  ```

  ```python tab="Python"
  import requests, os

  resp = requests.put(
      f"{os.environ['BASE_URL']}/v1/hosting/apps/{app_id}/subscription",
      headers={"Authorization": f"Bearer {os.environ['GODADDY_PAT']}"},
      json={"subscriptionId": subscription_id},
  )
  if resp.status_code != 200:
      print(f"Error: {resp.status_code}")
      exit(1)
  result = resp.json()
  ```

  ```go tab="Go"
  body := strings.NewReader(`{"subscriptionId":"` + subscriptionID + `"}`)
  req, _ := http.NewRequest("PUT",
      os.Getenv("BASE_URL")+"/v1/hosting/apps/"+appID+"/subscription",
      body)
  req.Header.Set("Authorization", "Bearer "+os.Getenv("GODADDY_PAT"))
  req.Header.Set("Content-Type", "application/json")
  resp, _ := http.DefaultClient.Do(req)
  defer resp.Body.Close()
  if resp.StatusCode != 200 {
      fmt.Printf("Error: %d\n", resp.StatusCode)
      return
  }
  var result map[string]interface{}
  json.NewDecoder(resp.Body).Decode(&result)
  ```

### Publish your app with the API

`POST /apps/{appId}/deployments` builds the latest source, deploys it to the publish environment, and returns `202 Accepted` with a `Deployment`. Poll it with `GET /apps/{appId}/deployments/{deploymentId}` until the status reaches `COMPLETED` or `FAILED`. The curl examples use `$DEPLOYMENT_ID` for the `deploymentId` in the response.

1. Publish the app:

   ```bash tab="curl"
   curl -s -X POST "$BASE_URL/v1/hosting/apps/$APP_ID/deployments" \
     -H "Authorization: Bearer $GODADDY_PAT" \
     -H "Content-Type: application/json" \
     -d '{}'
   ```

   ```js tab="Node"
   const res = await fetch(`${process.env.BASE_URL}/v1/hosting/apps/${appId}/deployments`, {
     method: 'POST',
     headers: {
       Authorization: `Bearer ${process.env.GODADDY_PAT}`,
       'Content-Type': 'application/json',
     },
     body: JSON.stringify({}),
   });
   const { deploymentId, links } = await res.json();
   const pollUrl = links.find(l => l.rel === 'self').href;
   ```

   ```python tab="Python"
   resp = requests.post(
       f"{os.environ['BASE_URL']}/v1/hosting/apps/{app_id}/deployments",
       headers={"Authorization": f"Bearer {os.environ['GODADDY_PAT']}"},
       json={},
   )
   data = resp.json()
   deployment_id = data["deploymentId"]
   poll_url = next(l["href"] for l in data["links"] if l["rel"] == "self")
   ```

   ```go tab="Go"
   req, _ := http.NewRequest("POST",
       os.Getenv("BASE_URL")+"/v1/hosting/apps/"+appID+"/deployments",
       strings.NewReader(`{}`))
   req.Header.Set("Authorization", "Bearer "+os.Getenv("GODADDY_PAT"))
   req.Header.Set("Content-Type", "application/json")
   resp, _ := http.DefaultClient.Do(req)
   var result map[string]interface{}
   json.NewDecoder(resp.Body).Decode(&result)
   deploymentId := result["deploymentId"].(string)
   // Find poll URL from links array where rel == "self"
   ```

2. Poll until deployment reaches a terminal state:

   ```bash tab="curl"
   curl -s "$BASE_URL/v1/hosting/apps/$APP_ID/deployments/$DEPLOYMENT_ID" \
     -H "Authorization: Bearer $GODADDY_PAT" | jq .status
   ```

   ```js tab="Node"
   let deploymentStatus;
   do {
     await new Promise(r => setTimeout(r, 5000));
     const r = await fetch(pollUrl, {
       headers: { Authorization: `Bearer ${process.env.GODADDY_PAT}` },
     });
     ({ status: deploymentStatus } = await r.json());
   } while (deploymentStatus !== 'COMPLETED' && deploymentStatus !== 'FAILED');
   ```

   ```python tab="Python"
   while True:
       r = requests.get(
           poll_url,
           headers={"Authorization": f"Bearer {os.environ['GODADDY_PAT']}"},
       )
       deployment_status = r.json()["status"]
       if deployment_status in ("COMPLETED", "FAILED"):
           break
       time.sleep(5)
   ```

   ```go tab="Go"
   for {
       req, _ := http.NewRequest("GET", pollUrl, nil)
       req.Header.Set("Authorization", "Bearer "+os.Getenv("GODADDY_PAT"))
       resp, _ := http.DefaultClient.Do(req)
       var result map[string]interface{}
       json.NewDecoder(resp.Body).Decode(&result)
       resp.Body.Close()
       if s := result["status"].(string); s == "COMPLETED" || s == "FAILED" {
           break
       }
       time.Sleep(5 * time.Second)
   }
   ```

### Verify with the API

`GET /apps/{appId}/status` returns the application lifecycle in top-level `status` and per-environment detail in `variants`. The app is healthy when `status` is `ACTIVE`. The other values are `CREATING`, `FAILED`, `DELETING`, `SUSPENDED`, and `UNKNOWN`. `UNKNOWN` means the state can't be determined, so don't treat it as healthy. Each entry in `variants` has its own `status`, which is `ACTIVE` when that environment is healthy. It also has a lowercase `lifecycleState`, which is `running` when that environment is up. The other main `lifecycleState` values are `provisioning`, `reloading`, `paused`, `deleting`, and `failed`. Other values are possible.

The following procedure confirms the app is running.

1. Read the app status:

   ```bash tab="curl"
   curl -s "$BASE_URL/v1/hosting/apps/$APP_ID/status" \
     -H "Authorization: Bearer $GODADDY_PAT" | jq .
   ```

   ```js tab="Node"
   const r = await fetch(`${process.env.BASE_URL}/v1/hosting/apps/${appId}/status`, {
     headers: { Authorization: `Bearer ${process.env.GODADDY_PAT}` },
   });
   console.log(await r.json());
   ```

   ```python tab="Python"
   resp = requests.get(
       f"{os.environ['BASE_URL']}/v1/hosting/apps/{app_id}/status",
       headers={"Authorization": f"Bearer {os.environ['GODADDY_PAT']}"},
   )
   print(resp.json())
   ```

   ```go tab="Go"
   req, _ := http.NewRequest("GET",
       os.Getenv("BASE_URL")+"/v1/hosting/apps/"+appID+"/status", nil)
   req.Header.Set("Authorization", "Bearer "+os.Getenv("GODADDY_PAT"))
   resp, _ := http.DefaultClient.Do(req)
   io.Copy(os.Stdout, resp.Body)
   resp.Body.Close()
   ```

2. Check that `status` is `ACTIVE`, and that the `PUBLISH` entry in `variants` has a `status` of `ACTIVE` and a `lifecycleState` of `running`.

3. Open the `urls.publish` address to see the live app. The next step shows how to read it.

### Get app URLs with the API

`GET /apps/{appId}` returns the full app record, including a `urls` object with the URL for each environment. Your code is not live at `urls.publish` until you publish.

* Read the app record to get its URLs:

  ```bash tab="curl"
  curl -s "$BASE_URL/v1/hosting/apps/$APP_ID" \
    -H "Authorization: Bearer $GODADDY_PAT" | jq .urls
  ```

  ```js tab="Node"
  const res = await fetch(`${process.env.BASE_URL}/v1/hosting/apps/${appId}`, {
    headers: { Authorization: `Bearer ${process.env.GODADDY_PAT}` },
  });
  const { urls } = await res.json();
  console.log(urls.preview);  // preview environment URL
  console.log(urls.publish);  // publish environment URL
  ```

  ```python tab="Python"
  resp = requests.get(
      f"{os.environ['BASE_URL']}/v1/hosting/apps/{app_id}",
      headers={"Authorization": f"Bearer {os.environ['GODADDY_PAT']}"},
  )
  urls = resp.json()["urls"]
  print(urls["preview"])  # preview environment URL
  print(urls["publish"])  # publish environment URL
  ```

  ```go tab="Go"
  req, _ := http.NewRequest("GET",
      os.Getenv("BASE_URL")+"/v1/hosting/apps/"+appID, nil)
  req.Header.Set("Authorization", "Bearer "+os.Getenv("GODADDY_PAT"))
  resp, _ := http.DefaultClient.Do(req)
  defer resp.Body.Close()
  var result map[string]interface{}
  json.NewDecoder(resp.Body).Decode(&result)
  urls := result["urls"].(map[string]interface{})
  fmt.Println(urls["preview"])  // preview environment URL
  fmt.Println(urls["publish"])  // publish environment URL
  ```

## Deploy updates with the API

To deploy new code to an existing app, repeat the upload and publish steps. You don't need to create a new app or re-attach it to a hosting plan.

The following procedure uploads new code and publishes it.

1. Upload the updated zip with `POST /apps/{appId}/imports`.

2. Poll the upload with `GET /apps/{appId}/imports/{importId}` until it reaches a terminal state.

3. Publish the update with `POST /apps/{appId}/deployments`.

4. Poll the deployment with `GET /apps/{appId}/deployments/{deploymentId}` until it reaches a terminal state.

## Common errors

The following table lists common errors and recommended actions:

| Status                                | Cause                                       | Action                                                                                                   |
| ------------------------------------- | ------------------------------------------- | -------------------------------------------------------------------------------------------------------- |
| `401`                                 | Expired or revoked PAT, or missing scope    | Go to [Hosting core concepts](https://developer.godaddy.com/docs/api-users/hosting/concepts#scopes-reference) for the scopes you need |
| `gddy` reports an auth or scope error | Not signed in, or the sign-in lacks a scope | Run `gddy auth status`, then `gddy auth login`. Add `--scope` for each missing scope                     |
| `429`                                 | Rate limit exceeded                         | Back off and retry. Go to [Rate limits](https://developer.godaddy.com/docs/api-users/rate-limits) for handling guidance               |
| Operation stuck in `PENDING`          | Upstream provisioning delay                 | Wait up to two minutes before treating it as failed                                                      |
| Import job `FAILED`                   | Malformed zip or build failure              | Check the application structure and reupload                                                             |
