# Your first cloud build

Create your own API key, build a bracket in AgentCAD Cloud, and download a checked STEP file.

Preview | Updated 2026-11-30

## Read with your agent

Give your agent the public Markdown guide. Reading it needs no account or API key. You create the key yourself in the browser when you reach that step.

### Prompt for your agent

```text
Read https://agentcad.dev/api/docs/cloud/first-cloud-build?format=markdown and help me follow it. Ask me to create my own API key in the browser and enter it privately in my terminal. Never ask me to paste the secret into chat. Keep the returned project and job IDs and poll the same job until it finishes.
```

### Fetch the guide in any terminal

```bash
curl --fail --silent --show-error 'https://agentcad.dev/api/docs/cloud/first-cloud-build?format=markdown'
```

Using local MCP: the AgentCAD docs tool reads the reference bundled with your package. It does not fetch this live guide. Give the Markdown URL above to an agent with web access, or let it use the terminal command above. If your MCP client has neither web nor terminal access, open the Markdown page and paste the guide text into that client. Do not include your API key.

> The CLI reader is available in v0.8.3 and later. With Python 3.10–3.12, install or upgrade agentcad[cloud]. Check agentcad cloud --help for docs. Older clients can use the public terminal fetch above without upgrading.

### Read the guide with CLI v0.8.3 or later

```bash
agentcad cloud docs
agentcad cloud docs first-cloud-build
agentcad cloud docs first-cloud-build --format json
```

The CLI reader returns Markdown by default; --format json gives structured output. It reads the same service-owned content as this website. The existing agentcad docs command remains the offline reference. Documentation access never grants cloud compute or access to private projects.

## What you will make

![Rendered model geometry: an L bracket with two holes in its base and a separate square spacer beside it.](https://agentcad.dev/docs/cloud/first-bracket.png)

Actual geometry from the script below: two holes, an upright bracket and a separate spacer. Overall bounds: 125 × 60 × 40 mm. The spacer is a second solid, not a defect.

1. **Account + key:** Sign in and create your own credential.
2. **Private project:** Keep the returned project ID.
3. **Accepted:** Save the job ID. Queued is not finished.
4. **Validated:** Wait for success and valid geometry.
5. **Downloaded:** Save the STEP and inspect it.
6. **Activity:** Find the same job in your history.

## Before you start

Ask your agent to follow this guide with you. You will sign in and create your own key in the browser, then use the production HTTP API to build an L bracket with two holes and a separate spacer. You need a terminal with curl and Python 3; no local CAD engine is required.

> Cloud preview access is self-service. No manual account approval is needed. These examples target production at https://api.agentcad.dev with keys from https://agentcad.dev. A preview-site key belongs to its matching service environment.

This first journey uses the HTTP API. The CLI can read this guide from the service; broader CLI and remote MCP operation parity is being delivered separately. Reading guides does not grant access to private projects or cloud jobs.

## 1. Create your account and key

- [Sign up or sign in and accept the terms](https://agentcad.dev/account)
- [Create a named API key](https://agentcad.dev/account/api-keys)

Your account gets its own private workspace. Create a key named for this integration. Copy the secret when it is shown: you only see the complete secret once. Keep it in your password manager. Never paste it into agent chat, source files, screenshots or a URL. Key management stays in the signed-in website.

### Set up a private working directory and enter your key

```bash
mkdir agentcad-first-cloud-build
cd agentcad-first-cloud-build
umask 077
export AGENTCAD_API_URL='https://api.agentcad.dev'
export AGENTCAD_API_KEY="$(python3 -c 'import getpass; print(getpass.getpass("AgentCAD API key: "))')"
```

> Run the commands in the same terminal. The key prompt is hidden and keeps the literal secret out of shell history. Environment variables can still be read by processes with access to your session. Use a secret manager for a deployed integration.

## 2. Check your connection

### List your projects

```bash
curl --fail-with-body --silent --show-error \
  "$AGENTCAD_API_URL/v1/projects" \
  -H "Authorization: Bearer $AGENTCAD_API_KEY"
```

A valid key returns a projects array; an empty array is normal for a new account. A 401 means the key is invalid, revoked or from another environment. Stop and check the key and API origin before creating work. Do not send the secret to support.

## 3. Create a private project

### Create a project and save its ID

```bash
PROJECT_ID=''
if [ -e project.json ]; then mv project.json project.previous.json; fi &&
curl --fail-with-body --silent --show-error \
  "$AGENTCAD_API_URL/v1/projects" \
  -H "Authorization: Bearer $AGENTCAD_API_KEY" \
  -H 'Content-Type: application/json' \
  --data '{"name":"My first cloud bracket","runtime":"build123d"}' \
  --output project.pending.json &&
PROJECT_ID=$(python3 -c 'import json; project=json.load(open("project.pending.json")); assert project["id"].startswith("prj_"); print(project["id"])') &&
mv project.pending.json project.json &&
printf '%s\n' "$PROJECT_ID"
```

Stop if a block exits with an error. Responses are saved to pending files and become the current JSON receipt only after the request and checks succeed. Any prior current receipt is kept in a previous file for inspection, not as a new result. Keep project.json and the returned prj_ ID. Project creation is not an idempotent build submission. If this request loses its response, list your projects before creating another one.

## 4. Upload a script and start one build

### Create bracket.py

```bash
cat > bracket.py <<'PY'
from build123d import Align, Box, Compound, Cylinder, Pos

base = Box(100, 60, 8, align=(Align.CENTER, Align.CENTER, Align.MIN))
upright = Pos(0, -26, 0) * Box(100, 8, 40, align=(Align.CENTER, Align.CENTER, Align.MIN))
bracket = base + upright
for x in (-30, 30):
    bracket -= Pos(x, 15, 0) * Cylinder(5, 8, align=(Align.CENTER, Align.CENTER, Align.MIN))
spacer = Pos(70, 0, 4) * Box(10, 10, 8)
show_object(Compound(children=[bracket, spacer]))
PY
```

### Save a retry key before submitting

```bash
python3 -c 'import uuid; print(uuid.uuid4().hex)' > build-retry-key.txt
```

### Submit the build

```bash
if [ -e submitted.json ]; then mv submitted.json submitted.previous.json; fi &&
RETRY_KEY=$(cat build-retry-key.txt) &&
curl --fail-with-body --silent --show-error \
  "$AGENTCAD_API_URL/v1/projects/$PROJECT_ID/runs" \
  -H "Authorization: Bearer $AGENTCAD_API_KEY" \
  -H "Idempotency-Key: $RETRY_KEY" \
  -F 'label=first-bracket' \
  -F 'file=@bracket.py;type=text/x-python' \
  --output submitted.pending.json &&
python3 - "$PROJECT_ID" <<'PY' &&
import json, sys
job = json.load(open('submitted.pending.json'))
assert job['id'].startswith('job_'), 'No job ID was returned'
assert job['project_id'] == sys.argv[1], 'Response belongs to another project'
assert job['poll_url'] == '/v1/projects/' + job['project_id'] + '/jobs/' + job['id'], 'Unexpected poll URL'
PY
mv submitted.pending.json submitted.json &&
python3 -m json.tool submitted.json
```

The API accepts the script and returns a job, its job_ ID and a poll_url. A new job is queued or running; replaying a saved retry key may return an already completed job. Acceptance is not completion. Keep submitted.json, bracket.py and build-retry-key.txt. If the submission response is lost, repeat only the Submit the build block with the same project, file, label and saved retry key. Do not regenerate the key for a retry. New work needs a new key.

> This uploads only bracket.py. Local paths are not cloud assets, and there is no automatic folder sync. The separate spacer is intentional; a valid model can contain more than one solid.

## 5. Poll the same job

### Check the submitted job

```bash
if [ -e job.json ]; then mv job.json job.previous.json; fi &&
POLL_PATH=$(python3 -c 'import json; print(json.load(open("submitted.json"))["poll_url"])') &&
curl --fail-with-body --silent --show-error \
  "$AGENTCAD_API_URL$POLL_PATH" \
  -H "Authorization: Bearer $AGENTCAD_API_KEY" \
  --output job.pending.json &&
python3 - <<'PY' &&
import json
submitted = json.load(open('submitted.json'))
job = json.load(open('job.pending.json'))
assert job['id'] == submitted['id'], 'Response belongs to another job'
assert job['project_id'] == submitted['project_id'], 'Response belongs to another project'
PY
mv job.pending.json job.json &&
python3 -m json.tool job.json
```

If status is queued or running, wait a few seconds and repeat this polling block. A request timeout also means poll the same saved job again. The old current job.json is moved to job.previous.json before each attempt, so a failed request cannot leave an older success available for verification. Do not rename a previous or pending response back to job.json; retry the polling block. Never submit another build just to check progress. A failed job is a failure even though the submission was accepted; inspect its reason/message and do not attempt the success-only download steps.

### Verify completion and geometry before downloading

```bash
python3 - <<'PY'
import json
job = json.load(open('job.json'))
submitted = json.load(open('submitted.json'))
project = json.load(open('project.json'))
assert job['project_id'] == project['id'], 'Response belongs to another project attempt'
assert job['id'] == submitted['id'], 'Response belongs to another job'
assert job['project_id'] == submitted['project_id'], 'Response belongs to another project'
assert job['status'] == 'succeeded', 'Not successful yet: poll again, or inspect the failure'
assert job['geometry_valid'] is True, 'The job did not prove valid geometry'
assert job.get('download_url'), 'No STEP download was returned'
print('Build succeeded and geometry is valid. Version:', job['version'])
PY
```

## 6. Download and verify the STEP

### Download the successful job output

```bash
DOWNLOAD_PATH=$(python3 -c 'import json; print(json.load(open("job.json"))["download_url"])') &&
curl --fail-with-body --silent --show-error \
  "$AGENTCAD_API_URL$DOWNLOAD_PATH" \
  -H "Authorization: Bearer $AGENTCAD_API_KEY" \
  --output bracket.step.part && mv bracket.step.part bracket.step &&
python3 - <<'PY'
from pathlib import Path
import hashlib
part = Path('bracket.step').read_bytes()
assert part.lstrip().startswith(b'ISO-10303-21;'), 'Not a STEP file'
print('STEP bytes:', len(part))
print('Local SHA-256:', hashlib.sha256(part).hexdigest())
PY
```

Use the returned download_url rather than guessing a version path. Successful geometry validation and a successful download are separate checks. Only run the file check after curl and the rename succeed. The printed hash identifies your local bytes; it is not an independent server receipt. Open the file in your CAD viewer and check the bracket, two holes and separate spacer before manufacturing anything.

## 7. Check activity and revoke the key

### Read recent job activity

```bash
curl --fail-with-body --silent --show-error \
  "$AGENTCAD_API_URL/v1/activity?limit=25" \
  -H "Authorization: Bearer $AGENTCAD_API_KEY"
```

- [View account activity](https://agentcad.dev/account/activity)
- [Manage or revoke your API key](https://agentcad.dev/account/api-keys)

Find the saved job ID in activity. The feed is paginated; follow next_cursor if needed. Activity is a view of job history, not proof that an artifact is downloadable or a final billing statement. Compute costs are estimates with incomplete provider/shared/storage/transfer allocation. Creating an account does not start paid billing.

When finished, revoke this test key on the website and repeat List your projects. It should return 401. To rotate a real integration key, create a replacement, update and test the integration, then revoke the old key. Revocation blocks new protected requests with that credential; it does not cancel accepted jobs or delete retained outputs.

### Clear the key from this terminal

```bash
unset AGENTCAD_API_KEY
```

## What stays and where to get help

The project, uploaded script and generated artifacts are retained in your cloud workspace. Clearing this terminal or revoking a key does not remove them. Keep until deleted is the default. You can choose automatic account-wide retention through the API, CLI or MCP and view its status at https://agentcad.dev/account/retention. Expiration blocks access; daily cleanup confirms deletion separately. Keep your own backups. Your local working directory contains the script, retry key, JSON responses and downloaded STEP; remove it yourself when you no longer need it.

- [Preview support and deletion requests](mailto:hello@jdilla.xyz)
- [Privacy policy](https://agentcad.dev/privacy)
- [Terms](https://agentcad.dev/terms)
