Concepts
Design templates
Reusable ad layouts. Use a public template or upload your own reference image to convert into one.
A design template is a reusable ad layout the API fills with your brand, product, and audience content. Templates are independent of any brand and can be used across unlimited image ad generations.
Mental model
Templates capture the structure of an ad — what goes where, what's a headline, what's a product shot, what's a CTA. They don't carry brand-specific styling; that's applied at generation time.
You can create a template two ways:
- Use a public template from our library — browse pre-built templates in the dashboard, ready to use immediately. No API call needed.
- Upload your own — submit a reference ad image (a screenshot of an ad you like). The API runs an AI pipeline that detects layout, identifies text and image regions, and assembles a structured template.
ID prefix: dt_.
Fields
| Field | Type | Description |
|---|---|---|
id | string | dt_… |
reference_image_url | string | null | URL of the source image for AI-converted templates |
status | enum | processing | completed | failed |
current_json_tree | object | null | The structured layout (see JSON trees) |
preview_url | string | null | Rendered preview of the template |
width / height | number | null | Pixel dimensions |
aspect_ratio | string | null | e.g. "1:1", "4:5" |
industry | string | null | Shopify L1 product category the template suits |
ad_format | string | null | Creative format (e.g. "Sale", "Testimonial", "Bold") |
json_tree_version | number | Bumps every time the tree changes |
duration_ms | number | null | Worker time taken to generate (when complete) |
created_at / updated_at | string | ISO timestamps |
Lifecycle
stateDiagram-v2
[*] --> processing: POST /v1/design-templates
processing --> completed
processing --> failed
completed --> [*]
failed --> [*]A template must reach status: "completed" before it can be used to generate image ads.
Endpoints
| Method | Path | Purpose |
|---|---|---|
POST | /v1/design-templates | Create a template from a reference image |
GET | /v1/design-templates | List templates |
GET | /v1/design-templates/:id | Get a template |
PATCH | /v1/design-templates/:id | Update a template |
DELETE | /v1/design-templates/:id | Delete a template |
POST | /v1/design-templates/:id/restore | Restore a deleted template |
Common patterns
Convert a reference image into a template
const response = await fetch("https://api.staticadslab.com/v1/design-templates", {
method: "POST",
headers: {
"X-API-Key": "YOUR_API_KEY",
"Content-Type": "application/json",
},
body: JSON.stringify({
reference_image_url: "https://example.com/ad-screenshot.png",
}),
});
const { data } = await response.json();
console.log(data.id, data.status); // dt_..., "processing"Then poll until completed:
async function waitForTemplate(id) {
while (true) {
const r = await fetch(
`https://api.staticadslab.com/v1/design-templates/${id}`,
{ headers: { "X-API-Key": "YOUR_API_KEY" } },
);
const { data } = await r.json();
if (data.status === "completed") return data;
if (data.status === "failed") throw new Error("Template generation failed");
await new Promise((res) => setTimeout(res, 2000));
}
}Pick a completed public template
const response = await fetch(
"https://api.staticadslab.com/v1/design-templates?status=completed",
{ headers: { "X-API-Key": "YOUR_API_KEY" } },
);
const { data } = await response.json();
const template = data[0];Pitfalls
- Templates created via reference image take a few seconds to a minute to process. Don't pass a
processingtemplate toPOST /v1/image-ads— the request will be rejected. - Templates are workspace-scoped. You can list and use templates created in your organization (and public ones); you can't list other organizations' templates.
- The
current_json_treeis the source of truth for the layout. You canPATCHit, but you usually don't need to — the AI generation pipeline tunes layout per ad.
Related
Prompt for your agent
Read https://www.staticadslab.com/docs/resources/design-templates.mdx and create a function that takes a reference image URL, creates a design template, polls until completed, and returns the template ID. Throw on failure.