---
title: "Create an embed session"
---

> Documentation Index
> Fetch the complete documentation index at: https://docs.cloudraker.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Create an embed session

Path: CloudRaker Paperwork API › Embeds

`POST /v1/embeds`

Creates a session for an embedded view and returns its iframe `url`.

Call this from your backend with your API key. Put `url` in the `src` of an iframe on one of the `origins` pages. The URL carries a short-lived token in its fragment: treat it as a secret, and create a new session for each person and each visit.

A `review` session binds one extraction run (`exr_…`) with unit `per_document` and 1 to 20 of its documents. In `write` mode the person can edit and approve values. `webhook` then receives each save and approval.

A `transcript` or `document` session binds one ready `file`, in read mode. `transcript` needs a transcribed audio file. `document` needs a PDF, an office file with a preview, or an image.

The session ends at `expiresAt`: the earliest of now plus `ttl` and the run expiry. Call `DELETE /v1/embeds/{id}` to end it sooner.

## Authentication

- `bearerAuth`, http, header `Authorization`

## Request body

_Required._

- `origins` (`createEmbedSession.origins`; array<string>, required) — The exact origins of the pages that frame the view, such as `https://app.example.com`. No path, no wildcard, no trailing slash.
  - maxLength 255
- `view` (`createEmbedSession.view`; string, optional) — The embedded view. `review` shows the results of an extraction run. `transcript` shows an audio file with its speaker transcript. `document` shows a PDF, an office file preview or an image. `transcript` and `document` are read only.
  - one of `"review"`, `"transcript"`, `"document"`; default `"review"`
- `run` (`createEmbedSession.run`; object, optional) — The extraction run (`exr_…`) to review.
  - `id` (`createEmbedSession.run.id`; string, required)
    - minLength 1
- `documents` (`createEmbedSession.documents`; array<string>, optional) — The file ids of the run to show, in this order. The default is every finished document of the run, in run order.
  - minLength 1
- `file` (`createEmbedSession.file`; object, optional) — The file to show (`transcript` and `document` views).
  - `id` (`createEmbedSession.file.id`; string, required)
    - minLength 1
- `space` (`createEmbedSession.space`; object, optional) — The space of `file` (`transcript` and `document` views). The default is the files of `/v1/files`.
  - `id` (`createEmbedSession.space.id`; string, required)
    - minLength 1
- `mode` (`createEmbedSession.mode`; string, optional) — `write` lets the person edit and approve the values.
  - one of `"read"`, `"write"`; default `"read"`
- `user` (`createEmbedSession.user`; object, optional) — The person who uses the embedded view, as your system knows them. It is stored as claimed and marked unverified. The email is never sent in a webhook or an audit event.
  - `id` (`createEmbedSession.user.id`; string, required)
    - minLength 1; maxLength 128
  - `name` (`createEmbedSession.user.name`; string, required)
    - minLength 1; maxLength 120
  - `email` (`createEmbedSession.user.email`; string, optional)
    - format `email`; maxLength 254; pattern `^(?:[A-Za-z0-9_'+\-]+\.)*[A-Za-z0-9_'+\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$`
- `webhook` (`createEmbedSession.webhook`; any of, optional) — Where to deliver this run's events, given one of two ways. - `{ "url": "…" }` — a one-off https endpoint for this run only. - `{ "id": "whe_…" }` — a saved endpoint from `POST /v1/webhooks`. Runs hold the reference, so pausing or re-pointing that endpoint applies to this run too. Deliveries are at-least-once and signed — dedupe on `eventId` and verify against `GET /v1/webhooks/jwks.json`.
  - any of:
    - `object`
      - `url` (`createEmbedSession.webhook.1.url`; string, required)
        - format `uri`
    - `object`
      - `id` (`createEmbedSession.webhook.2.id`; string, required)
        - minLength 1
- `theme` (`createEmbedSession.theme`; object, optional) — The look of the embedded view. The mode is fixed for the session.
  - `mode` (`createEmbedSession.theme.mode`; string, optional)
    - one of `"light"`, `"dark"`; default `"light"`
  - `colors` (`createEmbedSession.theme.colors`; map<string>, optional) — Hex colors (`#rgb`, `#rgba`, `#rrggbb` or `#rrggbbaa`) by theme key.
  - `radius` (`createEmbedSession.theme.radius`; string, optional) — Corner radius in `px` or `rem`, at most `32px` or `2rem`.
    - pattern `^\d{1,2}(\.\d{1,3})?(px|rem)$`
  - `font` (`createEmbedSession.theme.font`; string, optional)
    - one of `"inter"`, `"system"`
- `locale` (`createEmbedSession.locale`; string, optional)
  - one of `"en"`, `"fr-ca"`; default `"en"`
- `metadata` (`createEmbedSession.metadata`; map<unknown>, optional) — Arbitrary JSON you attach to the run and get back on every read of it. Use it to carry your own identifiers — an order number, a customer id — so a webhook or a polled run reconciles without a lookup table. Capped at 10 KB serialized.
- `ttl` (`createEmbedSession.ttl`; integer, optional) — Session lifetime in seconds (60 to 28800). The session also ends when the run expires.
  - min 60; max 28800; default `3600`

## Example request

```json
{
  "view": "review",
  "run": {
    "id": "string"
  },
  "documents": [
    "string"
  ],
  "file": {
    "id": "string"
  },
  "space": {
    "id": "string"
  },
  "mode": "read",
  "origins": [
    "string"
  ],
  "user": {
    "id": "string",
    "name": "string",
    "email": "user@example.com"
  },
  "webhook": {
    "url": "http://example.com"
  },
  "theme": {
    "mode": "light",
    "colors": {
      "property1": "string",
      "property2": "string"
    },
    "radius": "string",
    "font": "inter"
  },
  "locale": "en",
  "metadata": {
    "property1": null,
    "property2": null
  },
  "ttl": 3600
}
```

## Code samples

### cURL

```bash
curl --request POST \
  --url https://api.cloudraker.com/v1/embeds \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "view": "review",
  "run": {
    "id": "string"
  },
  "documents": [
    "string"
  ],
  "file": {
    "id": "string"
  },
  "space": {
    "id": "string"
  },
  "mode": "read",
  "origins": [
    "string"
  ],
  "user": {
    "id": "string",
    "name": "string",
    "email": "user@example.com"
  },
  "webhook": {
    "url": "http://example.com"
  },
  "theme": {
    "mode": "light",
    "colors": {
      "property1": "string",
      "property2": "string"
    },
    "radius": "string",
    "font": "inter"
  },
  "locale": "en",
  "metadata": {
    "property1": null,
    "property2": null
  },
  "ttl": 3600
}
'
```

### TypeScript

```typescript
const url = 'https://api.cloudraker.com/v1/embeds';
const options = {
  method: 'POST',
  headers: {'Content-Type': 'application/json', Authorization: 'Bearer <token>'},
  body: JSON.stringify({
    view: 'review',
    run: {id: 'string'},
    documents: ['string'],
    file: {id: 'string'},
    space: {id: 'string'},
    mode: 'read',
    origins: ['string'],
    user: {id: 'string', name: 'string', email: 'user@example.com'},
    webhook: {url: 'http://example.com'},
    theme: {
      mode: 'light',
      colors: {property1: 'string', property2: 'string'},
      radius: 'string',
      font: 'inter'
    },
    locale: 'en',
    metadata: {property1: null, property2: null},
    ttl: 3600
  })
};

fetch(url, options)
  .then(res => res.json())
  .then(json => console.log(json))
  .catch(err => console.error(err));
```

### Python

```python
import requests

url = "https://api.cloudraker.com/v1/embeds"

payload = {
    "view": "review",
    "run": { "id": "string" },
    "documents": ["string"],
    "file": { "id": "string" },
    "space": { "id": "string" },
    "mode": "read",
    "origins": ["string"],
    "user": {
        "id": "string",
        "name": "string",
        "email": "user@example.com"
    },
    "webhook": { "url": "http://example.com" },
    "theme": {
        "mode": "light",
        "colors": {
            "property1": "string",
            "property2": "string"
        },
        "radius": "string",
        "font": "inter"
    },
    "locale": "en",
    "metadata": {
        "property1": None,
        "property2": None
    },
    "ttl": 3600
}
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer <token>"
}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
```

## Responses

### 201

The session, with the iframe `url`.

#### Example

```json
{
  "object": "embed_session",
  "id": "ems_01K6ZQB3C4D5E6F7G8H9J0K1M2",
  "view": "review",
  "mode": "read",
  "url": "string",
  "run": {
    "id": "string"
  },
  "file": {
    "id": "string"
  },
  "documents": [
    "string"
  ],
  "expiresAt": "string",
  "createdAt": "string"
}
```

- `object` (`createEmbedSession.response.201.object`; string, required)
- `id` (`createEmbedSession.response.201.id`; string, required)
  - example `"ems_01K6ZQB3C4D5E6F7G8H9J0K1M2"`
- `view` (`createEmbedSession.response.201.view`; string, required)
  - one of `"review"`, `"transcript"`, `"document"`
- `mode` (`createEmbedSession.response.201.mode`; string, required)
  - one of `"read"`, `"write"`
- `url` (`createEmbedSession.response.201.url`; string, required) — The iframe `src`. It carries the session token in its fragment: treat it as a secret.
- `documents` (`createEmbedSession.response.201.documents`; array<string>, required)
- `expiresAt` (`createEmbedSession.response.201.expiresAt`; string, required)
- `createdAt` (`createEmbedSession.response.201.createdAt`; string, required)
- `run` (`createEmbedSession.response.201.run`; object, optional)
  - `id` (`createEmbedSession.response.201.run.id`; string, required)
    - minLength 1
- `file` (`createEmbedSession.response.201.file`; object, optional)
  - `id` (`createEmbedSession.response.201.file.id`; string, required)
    - minLength 1

### 400

`invalid_request`: the body failed validation (theme, origins, webhook, ttl, or more than 20 documents).

### 401

Missing or invalid credential.

### 403

The credential may not use the /v1 API.

### 404

`not_found`: unknown run, file or space.

### 409

`result_not_ready`: the run has not finished. `review_closed`: the review state is gone, or less than 60 seconds remain. `file_not_ready`: the file is not ready.

### 410

`run_expired`: the run expired.

### 422

`unsupported_run`: not a `per_document` extraction run. `unknown_document`: a `documents` id is not a finished document of the run. `unsupported_file`: the file type does not fit the view.

### 429

Rate limited. The `/v1` API allows at least **67 requests per minute per organization** (about 1,000 requests per 15 minutes) — a guaranteed floor, enforced per edge location, so a geographically spread caller may get more. Wait for the `Retry-After` interval and retry — the error is `retryable`.

#### Example

```json
{
  "code": "rate_limited",
  "message": "string",
  "retryable": true,
  "requestId": "string",
  "docUrl": "string"
}
```

- `code` (`createEmbedSession.response.429.code`; string, required)
  - one of `"rate_limited"`
- `message` (`createEmbedSession.response.429.message`; string, required)
- `retryable` (`createEmbedSession.response.429.retryable`; boolean, required)
  - one of `true`
- `requestId` (`createEmbedSession.response.429.requestId`; string, required)
- `docUrl` (`createEmbedSession.response.429.docUrl`; string, optional)

### 503

`embed_unconfigured`: embeds are not available right now.


Source: https://docs.cloudraker.com/paperwork/api/embeds/create-embed-session/index.md
