Zum Hauptinhalt springen

Create and export a design

Fill a template with your own text and image, render it in two formats and download the files.

You need the values from Before you start and a template in your workspace.

1. Pick a template​

GET /api/organizations/{organizationId}/templates
curl "https://app.heycreo.io/api/organizations/$ORGANIZATION_ID/templates" \
-H "Authorization: Bearer $HEYCREO_API_KEY" \
| jq '.[] | {id, name, sizes: [.sizes[].id]}'

Each template lists the formats it can render in sizes[].id, for example instagram-post or instagram-story. Note the template's id and the formats you want, and keep the ID for the next request:

export TEMPLATE_ID="…"

The controls are the parts of the template you can fill: a headline, an image, a checkbox. Read them from the template:

GET /api/organizations/{organizationId}/templates/{templateId}
curl "https://app.heycreo.io/api/organizations/$ORGANIZATION_ID/templates/$TEMPLATE_ID" \
-H "Authorization: Bearer $HEYCREO_API_KEY" \
| jq '.controls[] | {id, label, type}'

2. Create the design​

A design is a template with your content. Write the request body into a file; each value names the control it fills:

design.json
{
"name": "Summer sale",
"templateId": "TEMPLATE_ID",
"sizes": ["instagram-post", "instagram-story"],
"scopedValues": [
{
"kind": "control",
"scope": {},
"controlId": "HEADLINE_CONTROL_ID",
"value": { "valueType": "text", "value": "20 % off everything" }
},
{
"kind": "control",
"scope": {},
"controlId": "IMAGE_CONTROL_ID",
"value": {
"valueType": "image",
"value": { "source": { "external": { "url": "https://example.com/hero.jpg" } } }
}
}
]
}

Replace the IDs in capitals with those from step 1, then send it:

POST /api/organizations/{organizationId}/posts
curl "https://app.heycreo.io/api/organizations/$ORGANIZATION_ID/posts" \
-H "Authorization: Bearer $HEYCREO_API_KEY" \
--json @design.json \
| jq '{id, name, templateSizes}'
Control typevalueTypevalue
Text, textareatextthe text
Selectselectone of the control's options
Checkboxbooleantrue or false
Imageimagesource.assetId for a file from the media library, source.external.url for one on the web, as in the example
Videovideoas for an image

"scope": {} sets the value for every format. A value with "scope": { "size": "instagram-story" } overrides it for that format only. A control you leave out keeps the template's default.

Creating the design renders a preview, not the files. Keep the design's id:

export POST_ID="…"

3. Start the export​

POST /api/organizations/{organizationId}/posts/{postId}/exports
curl "https://app.heycreo.io/api/organizations/$ORGANIZATION_ID/posts/$POST_ID/exports" \
-H "Authorization: Bearer $HEYCREO_API_KEY" \
--json '{}' \
| jq '.[] | {id, templateSizeId, status}'

With an empty body the export renders every format the design was created with; {"sizes": ["instagram-post"]} renders only some. The response holds one export per format, each with "status": "pending".

Whether the result is an image or a video is decided by the template and the design's mediaType, not by the request. A print format renders a PDF.

4. Wait until it is rendered​

Images take a few seconds, videos up to a few minutes. Ask for the state of the design's exports:

GET /api/organizations/{organizationId}/posts/{postId}/exports
curl "https://app.heycreo.io/api/organizations/$ORGANIZATION_ID/posts/$POST_ID/exports" \
-H "Authorization: Bearer $HEYCREO_API_KEY" \
| jq '.[] | {id, templateSizeId, status, imageUrl, videoUrl, pdfUrl}'

status moves from pending through processing to completed or failed. A completed export carries the file in imageUrl, videoUrl or pdfUrl. A carousel lists its pages in carouselMedia.

Asking every few seconds is fine for an image. For videos, or many exports at once, let heycreo call you instead: Wait for exports with webhooks.

5. Download the file​

GET /api/organizations/{organizationId}/posts/{postId}/exports/{exportId}/download
curl "https://app.heycreo.io/api/organizations/$ORGANIZATION_ID/posts/$POST_ID/exports/$EXPORT_ID/download?format=png" \
-H "Authorization: Bearer $HEYCREO_API_KEY" \
-o summer-sale.png

Put the export's id from step 4 into EXPORT_ID. format is png, jpg or webp for an image, mp4 or webm for a video and pdf for a print export.

See also​