# AgentGrid API > A shared workspace where AI agents and humans build on the same artifact. If > you are an AI agent whose human asked you to build something and share it with > them via AgentGrid, this file is the fast path. The full guide is at > https://public-api.animaapp.com/connect. An **artifact** is a hosted app (HTML or React) that is also a real git repository. The first share needs no account, no API key, and no human approval. ## Pick your path | If you can | Use | Cost | | --- | --- | --- | | run shell commands | **the CLI**, below | 2 commands | | only make HTTP requests | **the HTTP flow**, further down | 2 requests + a poll | Both end in the same place: your human owns the artifact and you hold a scoped token. The CLI is the same flow with the token handling done for you — prefer it whenever you have a shell. ## The CLI path ```bash # 1. Create it. Prints a claim link for your human. npx @animaapp/cli@latest create --anonymous -t import --from ./my-app \ --client-name "Claude Code" --json # 2. Wait for them to claim it, then store your credentials. npx @animaapp/cli@latest login --handoff --json ``` Sharing a document rather than an app? Add `--artifact-type markdown` and point `--from` at the folder holding the `.md` files — a markdown artifact with no markdown in it is rejected. Step 1 returns `artifactUrl` — send your human that link — and a `handoffToken` for you. The token has two uses: ```bash npx @animaapp/cli@latest login --handoff # log in once claimed npx @animaapp/cli@latest create --anonymous --handoff … # same claim ``` The CLI stores it, so both default to your last one and `` can be left off. Keep it yourself if this machine's config will not outlive the process: it is delivered exactly once and cannot be re-fetched. Step 2 blocks until the claim lands. If you have other work to do, background it and collect the result later: ```bash npx @animaapp/cli@latest login --handoff --json > anima-login.json & npx @animaapp/cli@latest auth --status --json # awaiting_claim | expired, any time ``` After the claim the CLI is authenticated, and `create`, `list`, `get-git-token` and `publish` all work against your human's workspace. This is the flow where **you** lead: you make something, share it, and ask your human to claim it. They need no account until that moment. It is the default because you arrive with something to show rather than a permission request. If you would rather have access *before* you create anything, and your human is there to approve it, `npx @animaapp/cli@latest login` asks up front — they approve a short code on any device. ## The HTTP flow Everything below is the same flow done by hand. Skip it if you used the CLI. ## Create an artifact and share it `POST https://public-api.animaapp.com/v1/generationSessions` with a JSON body. No account, no API key, no human approval. ### Request | Field | Required | Value | | --- | --- | --- | | `files` | yes | Map of path -> UTF-8 text. Source and assets only, no node_modules or build output. | | `artifactType` | no | `app` or `markdown` - see below. Omitted, it is inferred: markdown when your files contain .md/.mdx and no HTML, otherwise app. The choice comes back in `notes`. | | `type` | no | `import` (default) - your files become the first commit. The only value available without an account. | | `name` | no | Display name your human sees. Defaults to "Untitled project". | | `clientName` | strongly | Your own product name: "Claude Code", "Cursor", "Codex". Shown on the claim page, so it is what your human approves. Display-only, never a credential, at most 120 characters. | | `framework` | no | `html` or `react`. Apps only, detected from your files when omitted. | | `handoffToken` | no | A token from an earlier create, to group several artifacts into one claim. | ### artifactType - what your human will see | Value | Send | Rendered as | | --- | --- | --- | | `app` | files including an **index.html** | a running web page | | `markdown` | one or more **.md** or **.mdx** files, no `framework` | a readable document | **This is the field agents get wrong.** `.md` files created as an app produce an artifact with nothing to render, and your human opens a blank page. ### Example ```bash curl -s -X POST "https://public-api.animaapp.com/v1/generationSessions" \ -H 'Content-Type: application/json' \ -d '{"artifactType":"markdown", "name":"Hello", "clientName":"Claude Code", "files":{"hello-world.md":"# Hello, world!"}}' ``` For an app, send `"artifactType":"app"` and files containing an `index.html`. ### Response | Field | Meaning | | --- | --- | | `sessionId` | The artifact id, and the last path segment of every URL below. | | `artifactUrl` | The artifact's page: live immediately, viewable by anyone with the link, and where your human takes ownership. This is the link to send them. | | `handoffToken` | **Yours, and returned exactly once.** Persist it before printing anything - it is the only way you will ever get an access token. Never send it to your human. | | `claimableUntil` | The claim deadline. An unclaimed artifact disappears after it. | | `artifactType` | What was actually created. Check it if you left the field out. | | `skippedFiles` | Paths dropped as unsafe to commit. Check it if something is missing. | | `notes` | Present when something needed explaining, including which artifactType was inferred. Read it. | | `nextSteps` | Written for you, and spells out the polling loop precisely. Read it. | ## Hand it to your human Send them `artifactUrl` from the response. A logged-in human claims it there, which moves the artifact into their team and unlocks editing over git. Tell them: it is read-only until claimed, and it **expires 24 hours** after creation if nobody claims it. Do not send them the `handoffToken` — it is yours, it claims nothing, and it is how you receive your own access token. ## Get your own token (background job) ```bash printf 'grant_type=urn:animaapp:params:oauth:grant-type:handoff_token&handoff_token=%s' \ "$HANDOFF_TOKEN" | curl -s -X POST "https://public-api.animaapp.com/oauth/token" --data-binary @- ``` Form-encoded, not JSON. Poll about every 30 seconds until `claimableUntil`; exactly one job per token. `authorization_pending` means keep going, `slow_down` means back off. On success you get an `access_token` (Bearer, `expires_in` 604800 — 7 days) scoped to what the human granted, plus a `refresh_token`. **Both are delivered exactly once and cannot be re-fetched — persist them before doing anything else.** **A token is not guaranteed.** Your human can claim the artifact without granting you agent access, and then polling never yields one: it stays `authorization_pending` until the window closes and ends in `expired_token` (which also covers an already-redeemed token). Stop polling on it. If you need to keep editing, ask them to grant agent access when they claim. ## Keep the token alive The access token lasts 7 days. Before it expires, trade the refresh token for a new pair at the same endpoint: ```bash printf 'grant_type=refresh_token&refresh_token=%s' "$REFRESH_TOKEN" | curl -s -X POST "https://public-api.animaapp.com/oauth/token" --data-binary @- ``` **Refresh tokens rotate — each works only once.** The response carries a new `refresh_token`; store it over the old one or your next refresh fails. Keep refreshing and you stay connected up to 30 days from the claim, after which your human approves you again. ## Then - Edit artifacts over git: `npx @animaapp/cli@latest get-git-token `, clone, commit, push. Git tokens last at most 1 hour and cannot be renewed. - MCP server: `https://public-api.animaapp.com/v1/mcp` (HTTP transport, `Authorization: Bearer `). ## Docs - [Connect guide](https://public-api.animaapp.com/connect): the complete onboarding page — anonymous flow, login, git, and the exact MCP tool contract. Plain text. - [Full reference](https://public-api.animaapp.com/llms-full.txt): every endpoint, the polling contract, refresh, git and error recovery in one fetch. - [Protected resource metadata](https://public-api.animaapp.com/.well-known/oauth-protected-resource) - [Authorization server metadata](https://public-api.animaapp.com/.well-known/oauth-authorization-server) ## Rules - Sharing is giving out the link. Publishing deploys a world-public site — only on explicit request. - Never paste tokens or git remote URLs into replies; they are secrets. - Tell your human about the 24-hour claim window when you hand over the link.