# Amadezing for AI agents

Connect your agent once. It asks Amadezing for designs, hands you a private review link with the previews, and you approve, reject, or edit. Or turn on auto-approve and the agent gets finished designs with no link at all.

Base URL: `https://amadezing.com` · MCP endpoint: `https://amadezing.com/api/mcp` · This page as markdown: `/agents.md`

## How it works

1. **Connect (once).** The agent asks for a code. The human opens one link, signs in, and approves. The agent receives its API key a single time.
2. **Request a design.** The agent sends a prompt (and optionally a canvas size). The request returns immediately with an `id`.
3. **Review.** When the design is ready the request has status `awaiting_review` and a `reviewUrl`. The agent gives that link to the human.
4. **Decide.** The human approves, rejects, requests changes with a note, or opens the editor, edits, and approves. The agent reads the result by polling `GET /api/v1/agent/designs/{id}` or via a callback.

With **auto-approve** on for the connection, step 3 and 4 are skipped: the request goes straight to `approved` with final image URLs.

## 1. Connect an account

Start a connection:

```bash
curl -X POST https://amadezing.com/api/agent/connect \
  -H "content-type: application/json" \
  -d '{"agent_name":"My agent"}'
```

Response:

```json
{
  "verification_url": "https://amadezing.com/connect?code=ABCD-EFGH",
  "user_code": "ABCD-EFGH",
  "device_code": "…secret, keep it…",
  "expires_in": 600,
  "interval": 3
}
```

Tell the human to open `verification_url`. They sign in, choose whether to enable auto-approve, and press Approve. Meanwhile poll every `interval` seconds:

```bash
curl -X POST https://amadezing.com/api/agent/connect/poll \
  -H "content-type: application/json" \
  -d '{"device_code":"…"}'
```

You get `{"status":"pending"}` until approval, then:

```json
{ "status": "approved", "api_key": "amz_…", "auto_approve": false }
```

The key is returned once. Store it. Other statuses: `denied`, `expired`.

## 2. Request a design

```bash
curl -X POST https://amadezing.com/api/v1/agent/designs \
  -H "Authorization: Bearer amz_…" \
  -H "content-type: application/json" \
  -d '{
    "prompt": "Instagram carousel announcing our summer menu, friendly tone",
    "format": "1080x1350",
    "callback_url": "https://example.com/hooks/amadezing"
  }'
```

| Field | Required | Notes |
| --- | --- | --- |
| `prompt` | AI path | 8 to 8000 characters: topic, goal, audience, tone. Required unless you pass `template_id`. |
| `template_id` | no | Instant path: id from the templates list. Use with `fields`. `prompt` becomes an optional note. |
| `fields` | no | With `template_id`: `headline`, `subheadline`, `cta`, `brand`. |
| `images` | no | With `template_id`: real images for the design, `[{ "url": "https://…", "role": "photo" }]` (`role` is `photo` or `logo`). See [Your own photo or logo](#your-own-photo-or-logo). |
| `format` | no | AI path. Canvas size such as `1080x1350` (Instagram 4:5), `1080x1920` (story), `1920x1080` (16:9). |
| `mode` | no | `review` forces a human check even when auto-approve is on. `auto` only applies when the connection allows it. |
| `callback_url` | no | Public `https` URL. We POST the final status there. |
| `agent_name` | no | Shown to the human on the review page. |

Response `202`:

```json
{
  "id": "0b1c…",
  "status": "generating",
  "mode": "review",
  "reviewUrl": "https://amadezing.com/review/…",
  "previews": [],
  "editUrl": null,
  "next": "Generating. When status becomes awaiting_review, send the human reviewUrl…"
}
```

## 2b. Instant designs from templates (no AI wait)

Published templates all share the same fields and character limits, so one set of values fits any of them. List them, pick one, fill the fields:

```bash
curl https://amadezing.com/api/v1/agent/templates -H "Authorization: Bearer amz_…"
```

```json
{
  "fields": { "headline": 32, "subheadline": 80, "cta": 18, "brand": 20 },
  "templates": [
    { "id": "5f0c…", "name": "Summer sale", "format": "1080x1350", "popular": true,
      "fields": [{ "key": "headline", "original": "Big headline here", "max_chars": 32 }],
      "image_slots": ["photo", "logo"] }
  ],
  "nextOffset": 8
}
```

Create a design from one:

```bash
curl -X POST https://amadezing.com/api/v1/agent/designs \
  -H "Authorization: Bearer amz_…" -H "content-type: application/json" \
  -d '{ "template_id": "5f0c…", "fields": { "headline": "Summer sale is here", "cta": "Shop now", "brand": "Acme" } }'
```

The design is created immediately and the request is ready for review (or approved, with auto-approve). The review page renders the design live; `previews` fills in with a PNG within a few seconds (`previewsReady` turns `true`). Values longer than a field's limit are cut to the limit. `editUrl` opens the design in the editor.

### Your own photo or logo

Templates can take real images. Each template in the list reports `image_slots`: the roles it accepts, `["photo","logo"]` or `[]` (most templates have none yet). Add `images` to a template request:

```bash
curl -X POST https://amadezing.com/api/v1/agent/designs \
  -H "Authorization: Bearer amz_…" -H "content-type: application/json" \
  -d '{ "template_id": "5f0c…", "fields": { "headline": "Meet Luna" },
        "images": [ { "url": "https://example.com/luna.jpg", "role": "photo" },
                    { "url": "https://example.com/logo.png", "role": "logo" } ] }'
```

| Rule | Detail |
| --- | --- |
| Roles | `photo` is cropped and centered to fill its frame. `logo` is shown whole, never cropped. |
| Count | At most 1 `photo` and 1 `logo` per request. |
| URL | `https` only, up to 2000 characters, no credentials, no custom port, and the host must be public (private, loopback and link-local addresses are refused, also after redirects; up to 3 redirects are followed). |
| File | PNG, JPEG or WebP, judged from the file itself rather than its `Content-Type`. At most 10 MB, downloaded within 10 seconds. Shortest side at least 200 px, longest side at most 8000 px. |
| Storage | We download the image once and keep our own copy; the design never loads your URL. |
| Template | Only templates whose `image_slots` include the role accept it. |

Images are never skipped silently: if one cannot be used the whole request is rejected and no design is created. Requests without `images` behave exactly as before. Images apply to the template path only, not to `prompt` designs.

## 3. Get the status

```bash
curl https://amadezing.com/api/v1/agent/designs/{id} -H "Authorization: Bearer amz_…"
```

| `status` | Meaning | What the agent does |
| --- | --- | --- |
| `generating` | Being planned and rendered (usually under a minute). | Poll every 3 to 5 seconds. |
| `awaiting_review` | Ready. Waiting for the human. | Send `reviewUrl` to the human. |
| `approved` | Approved by the human, or automatically. | Use `previews[].url`. `decidedBy` is `human` or `auto`. |
| `changes_requested` | The human wants changes. | Read `note`, then request a new design. |
| `rejected` | The human rejected it. | Stop or ask what they want. |
| `failed` | Something went wrong (see `error`, for example not enough credits). | Report it. |

List recent requests with `GET /api/v1/agent/designs?limit=20`.

## Review links

`reviewUrl` is private and unguessable. Anyone holding it can view and decide that one design, so only share it with the human. Links expire after 7 days. On the page the human can approve, reject, request changes with a note, or open the editor (requires sign-in), edit the design, and come back to approve.

## Auto-approve

The human turns auto-approve on or off per connection: during the connect step, or later in Account → Agents. When it is on, new requests default to `mode: "auto"` and finish as `approved` with no review link. The agent can still pass `"mode": "review"` for anything it is unsure about.

## Callbacks

If you pass `callback_url`, we send one `POST` with `Content-Type: application/json` when the request settles (`approved`, `rejected`, `changes_requested`, or `failed`):

```json
{ "event": "design.approved", "id": "0b1c…", "status": "approved", "note": null, "previews": [{ "url": "https://…", "label": "Design" }], "error": null }
```

Callbacks are best effort. Polling always works.

## MCP

Add `https://amadezing.com/api/mcp` as a remote MCP server (Streamable HTTP). No key is needed to start: the connect tools are open. Tools:

| Tool | Purpose |
| --- | --- |
| `connect_account` | Starts the connect flow and returns the URL and code for the human. |
| `check_connection` | Polls with the `device_code`. Returns the `api_key` once approved. |
| `request_design` | Creates a design: `template_id` + `fields` (instant) or `prompt` (AI). Optional `format`, `mode`, `callback_url`, and `images` (template path: at most 1 `photo` and 1 `logo`, see above). |
| `get_design` | Returns status, previews, `reviewUrl`, and the human's note. |
| `list_designs` | Lists recent requests. |
| `list_templates` | Lists published templates with their fields, character limits and `image_slots`. |

Account tools take the key as `api_key` or as an `Authorization: Bearer` header. Typical agent loop: `connect_account` → human approves → `check_connection` → `request_design` → `get_design` until `awaiting_review` → share `reviewUrl` → `get_design` until `approved`.

## Errors

Errors are JSON: `{ "error": "message", "code": "CODE" }`.

| HTTP | `code` | Meaning |
| --- | --- | --- |
| 400 | `INVALID_PROMPT`, `INVALID_CALLBACK_URL` | Fix the input. |
| 400 | `IMAGE_SLOT_MISSING` | You sent an image for a role the chosen template has no slot for (or sent `images` without a `template_id`). The message lists the published templates that do support that role. |
| 400 | `INVALID_IMAGE` | An image was rejected (not https, private address, not a PNG/JPEG/WebP, over 10 MB, under 200 px or over 8000 px, timed out, unreachable...). `issues` has one entry per image, like `images[0]: image is 150x900px; the shortest side must be at least 200px`. |
| 401 | `API_KEY_REQUIRED`, `INVALID_API_KEY` | Missing, wrong, or revoked key. Reconnect. |
| 404 | `NOT_FOUND`, `TEMPLATE_NOT_FOUND` | Unknown request or template id. |
| 409 | `ALREADY_DECIDED` | A review link was already used. |
| 410 | `EXPIRED` | Review link expired. Request the design again. |
| 429 | `TOO_MANY_ACTIVE` | Five designs are already generating. Wait for one to finish. |
| 503 | `NO_AI_GATEWAY` | Generation is temporarily unavailable. |
| 503 | `IMAGE_STORAGE_UNAVAILABLE` | We could not save your image copy right now (our side, not yours). Retry. Used by template designs and by the video endpoints. |

## Security and limits

- Each connection is its own `amz_` key. The human can revoke it in Account at any time and access stops immediately.
- Generations spend the account's credits. The free plan is enough to try the flow.
- Callback URLs must be public `https` endpoints.
- Do not put keys or review links in public places.

## Videos

`POST /api/agent/video/request` stores a rendered MP4 for review (same key, same review link). Add `"publish": true` to
have Amadezing schedule it through your connected Post for Me accounts right after a person approves it on the review
link. Without it nothing is scheduled. Auto-approval never publishes. Current scope: Instagram.

### One call from idea to review link

`POST /api/agent/video/render` generates the storyboard, checks it, renders the video and puts it on a review link:

```json
{ "topic": "Why dogs need fresh water", "mode": "explainer", "site": "acme-pets", "networks": ["instagram"],
  "caption": "…", "publishAt": "2026-12-02T10:00:00Z", "publish": true, "preset": "clean" }
```

`site` is the slug of your brand and `brand` is required:
`{ "name": "Acme Pets", "bg": "#12263a", "accent": "#ff9f1c", "url": "acmepets.com", "about": "Friendly pet care tips" }`.
`bg` must be a dark `#rrggbb` and `accent` a bright one; pairs that make text hard to read are rejected with an explanation.
Users get the same flow in the design editor: New design → AI video.

The video is saved as an **editable design** in the user's account (the response has `designId` and `editUrl`, which
opens it in the design editor in Animation mode), then rendered to an MP4. It returns `202` with `id`,
`status: "generating"`, the `reviewUrl`, `designId` and `editUrl`. The render takes a few minutes; poll
`GET /api/v1/agent/designs/{id}` until `status` is `awaiting_review` (or pass `callbackUrl`), then give the human the
`reviewUrl`. `preset` is `clean`, `bold` or `calm`. A storyboard that fails the layout checks returns `422` and nothing
is rendered. `publish: true` schedules the video through your connected accounts only after a person approves it.

**Real images (optional).** Add `"images": [{ "url": "https://…", "role": "photo" }, { "url": "https://…", "role": "logo" }]`
(up to 4 photos and 1 logo) to use your own pictures. `"scenes": [1, 3]` picks which scenes (1-based) get a photo; leave it out
for all scenes. A photo fills the scene behind a dark overlay so the caption stays readable; a logo replaces the brand name text.
Each URL must be public `https`, a PNG, JPEG or WebP, under 10 MB and downloadable within 10 seconds; we copy it to our own
storage before anything is generated. If any image fails you get `400` with `code: "INVALID_IMAGE"` and one message per image
(`issues`), and nothing is created or charged. If the only problem is that we could not store your images, you get `503` with
`code: "IMAGE_STORAGE_UNAVAILABLE"` instead (retry; nothing is created or charged). The URL, redirect and address rules are the
same as for template designs. Requests without `images` behave exactly as before. The same fields work on
`POST /api/video/design`.

Videos use credits: 25 on Free, 20 on Starter, 16 on Pro. They are charged when the editable design is created; exporting it to MP4 is free. The call returns `402 USAGE_LIMIT` when the balance is too low.
