# PagesApi.insert()

```ts
insert(options?: InsertPageOptions): Promise<number>
```

Inserts a blank page. Needs the `edit-pages` feature.

- Kind: method
- Since: 1.0.0

| Parameter | Type | Description |
| --- | --- | --- |
| `options?` | `InsertPageOptions` | `position` is `{ after }` or `{ before }` (zero-based); omit to append. `size` is `{ width, height }` in points, default A4. `invalidateSignatures` breaks a certification that forbids the change. |

Returns `Promise<number>`: The index the new page landed at.

Throws:

- `FEATURE_NOT_LICENSED` — the license lacks `edit-pages`.
- `INVALID_ARGUMENT` — the position is not a whole number (one past the ends is clamped).
- `PAGE_ERROR` — the page tree is nested too deeply, or the page could not be created.
- `DOCUMENT_CLOSED` — the document has been closed.
- `INVALID_STATE` — a certified document whose certification forbids it, unless `options.invalidateSignatures`; or a progressive document still downloading.

```ts
await doc.pages.insert({ position: { after: 0 } }); // second page, A4
await doc.pages.insert({ size: { width: 612, height: 792 } }); // US Letter, at the end
```

Part of [PagesApi](https://kernstra.com/docs/web-sdk/api/doc-pages) in the Kernstra Web SDK 1.0.0 API reference.

Web page: https://kernstra.com/docs/web-sdk/api/doc-pages/insert
