> ## Documentation Index
> Fetch the complete documentation index at: https://docs.hypastack.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Uploading

> The three-step reserve, PUT, commit flow used by both Files and CDN.

Uploads take three steps, and they're the same three for files and for CDN assets. Learn it once.

<Steps>
  <Step title="Reserve">
    Tell Hypastack the name, size, and type. You get back an `upload_url`.
  </Step>

  <Step title="PUT the bytes">
    PUT the raw bytes to that URL. They go straight to storage and never touch Hypastack's application servers.
  </Step>

  <Step title="Commit">
    Call `/complete`. Now the file (or asset) exists.
  </Step>
</Steps>

```bash theme={null}
# 1. reserve
INIT=$(curl -s -X POST "https://api.hypastack.com/v3/files" \
  -H "Authorization: Bearer $HYPASTACK_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "name": "hello.txt", "size": 28, "content_type": "text/plain" }')

ID=$(echo "$INIT" | jq -r .id)
URL=$(echo "$INIT" | jq -r .upload_url)

# 2. send the bytes straight to storage
curl -X PUT "$URL" -H "Content-Type: text/plain" --data-binary @hello.txt

# 3. commit
curl -X POST "https://api.hypastack.com/v3/files/$ID/complete" \
  -H "Authorization: Bearer $HYPASTACK_API_KEY"
```

<Note>
  The commit step is safe to repeat. If your connection drops and you're not sure the call landed, just call it again, you get the same file back rather than an error.
</Note>

This is why uploads are fast: bytes go directly to storage rather than being relayed through Hypastack's application servers, so a large file is limited by your own connection and nothing else.
