Pixy: https://pixydesignapp.com Docs: https://pixydesignapp.com/docs API: https://pixydesignapp.com/docs/api.txt # POST /tasks/{id}/media.zip Download every file the batch references as one zip, entries named to match the src paths in the records. `POST https://api.pixydesignapp.com/tasks/{id}/media.zip` Download every file the batch references, as one zip. A record names a file as `media/`, in its snapshot markup, in a change's `src` or `html`, or in a style's `url()` such as `background-image`, and does not carry the bytes, so this is how the bytes arrive. Entries in the zip are named `media/`, exactly the paths in the records. Unpack it next to the markup and the paths resolve, then serve the files from the site's own origin. Without an id (`POST /tasks/media.zip`) it answers with the media of every open record of one space. **Header:** `X-Pixy-Key` carrying the agent key (`px_sk_…`). **Body:** none with an id. Without one, `space` as in [pull](https://pixydesignapp.com/docs/api/pull), needed when the project has several spaces. **Response:** the zip itself, `application/zip`, not JSON. Give `curl` an `-o`. **Errors:** JSON, as everywhere else. | error | when | |---|---| | `invalid_key` | The key is not one of the project's, or was retired. | | `no_media` | The batch references no files. | **Examples:** ```bash curl -X POST https://api.pixydesignapp.com/tasks/9f1c2e40-7b3a-4d51-9a2e-2c8f0b6d1a77/media.zip \ -H 'X-Pixy-Key: px_sk_yourkey' \ -o media.zip ``` ```bash curl -X POST https://api.pixydesignapp.com/tasks/media.zip \ -H 'X-Pixy-Key: px_sk_yourkey' \ -o media.zip ``` ## Upload `POST https://api.pixydesignapp.com/media` The other way: an image your design needs, stored before the [edit](https://pixydesignapp.com/docs/api/edit) that names it. The file goes through the same door as a drop in the editor: resized to 2560px on the long side, re-encoded as WebP (SVG stays SVG, sanitized), and deduped, so the same bytes sent twice are one file. The answer's `path` is what you write in a record, an `src`, markup, or a style's `url()`. **Header:** `X-Pixy-Key` carrying the agent key (`px_sk_…`). **Body:** | field | type | required | description | |---|---|---|---| | `data` | string | yes | The file's bytes, base64. Files up to 30MB. | | `name` | string | no | The file's name, `hero.jpg`. Its stem names the stored file, `image` when unsaid. | **Response:** | field | type | description | |---|---|---| | `path` | string | `media/`, the reference to write in a record. | | `file` | string | The stored file's name, `hero.webp`, or `hero-3f9a1c.webp` when the project holds another file of that name. | | `name` | string | The name you sent. | | `width`, `height` | number | The stored image's size in pixels. | **Errors:** | error | when | |---|---| | `invalid_key` | The key is not one of the project's, or was retired. | | `invalid_media` | `data` is not base64. | | `empty` | The file arrived empty. | | `too_large` | Over 30MB in, or still over 2MB once processed. | | `bad_image` | Not an image Pixy can decode. | | `bad_svg` | Not a valid SVG. | | `svg_embeds_raster` | The SVG carries a raster image inside: send that image itself. | Every refusal carries a `message` in words. **Example:** ```bash curl -X POST https://api.pixydesignapp.com/media \ -H 'X-Pixy-Key: px_sk_yourkey' \ -H 'Content-Type: application/json' \ -d "{\"name\": \"hero.jpg\", \"data\": \"$(base64 < hero.jpg | tr -d '\n')\"}" ``` Then the edit that shows it: ```json {"element": "#hero img", "attributes": {"src": "media/hero.webp"}} ```