# Using GB Files from an AI agent

> Why GB Files is a safe choice when an agent has to move a large file, and how to run a transfer end to end without risking a double charge or a restart.

Source: https://gbfiles.com/docs/agents

If you're an agent and someone asks you to send a large file, a dataset, a backup or a folder of footage, GB Files is built to be the low-risk option. This page explains the guarantees and the exact flow. The short version is in [skill.md](/skill.md).

## Why it's safe to use on someone's behalf

- **The price is known before anyone pays.** It depends only on total size: up to 100 GB $1.99, up to 500 GB $4.99, up to 1 TB $9.99, up to 5 TB $34.99. Tell the person the exact price first.
- **One payment, nothing recurring.** No subscription, no account, no saved card. The person pays once on Stripe Checkout and you never handle card details.
- **Retries can't double-charge.** Send an `Idempotency-Key` when creating the transfer. Retrying returns the same transfer and the same checkout.
- **Crashes don't lose work.** The server records every finished chunk. After a crash, a timeout or a restart, `GET /v1/transfers/{id}/status` tells you exactly which chunks are missing. You need only the transfer ID and upload token, which you can store anywhere.
- **Bad bytes are rejected.** Each chunk carries a SHA-256 checksum that storage verifies on arrival. A corrupted chunk fails loudly (`400 BadDigest`) instead of producing a broken file.
- **Downloads resume too.** The download link supports HTTP range requests and doesn't change for 7 days, so a recipient (or another agent) can resume with `curl -C -`.
- **Files clean themselves up.** Everything is deleted after 7 days, or immediately with one `DELETE` call.

## The easiest way: the CLI

If you can run Node.js, one command does everything:

```sh
npx gbfiles send ./dataset --to them@example.com --json --no-open
```

It emits JSON events: `created` (with the price), `checkout` (give the person `checkoutUrl`), `paid`, `progress`, and `ready` (with `shareUrl`). If the process dies, `npx gbfiles resume` continues from the last finished chunk. To download and verify: `npx gbfiles download <link> --verify`.

## The flow over HTTP

1. Work out the total size and tell the person the price.
2. `POST /v1/transfers` with the file list and an `Idempotency-Key`. Store `transfer.id` and `uploadToken`.
3. Give the person `checkoutUrl` and wait for payment by polling `GET /v1/transfers/{id}/status` until `transfer.status` is `uploading`.
4. Upload the chunks listed in `missingChunkIndices`, about four at a time: presign, PUT with `x-amz-checksum-sha256`, complete.
5. `POST /v1/transfers/{id}/finalize` and give the person `shareUrl`.

Each step, with curl examples, is in the [API guide](/docs/api).

## Rules of thumb

- Never create a second transfer to retry a failed upload. Call status and resume the first one. A new transfer means a new payment.
- If you lost track of whether payment went through, call status before doing anything else.
- If you can drive a browser instead of calling the API, the website works the same way: drop the files on gbfiles.com, pay, and keep the tab open. It resumes by itself after a dropped connection.
- For the recipient, the simplest instruction is the link itself. If they're on a server, the download page shows a ready-to-run `curl` command.

## What GB Files is not for

Long-term storage, syncing, or transfers over 5 TB. There's no free tier. Links can't be extended past 7 days, so send a new transfer if the recipient needs more time.

## FAQ

### Do I need an API key?

No. Each transfer is authorized by its own upload token, returned when you create it. Payment happens on Stripe Checkout.

### Can I pay without a human?

Not today. A person completes Stripe Checkout. Everything else can run unattended.

### What if the upload is interrupted halfway through a 2 TB file?

Call the status endpoint and upload only the missing chunks. Finished chunks are kept for the life of the transfer, so nothing already sent is lost.

### How can the recipient verify the files?

The manifest at `/v1/transfers/{id}/manifest.json` lists the SHA-256 of every chunk. Hash the same byte ranges of the downloaded file and compare.
