---
title: "Create an extraction template"
method: POST
path: "/api/v3/datasources/{datasource_name}/extract-templates"
tags: ["Extraction templates"]
---

# Create an extraction template

`POST /api/v3/datasources/{datasource_name}/extract-templates`

## Request

- Base URL: `https://embedded.improvado.io`
- URL: `https://embedded.improvado.io/api/v3/datasources/{datasource_name}/extract-templates`
- Auth: one of:
  - HTTP bearer
  - API key in cookie `dts_session_id`
- TypeScript: <https://skmtc.dev/improvado/apis/improvado-embedded-api-v3/docs/api/v3/datasources/:datasource_name/extract-templates/post.ts> (a function with typed inputs; its response is checked against the schema)

Create a custom (agency-level) extraction template based on a parent global template.

For wide report templates (parent has `allow_to_select_dimensions` or `is_created_from_wide`),
a `connection_id` is required and the selected fields are validated against the DSAS API.

Required RBAC permission: `EXTRACT.CREATE`.

## Path parameters

- `datasource_name` string, required

## Request body

- ExtractTemplateCreateRequest: Request body for creating a custom extraction template
  - `parent_id` integer, required: ID of the parent (global) extraction template to base this template on
  - `title` string, required: Title for the new template (must be unique within the agency)
  - `description` string, required: Description of the template (can be empty)
  - `fields` string[], required: List of field names to include in the template
  - `scheduling` Scheduling[], required: Extraction schedule configuration
    - `days` integer: Day offset within the interval, starting from 0. The valid range depends on `interval`: - `hour`, `day` — must be 0 - `week` — 0–6 (day of week) - `month` — 0–30 (day of month)
    - `hours` integer: Hour at which the run will start (0–23)
    - `minutes` integer: Minute of hour at which the run will start (0–59)
    - `interval` 'hour' | 'day' | 'week' | 'month': Frequency at which the run will be performed: - `hour` — every hour - `day` — once per day - `week` — once per week - `month` — once per month
    - `timezone` string: IANA timezone name (e.g. `UTC`, `America/New_York`) the schedule is interpreted in.
    - `recurrence` integer: How often the schedule repeats within the interval. Defaults to 1.
    - `lookback_window` object: Defines the period data will be extracted for. Applies to extract schedules only — ignored for load schedules.
      - `name` 'default' | 'live' | 'max': Lookback window preset: - `default` — past 30 days from the day of extract - `live` — past 1 day from the day of extract - `max` — past 60 days from the day of extract
  - `additional_params` object, required: Additional parameters for the template (e.g. time_granularity)
  - `hashed_fields` string[]: List of field names to hash (optional)
  - `historical_data_depth_limit` integer, nullable: Limit on historical data depth in days (optional, null for no limit)
  - `connection_id` integer, nullable: Connection ID, required for wide report templates (parent has allow_to_select_dimensions or is_created_from_wide)

## Response `201`

Template created successfully

- ExtractTemplate: Extract Template object
  - `id` integer: Extract Template ID
  - `title` string: Extract Template title
  - `description` string: Extract Template description
  - `data_class` string: Data class
  - `datasource_name` string: Data source name
  - `is_wide_template` boolean: Whether the template is a wide report template
  - `schedules_limit` integer: Schedules limit
  - `scheduling` Scheduling[]
    - `days` integer: Day offset within the interval, starting from 0. The valid range depends on `interval`: - `hour`, `day` — must be 0 - `week` — 0–6 (day of week) - `month` — 0–30 (day of month)
    - `hours` integer: Hour at which the run will start (0–23)
    - `minutes` integer: Minute of hour at which the run will start (0–59)
    - `interval` 'hour' | 'day' | 'week' | 'month': Frequency at which the run will be performed: - `hour` — every hour - `day` — once per day - `week` — once per week - `month` — once per month
    - `timezone` string: IANA timezone name (e.g. `UTC`, `America/New_York`) the schedule is interpreted in.
    - `recurrence` integer: How often the schedule repeats within the interval. Defaults to 1.
    - `lookback_window` object: Defines the period data will be extracted for. Applies to extract schedules only — ignored for load schedules.
      - `name` 'default' | 'live' | 'max': Lookback window preset: - `default` — past 30 days from the day of extract - `live` — past 1 day from the day of extract - `max` — past 60 days from the day of extract
  - `fields` Field[]
    - `title` string: Field title
    - `name` string: Field name
    - `user_kind` string: Field kind
    - `user_type` string: Field type
    - `selected` boolean: Is the field selected
    - `can_edit` boolean: Can the field be edited
    - `sql_name` string: Sql Name of a Field
    - `format` 'string' | 'float' | 'integer' | 'iso_8601_date' | 'currency' | 'percent' | 'duration' | 'url' | 'image_url': Hint on how the value is meant to be rendered — not a storage contract. Metrics fall back to `float` whenever a data source does not declare a format explicitly, so `float` does not imply the value is fractional, and no decimal precision is guaranteed: values are passed through exactly as the data source returns them, without rounding. New formats may be added over time, so treat an unrecognised value as an unformatted string rather than failing.
    - `is_dynamic` boolean: Is the field dynamic
  - `additional_params` AdditionalParams[]
    - `type` string: Additional Params type
    - `name` string: Additional Params name
    - `required` boolean: Is the Additional Params required
    - `title` string: Additional Params title
    - `description` string: Additional Params description
    - `params` object: Additional Params params
    - `initial_value` string: Additional Params initial value

## Other responses

- `400`: Bad Request
- `401`: Forbidden

---

[API](https://skmtc.dev/improvado/apis/improvado-embedded-api-v3.md) - [All operations](https://skmtc.dev/improvado/apis/improvado-embedded-api-v3/llms.txt) - [OpenAPI document](https://skmtc.dev/improvado/apis/improvado-embedded-api-v3/revisions/a881099bd6c4?raw)
