---
title: Deployment API
description: Deploy Node.js and Next.js apps to your own Hostino Node.js hosting via the API
sidebar:
  order: 7
  badge:
    text: Alpha
    variant: tip
---

All endpoints live on `https://api.hostino.ai` and use an OAuth (Bearer) token. The full flow and behaviour (build on the server, zero-downtime switch, automatic restore, dependency reuse) is described in [AI Deploy](/en/ai-mcp/ai-deploy/).

| Endpoint | Scope | What it does |
|---|---|---|
| `GET /v1/deploy/targets` | `deploy:read` | Services that can run a Node.js app, and the apps on each |
| `GET /v1/apps` | `deploy:read` | Apps, domain/path, Node version and environment variable names |
| `POST /v1/deployments` | `deploy:write` | Start a deployment and get a single-use upload link |
| `PUT /v1/uploads/:token` | single-use token | Upload the project's `tar.gz` archive (up to 50 MB) |
| `GET /v1/deployments/:id` | `deploy:read` | Status |
| `GET /v1/deployments/:id/logs?tail=` | `deploy:read` | Install/build and runtime logs |
| `GET /v1/deployments/:id/analysis` | `deploy:read` | Why a deploy failed: known causes with evidence from the logs and fixes |
| `POST /v1/apps/:app/env` | `deploy:write` | Set/remove environment variables (`set`, `unset`) |
| `POST /v1/apps/:app/rollback` | `deploy:write` | Switch back to an earlier successful deployment (`deployment_id`) |
| `POST /v1/apps/:app/restart` | `deploy:write` | Restart |

## Start a deployment

```bash
curl -s -X POST https://api.hostino.ai/v1/deployments -H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" \
  -d '{"service_id":"389","app_name":"web","node_version":"20"}'
```

`domain` (one of the account's domains or subdomains) and `app_uri` (a path, e.g. `api`) are optional. The response includes `upload.url` and `upload.command`:

```bash
tar --exclude=node_modules --exclude=.next --exclude=.git --exclude='.env*' -czf /tmp/hostino-deploy.tgz . \
  && curl -sS --fail-with-body -X PUT -H 'Content-Type: application/gzip' --data-binary @/tmp/hostino-deploy.tgz '<upload.url>'
```

## Statuses

`awaiting_upload` → `uploading` → `extracting` → `building` → `activating` → `live` or `failed` (with `error` and `error_detail`). The previous deployment becomes `replaced` once the new one is live. If the backup copy had to be removed to make room, `note` says so, and `dependencies_reused` shows whether dependencies were reused instead of reinstalled.

## Failed-deploy analysis

`GET /v1/deployments/:id/analysis` matches a deployment's error and its build and runtime logs against known causes on Hostino Node.js hosting, and returns for each a `cause`, `evidence` from the log and a concrete `fix` (up to 5). The analysis runs on Hostino's side; no log is sent anywhere. When a deployment is `failed`, `GET /v1/deployments/:id` also includes these findings as `diagnosis`.

```json
{
  "deployment_id": "web-k3x9", "status": "failed", "error": "build_failed",
  "findings": [
    { "cause": "missing_module", "title": "Package \"axios\" is missing",
      "fix": "Add it to \"dependencies\" (not devDependencies) in package.json — e.g. npm install axios — commit package.json and package-lock.json, then deploy again.",
      "evidence": "Error: Cannot find module 'axios'" }
  ]
}
```

Recognized causes: a missing package or letter-case differences in an import path, conflicting package versions, the Node.js version, syntax and TypeScript errors, the memory and process limits of the hosting, a full disk, network errors while downloading npm packages, a missing `build` script or start file, a fixed port instead of `process.env.PORT`, an unset environment variable, Next.js starting without a build, and database connection errors. If nothing matches, `findings` is empty and `note` says to read the last log lines.

## Errors

Error codes and their fixes are listed in [AI Deploy → Errors and fixes](/en/ai-mcp/ai-deploy/#errors-and-fixes).
