> For the complete documentation index, see [llms.txt](https://developers.flipsnack.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developers.flipsnack.com/api-reference/collection.createfromtemplate.md).

# collection.createFromTemplate

Creates a flipbook from ordered static template pages and optional blank spacers.

Generation runs asynchronously. The call returns when the flipbook is queued.

Poll [collection.getCollection](/api-reference/api-method-collection.getcollection.md) until `collectionStatus` is no longer `processing`.

For product catalogs built from feeds, use [collection.createCatalog](/api-reference/collection.createcatalog.md).

**Note:** Requests must be made to **<https://api.flipsnack.com/v1/>**.

### Request parameters

| Name                   | Type        | Description                                                                                                                                                                                                                                                                                                                       |
| ---------------------- | ----------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `apiKey` (required)    | string      | API key for your user. Omission returns `30 - Missing mandatory parameter`. An invalid key returns `41 - Invalid credentials`.                                                                                                                                                                                                    |
| `signature` (required) | string      | Request signature. See [How to sign a request](/how-to-sign-a-request.md). Omission returns `30 - Missing mandatory parameter`. An invalid signature returns `44 - Invalid signature`.                                                                                                                                            |
| `action` (required)    | string      | Must be `collection.createFromTemplate`. Omission returns `30 - Missing mandatory parameter`.                                                                                                                                                                                                                                     |
| `sections` (required)  | JSON string | JSON-encoded array that defines flipbook pages in order. See [Sections](#sections). Sign this as one flat parameter.                                                                                                                                                                                                              |
| `title`                | string      | Title of the generated flipbook.                                                                                                                                                                                                                                                                                                  |
| `folder`               | string      | Destination path, such as `Catalogs/2026`. Names use English letters, digits, and spaces. They start and end with a letter or digit. Paths are case-insensitive, support up to three levels, and omit leading or trailing `/`. Omit or leave empty for the root folder. Existing folders are reused; missing folders are created. |

### Sections

`sections` is a non-empty ordered array of section objects. Only `static` and `blank` sections are accepted. `feed` sections are rejected.

Include at least one `static` section.

#### Common fields

| Name                     | Type    | Description                                          |
| ------------------------ | ------- | ---------------------------------------------------- |
| `sectionType` (required) | string  | `static` or `blank`.                                 |
| `pageBreak`              | boolean | Starts this section on a new page. Default: `false`. |

#### Static sections

Static sections render fixed pages, such as covers, intros, and dividers.

| Name                   | Type      | Description                                                                   |
| ---------------------- | --------- | ----------------------------------------------------------------------------- |
| `templates` (required) | object\[] | Non-empty array of templates to render in order. See [Templates](#templates). |
| `elements`             | object\[] | Values injected into layers by name. See [Elements](#elements).               |

**Templates**

| Name                      | Type       | Description                                                                                         |
| ------------------------- | ---------- | --------------------------------------------------------------------------------------------------- |
| `templateHash` (required) | string     | Generator template hash.                                                                            |
| `templatePages`           | integer\[] | **Zero-based** indexes in the template page order. Omit for all pages. Invalid indexes are skipped. |

**Elements**

Elements inject values into named template layers. The `name` matches the layer's `layerLabel` in the template editor.

| Name               | Type                | Description                                                   |
| ------------------ | ------------------- | ------------------------------------------------------------- |
| `name` (required)  | string              | Template layer name (`layerLabel`).                           |
| `value` (required) | string or string\[] | Text, a URL, or a list of media URLs.                         |
| `style`            | object              | Style overrides, such as color. Reserved and not yet applied. |

#### Blank sections

Blank sections insert empty spacer pages.

| Name        | Type    | Description                                    |
| ----------- | ------- | ---------------------------------------------- |
| `pageCount` | integer | Number of blank pages to insert. Default: `1`. |

#### Sections example

Use this structure before URL or JSON encoding the `sections` parameter:

```json
[
  {
    "sectionType": "static",
    "templates": [
      { "templateHash": "tmplCoverHash", "templatePages": [0] }
    ],
    "elements": [
      { "name": "Headline1", "value": "Welcome" },
      { "name": "Image", "value": "https://example.com/hero.jpg" }
    ]
  },
  {
    "sectionType": "blank",
    "pageCount": 1
  },
  {
    "sectionType": "static",
    "templates": [
      { "templateHash": "tmplCoverHash", "templatePages": [1] }
    ]
  }
]
```

### Response parameters

A successful request returns the new flipbook hash. Generation continues in the background.

| Name             | Type   | Description                                                                                                                                                   |
| ---------------- | ------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `collectionHash` | string | New flipbook hash. Poll [collection.getCollection](/api-reference/api-method-collection.getcollection.md) until `collectionStatus` changes from `processing`. |

### Error codes

See [API status codes](/api-status-codes.md) for all error codes.

Validation failures (`code` `40`) can include `data.message` and field-level entries in `data.errors`.

### Examples

#### Request

{% tabs %}
{% tab title="cURL" %}

```bash
# POST
curl -X POST "https://api.flipsnack.com/v1/" \
     -F "action=collection.createFromTemplate" \
     -F "apiKey=<YOUR-API-KEY>" \
     -F "signature=<YOUR-REQUEST-SIGNATURE>" \
     -F "title=My static book" \
     -F "folder=Catalogs/2026" \
     -F 'sections=[{"sectionType":"static","templates":[{"templateHash":"tmplCoverHash","templatePages":[0]}],"elements":[{"name":"Headline1","value":"Welcome"}]},{"sectionType":"blank","pageCount":1}]'
```

{% endtab %}

{% tab title="HTML" %}

```html
<form method="post" action="https://api.flipsnack.com/v1/">
    <input type="hidden" name="action" value="collection.createFromTemplate">
    <input type="hidden" name="apiKey" value="<YOUR-API-KEY>">
    <input type="hidden" name="signature" value="<YOUR-REQUEST-SIGNATURE>">
    <input type="text" name="title" value="My static book">
    <input type="text" name="folder" value="Catalogs/2026">
    <textarea name="sections">[{"sectionType":"static","templates":[{"templateHash":"tmplCoverHash","templatePages":[0]}],"elements":[{"name":"Headline1","value":"Welcome"}]},{"sectionType":"blank","pageCount":1}]</textarea>
    <button type="submit">Submit</button>
</form>
```

{% endtab %}
{% endtabs %}

#### Response

{% tabs %}
{% tab title="Success" %}

```json
{
  "code": 20,
  "status": "OK",
  "data": {
    "collectionHash": "newHash123"
  }
}
```

{% endtab %}

{% tab title="Error" %}

```json
{
  "code": 40,
  "status": "Bad Request",
  "data": {
    "message": "Validation errors",
    "errors": [
      "sections: must include at least one static section."
    ]
  }
}
```

{% endtab %}
{% endtabs %}
