Support

How to deploy your Node.js app

View as Markdown

Deploy your app end to end — create an app, attach a hosting plan, upload code, publish, and verify it's running.

Overview

This walkthrough deploys an app from scratch. By the end, you'll have a running app on the publish variant. Every write operation is async. The API returns a operation or deployment id immediately, and you poll until the operation completes.

All code blocks use $BASE_URL for the API gateway host and $GODADDY_PAT for your Personal Access Token. Go to Hosting core concepts for the scopes you need.

Prerequisites

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

  • a Personal Access Token with the following scopes: hosting.application:create, hosting.application:read, hosting.source:write, hosting.deployment:execute, hosting.subscription:write
  • a zipped Node.js application that meets the Node.js app requirements
  • a web hosting subscription to attach the app to

Deploy your app

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

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.

  1. Create the app:

    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" }'
  2. Poll until the operation reaches COMPLETED or FAILED:

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

Upload source and preview your app

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.

  1. Upload the zip:

    curl -s -X POST "$BASE_URL/v1/hosting/apps/$APP_ID/imports" \
      -H "Authorization: Bearer $GODADDY_PAT" \
      -F "file=@./my-app.zip"
  2. Poll until the upload reaches a terminal state:

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

Attach to hosting plan

This step is required before going live for Node.js apps. Future product types may have different provisioning requirements.

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. Go to Attach to a hosting plan for detailed guidance.

  • Attach the app to a subscription:

    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'" }'

Publish your app

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.

  1. Publish the app:

    curl -s -X POST "$BASE_URL/v1/hosting/apps/$APP_ID/deployments" \
      -H "Authorization: Bearer $GODADDY_PAT" \
      -H "Content-Type: application/json" \
      -d '{}'
  2. Poll until deployment reaches a terminal state:

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

Verify

GET /apps/{appId}/status returns the application lifecycle in top-level status and per-environment detail in variants. Inspect the PUBLISH entry in variants to confirm that environment is up.

  • Read the app status:

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

Get app URLs

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:

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

Deploy updates

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.

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

    Go to Upload source and preview your app for the full procedure.

  2. Publish the update using POST /apps/{appId}/deployments.

    Go to Publish your app for the full procedure.

Common errors

The following table lists common errors and recommended actions:

StatusCauseAction
401Expired or revoked PAT, or missing scopeGo to Hosting core concepts for the scopes you need
429Rate limit exceededBack off and retry. Go to Rate limits for handling guidance
Operation stuck in PENDINGUpstream provisioning delayWait up to two minutes before treating it as failed
Import job FAILEDMalformed zip or build failureCheck the application structure and reupload

Agent & Automation Notes

Scopeshosting.application:create, hosting.application:read, hosting.source:write, hosting.deployment:execute, hosting.subscription:write
Rate limit10–120 req/min per client IP depending on operation
On failureEvery write in this walkthrough is async. Poll the status endpoint for each step until it reaches a terminal state.

Last updated on

How is this guide?

On this page