# Ship with an AI agent

The only thing your agent needs from you is a site API key; every step after that can be delegated. Paste the prompt below into Claude Code, ChatGPT, Cursor or any agent that can run commands, and it ships the site with the deploy API.

## What does the agent need from me?

1. A Soartana account and a site: open **Hosting** and choose **New site**.
2. A site API key: on the site page open **API keys**, create one, and copy it. It is shown once.
3. The key in your agent's environment as `SOARTANA_API_KEY`.

Shell setup

```sh
export SOARTANA_API_KEY="shk_..."   # never commit it
export API="https://api.soartana.com/api/public/hosting/v1"
```

## What do I paste into the agent?

Agent prompt

```text
You are deploying a static website to Soartana Hosting for me.

1. Read https://app.soartana.com/docs/llms.txt, then https://app.soartana.com/docs/developer/ship-with-an-ai-agent.md.
2. My site API key is in the environment variable SOARTANA_API_KEY (it starts with shk_). Never print it, log it or commit it.
3. Build the site if it needs a build, and find the output folder that contains index.html.
4. Deploy that folder with the Soartana Hosting deploy API v1 at https://api.soartana.com/api/public/hosting/v1:
   create the deploy from a manifest of every file, PUT each file to its presigned URL with every header the API returned,
   finalize the deploy, then promote it.
5. If a call fails, read error_code and message, fix the cause and start a new deploy. Do not retry a failed deploy.
6. When it is live, tell me the site's default_url.
```

> **Warning:** The key can deploy, promote and roll back this one site. Keep it out of chats you share and out of your repository; revoke it on the API keys tab if it leaks.

## Which calls will the agent make?

The same four calls a person makes, shown for one `index.html`:

1\. Start the deploy: send the manifest, get one presigned PUT per file

```sh
SIZE=$(wc -c < index.html | tr -d ' ')
curl -sS -X POST "$API/deploys" \
  -H "Authorization: Bearer $SOARTANA_API_KEY" \
  -H "Content-Type: application/json" \
  -d "{\"files\":[{\"path\":\"index.html\",\"size\":$SIZE,\"content_type\":\"text/html\"}]}" \
  > deploy.json
DEPLOY_ID=$(jq -r '.data.deploy.id' deploy.json)
```

2\. Upload the file with every header the API returned

```sh
jq -r '.data.uploads[0].headers | to_entries[] | "header = \"\(.key): \(.value)\""' deploy.json > put.cfg
curl -sS -X PUT "$(jq -r '.data.uploads[0].url' deploy.json)" -K put.cfg --data-binary @index.html
```

3\. Finalize: every file is checked for presence and exact size

```sh
curl -sS -X POST "$API/deploys/$DEPLOY_ID/finalize" \
  -H "Authorization: Bearer $SOARTANA_API_KEY"
```

4\. Promote the deploy to production

```sh
curl -sS -X POST "$API/deploys/$DEPLOY_ID/promote" \
  -H "Authorization: Bearer $SOARTANA_API_KEY"
```

## Is there a script that does all of it?

Yes. This one file has no dependencies, uploads a whole folder and prints the live address. Run it with `node deploy.mjs ./dist`.

deploy.mjs

```js
// deploy.mjs. Usage: SOARTANA_API_KEY=shk_... node deploy.mjs ./dist
import { readdir, readFile, stat } from "node:fs/promises";
import { join, relative, sep } from "node:path";

const API = "https://api.soartana.com/api/public/hosting/v1";
const KEY = process.env.SOARTANA_API_KEY;
const root = process.argv[2] ?? "dist";
if (!KEY) throw new Error("Set SOARTANA_API_KEY to a site API key.");

async function walk(dir) {
  const files = [];
  for (const entry of await readdir(dir, { withFileTypes: true })) {
    if (entry.name === "node_modules") continue;
    if (entry.name.startsWith(".") && entry.name !== ".well-known") continue;
    const full = join(dir, entry.name);
    if (entry.isDirectory()) files.push(...(await walk(full)));
    else if (entry.isFile()) files.push(full);
  }
  return files;
}

async function call(method, path, body) {
  const res = await fetch(API + path, {
    method,
    headers: { Authorization: `Bearer ${KEY}`, ...(body ? { "Content-Type": "application/json" } : {}) },
    body: body ? JSON.stringify(body) : undefined,
  });
  const json = await res.json();
  if (!json.success) throw new Error(`${res.status} ${json.error_code ?? ""} ${json.message}`);
  return json.data;
}

const files = [];
for (const full of await walk(root)) {
  files.push({ path: relative(root, full).split(sep).join("/"), size: (await stat(full)).size });
}
const { deploy, uploads } = await call("POST", "/deploys", { files });
for (const upload of uploads) {
  const body = await readFile(join(root, upload.path));
  const res = await fetch(upload.url, { method: "PUT", headers: upload.headers, body });
  // 412 means this exact file is already stored (a retried upload).
  if (!res.ok && res.status !== 412) throw new Error(`Upload of ${upload.path} answered ${res.status}`);
}
await call("POST", `/deploys/${deploy.id}/finalize`);
const site = await call("POST", `/deploys/${deploy.id}/promote`);
console.log(`Live at ${site.default_url}`);
```

## Where does the agent read more?

- [llms.txt](/docs/llms.txt): the index for agents, with the base URL and the auth header.
- [API reference](/docs/developer/hosting/v1/api) and [the OpenAPI document](/openapi/hosting-v1.json) for every field.
- [Errors](/docs/developer/hosting/v1/errors) for every code, and [Limits and plans](/docs/developer/hosting/v1/limits) for the caps.
